public class TriFaceClipper
extends java.lang.Object
The class can also calculate the maximum (unsigned) distance to the face of the portion of either a line segment or triangle that is clipped to one of these regions. Triangles are clipped as areas, and so the distance returned for them is exact.
The clipping is done with respect to a coordinate frame attached to the face, in which the face lies in the x-y plane so that the distance of a point from the face is simply the absolute value of its z coordinate and the planes bounding the region from the side are perpendicular to the x-y plane.
When a sequence of adjacent triangles is tested using maxClippedDistance(Face,int,boolean), the coordinates computed for the
vertices of one triangle can be reused for those it shares with the next.
| Constructor and Description |
|---|
TriFaceClipper()
Creates an uninitialized TriFaceClipper.
|
TriFaceClipper(Face tri)
Creates a TriFaceClipper initialized to a triangle specified by vertices
(in world coordinates) of a
Face. |
TriFaceClipper(Point3d p0,
Point3d p1,
Point3d p2)
Creates a TriFaceClipper initialized to a triangle specified by three
points oriented counter-clockwise.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
clipSegment(double[] svals,
Point3d ps0,
Point3d ps1,
Point3d p0,
Point3d p1,
int side)
Clips a line segment to either the upper or lower Voronoi region
depending on whether
side is 1 or -1. |
boolean |
isInitialized()
Queries whether if this clipper is initialized to a non-degenerate
triangle.
|
double |
maxClippedDistance(Face tri,
int side,
boolean checkAdjacent)
Computes the maximum unsigned distance from the face of a triangle
tri that is clipped to either the upper or lower region, depending on
whether side is positive or negative. |
double |
maxClippedDistance(HalfEdge he,
int side)
Computes the maximum unsigned distance from the face of an edge that is
clipped to either the upper or lower region, depending on whether
side is positive or negative. |
double |
maxClippedDistance(Point3d p0,
Point3d p1,
int side)
Computes the maximum unsigned distance from the face of a line segment
that is clipped to either the upper or lower region, depending on whether
side is positive or negative. |
double |
maxClippedDistance(Point3d p0,
Point3d p1,
Point3d p2,
int side)
Computes the maximum unsigned distance from the face of a triangle that
is clipped to either the upper or lower region, depending on whether
side is positive or negative. |
void |
set(Face tri)
Sets the TriFaceClipper to correspond to a triangle specified by the
world coordinates of a
Face. |
boolean |
set(Point3d p0,
Point3d p1,
Point3d p2)
Sets this TriFaceClipper to correspond to a triangle specified by three
points oriented counter-clockwise.
|
public TriFaceClipper()
public TriFaceClipper(Point3d p0, Point3d p1, Point3d p2)
p0 - first triangle pointp1 - second triangle pointp2 - third triangle pointpublic boolean set(Point3d p0, Point3d p1, Point3d p2)
false and the clipper will be set so that isInitialized() returns false.p0 - first triangle pointp1 - second triangle pointp2 - third triangle pointfalse if the triangle is degeneratepublic void set(Face tri)
Face. The first vertex corresponds to the
tail of the face's first half edge.tri - face defining the trianglepublic boolean isInitialized()
true if clipper is initialzedpublic boolean clipSegment(double[] svals,
Point3d ps0,
Point3d ps1,
Point3d p0,
Point3d p1,
int side)
side is 1 or -1. The segment
is assumed to lie between the points p0 and p1, such that
points on it are defined by
p = (1-s) p0 + s p1where
s is a scalar parameter in the range [0, 1].svals - If non-null, must be of length >= 2 and will be used
to return the parameter range of the segment after clipping. If all of
the segment lies in the region, svals will contain [0,1].
If none of the segment lies in the region, then it will be set to
contain [1,0].ps0 - if non-null and the segment is not completely clipped, returns
the clipped segment point corresponding to svals[0]ps1 - if non-null and the segment is not completely clipped,
returns the clipped segment point corresponding to svals[1]p0 - first point of the segmentp1 - last point of the segmentside - clips to the upper region if positive or the lower region if
negative. Must not be 0.false if no part of the segment lies in the region and so
any values returned by ps0 and ps1 are undefinedpublic double maxClippedDistance(HalfEdge he, int side)
side is positive or negative. The edge is specified by the world
coordinates of the vertices of a half-edge.he - edge to checkside - clips to the upper region if positive or the lower region if
negative. Must not be 0.public double maxClippedDistance(Point3d p0, Point3d p1, int side)
side is positive or negative. The segment is specified by
the points p0 and p1.p0 - first segment pointp1 - second segment pointside - clips to the upper region if positive or the lower region if
negative. Must not be 0.public double maxClippedDistance(Face tri, int side, boolean checkAdjacent)
tri that is clipped to either the upper or lower region, depending on
whether side is positive or negative. The triangle is evaluated
in world coordinates.
As with maxClippedDistance(Point3d,Point3d,Point3d,int), the
triangle is clipped as an area and so the distance returned is exact.
The argument checkAdjacent is used to help efficiently compute
the maximum distance for a clipped triangle strip. If set true,
then for each vertex of tri which is shared with the triangle
most recently tested by this method, the coordinates computed for that
vertex are reused instead of being recomputed. This does not affect the
value returned; it is purely an optimization, and callers should set it
false if the vertex positions may have changed since the previous
call.
tri - triangle to checkside - clips to the upper region if positive or the lower region if
negative. Must not be 0.checkAdjacent - if true, reuses coordinates for vertices
shared with the most recent triangle tested with this methodpublic double maxClippedDistance(Point3d p0, Point3d p1, Point3d p2, int side)
side is positive or negative. The triangle is defined by three
points specified in counter-clockwise order.
The triangle is clipped as an area, and so the distance returned is exact. In particular, the method detects the case in which the triangle's interior intersects the region while none of its edges do.
The computation is done in the triangle coordinate frame, where the face lies in the x-y plane and the distance of a point from the face is simply the absolute value of its z coordinate. The three planes bounding the region from the side are then perpendicular to the x-y plane, and the triangle is clipped to them using the (2d) edge descriptions.
p0 - first triangle pointp1 - second triangle pointp2 - third triangle pointside - clips to the upper region if positive or the lower region if
negative. Must not be 0.