#include <c4d_baseobject.h>
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.

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 (void) 

PolyInfo *  GetPolyInfo (Int32 poly) 

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

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

◆ Neighbor()
◆ ~Neighbor()
◆ Init()
Initializes the internal polygon information.
 Warning
 Must be called before the class can be used to get the neighboring polygons.
 Parameters

[in]  pcnt  The total number of points from the polygon object. This can be obtained calling PointObject::GetPointCount(). 
[in]  vadr  Pointer to the polygons array. This can be obtained calling PolygonObject::GetPolygonR(). The caller owns the pointed polygons array. 
[in]  vcnt  The total number of polygons in the polygons array. This can be obtained calling PolygonObject::GetPolygonCount(). 
[in]  bs  Pointer 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()
Gets the polygons that neighbor the given edge.
 Parameters

[in]  a  The point index that defines the first edge point. 
[in]  b  The point index that defines the second edge point. 
[in]  first  Assigned the first polygon index associated with the edge. 
[in]  second  Assigned the second polygon index associated with the edge. 
◆ GetPointPolys()
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];
}
maxon::Int32 Int32
Definition: ge_sys_math.h:60
 Parameters

[in]  pnt  The point index to use to find the associated polygons. 
[in]  dadr  Assigned the address of the returned polygon array. 
[in]  dcnt  Assigned the number of polygons returned in the array daddr. 
◆ GetPointOneRingPoints()
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];
}
 Parameters

[in]  pnt  The point index to use to find the associated one ring points. 
[in]  dadr  Assigned the address of the returned points array. The caller owns the pointed points array. 
[in]  dcnt  Assigned the number of points returned in daddr. 
◆ GetEdgeCount()
Int32 GetEdgeCount 
( 
void 
 ) 

Gets the total number of edges found.
 Returns
 The number of edges in the given polygons in Init().
◆ GetPolyInfo()
Gets neighbor information about the given polygon.
 Parameters

[in]  poly  The polygon index to get the neighbor information for. 
 Returns
 The neighbor information. The neighbor object owns the pointed polygon information.
◆ GetNeighbor()
Gets the polygon opposite to poly with respect to the edge from point a to b.
 Parameters

[in]  a  The point index that defines the first edge point. 
[in]  b  The point index that defines the second edge point. 
[in]  poly  The 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()
Gets the Ngon neighbors.
 Parameters

[in]  op  The polygon object. The caller owns the pointed polygon object. 
[out]  ngoncnt  Assigned the Ngon count. 
[out]  ngons  Assigned a pointer to the Ngon neighbor information.
Free the array afterwards with DeleteMem() (not the segments, points, edges or neighbor members). 
 Returns
 true if the Ngon neighbors were successfully retrieved, otherwise false.
◆ 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_polyadr  The new polygon address to set. 
◆ ee