Class TransformedPathIterator3D

java.lang.Object
org.bzdev.geom.TransformedPathIterator3D
All Implemented Interfaces:
PathIterator3D

public class TransformedPathIterator3D extends Object implements PathIterator3D
PathIterator3D based on a transformation of another PathIterator3D. This class obtains the segment type and control points from a path iterator that it encapsulates, and applies a transform to those control points. The path iterator passed to the constructor will be modified as methods are called.

The rationale for this class is the same as for TransformedPathIterator.

The same effect can be achieved by calling FlattenedPathIterator3D with a limit of 0, albeit with slightly worse performance.

  • Constructor Details

    • TransformedPathIterator3D

      public TransformedPathIterator3D(PathIterator3D pi, AffineTransform3D at)
      Constructor given an AffineTransform3D. Because the path iterator passed to this constructor will be modified by this object's methods, it is a good practice to call the constructor as follows
      
            PathIterator3D pi = ...
            AffineTransform3D at = ...
            pi = new TransformedPathIterator3D(pi, at);
       
      to avoid having multiple references that modify the same object.
      Parameters:
      pi - the path iterator
      at - the affine transform; null if there is none.
      Throws:
      NullPointerException - the path iterator was null
    • TransformedPathIterator3D

      public TransformedPathIterator3D(PathIterator3D pi, Transform3D tf)
      Constructor given a Transform3D. Because the path iterator passed to this constructor will be modified by this object's methods, it is a good practice to call the constructor as follows
      
            PathIterator pi = ...
            Transform3D at = ...
            pi = new TransformedPathIterator(pi, at);
       
      to avoid having multiple references that modify the same object.
      Parameters:
      pi - the path iterator
      tf - the transform; null if there is none.
      Throws:
      NullPointerException - the path iterator was null
  • Method Details

    • currentSegment

      public int currentSegment(double[] coords)
      Description copied from interface: PathIterator3D
      Returns the coordinates and type of the current path segment in the iteration. The return value is the path-segment type: SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A double array of length 9 must be passed in and can be used to store the coordinates of the point(s). Each point is stored as a triplet of double x,y,z coordinates. SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns two points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return any points.
      Specified by:
      currentSegment in interface PathIterator3D
      Parameters:
      coords - - an array that holds the data returned from this method
      Returns:
      he path-segment type of the current path segment
    • currentSegment

      public int currentSegment(float[] coords)
      Description copied from interface: PathIterator3D
      Returns the coordinates and type of the current path segment in the iteration. The return value is the path-segment type: SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE. A float array of length 9 must be passed in and can be used to store the coordinates of the point(s). Each point is stored as a triplet of float x,y,z coordinates. SEG_MOVETO and SEG_LINETO types returns one point, SEG_QUADTO returns two points, SEG_CUBICTO returns 3 points and SEG_CLOSE does not return any points.
      Specified by:
      currentSegment in interface PathIterator3D
      Parameters:
      coords - - an array that holds the data returned from this method
      Returns:
      the path-segment type of the current path segment.
    • isDone

      public boolean isDone()
      Description copied from interface: PathIterator3D
      Tests if the iteration is complete.
      Specified by:
      isDone in interface PathIterator3D
      Returns:
      true if all the segments have been read; false otherwise.
    • next

      public void next()
      Description copied from interface: PathIterator3D
      Moves the iterator to the next segment of the path forwards along the primary direction of traversal as long as there are more points in that direction.
      Specified by:
      next in interface PathIterator3D