public function parseSpline(FileReader $iter, $matrix) { $line = $iter->current(); echo "New Spline: " . $iter->key() . "\n"; $d = preg_split('/\\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); $total = $d[13]; echo "Parsing {$total} points\n"; $count = 0; $points = array(); $state = 1; // fetch points $iter->next(); // advance to next line foreach ($iter as $line) { $d = preg_split('/\\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); //echo implode(",",$d)."\n"; switch ($state) { case 1: $points[] = transformPoint($matrix, (object) array('x' => $d[0], 'y' => $d[1])); ++$count; if ($count == $total) { $state = 2; $count = 0; } break; case 2: $count += count($d); if ($count >= $total) { break 2; } break; } } // finished spline echo "Ending Spline: " . $iter->key() . "\n"; return $points; }