3ds Max C++ API Reference
Loading...
Searching...
No Matches
PolyLine Class Reference

Describes a single polygon in a PolyShape using linear segments. More...

#include <polyshp.h>

+ Inheritance diagram for PolyLine:

Public Member Functions

CoreExport PolyLine ()
 Constructor.
 
CoreExport PolyLine (const PolyLine &from)
 Constructor.
 
CoreExport ~PolyLine ()
 Destructor.
 
CoreExport void Init ()
 Initializes the PolyLine.
 
CoreExport BOOL SetNumPts (int count, BOOL keep=TRUE)
 Sets the number of points in the polyline.
 
CoreExport void Append (const PolyPt &p)
 Appends the specified point to the polyline.
 
CoreExport void Insert (int where, const 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 PolyLineoperator= (const PolyLine &from)
 Assignment operator.
 
CoreExport PolyLineoperator= (Spline3D &from)
 Assignment operator.
 
CoreExport PolyPtoperator[] (int index)
 Array access operator.
 
CoreExport const PolyPtoperator[] (int index) const
 
CoreExport void Dump (const 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 BOOL HitsPolyLine (PolyLine &line, BOOL findAll=FALSE, IntersectionCallback3D *cb=NULL)
 Tells if the input PolyLine intersects this PolyLine or not.
 
CoreExport MtlID GetMatID (int segment)
 Returns the material ID for the specified segment.
 
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.
 
Opened/Closed/Self Intersects/Clockwise/Surrounds Point
void Close ()
 Marks the polyline as closed by setting the POLYLINE_CLOSED flag to one.
 
CoreExport BOOL IsClosed () const
 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 () const
 Tells if the polyline is open or not.
 
void SetNoSelfInt ()
 Sets the POLYLINE_NO_SELF_INT flag.
 
BOOL IsNoSelfInt () const
 Returns true if the POLYLINE_NO_SELF_INT flag is set, false if it is not.
 
CoreExport BOOL SurroundsPoint (Point2 &point)
 Returns TRUE if the specified point is surrounded (contained within) this PolyLine.
 
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.
 
Vertex/Segment counts
int Verts () const
 Returns the number of vertices (points) in the polyline.
 
CoreExport int Segments () const
 Returns the number of segments (edges between vertices) of the polyline.
 
Bounding Box/InvalidateGeomCache
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.
 
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.
 
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 (const Matrix3 &tm)
 Transforms the points of the polyline by the specified matrix.
 
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.
 
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.
 

Public Attributes

int numPts
 The number of points in the polyline.
 
PolyPtpts
 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.
 

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator.
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator.
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary.
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary.
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc.
 

Detailed 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

Constructor & Destructor Documentation

◆ PolyLine() [1/2]

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.

◆ PolyLine() [2/2]

CoreExport PolyLine ( const PolyLine from)

Constructor.

The PolyLine is initialized using the input object "from".

◆ ~PolyLine()

Destructor.

The array of points is freed.

Member Function Documentation

◆ Init()

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.

◆ Close()

void Close ( )
inline

Marks the polyline as closed by setting the POLYLINE_CLOSED flag to one.

239 {
241 }
DWORD flags
See PolyLine Flags.
Definition: polyshp.h:212
#define POLYLINE_CLOSED
Indicates the polyline is closed.
Definition: polyshp.h:195

◆ IsClosed()

CoreExport BOOL IsClosed ( ) const

Tells if the polyline is closed or not.

Returns
true if polyline is closed, false if it is not.

◆ Open()

void Open ( )
inline

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

249 {
250 flags &= ~POLYLINE_CLOSED;
251 }

◆ IsOpen()

CoreExport BOOL IsOpen ( ) const

Tells if the polyline is open or not.

Returns
true if polyline is open, false if it is not.

◆ SetNoSelfInt()

void SetNoSelfInt ( )
inline

Sets the POLYLINE_NO_SELF_INT flag.

259 {
261 }
#define POLYLINE_NO_SELF_INT
Ignore self-intersections.
Definition: polyshp.h:200

◆ IsNoSelfInt()

BOOL IsNoSelfInt ( ) const
inline

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

265 {
266 return (flags & POLYLINE_NO_SELF_INT) ? TRUE : FALSE;
267 }

◆ SurroundsPoint()

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.

◆ Verts()

int Verts ( ) const
inline

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

280 {
281 return numPts;
282 }
int numPts
The number of points in the polyline.
Definition: polyshp.h:210

◆ Segments()

CoreExport int Segments ( ) const

Returns the number of segments (edges between vertices) of the polyline.

◆ SetNumPts()

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.

◆ Append()

CoreExport void Append ( const 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.

◆ Insert()

CoreExport void Insert ( int  where,
const 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.

◆ Delete()

CoreExport void Delete ( int  where)

Deletes the specified point.

Parameters
whereThe "pts" array index indicating which point to delete.

◆ Reverse()

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.

◆ operator=() [1/2]

CoreExport PolyLine & operator= ( const PolyLine from)

Assignment operator.

◆ operator=() [2/2]

CoreExport PolyLine & operator= ( Spline3D from)

Assignment operator.

This generates a polyline from the spline.

◆ operator[]() [1/2]

CoreExport PolyPt & operator[] ( int  index)
inline

Array access operator.

Returns the specified point in the pts array.

327 {
328 return pts[index];
329 }
PolyPt * pts
Pointer to the actual points in the polyline.
Definition: polyshp.h:211

◆ operator[]() [2/2]

CoreExport const PolyPt & operator[] ( int  index) const
inline
331 {
332 return pts[index];
333 }

◆ BuildBoundingBox()

CoreExport void BuildBoundingBox ( void  )

Computes the bounding box of the polyline.

The result is stored in the bdgBox data member.

◆ InvalidateGeomCache()

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.

◆ GetBoundingBox()

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.

◆ Render() [1/2]

CoreExport void Render ( GraphicsWindow gw,
Material ma,
RECT *  rp,
int  compFlags,
int  numMat 
)

This method is used internally.

◆ Render() [2/2]

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

◆ Select()

CoreExport BOOL Select ( GraphicsWindow gw,
Material ma,
HitRegion hr,
int  abortOnHit = FALSE 
)

This method is used internally.

◆ Snap()

CoreExport void Snap ( GraphicsWindow gw,
SnapInfo snap,
IPoint2 p,
Matrix3 tm,
DWORD  vflags 
)

This method is used internally.

◆ Transform()

CoreExport void Transform ( const Matrix3 tm)

Transforms the points of the polyline by the specified matrix.

Parameters
tmThe matrix used to transform the points.

◆ Dump()

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.

◆ SpliceLine()

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.

◆ HitsSegment()

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.

◆ Cap3DS()

CoreExport int Cap3DS ( CapVert capverts,
MeshCapInfo capInfo,
DWORD  options = 0 
)

This method is used internally.

◆ HitsPolyLine()

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.

◆ InterpPiece3D()

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.

◆ InterpCurve3D()

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.

◆ TangentPiece3D()

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.

◆ TangentCurve3D()

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.

◆ GetMatID()

CoreExport MtlID GetMatID ( int  segment)

Returns the material ID for the specified segment.

Parameters
segmentThe zero based index of the segment.

◆ CurveLength()

CoreExport float CurveLength ( )

Returns the length of the calling PolyLine object.

◆ IsClockWise()

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.

◆ SelfIntersects()

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.

◆ GetSmoothingMap()

CoreExport void GetSmoothingMap ( IntTab map)

◆ Save()

CoreExport IOResult Save ( ISave isave)

◆ Load()

CoreExport IOResult Load ( ILoad iload)

◆ Swap()

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

◆ numPts

int numPts

The number of points in the polyline.

◆ pts

PolyPt* pts

Pointer to the actual points in the polyline.

◆ flags

DWORD flags

◆ bdgBox

Box3 bdgBox

The bounding box of the polyline.

◆ cachedLength

float cachedLength

The length of the polyline.

◆ lengths

float* lengths

Cached lengths for each point.

◆ percents

float* percents

Cached percentages for each point.

◆ cacheValid

BOOL cacheValid

Indicates if the cache is valid.