PolyLine Class Reference

#include <polyshp.h>

Class Description

Describes a single polygon in a PolyShape using linear segments.

All methods of this class are implemented by the system.

See also
PolyPt, PolyShape
+ Inheritance diagram for PolyLine:

Public Member Functions

CoreExport PolyLine ()
 Constructor. More...
 
CoreExport PolyLine (PolyLine &from)
 Constructor. More...
 
CoreExport ~PolyLine ()
 Destructor. More...
 
CoreExport void Init ()
 Initializes the PolyLine. More...
 
CoreExport BOOL SetNumPts (int count, BOOL keep=TRUE)
 Sets the number of points in the polyline. More...
 
CoreExport void Append (PolyPt &p)
 Appends the specified point to the polyline. More...
 
CoreExport void Insert (int where, PolyPt &p)
 Inserts the specified point at the location passed. More...
 
CoreExport void Delete (int where)
 Deletes the specified point. More...
 
CoreExport void Reverse (BOOL keepZero=FALSE)
 Reverses the order of the points in the polyline. More...
 
CoreExport PolyLineoperator= (PolyLine &from)
 Assignment operator. More...
 
CoreExport PolyLineoperator= (Spline3D &from)
 Assignment operator. More...
 
CoreExport PolyPtoperator[] (int index)
 Array access operator. More...
 
CoreExport void Dump (const MCHAR *title=NULL)
 Called to dump the polyline structure via DebugPrint(). More...
 
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. More...
 
CoreExport BOOL HitsPolyLine (PolyLine &line, BOOL findAll=FALSE, IntersectionCallback3D *cb=NULL)
 Tells if the input PolyLine intersects this PolyLine or not. More...
 
CoreExport MtlID GetMatID (int segment)
 Returns the material ID for the specified segment. More...
 
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. More...
 
Opened/Closed/Self Intersects/Clockwise/Surrounds Point
 
void Close ()
 Marks the polyline as closed by setting the POLYLINE_CLOSED flag to one. More...
 
CoreExport BOOL IsClosed ()
 Tells if the polyline is closed or not. More...
 
void Open ()
 Marks the polyline as open by resetting the POLYLINE_CLOSED flag to zero. More...
 
CoreExport BOOL IsOpen ()
 Tells if the polyline is open or not. More...
 
void SetNoSelfInt ()
 Sets the POLYLINE_NO_SELF_INT flag. More...
 
BOOL IsNoSelfInt ()
 Returns true if the POLYLINE_NO_SELF_INT flag is set, false if it is not. More...
 
CoreExport BOOL SurroundsPoint (Point2 &point)
 Returns TRUE if the specified point is surrounded (contained within) this PolyLine. More...
 
CoreExport float CurveLength ()
 Returns the length of the calling PolyLine object. More...
 
CoreExport BOOL IsClockWise ()
 Returns true if the polyline is clockwise in the XY plane (ignoring the Z dimension), false otherwise. More...
 
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. More...
 
Vertex/Segment counts
 
int Verts ()
 Returns the number of vertices (points) in the polyline. More...
 
CoreExport int Segments ()
 Returns the number of segments (edges between vertices) of the polyline. More...
 
Bounding Box/InvalidateGeomCache
 
CoreExport void BuildBoundingBox (void)
 Computes the bounding box of the polyline. More...
 
CoreExport void InvalidateGeomCache ()
 Ensures that the calling PolyLine object has flushed out any cached data it may have had. More...
 
CoreExport Box3 GetBoundingBox (Matrix3 *tm=NULL)
 Returns the bound box of the polyline. More...
 
Render/Select/Snap/Transform
 
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. More...
 
CoreExport BOOL Select (GraphicsWindow *gw, Material *ma, HitRegion *hr, int abortOnHit=FALSE)
 
CoreExport void Snap (GraphicsWindow *gw, SnapInfo *snap, IPoint2 *p, Matrix3 &tm, DWORD vflags)
 
CoreExport void Transform (Matrix3 &tm)
 Transforms the points of the polyline by the specified matrix. More...
 
Capping Method
 
CoreExport int Cap3DS (CapVert *capverts, MeshCapInfo &capInfo, DWORD options=0)
 
Interpolated Points/Tangent Vectors
 
CoreExport Point3 InterpPiece3D (int segment, float t)
 Returns a point interpolated on a segment between two points. More...
 
CoreExport Point3 InterpCurve3D (float u, int ptype=POLYSHP_INTERP_SIMPLE)
 Returns a point interpolated on the entire curve. More...
 
CoreExport Point3 TangentPiece3D (int segment, float t)
 Returns a tangent vector interpolated on a segment between two points. More...
 
CoreExport Point3 TangentCurve3D (float u, int ptype=POLYSHP_INTERP_SIMPLE)
 Returns a tangent vector interpolated on the entire curve. More...
 

Public Attributes

int numPts
 The number of points in the polyline. More...
 
PolyPtpts
 Pointer to the actual points in the polyline. More...
 
DWORD flags
 See PolyLine Flags. More...
 
Box3 bdgBox
 The bounding box of the polyline. More...
 
float cachedLength
 The length of the polyline. More...
 
float * lengths
 Cached lengths for each point. More...
 
float * percents
 Cached percentages for each point. More...
 
BOOL cacheValid
 Indicates if the cache is valid. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 

Constructor & Destructor Documentation

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".

Destructor.

The array of points is freed.

Member Function Documentation

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.

204 { flags |= POLYLINE_CLOSED; }
#define POLYLINE_CLOSED
Indicates the polyline is closed.
Definition: polyshp.h:162
DWORD flags
See PolyLine Flags.
Definition: polyshp.h:178
CoreExport BOOL IsClosed ( )

Tells if the polyline is closed or not.

Returns
true if polyline is closed, false if it is not.
void Open ( )
inline

Marks the polyline as open by resetting the POLYLINE_CLOSED flag to zero.

211 { flags &= ~POLYLINE_CLOSED; }
#define POLYLINE_CLOSED
Indicates the polyline is closed.
Definition: polyshp.h:162
DWORD flags
See PolyLine Flags.
Definition: polyshp.h:178
CoreExport BOOL IsOpen ( )

Tells if the polyline is open or not.

Returns
true if polyline is open, false if it is not.
void SetNoSelfInt ( )
inline

Sets the POLYLINE_NO_SELF_INT flag.

DWORD flags
See PolyLine Flags.
Definition: polyshp.h:178
#define POLYLINE_NO_SELF_INT
Ignore self-intersections.
Definition: polyshp.h:167
BOOL IsNoSelfInt ( )
inline

Returns true if the POLYLINE_NO_SELF_INT flag is set, false if it is not.

221 { return (flags & POLYLINE_NO_SELF_INT) ? TRUE : FALSE; }
DWORD flags
See PolyLine Flags.
Definition: polyshp.h:178
#define POLYLINE_NO_SELF_INT
Ignore self-intersections.
Definition: polyshp.h:167
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.

Parameters
pointThe point to check if it is inside the polyline or not.
int Verts ( )
inline

Returns the number of vertices (points) in the polyline.

233 { return numPts; }
int numPts
The number of points in the polyline.
Definition: polyshp.h:176
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.

Parameters
countThe number to set.
keepIf set to true, any existing points are copied to the new array. If not, they are freed. Defaults to true.
Returns
true if the number of points was set, false otherwise.
CoreExport void Append ( PolyPt p)

Appends the specified point to the polyline.

This adds the point to the end of the points list.

Parameters
pThe point to appended.
CoreExport void Insert ( int  where,
PolyPt p 
)

Inserts the specified point at the location passed.

Parameters
whereThe "pts" array index indicating where to insert the point.
pThe point to insert.
CoreExport void Delete ( int  where)

Deletes the specified point.

Parameters
whereThe "pts" array index indicating which point to delete.
CoreExport void Reverse ( BOOL  keepZero = FALSE)

Reverses the order of the points in the polyline.

Parameters
keepZeroDefaults 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.
CoreExport PolyLine& operator= ( PolyLine from)

Assignment operator.

CoreExport PolyLine& operator= ( Spline3D from)

Assignment operator.

This generates a polyline from the spline.

CoreExport PolyPt& operator[] ( int  index)
inline

Array access operator.

Returns the specified point in the pts array.

277 { return pts[index]; }
PolyPt * pts
Pointer to the actual points in the polyline.
Definition: polyshp.h:177
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.

CoreExport Box3 GetBoundingBox ( Matrix3 tm = NULL)

Returns the bound box of the polyline.

The optional TM allows the box to be calculated in any space.

Parameters
tmThe 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.

Parameters
gwPoints to the graphics window to render to.
maThe list of materials to use to render the polyline. See Class Material, Class INode - Material methods.
numMatThe number of materials for the polyline.
colorSegsif this is set material is used to determine what colors to render the polyline. Otherwise the standard sel/subsel colors are used
segselthis is the segment sel bitarray used to draw the selected segments
useStartSegments= TRUE if this is set the start/endsegments 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  vflags 
)

This method is used internally.

CoreExport void Transform ( Matrix3 tm)

Transforms the points of the polyline by the specified matrix.

Parameters
tmThe matrix used to transform the points.
CoreExport void Dump ( const MCHAR title = NULL)

Called to dump the polyline structure via DebugPrint().

See Troubleshooting.

Parameters
titleThis 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.

Parameters
p1,p2The endpoints of the line to check.
findAllTRUE to find all intersections. FALSE to find only the first intersection. Defaults to FALSE.
cbA pointer to an IntersectionCallback3D class.
Returns
true if the line segment defined between points p1 and p2 intersects this PolyLine, false otherwise.
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.

Parameters
lineThe input PolyLine to check.
findAllTRUE to find all intersections. FALSE to find only the first intersection.
cbA pointer to an IntersectionCallback3D class.
Returns
true if the input PolyLine line intersects this PolyLine, false otherwise.
CoreExport Point3 InterpPiece3D ( int  segment,
float  t 
)

Returns a point interpolated on a segment between two points.

Parameters
segmentThe index of the segment to interpolate.

tA value in the range of 0.0 to 1.0. 0 is the first point and 1 is the second point.
Returns
The interpolated 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.

Parameters
uA value in the range of 0.0 to 1.0 for the entire curve.
ptypeThe 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
Returns
The interpolated point.
CoreExport Point3 TangentPiece3D ( int  segment,
float  t 
)

Returns a tangent vector interpolated on a segment between two points.

Parameters
segmentThe index of the segment.
tA value in the range of 0.0 to 1.0. 0 is the first point and 1 is the second point.
Returns
The tangent vector.
CoreExport Point3 TangentCurve3D ( float  u,
int  ptype = POLYSHP_INTERP_SIMPLE 
)

Returns a tangent vector interpolated on the entire curve.

Parameters
uA value in the range of 0.0 to 1.0 for the entire curve.
ptypeThe 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
Returns
The tangent vector.
CoreExport MtlID GetMatID ( int  segment)

Returns the material ID for the specified segment.

Parameters
segmentThe 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.

Parameters
findAlltrue to find all self intersections, false to find only the first self intersection. Defaults to false.
cbPointer to an IntersectionCallback3D class. Defaults to NULL.
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.

This is useful to transfer polylines to a new array, for instance.

Parameters
[in,out]linePolLine object to swap with.

Member Data Documentation

int numPts

The number of points in the polyline.

PolyPt* pts

Pointer to the actual points in the polyline.

DWORD 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.