This reference page is linked to from the following overview topics: Capping a Shape with a Mesh, Gizmo Hit Testing using PolyLines.
Describes a single polygon in a PolyShape using linear segments.
All methods of this class are implemented by the system.
#include <polyshp.h>
Public Member Functions |
|
CoreExport | PolyLine () |
Constructor. |
|
CoreExport | PolyLine (PolyLine &from) |
Constructor. |
|
CoreExport | ~PolyLine () |
Destructor. |
|
CoreExport void | Init () |
Initializes the PolyLine.
|
|
void | Close () |
Marks the polyline as closed by setting the
POLYLINE_CLOSED flag to one. |
|
CoreExport BOOL | IsClosed () |
Tells if the polyline is closed or not.
|
|
void | Open () |
Marks the polyline as open by resetting the
POLYLINE_CLOSED flag to zero. |
|
CoreExport BOOL | IsOpen () |
Tells if the polyline is open or not.
|
|
void | SetNoSelfInt () |
Sets the POLYLINE_NO_SELF_INT flag. |
|
BOOL | IsNoSelfInt () |
Returns true if the POLYLINE_NO_SELF_INT
flag is set, false if it is not. |
|
int | Verts () |
Returns the number of vertices (points) in
the polyline. |
|
CoreExport int | Segments () |
Returns the number of segments (edges
between vertices) of the polyline. |
|
CoreExport BOOL | SetNumPts (int count, BOOL keep=TRUE) |
Sets the number of points in the polyline.
|
|
CoreExport void | Append (PolyPt &p) |
Appends the specified point to the polyline.
|
|
CoreExport void | Insert (int where, PolyPt &p) |
Inserts the specified point at the location
passed. |
|
CoreExport void | Delete (int where) |
Deletes the specified point. |
|
CoreExport void | Reverse (BOOL keepZero=FALSE) |
Reverses the order of the points in the
polyline. |
|
CoreExport PolyLine & | operator= (PolyLine &from) |
Assignment operator. |
|
CoreExport PolyLine & | operator= (Spline3D &from) |
Assignment operator. |
|
CoreExport PolyPt & | operator[] (int index) |
Array access operator. |
|
CoreExport void | BuildBoundingBox (void) |
Computes the bounding box of the polyline.
|
|
CoreExport void | InvalidateGeomCache () |
Ensures that the calling PolyLine
object has flushed out any cached data it may have had. |
|
CoreExport Box3 | GetBoundingBox (Matrix3 *tm=NULL) |
Returns the bound box of the polyline.
|
|
CoreExport void | Render (GraphicsWindow *gw, Material *ma, RECT *rp, int compFlags, int numMat) |
CoreExport void | Render (GraphicsWindow *gw, Material *ma, int numMat, BOOL colorSegs, BitArray &segsel, BOOL useStartSegments=TRUE) |
This renders the polyline to the display.
|
|
CoreExport BOOL | Select (GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit=FALSE) |
CoreExport void | Snap (GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm, DWORD flags) |
CoreExport void | Transform (Matrix3 &tm) |
Transforms the points of the polyline by the
specified matrix. |
|
CoreExport void | Dump (MCHAR *title=NULL) |
Called to dump the polyline structure via
DebugPrint(). |
|
CoreExport void | SpliceLine (int where, PolyLine &source, int splicePoint) |
CoreExport BOOL | HitsSegment (Point2 p1, Point2 p2, BOOL findAll=FALSE, IntersectionCallback3D *cb=NULL) |
Tells if the line segment defined between
the two input points intersects this PolyLine
object or not. |
|
CoreExport int | Cap3DS (CapVert *capverts, MeshCapInfo &capInfo, DWORD options=0) |
CoreExport BOOL | HitsPolyLine (PolyLine &line, BOOL findAll=FALSE, IntersectionCallback3D *cb=NULL) |
Tells if the input PolyLine
intersects this PolyLine
or not. |
|
CoreExport BOOL | SurroundsPoint (Point2 &point) |
Returns TRUE if the specified point is
surrounded (contained within) this PolyLine.
|
|
CoreExport Point3 | InterpPiece3D (int segment, float t) |
Returns a point interpolated on a segment
between two points. |
|
CoreExport Point3 | InterpCurve3D (float u, int ptype=POLYSHP_INTERP_SIMPLE) |
Returns a point interpolated on the entire
curve. |
|
CoreExport Point3 | TangentPiece3D (int segment, float t) |
Returns a tangent vector interpolated on a
segment between two points. |
|
CoreExport Point3 | TangentCurve3D (float u, int ptype=POLYSHP_INTERP_SIMPLE) |
Returns a tangent vector interpolated on the
entire curve. |
|
CoreExport MtlID | GetMatID (int segment) |
Returns the material ID for the specified
segment. |
|
CoreExport float | CurveLength () |
Returns the length of the calling PolyLine
object. |
|
CoreExport BOOL | IsClockWise () |
Returns true if the polyline is clockwise in
the XY plane (ignoring the Z dimension), false otherwise. |
|
CoreExport BOOL | SelfIntersects (BOOL findAll=FALSE, IntersectionCallback3D *cb=NULL) |
Returns TRUE if the polyline intersects
itself in the XY plane (ignoring the Z dimension), false otherwise.
|
|
CoreExport void | GetSmoothingMap (IntTab &map) |
CoreExport IOResult | Save (ISave *isave) |
CoreExport IOResult | Load (ILoad *iload) |
CoreExport void | Swap (PolyLine &line) |
Lets the developer transfer the content of a
line object to another object without suffering from any copy
penalties. |
|
Public Attributes |
|
int | numPts |
The number of points in the polyline.
|
|
PolyPt * | pts |
Pointer to the actual points in the
polyline. |
|
DWORD | flags |
See PolyLine Flags. |
|
Box3 | bdgBox |
The bounding box of the polyline. |
|
float | cachedLength |
The length of the polyline. |
|
float * | lengths |
Cached lengths for each point. |
|
float * | percents |
Cached percentages for each point. |
|
BOOL | cacheValid |
Indicates if the cache is valid. |
CoreExport PolyLine | ( | ) |
Constructor.
The number of points is set to zero, the points array is set to NULL, the flags are set to 0, the cache validity is set to FALSE and the bounding box is set to empty.
Constructor.
The PolyLine is initialized using the input object "from".
CoreExport ~PolyLine | ( | ) |
Destructor.
The array of points is freed.
CoreExport void Init | ( | ) |
Initializes the PolyLine.
The array of points (pts) is freed, the number of points is set to 0, and the cache validity is set to FALSE.
void Close | ( | ) | [inline] |
Marks the polyline as closed by setting the POLYLINE_CLOSED flag to one.
{ flags |= POLYLINE_CLOSED; }
CoreExport BOOL IsClosed | ( | ) |
Tells if the polyline is closed or not.
void Open | ( | ) | [inline] |
Marks the polyline as open by resetting the POLYLINE_CLOSED flag to zero.
{ flags &= ~POLYLINE_CLOSED; }
CoreExport BOOL IsOpen | ( | ) |
Tells if the polyline is open or not.
void SetNoSelfInt | ( | ) | [inline] |
BOOL IsNoSelfInt | ( | ) | [inline] |
Returns true if the POLYLINE_NO_SELF_INT flag is set, false if it is not.
{ return (flags & POLYLINE_NO_SELF_INT) ? TRUE : FALSE; }
int Verts | ( | ) | [inline] |
Returns the number of vertices (points) in the polyline.
{ return numPts; }
CoreExport int Segments | ( | ) |
Returns the number of segments (edges between vertices) of the polyline.
CoreExport BOOL SetNumPts | ( | int | count, |
BOOL | keep = TRUE |
||
) |
Sets the number of points in the polyline.
count | The number to set. |
keep | If set to true, any existing points are copied to the new array. If not, they are freed. Defaults to true. |
CoreExport void Append | ( | PolyPt & | p | ) |
Appends the specified point to the polyline.
This adds the point to the end of the points list.
p | The point to appended. |
CoreExport void Insert | ( | int | where, |
PolyPt & | p | ||
) |
Inserts the specified point at the location passed.
where | The "pts" array index indicating where to insert the point. |
p | The point to insert. |
CoreExport void Delete | ( | int | where | ) |
Deletes the specified point.
where | The "pts" array index indicating which point to delete. |
CoreExport void Reverse | ( | BOOL | keepZero = FALSE |
) |
Reverses the order of the points in the polyline.
keepZero | Defaults to false. This should normally be passed as TRUE. If TRUE, and the polyline is closed, this method will make sure that vertex zero is the same on the reversed version as on the non-reversed version. Otherwise if passed as FALSE the last vertex becomes the first vertex, and the first vertex becomes the last. This is an important distinction for the lofter because it always wants vertex zero to be in the same place. |
Assignment operator.
This generates a polyline from the spline.
CoreExport PolyPt& operator[] | ( | int | index | ) | [inline] |
CoreExport void BuildBoundingBox | ( | void | ) |
Computes the bounding box of the polyline.
The result is stored in the bdgBox data member.
CoreExport void InvalidateGeomCache | ( | ) |
Ensures that the calling PolyLine object has flushed out any cached data it may have had.
This resets the bounding box size and sets the cache validity to false. This should be called when any points have been changed in the polyline.
Returns the bound box of the polyline.
The optional TM allows the box to be calculated in any space.
tm | The points of the polyline are multiplied by this matrix before the box computation. Defaults to NULL. |
CoreExport void Render | ( | GraphicsWindow * | gw, |
Material * | ma, | ||
RECT * | rp, | ||
int | compFlags, | ||
int | numMat | ||
) |
This method is used internally.
CoreExport void Render | ( | GraphicsWindow * | gw, |
Material * | ma, | ||
int | numMat, | ||
BOOL | colorSegs, | ||
BitArray & | segsel, | ||
BOOL | useStartSegments =
TRUE |
||
) |
This renders the polyline to the display.
gw | Points to the graphics window to render to. |
ma | The list of materials to use to render the polyline. See Class Material, Class INode - Material methods. |
numMat | The number of materials for the polyline. |
colorSegs | if this is set material is used to determine what colors to render the polyline. Otherwise the standard sel/subsel colors are used |
segsel | this is the segment sel bitarray used to draw the selected segments |
useStartSegments | = TRUE if this is set the start/endsegmens will be used around the polyline draw. If you are drawing several polylines in a row it is faster to set this to false and use start/endsegments around the entire draw instead of each individual polyline |
CoreExport BOOL Select | ( | GraphicsWindow * | gw, |
Material * | ma, | ||
HitRegion * | hr, | ||
int | abortOnHit =
FALSE |
||
) |
This method is used internally.
CoreExport void Snap | ( | GraphicsWindow * | gw, |
SnapInfo * | snap, | ||
IPoint2 * | p, | ||
Matrix3 & | tm, | ||
DWORD | flags | ||
) |
This method is used internally.
CoreExport void Transform | ( | Matrix3 & | tm | ) |
Transforms the points of the polyline by the specified matrix.
tm | The matrix used to transform the points. |
CoreExport void Dump | ( | MCHAR * | title = NULL |
) |
Called to dump the polyline structure via DebugPrint().
See Debugging.
title | This title string is displayed using a DebugPrint() before the rest of the data. |
CoreExport void SpliceLine | ( | int | where, |
PolyLine & | source, | ||
int | splicePoint | ||
) |
This method is used internally as part of the capping mechanism and should not be used.
CoreExport BOOL HitsSegment | ( | Point2 | p1, |
Point2 | p2, | ||
BOOL | findAll = FALSE , |
||
IntersectionCallback3D * | cb = NULL |
||
) |
Tells if the line segment defined between the two input points intersects this PolyLine object or not.
p1,p2 | The endpoints of the line to check. |
findAll | TRUE to find all intersections. FALSE to find only the first intersection. Defaults to FALSE. |
cb | A pointer to an IntersectionCallback3D class. |
CoreExport int Cap3DS | ( | CapVert * | capverts, |
MeshCapInfo & | capInfo, | ||
DWORD | options = 0 |
||
) |
This method is used internally.
CoreExport BOOL HitsPolyLine | ( | PolyLine & | line, |
BOOL | findAll = FALSE , |
||
IntersectionCallback3D * | cb = NULL |
||
) |
Tells if the input PolyLine intersects this PolyLine or not.
line | The input PolyLine to check. |
findAll | TRUE to find all intersections. FALSE to find only the first intersection. |
cb | A pointer to an IntersectionCallback3D class. |
CoreExport BOOL SurroundsPoint | ( | Point2 & | point | ) |
Returns TRUE if the specified point is surrounded (contained within) this PolyLine.
This method should only be called on closed PolyLines.
point | The point to check if it is inside the polyline or not. |
CoreExport Point3 InterpPiece3D | ( | int | segment, |
float | t | ||
) |
Returns a point interpolated on a segment between two points.
segment | The index of the segment to interpolate. |
t | A value in the range of 0.0 to 1.0. 0 is the first point and 1 is the second point. |
CoreExport Point3 InterpCurve3D | ( | float | u, |
int | ptype =
POLYSHP_INTERP_SIMPLE |
||
) |
Returns a point interpolated on the entire curve.
This method returns a point but does not tell on which segment the point falls.
u | A value in the range of 0.0 to 1.0 for the entire curve. |
ptype | The parameter type for interpolation. The default value, POLYSHP_INTERP_SIMPLE, is based on segments (rather than the entire curve). See Parameter types for shape interpolation |
CoreExport Point3 TangentPiece3D | ( | int | segment, |
float | t | ||
) |
Returns a tangent vector interpolated on a segment between two points.
segment | The index of the segment. |
t | A value in the range of 0.0 to 1.0. 0 is the first point and 1 is the second point. |
CoreExport Point3 TangentCurve3D | ( | float | u, |
int | ptype =
POLYSHP_INTERP_SIMPLE |
||
) |
Returns a tangent vector interpolated on the entire curve.
u | A value in the range of 0.0 to 1.0 for the entire curve. |
ptype | The parameter type for interpolation. The default value, POLYSHP_INTERP_SIMPLE, is based on segments (rather than the entire curve). See Parameter types for shape interpolation |
CoreExport MtlID GetMatID | ( | int | segment | ) |
Returns the material ID for the specified segment.
segment | The zero based index of the segment. |
CoreExport float CurveLength | ( | ) |
Returns the length of the calling PolyLine object.
CoreExport BOOL IsClockWise | ( | ) |
Returns true if the polyline is clockwise in the XY plane (ignoring the Z dimension), false otherwise.
If the calling PolyLine object self intersects, the result is meaningless.
CoreExport BOOL SelfIntersects | ( | BOOL | findAll = FALSE , |
IntersectionCallback3D * | cb = NULL |
||
) |
Returns TRUE if the polyline intersects itself in the XY plane (ignoring the Z dimension), false otherwise.
findAll | true to find all self intersections, false to find only the first self intersection. Defaults to false. |
cb | Pointer to an IntersectionCallback3D class. Defaults to NULL. |
CoreExport void GetSmoothingMap | ( | IntTab & | map | ) |
CoreExport void Swap | ( | PolyLine & | line | ) |
Lets the developer transfer the content of a line object to another object without suffering from any copy penalties.
This is useful to transfer polylines to a new array, for instance.
[in,out] | line | PolLine object to swap with. |
int numPts |
The number of points in the polyline.
Pointer to the actual points in the polyline.
DWORD flags |
The bounding box of the polyline.
float cachedLength |
The length of the polyline.
float* lengths |
Cached lengths for each point.
float* percents |
Cached percentages for each point.
BOOL cacheValid |
Indicates if the cache is valid.