- All Implemented Interfaces:
Shape3D
A two paths will typically lie in the same plane or be fairly close to such a plane. A typical use for this class is to act as a bridge between a Bézier grid and a rectilinear object whose control points may be separated by distances much larger than those for the grid.
Occasionally it is easier to start with a 2D path in order
to take advantage of methods in classes such as Paths2D
,
and convert the 2D path to a 3D path. Subclasses of Path3D
have constructors that simplify this process: for example,
Double(Path2D,Transform3D)
.
-
Constructor Summary
ConstructorsConstructorDescriptionConvexPathConnector
(Path2D inner, Path2D outer) Constructor using 2D paths.ConvexPathConnector
(Path3D inner, Path3D outer) Constructor using 3D paths.ConvexPathConnector
(Path3D inner, Path3D outer, boolean counterclockwise) Constructor using 3D paths. -
Method Summary
Modifier and TypeMethodDescriptionvoid
flip()
Invert the orientation from its current value.Get the boundary for this Shape3D.Get a bounding rectangular cuboid for a 3D shape.getColor()
Get the color color for this shape.getComponent
(int i) Get a component of this shape.getSurfaceIterator
(Transform3D tform) Get a surface iterator for this Shape3D.final SurfaceIterator
getSurfaceIterator
(Transform3D tform, int level) Get a surface iterator for this Shape3D, subdividing the surface.getTag()
Get this object's tag.boolean
Determine if this Shape3D is a closed two-dimensional manifold.boolean
Determine if a surface is oriented.boolean
Determine if the orientation for this grid is reversed.boolean
Determine if this BezierVertex is well formed.boolean
isWellFormed
(Appendable out) Determine if thisConvexPathConnector
is well formed, logging error messages to an Appendable.int
Get the number of components for this shape.void
print()
Print this object's control points.void
print
(Appendable out) Print this object's control points, specifying an output.void
Print this object's control points, specifying a prefix.void
print
(String prefix, Appendable out) Print this object's control points, specifying a prefix and output.void
reverseOrientation
(boolean reverse) Change the orientation of the Bézier triangles associated with this object.void
Set the color for this shape.void
Set this object's tag.static void
setupDebuggingGraph
(Graph graph, File file) Set up a graph for debugging.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.geom.Shape3D
getBoundary
-
Constructor Details
-
ConvexPathConnector
public ConvexPathConnector(Path2D inner, Path2D outer) throws IllegalArgumentException, NullPointerException Constructor using 2D paths. The paths must be convex and closed. The surface produced will be oriented so that its normal vector points in the Z direction regardless of whether the paths are clockwise or counterclockwise.- Parameters:
inner
- the inner of the two pathsouter
- the outer of the two paths- Throws:
IllegalArgumentException
- if the planar projections of the paths are not convex paths, if the paths were empty, if the paths are not continuous, if the paths are not closed, or if a vertex does not have a peer vertex that is visible to it (e.g., a path does not have enough control points)NullPointerException
- if the inner or outer paths were null
-
ConvexPathConnector
public ConvexPathConnector(Path3D inner, Path3D outer) throws IllegalArgumentException, NullPointerException Constructor using 3D paths. The paths must be convex and closed. The orientation is that obtained by using the right-hand rule when traversing the outer path from its end to its start (the reverse of the expected case where the path is traversed from its start to its end, but appropriate when the path is the boundary of a hole in a surface). The inner path will be reversed if necessary automatically. To determine if a curve is convex, it is first projected onto a plane and the test is performed on the projection.- Parameters:
inner
- the inner of the two pathsouter
- the outer of the two paths- Throws:
IllegalArgumentException
- if the planar projections of the paths are not convex paths, if the paths were empty, if the paths are not continuous, if the paths are not closed, or if a vertex does not have a peer vertex that is visible to it (e.g., a path does not have enough control points)NullPointerException
- if the inner or outer paths were null
-
ConvexPathConnector
public ConvexPathConnector(Path3D inner, Path3D outer, boolean counterclockwise) throws IllegalArgumentException, NullPointerException Constructor using 3D paths. The paths must be convex and closed. The orientation is that obtained by using the right-hand rule when traversing the outer path from its end to its start (the reverse of the expected case where the path is traversed from its start to its end, but appropriate when the path is the boundary of a hole in a surface). The inner path will be reversed if necessary automatically. To determine if a curve is convex, it is first projected onto a plane and the test is performed on the projection.The last argument should be false if the path is a boundary associated with a hole in a surface.
- Parameters:
inner
- the inner of the two pathsouter
- the outer of the two pathscounterclockwise
- true if the orientation is determined by using the right hand rule when traversing the outer path; false otherwise- Throws:
IllegalArgumentException
- if the planar projections of the paths are not convex paths, if the paths were empty, if the paths are not continuous, if the paths are not closed, or if a vertex does not have a peer vertex that is visible to it (e.g., a path does not have enough control points)NullPointerException
- if the inner or outer paths were null
-
-
Method Details
-
setTag
Set this object's tag.- Parameters:
tag
- the tag
-
getTag
Get this object's tag.- Returns:
- the tag
-
setupDebuggingGraph
Set up a graph for debugging. The graph should be square in shape, and will be written when the next constructor is called, after which the class will reset itself so that no additional graphs will be outputted until this method is called again.The graph shows the following:
- the 'knots' for the outer path are shown as a set of square symbols.
- the 'knots' for the inner path are shown as a set of round symbols.
- a series of triangles are drawn showing the surface segments created. This is a simplified representation: Bézier path segments are represented as straight lines connecting the end points.
- if an exception is thrown while the segments are being generated, red lines are drawn connecting the center point to the current inner and outer points, indicating where the constructor threw an exception.
- the region in which angles from the center point are negative are shown in a pale yellow. Angles increase in the counterclockwise direction. Note that the graph is sometimes rotated to make the displayed image as large as feasible.
This method may be useful when trying to identify problems with the paths such as an insufficient number of path segments.
- Parameters:
graph
- the graphfile
- the output file for the graph
-
reverseOrientation
public void reverseOrientation(boolean reverse) Change the orientation of the Bézier triangles associated with this object. This method affects the orientation of triangles provided by iterators. It does not change the values returned by calling methods such asprint()
.- Parameters:
reverse
- true if the orientation is the reverse of the one that was initially defined; false if the orientation is the same as the one that was initially defined.
-
flip
public void flip()Invert the orientation from its current value. -
isReversed
public boolean isReversed()Determine if the orientation for this grid is reversed.- Returns:
- true if the orientation is reversed; false if not
-
setColor
Set the color for this shape.- Parameters:
c
- the color; null if the color should not be defined
-
getColor
Get the color color for this shape. This is the color for the shape, excluding Bézier triangles for which an explicit color has been specified.- Returns:
- the color; null if it is not defined
-
print
Print this object's control points. Planar triangles are printed with the vertices in the order used in barycentric coordinates: v1 followed by v3 followed by v2, where the sequence v1 followed by v2 followed by v3 gives the orientation using the right-and rule.- Throws:
IOException
- an IO error occurred.
-
print
Print this object's control points, specifying an output. Planar triangles are printed with the vertices in the order used in barycentric coordinates: v1 followed by v3 followed by v2, where the sequence v1 followed by v2 followed by v3 gives the orientation using the right-and rule.- Parameters:
out
- the output- Throws:
IOException
- an IO error occurred.
-
print
Print this object's control points, specifying a prefix. Each line will start with the prefix (typically some number of spaces).Planar triangles are printed with the vertices in the order used in barycentric coordinates: v1 followed by v3 followed by v2, where the sequence v1 followed by v2 followed by v3 gives the orientation using the right-and rule.
- Parameters:
prefix
- the prefix- Throws:
IOException
- an IO error occurred.
-
print
Print this object's control points, specifying a prefix and output. Each line will start with the prefix (typically some number of spaces).Planar triangles are printed with the vertices in the order used in barycentric coordinates: v1 followed by v3 followed by v2, where the sequence v1 followed by v2 followed by v3 gives the orientation using the right-and rule.
- Parameters:
prefix
- the prefixout
- the output- Throws:
IOException
- an IO error occurred.
-
getSurfaceIterator
Description copied from interface:Shape3D
Get a surface iterator for this Shape3D. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface should be small enough that the transform can be approximated by an affine transform over the region containing the control points.
- Specified by:
getSurfaceIterator
in interfaceShape3D
- Parameters:
tform
- a transform to apply to each control point; null for the identity transform- Returns:
- a surface iterator
-
getSurfaceIterator
Description copied from interface:Shape3D
Get a surface iterator for this Shape3D, subdividing the surface. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface after each is subdivided should be small enough that the transform can be approximated by an affine transform over the region containing the control points.
- Specified by:
getSurfaceIterator
in interfaceShape3D
- Parameters:
tform
- a transform to apply to each control point; null for the identity transformlevel
- the number of levels of partitioning (each additional level splits the previous level into quarters)- Returns:
- a surface iterator
-
getBoundary
Description copied from interface:Shape3D
Get the boundary for this Shape3D. For a closed surface, the boundary will be an empty path.Typically, a boundary will consist of a series of distinct closed subpaths. Subpaths are separated by segments whose type is {link PathIterator3D#SEG_MOVETO}. For a closed manifold, the boundary will be an empty path.
- Specified by:
getBoundary
in interfaceShape3D
- Returns:
- the boundary of this surface; null if a boundary cannot be computed
- See Also:
-
isWellFormed
public boolean isWellFormed()Determine if this BezierVertex is well formed.- Returns:
- true if the grid is well formed; false otherwise
-
isWellFormed
Determine if thisConvexPathConnector
is well formed, logging error messages to an Appendable.- Parameters:
out
- an Appendable for logging error messages- Returns:
- true if the grid is well formed; false otherwise
-
getComponent
Description copied from interface:Shape3D
Get a component of this shape. Components are connected shapes - surfaces for which every point can connect to any other point. The components are referenced by an index, specified as an integer in the range [0,n), where n is the number of manifold components. If n is zero, no index is valid.- Specified by:
getComponent
in interfaceShape3D
- Parameters:
i
- the component's index- Returns:
- a model containing the specified component
- Throws:
IllegalArgumentException
- the argument is out of range- See Also:
-
getBounds
Description copied from interface:Shape3D
Get a bounding rectangular cuboid for a 3D shape. The edges will be aligned with the X, Y and Z axes. The cuboid created may not be the smallest one possible (for example, shapes defined by Bézier surfaces may just use the control points to determine the cuboid as the convex hull for the control points includes all of the surface for parameters in the normal range [0,1]). -
isClosedManifold
public boolean isClosedManifold()Description copied from interface:Shape3D
Determine if this Shape3D is a closed two-dimensional manifold.- Specified by:
isClosedManifold
in interfaceShape3D
- Returns:
- true if the surface is a closed two-dimensional manifold; false otherwise
-
isOriented
public boolean isOriented()Description copied from interface:Shape3D
Determine if a surface is oriented.- Specified by:
isOriented
in interfaceShape3D
- Returns:
- true if the surface has an orientation; false if it does not
-
numberOfComponents
public int numberOfComponents()Description copied from interface:Shape3D
Get the number of components for this shape. Components are connected shapes - surfaces for which every point can connect to any other point.- Specified by:
numberOfComponents
in interfaceShape3D
- Returns:
- the number of components for this shape
-