java.lang.Object
org.bzdev.geom.ConditionalPathIterator3D
- All Implemented Interfaces:
PathIterator3D
Conditional path iterator class for three dimensions.
This iterator adds segments to the segments returned by
another path iterator by splitting quadratic and cubic Bézier-curve
segments unless the points along a segment fails to satisfy a condition
that indicates that splitting should continue. If that condition is not
satisfied, splitting may continue in some circumstances: the
second control point, for example, should not be closer to the initial
control point than the first control point. The condition is a predicate
whose argument is a control point array including the end points of a
segment. It will have a length of 9 for qudratic segments and a length of
12 for cubic segments.
The iterator has a recursion limit (the default value is 10) to prevent the number of segments from becoming excessively large. Incrementing the recursion limit by 1 can double the number of segments from that returned by the previous limit.
The path may be partially flattened.
This class does not modify segment types, unlike
FlatteningPathIterator
which turns quadratic
and cubic segments into straight lines.
-
Field Summary
Fields inherited from interface org.bzdev.geom.PathIterator3D
SEG_CLOSE, SEG_CUBICTO, SEG_LINETO, SEG_MOVETO, SEG_QUADTO
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalPathIterator3D
(int type, double x0, double y0, double z0, double[] coords, Predicate<double[]> condition, int limit) Constructor give a type and a double-precision coordinate array.ConditionalPathIterator3D
(int type, double x0, double y0, double z0, double[] coords, AffineTransform3D transform, Predicate<double[]> condition, int limit) Constructor give a type and double-precision coordinate array, with an AffineTransform.ConditionalPathIterator3D
(int type, float x0, float y0, float z0, float[] coords, Predicate<double[]> condition, int limit) Constructor given a type and a single-precision coordinate array.ConditionalPathIterator3D
(int type, float x0, float y0, float z0, float[] coords, AffineTransform3D transform, Predicate<double[]> condition, int limit) Constructor give a type and single-precision coordinate array, with an AffineTransform3D.ConditionalPathIterator3D
(PathIterator3D src, Predicate<double[]> condition) Constructor.ConditionalPathIterator3D
(PathIterator3D src, Predicate<double[]> condition, int limit) Constructor with a recursion limit.ConditionalPathIterator3D
(PathIterator3D src, AffineTransform3D transform, Predicate<double[]> condition) Constructor given a transform.ConditionalPathIterator3D
(PathIterator3D src, AffineTransform3D transform, Predicate<double[]> condition, int limit) Constructor with a transform and a recursion limit. -
Method Summary
Modifier and TypeMethodDescriptionint
currentSegment
(double[] coords) Returns the coordinates and type of the current path segment in the iteration.int
currentSegment
(float[] coords) Returns the coordinates and type of the current path segment in the iteration.Predicate<double[]>
Get the condition parameter.int
Get the recursion limit.boolean
isDone()
Tests if the iteration is complete.void
next()
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.
-
Constructor Details
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(PathIterator3D src, Predicate<double[]> condition) throws IllegalArgumentException Constructor. The default recursion limit is 10. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened.- Parameters:
src
- a path iterator to flattencondition
- the condition- Throws:
IllegalArgumentException
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(PathIterator3D src, Predicate<double[]> condition, int limit) throws IllegalArgumentException Constructor with a recursion limit. The limit must be non-negative. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened.- Parameters:
src
- a path iterator to flattencondition
- the conditionlimit
- the recursion limit- Throws:
IllegalArgumentException
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(PathIterator3D src, AffineTransform3D transform, Predicate<double[]> condition) throws IllegalArgumentException Constructor given a transform. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened. The default recursion limit is 10.- Parameters:
src
- a path iterator to flattentransform
- the transform to applycondition
- the condition- Throws:
IllegalArgumentException
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(PathIterator3D src, AffineTransform3D transform, Predicate<double[]> condition, int limit) throws IllegalArgumentException Constructor with a transform and a recursion limit. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened. The limit must be non-negative.- Parameters:
src
- a path iterator to flattentransform
- a transform to applycondition
- the conditionlimit
- the recursion limit- Throws:
IllegalArgumentException
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(int type, double x0, double y0, double z0, double[] coords, Predicate<double[]> condition, int limit) Constructor give a type and a double-precision coordinate array. The limit must be non-negative. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened. If the segment type is PathIterator3D.SEG_MOVETO, the arguments x0 and y0 are ignored.- Parameters:
type
- the type of a segment (PathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
,PathIterator3D.SEG_QUADTO
,PathIterator3D.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,z0
- the starting Z coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
condition
- the conditionlimit
- the recursion limit
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(int type, float x0, float y0, float z0, float[] coords, Predicate<double[]> condition, int limit) Constructor given a type and a single-precision coordinate array. The limit must be non-negative. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened.- Parameters:
type
- the type of a segment (PathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
,PathIterator3D.SEG_QUADTO
,PathIterator3D.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,z0
- the starting Z coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
condition
- the conditionlimit
- the recursion limit
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(int type, double x0, double y0, double z0, double[] coords, AffineTransform3D transform, Predicate<double[]> condition, int limit) Constructor give a type and double-precision coordinate array, with an AffineTransform. The limit must be non-negative. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened.- Parameters:
type
- the type of a segment (PathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
,PathIterator3D.SEG_QUADTO
,PathIterator3D.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,z0
- the starting Z coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applycondition
- the conditionlimit
- the recursion limit
-
ConditionalPathIterator3D
public ConditionalPathIterator3D(int type, float x0, float y0, float z0, float[] coords, AffineTransform3D transform, Predicate<double[]> condition, int limit) Constructor give a type and single-precision coordinate array, with an AffineTransform3D. The limit must be non-negative. The condition's test method must return true if the the path is to be flattened further and false otherwise. The test method's argument is an array containing the control points, including the starting point for a segment. The length of the array is 9 when a segment's type isPathIterator3D.SEG_QUADTO
and is 12 when a segment's type isPathIterator3D.SEG_CUBICTO
. Segments whose type isPathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
, orPathIterator3D.SEG_CLOSE
are not flattened.- Parameters:
type
- the type of a segment (PathIterator3D.SEG_MOVETO
,PathIterator3D.SEG_LINETO
,PathIterator3D.SEG_QUADTO
,PathIterator3D.SEG_CUBICTO
)x0
- the starting X coordinate for the segmenty0
- the starting Y coordinate for the segment,z0
- the starting Z coordinate for the segment,coords
- the coordinates for the segment as returned bycurrentSegment(double[])
transform
- a transform to applycondition
- the conditionlimit
- the recursion limit
-
-
Method Details
-
getCondition
Get the condition parameter.- Returns:
- the condition
-
getRecursionLimit
public int getRecursionLimit()Get the recursion limit.- Returns:
- the recursion limit
-
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 interfacePathIterator3D
- 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 interfacePathIterator3D
- 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 interfacePathIterator3D
- 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 interfacePathIterator3D
-