Neighbor Class Reference

#include <c4d_baseobject.h>

Detailed Description

Helper class to get neighboring polygons from edges and points:

Note
This class assumes that the geometry is clean such that an edge is only shared by two polygons.
If this is not the case then the information may not be correct.
Warning
The polygon array passed to Init() must not be modified during the use of the class.
For example, if a polygon object is resized or its polygons modified the class may crash if it is used afterwards.

Private Attributes

EnumerateEdges * ee
 

Constructor/Destructor

 Neighbor ()
 
virtual ~Neighbor ()
 

Init

virtual Bool Init (Int32 pcnt, const CPolygon *vadr, Int32 vcnt, BaseSelect *bs)
 

Get Neighbor Information

void GetEdgePolys (Int32 a, Int32 b, Int32 *first, Int32 *second)
 
void GetPointPolys (Int32 pnt, Int32 **dadr, Int32 *dcnt)
 
void GetPointOneRingPoints (Int32 pnt, Int32 **dadr, Int32 *dcnt)
 
Int32 GetEdgeCount ()
 
PolyInfoGetPolyInfo (Int32 poly)
 
Int32 GetNeighbor (Int32 a, Int32 b, Int32 poly)
 
Bool GetNGons (PolygonObject *op, Int32 &ngoncnt, NgonNeighbor *&ngons)
 

Miscellaneous

void Flush ()
 
void ResetAddress (const CPolygon *a_polyadr)
 

Constructor & Destructor Documentation

◆ Neighbor()

Neighbor ( )

Default constructor.

◆ ~Neighbor()

virtual ~Neighbor ( )
virtual

Default destructor.

Member Function Documentation

◆ Init()

virtual Bool Init ( Int32  pcnt,
const CPolygon vadr,
Int32  vcnt,
BaseSelect bs 
)
virtual

Initializes the internal polygon information.

Warning
Must be called before the class can be used to get the neighboring polygons.
Parameters
[in]pcntThe total number of points from the polygon object. This can be obtained calling PointObject::GetPointCount().
[in]vadrPointer to the polygons array. This can be obtained calling PolygonObject::GetPolygonR(). The caller owns the pointed polygons array.
[in]vcntThe total number of polygons in the polygons array. This can be obtained calling PolygonObject::GetPolygonCount().
[in]bsPointer to the polygon selection used to build the neighbor information. Set nullptr to use all polygons. The caller owns the pointed base select.
Returns
true if the initialization was successful, otherwise false.

◆ GetEdgePolys()

void GetEdgePolys ( Int32  a,
Int32  b,
Int32 first,
Int32 second 
)

Gets the polygons that neighbor the given edge.

Parameters
[in]aThe point index that defines the first edge point.
[in]bThe point index that defines the second edge point.
[in]firstAssigned the first polygon index associated with the edge.
[in]secondAssigned the second polygon index associated with the edge.

◆ GetPointPolys()

void GetPointPolys ( Int32  pnt,
Int32 **  dadr,
Int32 dcnt 
)

Gets the polygons that are attached to the given point.

Note
No memory allocation/freeing is necessary.

Example:
To get the polygons around say point 137 we would use:

Int32 *dadr = nullptr, dcnt = 0, poly;
neighbor.GetPointPolys(137, &dadr, &dcnt);
for (Int32 i=0; i<dcnt; i++)
{
poly = dadr[i];
// Do something
}
Py_ssize_t i
Definition: abstract.h:645
maxon::Int32 Int32
Definition: ge_sys_math.h:60
Parameters
[in]pntThe point index to use to find the associated polygons.
[in]dadrAssigned the address of the returned polygon array.
[in]dcntAssigned the number of polygons returned in the array daddr.

◆ GetPointOneRingPoints()

void GetPointOneRingPoints ( Int32  pnt,
Int32 **  dadr,
Int32 dcnt 
)

Gets the points that are attached through one edge to the given point.

Since
R19
Note
No memory allocation/freeing is necessary.

Example:
To get the points around say point 137 we would use:

Int32 *dadr = nullptr, dcnt = 0, poly;
neighbor.GetPointOneRingPoints(137, &dadr, &dcnt);
for (Int32 i=0; i<dcnt; i++)
{
pointIndex = dadr[i];
// Do something
}
Parameters
[in]pntThe point index to use to find the associated one ring points.
[in]dadrAssigned the address of the returned points array. The caller owns the pointed points array.
[in]dcntAssigned the number of points returned in daddr.

◆ GetEdgeCount()

Int32 GetEdgeCount ( )

Gets the total number of edges found.

Returns
The number of edges in the given polygons in Init().

◆ GetPolyInfo()

PolyInfo* GetPolyInfo ( Int32  poly)

Gets neighbor information about the given polygon.

Parameters
[in]polyThe polygon index to get the neighbor information for.
Returns
The neighbor information. The neighbor object owns the pointed polygon information.

◆ GetNeighbor()

Int32 GetNeighbor ( Int32  a,
Int32  b,
Int32  poly 
)

Gets the polygon opposite to poly with respect to the edge from point a to b.

Parameters
[in]aThe point index that defines the first edge point.
[in]bThe point index that defines the second edge point.
[in]polyThe index of the polygon to get the polygon opposite to.
Returns
The opposite polygon index, or if formatParam{poly} is not one of the edge polygons, or NOTOK if none exists.

◆ GetNGons()

Bool GetNGons ( PolygonObject op,
Int32 ngoncnt,
NgonNeighbor *&  ngons 
)

Gets the N-gon neighbors.

Parameters
[in]opThe polygon object. The caller owns the pointed polygon object.
[out]ngoncntAssigned the N-gon count.
[out]ngonsAssigned a pointer to the N-gon neighbor information.
Free the array afterwards with DeleteMem() (not the segments, points, edges or neighbor members).
Returns
true if the N-gon neighbors were successfully retrieved, otherwise false.

◆ Flush()

void Flush ( )

Flushes the neighbor information.

◆ ResetAddress()

void ResetAddress ( const CPolygon a_polyadr)

Allows to set the new pointer to the polygon object if changed.
It is then possible to continue using the Neighbor data.

Warning
Use carefully!
The array lengths and orders must not have changed, only the pointer used.
Parameters
[in]a_polyadrThe new polygon address to set.

Member Data Documentation

◆ ee

EnumerateEdges* ee
private