Modeling Class Reference

#include <lib_modeling.h>

Detailed Description

Modeling engine.

Private Member Functions

 Modeling ()
 
 ~Modeling ()
 

Private Attributes

ModelingBase * m_pBase
 
ModelingKernel * m_pKernelCache
 
C4DAtomm_pObjectCache
 

Alloc/Free

static ModelingAlloc ()
 
static void Free (Modeling *&p)
 

Init/Commit/Release

Bool InitArray (AtomArray *objs, Int32 flags=0)
 
Bool InitObject (C4DAtom *op, Int32 flags=0)
 
Bool Commit (C4DAtom *op=nullptr, Int32 flags=0, BaseObject *cobj=nullptr)
 
void Release ()
 
void ReleaseObject (C4DAtom *op)
 

Map

Bool GetPointMap (C4DAtom *op, Int32 **map, Int32 *count)
 
Bool GetNgonMap (C4DAtom *op, Int32 **map, Int32 *count)
 
Bool ReleaseMap (C4DAtom *op, Int32 *map)
 
Bool FreeMap (C4DAtom *op, Int32 *map)
 

Point

Int32 AddPoint (C4DAtom *op, const Vector &p)
 
Int32 ClonePoint (C4DAtom *op, Int32 index)
 
Bool DeletePoint (C4DAtom *op, Int32 index)
 
Bool GetPoint (C4DAtom *op, Int32 index, Vector *p)
 
Bool SetPoint (C4DAtom *op, Int32 index, const Vector &p, Int32 flags=0)
 
Bool SetEdgePoint (C4DAtom *op, Int32 index, Float l, Int32 flags=0)
 
Bool SetPoints (C4DAtom *op, PointMove *pnts, Int32 cnt, Bool commit=false, Int32 flags=0)
 
Bool GetPointInfo (C4DAtom *op, Int32 index, Int32 &ia, Int32 &ib, Float &t)
 
Bool GetOriginPoint (C4DAtom *op, Int32 index, Int32 &ci)
 
Bool SetPointInfo (C4DAtom *op, Int32 index, Int32 ia, Int32 ib, Float t)
 
Bool SetOriginPoint (C4DAtom *op, Int32 index, Int32 ci)
 
Int32 GetPointFlags (C4DAtom *op, Int32 index)
 
Int32 SetPointFlags (C4DAtom *op, Int32 index, Int32 flags)
 
Bool GetPointOrigin (C4DAtom *op, Int32 index, Vector &opnt)
 
Bool SetPointOrigin (C4DAtom *op, Int32 index, Vector opnt, Int32 flags)
 
Bool SetInterPoint (C4DAtom *op, Int32 index, Vector npnt, Float t, Int32 flags=0)
 
Bool SetInterPoint (C4DAtom *op, Int32 index, const Vector &move, const Vector &offset, Int32 flags=0)
 

Polygon/Ngon

Int32 NewNgon (C4DAtom *op, Int32 flags=0)
 
Int32 AddNgon (C4DAtom *op, const Ngon &ngon, Int32 flags=0)
 
Int32 CreateNgon (C4DAtom *op, Int32 *padr, Int32 cnt, Int32 flags=0)
 
Bool DeleteNgon (C4DAtom *op, Int32 index, Bool points)
 
Int32 CloneNgon (C4DAtom *op, Int32 index, Int32 flags=0)
 
Bool GetNgon (C4DAtom *op, Int32 index, Ngon *ngon, Int32 flags=0)
 
Bool SetNgon (C4DAtom *op, Int32 index, Ngon &ngon, Int32 flags=0)
 
Bool GetNgonNormal (C4DAtom *op, Int32 index, Vector *n)
 
Bool FlipNgonNormal (C4DAtom *op, Int32 index)
 
Bool GetOriginNgon (C4DAtom *op, Int32 index, Int32 &ci)
 
Bool SetOriginNgon (C4DAtom *op, Int32 index, Int32 ci)
 
Int32 GetNgonFlags (C4DAtom *op, Int32 index)
 
Int32 SetNgonFlags (C4DAtom *op, Int32 index, Int32 flags)
 
Bool ResizeNgon (C4DAtom *op, Int32 index, Int32 pcnt, Int32 scnt)
 

Operations

Bool WeldPoints (C4DAtom *op, Int32 source, Int32 dest)
 
Bool InsertFacePoint (C4DAtom *op, Int32 pa, Int32 p1)
 
Bool CreateHole (C4DAtom *op, Int32 index, const Ngon &ngon)
 
Bool CreateHole (C4DAtom *op, Int32 index, Int32 *pnts, Int32 pcnt)
 
Int32 SplitEdge (C4DAtom *op, Int32 p1, Int32 p2, Float l)
 
Bool DeleteEdge (C4DAtom *op, Int32 index, Int32 p1, Int32 p2)
 
Bool MeltEdgeBetween (C4DAtom *op, Int32 pa, Int32 pb, Int32 p1, Int32 p2)
 
Bool MeltEdge (C4DAtom *op, Int32 pa, Int32 p1, Int32 p2)
 
Bool MeltPoint (C4DAtom *op, Int32 p)
 
Bool MeltNgon (C4DAtom *op, Int32 pa)
 
Int32 SplitPolygon (C4DAtom *op, Int32 index, Int32 p1, Int32 p2)
 
Bool MergePolygons (C4DAtom *op, Int32 pa, Int32 pb)
 
Bool IsValidEdge (C4DAtom *op, Int32 index, Int32 p1, Int32 p2)
 
Bool IsValidNgon (C4DAtom *op, Int32 index)
 
Bool IsValidPoint (C4DAtom *op, Int32 index)
 
Int32GetEdgeNgons (C4DAtom *op, Int32 p1, Int32 p2, Int32 &pcnt)
 
Int32GetPointNgons (C4DAtom *op, Int32 p, Int32 &pcnt, Bool clone=true)
 
Int32GetNeighborNgons (C4DAtom *op, Int32 index, Int32 &pcnt)
 
Int32GetPointEdges (C4DAtom *op, Int32 p, Int32 &ecnt)
 
Bool FindNgon (C4DAtom *op, Int32 p1, Int32 p2, Int32 &index)
 
Bool GetEdgeSegment (C4DAtom *op, Int32 pa, Int32 p1, Int32 p2, Int32 *seg, Int32 *s1, Int32 *s2, Bool rel)
 
Bool GetOriginalEdgePoints (C4DAtom *op, Int32 edge, Int32 &p1, Int32 &p2)
 
Bool IsEdgeDeleted (C4DAtom *op, Int32 p1, Int32 p2)
 
Bool IsPointDeleted (C4DAtom *op, Int32 index)
 
Bool IsFaceDeleted (C4DAtom *op, Int32 index)
 
Int32 TranslateNgonIndex (C4DAtom *op, Int32 index, Bool tovirtual=false)
 
Int32 TranslatePointIndex (C4DAtom *op, Int32 index, Bool tovirtual=false)
 
Bool GetFaceSelection (C4DAtom *op, BaseSelect *select, BaseSelect *faceselect, BaseSelect *hidden=nullptr)
 
Bool GetEdgeSelection (C4DAtom *op, BaseSelect *select, BaseSelect *edgeselect, BaseSelect *hidden=nullptr)
 
Int32GetEdgeSelectionArray (C4DAtom *op, BaseSelect *select, Int32 &ecnt, BaseSelect *hidden=nullptr, Bool tovirtual=true)
 

Information

Int32 GetLastError (C4DAtom *op)
 
Bool IsModified (C4DAtom *op)
 

Free Table

void FreeTable (C4DAtom *op, void *table)
 

Helpers

Bool PointInFace (C4DAtom *op, Int32 index, const Vector &p)
 
Bool PointInFace (C4DAtom *op, const Ngon &ngon, const Vector &p)
 
Bool LineFaceIntersection (C4DAtom *op, Int32 index, const Vector &p1, const Vector &p2)
 
Bool LineFaceIntersection (C4DAtom *op, const Ngon &ngon, const Vector &p1, const Vector &p2)
 

Triangulate Hook

void SetTriangulateHook (C4DAtom *op, TriangulateHook pHook, void *pData)
 
void GetTriangulateHook (C4DAtom *op, TriangulateHook *ppHook, void **ppData)
 

Constructor & Destructor Documentation

◆ Modeling()

Modeling ( )
private

◆ ~Modeling()

~Modeling ( )
private

Member Function Documentation

◆ Alloc()

static Modeling* Alloc ( )
static

Allocates a modeling engine. Destroy the allocated modeling engine with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated modeling engine, or nullptr if the allocation failed.

◆ Free()

static void Free ( Modeling *&  p)
static

Destructs modeling engines allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]pThe modeling engine to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ InitArray()

Bool InitArray ( AtomArray objs,
Int32  flags = 0 
)

Initializes the modeling engine with the objects in objs.

Parameters
[in]objsAn atom array with the objects to perform the modeling on. The caller owns the pointed objects array.
[in]flagsNot used.
Returns
true if successful, otherwise false.

◆ InitObject()

Bool InitObject ( C4DAtom op,
Int32  flags = 0 
)

Initialize the modeling engine with the object op.

Parameters
[in]opThe object to perform the modeling on. The caller owns the pointed object.
[in]flagsNot used.
Returns
true if successful, otherwise false.

◆ Commit()

Bool Commit ( C4DAtom op = nullptr,
Int32  flags = 0,
BaseObject cobj = nullptr 
)

Commits the modeling transformation.

Parameters
[in]opThe pointer of the initialized object to use for the commit, or nullptr to commit all initialized objects.
[in]flagsThe commit flags: MODELING_COMMIT
[in]cobjThe object to commit the changes to, or nullptr to use the initialized object.
Setting cobj is only valid when committing a single object. The object must match the original.
Returns
true if successful, otherwise false.

◆ Release()

void Release ( )

Frees all data for all initialized objects.

◆ ReleaseObject()

void ReleaseObject ( C4DAtom op)

Frees the data for op.

Parameters
[in]opAn initialized object. The caller owns the pointed object.

◆ GetPointMap()

Bool GetPointMap ( C4DAtom op,
Int32 **  map,
Int32 count 
)

Retrieves a table of where the old/new points were set in the changed object after a Modeling::Commit().
The table is interleaved with virtual indices at (*map)[2*n] and real indices at (*map)[2*n+1], where n goes from 0 to count - 1.

Note
Set MODELING_COMMIT_CREATEMAP flag in Modeling::Commit() for this function to work.
Parameters
[in]opAn initialized object. The caller owns the pointed object.
[out]mapAssigned a pointer to the map array. The modeling engine owns the pointed array.
[out]countAssigned the number of points. The array size is 2 * count.
Returns
true if successful, otherwise false.

◆ GetNgonMap()

Bool GetNgonMap ( C4DAtom op,
Int32 **  map,
Int32 count 
)

Not implemented.

◆ ReleaseMap()

Bool ReleaseMap ( C4DAtom op,
Int32 map 
)

Call this function to keep the table map for later use. When finished use FreeMap().

Note
Memory allocated with the modeling library (as with the N-gon library) does not use the usual Cinema 4D memory manager but has its own system.
So all memory must be freed through the correct library.
Parameters
[in]opAn initialized object. The caller owns the pointed object.
[out]mapThe map pointer to release.
Returns
true if successful, otherwise false.

◆ FreeMap()

Bool FreeMap ( C4DAtom op,
Int32 map 
)

Frees a map table released by ReleaseMap().

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[out]mapThe map pointer to free.
Returns
true if successful, otherwise false.

◆ AddPoint()

Int32 AddPoint ( C4DAtom op,
const Vector p 
)

Adds a new point to the object.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pThe position of the point to add.
Returns
The virtual index of the added point, or 0 if an error occurred.

◆ ClonePoint()

Int32 ClonePoint ( C4DAtom op,
Int32  index 
)

Clones the point at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to clone. Can be an old index (positive) or a virtual index (negative).
Returns
The virtual index of the new point, or 0 if an error occurred.

◆ DeletePoint()

Bool DeletePoint ( C4DAtom op,
Int32  index 
)

Deletes the point at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to delete. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ GetPoint()

Bool GetPoint ( C4DAtom op,
Int32  index,
Vector p 
)

Retrieves the position vector for a point at index in p.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to get. Can be an old index (positive) or a virtual index (negative).
[out]pAssigned the point position.
Returns
true if successful, otherwise false.

◆ SetPoint()

Bool SetPoint ( C4DAtom op,
Int32  index,
const Vector p,
Int32  flags = 0 
)

Sets the position vector for a point at index to p.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set. Can be an old index (positive) or a virtual index (negative).
[in]pThe point position to set.
[in]flagsThe flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ SetEdgePoint()

Bool SetEdgePoint ( C4DAtom op,
Int32  index,
Float  l,
Int32  flags = 0 
)

Sets position vector for an edge point at index to p. An edge point is a point that has been inserted between 2 other points with the library (along an edge).
This information is kept internal and can adjust the point along this edge with l.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the edge point to set.
[in]lThe edge coordinate, between 0 and 1.
[in]flagsThe flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ SetPoints()

Bool SetPoints ( C4DAtom op,
PointMove pnts,
Int32  cnt,
Bool  commit = false,
Int32  flags = 0 
)

Sets many points in one call using an array of PointMove.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pntsAn array with instructions how to move the points. The caller owns the pointed array.
[in]cntThe size of the pnts array.
[in]commitIf true the move triggers a Commit().
[in]flagsThe flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ GetPointInfo()

Bool GetPointInfo ( C4DAtom op,
Int32  index,
Int32 ia,
Int32 ib,
Float t 
)

Retrieves the information for a point that was inserted along an edge.
If the point was not an edge point then the indexes will be assigned NOTINDEX.
This can also be used to check if a point was a clone, as cloned points would return ia == ib.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the edge point to get information for.
[out]iaAssigned the index of the first point of the original edge.
[out]ibAssigned the index of the second point of the original edge.
[out]tAssigned the position along the edge.
Returns
true if successful, otherwise false.

◆ GetOriginPoint()

Bool GetOriginPoint ( C4DAtom op,
Int32  index,
Int32 ci 
)

Retrieves the original point for a cloned point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the cloned point.
[out]ciAssigned the cloned index.
Returns
true if successful, otherwise false.

◆ SetPointInfo()

Bool SetPointInfo ( C4DAtom op,
Int32  index,
Int32  ia,
Int32  ib,
Float  t 
)

Sets the edge/clone information for a point. For a clone ia == ib and t is 0.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set.
[in]iaThe first point of the original edge.
[in]ibThe second point of the original edge.
[in]tThe position along the edge.
Returns
true if successful, otherwise false.

◆ SetOriginPoint()

Bool SetOriginPoint ( C4DAtom op,
Int32  index,
Int32  ci 
)

Sets the original index for a point, making it a clone of that point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set.
[in]ciThe index of the original point. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ GetPointFlags()

Int32 GetPointFlags ( C4DAtom op,
Int32  index 
)

Gets the flags for a point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to get the flags for. Can be an old index (positive) or a virtual index (negative).
Returns
The point flags: MODELING_SETPOINT_FLAG

◆ SetPointFlags()

Int32 SetPointFlags ( C4DAtom op,
Int32  index,
Int32  flags 
)

Sets the flags for a point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set the flags for. Can be an old index (positive) or a virtual index (negative).
[in]flagsThe new point flags: MODELING_SETPOINT_FLAG
Returns
The old point flags.

◆ GetPointOrigin()

Bool GetPointOrigin ( C4DAtom op,
Int32  index,
Vector opnt 
)

Gets the original position of a cloned point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to get the original position for.
[out]opntAssigned the original point position.
Returns
true if successful, otherwise false.

◆ SetPointOrigin()

Bool SetPointOrigin ( C4DAtom op,
Int32  index,
Vector  opnt,
Int32  flags 
)

Sets the original position of a cloned point.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set the original position for.
[in]opntThe new original point position.
[in]flagsThe point flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ SetInterPoint() [1/2]

Bool SetInterPoint ( C4DAtom op,
Int32  index,
Vector  npnt,
Float  t,
Int32  flags = 0 
)

Sets an interpolated point npnt on the position t along its edge.
The point along an edge must have been previoulsy created e.g. with SplitEdge(), so that the modeling engine knows which 2 points it was created between.
Then use this function to give it a new position along the edge.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set the interpolation information for.
[in]npntThe new position for the point. It is supposed to be along its edge, but it can actually be anywhere. The main aim here is to get the UVs along the edge.
[in]tThe new position along the edge for the interpolation. This information is used to update tags, e.g. finding the UVs within a polygon.
[in]flagsThe point flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ SetInterPoint() [2/2]

Bool SetInterPoint ( C4DAtom op,
Int32  index,
const Vector move,
const Vector offset,
Int32  flags = 0 
)

For N-gon interpolation. The move vector should be within the N-gon, e.g. something like extrude inner, while offset is just added to the point and not used for the interpolation within the N-gon.
The information set is used to update tags, e.g. finding the UVs within a polygon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to set the interpolation information for.
[in]moveThe move vector within the N-gon.
[in]offsetThe offset vector for the point.
[in]flagsThe point flags: MODELING_SETPOINT_FLAG
Returns
true if successful, otherwise false.

◆ NewNgon()

Int32 NewNgon ( C4DAtom op,
Int32  flags = 0 
)

Creates an empty N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
The virtual index of the new N-gon, or 0 if an error occurred.

◆ AddNgon()

Int32 AddNgon ( C4DAtom op,
const Ngon ngon,
Int32  flags = 0 
)

Creates an N-gon based on the passed Ngon data.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]ngonThe N-gon to add.
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
true if successful, otherwise false.

◆ CreateNgon()

Int32 CreateNgon ( C4DAtom op,
Int32 padr,
Int32  cnt,
Int32  flags = 0 
)

Creates an N-gon based on an array of point indices in padr.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]padrThe array with indices for the points of the N-gon to create. The caller owns the pointed array.
[in]cntThe size of the padr array.
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
true if successful, otherwise false.

◆ DeleteNgon()

Bool DeleteNgon ( C4DAtom op,
Int32  index,
Bool  points 
)

Removes an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to delete. Can be an old index (positive) or a virtual index (negative).
[in]pointsIf true the points of the N-gon are checked and removed if they are not used by other N-gons.
Returns
true if successful, otherwise false.

◆ CloneNgon()

Int32 CloneNgon ( C4DAtom op,
Int32  index,
Int32  flags = 0 
)

Create an N-gon based on another N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to clone. Can be an old index (positive) or a virtual index (negative).
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
The virtual index of the new N-gon, or 0 if an error occurred.

◆ GetNgon()

Bool GetNgon ( C4DAtom op,
Int32  index,
Ngon ngon,
Int32  flags = 0 
)

Retrieves an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to get. Can be an old index (positive) or a virtual index (negative).
[out]ngonThe structure to fill with the N-gon information. The caller owns the pointed structure.
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
true if successful, otherwise false.

◆ SetNgon()

Bool SetNgon ( C4DAtom op,
Int32  index,
Ngon ngon,
Int32  flags = 0 
)

Sets an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to set. Can be an old index (positive) or a virtual index (negative).
[in]ngonThe N-gon structure to set.
[in]flagsThe flags: MODELING_SETNGON_FLAG
Returns
true if successful, otherwise false.

◆ GetNgonNormal()

Bool GetNgonNormal ( C4DAtom op,
Int32  index,
Vector n 
)

Calculates the normal for an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to get the normal for. Can be an old index (positive) or a virtual index (negative).
[in]nAssigned the normal vector. The caller owns the pointed vector.
Returns
true if successful, otherwise false.

◆ FlipNgonNormal()

Bool FlipNgonNormal ( C4DAtom op,
Int32  index 
)

Reverses the normal of an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to reverse the normal of. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ GetOriginNgon()

Bool GetOriginNgon ( C4DAtom op,
Int32  index,
Int32 ci 
)

Gets the original index of an N-gon.
This index is used when updating tags so the tag translation knows where any N-gon clones originated from.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the cloned N-gon.
[in]ciAssigned the original index.
Returns
true if successful, otherwise false.

◆ SetOriginNgon()

Bool SetOriginNgon ( C4DAtom op,
Int32  index,
Int32  ci 
)

Sets the original index of a cloned N-gon.
This index is used when updating tags so the tag translation knows where any N-gon clones originated from.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to set the original index for.
[in]ciThe original index.
Returns
true if successful, otherwise false.

◆ GetNgonFlags()

Int32 GetNgonFlags ( C4DAtom op,
Int32  index 
)

Gets the flags for an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to get the flags for. Can be an old index (positive) or a virtual index (negative).
Returns
The flags: MODELING_SETNGON_FLAG

◆ SetNgonFlags()

Int32 SetNgonFlags ( C4DAtom op,
Int32  index,
Int32  flags 
)

Sets the flags for an N-gon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to set the flags for. Can be an old index (positive) or a virtual index (negative).
[in]flagsThe new flags: MODELING_SETNGON_FLAG
Returns
The old flags.

◆ ResizeNgon()

Bool ResizeNgon ( C4DAtom op,
Int32  index,
Int32  pcnt,
Int32  scnt 
)

Private.

◆ WeldPoints()

Bool WeldPoints ( C4DAtom op,
Int32  source,
Int32  dest 
)

Welds the source point index to dest.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]sourceThe index of the source point. Can be an old index (positive) or a virtual index (negative).
[in]destThe index of the destination point. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ InsertFacePoint()

Bool InsertFacePoint ( C4DAtom op,
Int32  pa,
Int32  p1 
)

Private.

◆ CreateHole() [1/2]

Bool CreateHole ( C4DAtom op,
Int32  index,
const Ngon ngon 
)

Adds the hole in ngon into the N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to add the hole to. Can be an old index (positive) or a virtual index (negative).
[in]ngonThe hole N-gon.
Returns
true if successful, otherwise false.

◆ CreateHole() [2/2]

Bool CreateHole ( C4DAtom op,
Int32  index,
Int32 pnts,
Int32  pcnt 
)

Adds the hole with points in pnts into the N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to add the hole to. Can be an old index (positive) or a virtual index (negative).
[in]pntsAn array with the hole N-gon points.
[in]pcntThe size of the pnts array.
Returns
true if successful, otherwise false.

◆ SplitEdge()

Int32 SplitEdge ( C4DAtom op,
Int32  p1,
Int32  p2,
Float  l 
)

Splits an edge (defined by the point indices p1 to p2) at l (0 to 1) creating a new edge point with the index returned.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]p1The index of the first point of the edge. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge. Can be an old index (positive) or a virtual index (negative).
[in]lThe position along the edge, between 0 and 1.
Returns
The virtual index of the new edge point, or 0 if an error occurred.

◆ DeleteEdge()

Bool DeleteEdge ( C4DAtom op,
Int32  index,
Int32  p1,
Int32  p2 
)

Deletes an edge defined by p1 and p2. If this results in an N-gon with less than 3 points then the N-gon will be removed.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon. Can be an old index (positive) or a virtual index (negative).
[in]p1The index of the first point of the edge to remove. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to remove. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ MeltEdgeBetween()

Bool MeltEdgeBetween ( C4DAtom op,
Int32  pa,
Int32  pb,
Int32  p1,
Int32  p2 
)

Melts an edge between the 2 n-gons at pa and pb. The edge is defined by the points p1 and p2.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]paThe index of the first N-gon. Can be an old index (positive) or a virtual index (negative).
[in]pbThe index of the second N-gon. Can be an old index (positive) or a virtual index (negative).
[in]p1The index of the first point of the edge. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ MeltEdge()

Bool MeltEdge ( C4DAtom op,
Int32  pa,
Int32  p1,
Int32  p2 
)

Melt the edge (p1 to p2) of N-gon pa.

Note
MeltEdge() accepts NOTINDEX for the N-gon index pa, in which case it takes the first index for the edge it finds.
Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]paThe index of the N-gon. Can be an old index (positive) or a virtual index (negative).
[in]p1The index of the first point of the edge to melt. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to melt. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ MeltPoint()

Bool MeltPoint ( C4DAtom op,
Int32  p 
)

Melts the N-gons around point p.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pThe index of the point, the N-gons around which are to be melted. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ MeltNgon()

Bool MeltNgon ( C4DAtom op,
Int32  pa 
)

Melts the N-gon pa into its surrounding N-gons.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]paThe index of the N-gon to melt. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ SplitPolygon()

Int32 SplitPolygon ( C4DAtom op,
Int32  index,
Int32  p1,
Int32  p2 
)

Cuts the N-gon at index between points p1 and p2, returning the newly created N-gon index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to split. Can be an old index (positive) or a virtual index (negative).
[in]p1The index of the first point of the split. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the split. Can be an old index (positive) or a virtual index (negative).
Returns
The newly created N-gon index or the passed index for no change, otherwise NOTINDEX for fail.

◆ MergePolygons()

Bool MergePolygons ( C4DAtom op,
Int32  pa,
Int32  pb 
)

Merges the points of pb into pa making them into holes of pa.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]paThe index of the first N-gon. Can be an old index (positive) or a virtual index (negative).
[in]pbThe index of the second N-gon. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ IsValidEdge()

Bool IsValidEdge ( C4DAtom op,
Int32  index,
Int32  p1,
Int32  p2 
)

Checks if the edge (p1 to p2) of the N-gon at index is valid (exists).

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to check. Can be an old index (positive) or a virtual index (negative).
Pass NOTINDEX to check that the edge (p1,p2) exists and is an N-gon edge.
[in]p1The index of the first point of the edge to check. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if the edge is valid, otherwise false.

◆ IsValidNgon()

Bool IsValidNgon ( C4DAtom op,
Int32  index 
)

Check if the N-gon at index is valid (exists).

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if the N-gon is valid, otherwise false.

◆ IsValidPoint()

Bool IsValidPoint ( C4DAtom op,
Int32  index 
)

Check if the point at index exists.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if the point is valid, otherwise false.

◆ GetEdgeNgons()

Int32* GetEdgeNgons ( C4DAtom op,
Int32  p1,
Int32  p2,
Int32 pcnt 
)

Retrieves an array with the N-gons that share the edge between p1 and p2.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]p1The index of the first point of the edge to check. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to check. Can be an old index (positive) or a virtual index (negative).
[out]pcntAssigned the number of N-gons found.
Returns
The array of N-gon indices. The size is given by pcnt. The caller owns the pointed array.
Use the modeling library FreeTable() function to free the data afterwards.

◆ GetPointNgons()

Int32* GetPointNgons ( C4DAtom op,
Int32  p,
Int32 pcnt,
Bool  clone = true 
)

Retrieves a table of the N-gons that share the point at p.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pThe index of the point to check. Can be an old index (positive) or a virtual index (negative).
[out]pcntAssigned the number of N-gons found.
[in]cloneIf false a pointer to an internal array is returned. Then it is not need to use FreeTable().
Returns
The array of N-gon indices. The size is given by pcnt. The caller owns the pointed array.
Use the modeling library FreeTable() function to free the data afterwards if clone was true.

◆ GetNeighborNgons()

Int32* GetNeighborNgons ( C4DAtom op,
Int32  index,
Int32 pcnt 
)

Retrieves the N-gons that neighbour the N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to check. Can be an old index (positive) or a virtual index (negative).
[out]pcntAssigned the number of N-gons found.
Returns
The array of N-gon indices. The size is given by pcnt. The caller owns the pointed array.
Use the modeling library FreeTable() function to free the data afterwards.

◆ GetPointEdges()

Int32* GetPointEdges ( C4DAtom op,
Int32  p,
Int32 ecnt 
)

Retrieves all the edges that use the point p.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pThe index of the point to check. Can be an old index (positive) or a virtual index (negative).
[in]ecntAssigned the number of edges found.
Returns
The array of edge indices. The size is given by ecnt.

◆ FindNgon()

Bool FindNgon ( C4DAtom op,
Int32  p1,
Int32  p2,
Int32 index 
)

Finds any N-gon with the edge p1 to p2.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]p1The index of the first point of the edge to search for. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to search for. Can be an old index (positive) or a virtual index (negative).
[out]indexAssigned the index of the found N-gon.
Returns
true if the N-gon was found, otherwise false.

◆ GetEdgeSegment()

Bool GetEdgeSegment ( C4DAtom op,
Int32  pa,
Int32  p1,
Int32  p2,
Int32 seg,
Int32 s1,
Int32 s2,
Bool  rel 
)

Private.

◆ GetOriginalEdgePoints()

Bool GetOriginalEdgePoints ( C4DAtom op,
Int32  edge,
Int32 p1,
Int32 p2 
)

Gets the original points from edge.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]edgeThe index of the edge to get the points for. Can be an old index (positive) or a virtual index (negative).
[out]p1Assigned the index of the first point of the edge.
[out]p2Assigned the index of the second point of the edge.
Returns
true if successful, otherwise false.

◆ IsEdgeDeleted()

Bool IsEdgeDeleted ( C4DAtom op,
Int32  p1,
Int32  p2 
)

Checks if the edge between p1 and p2 has been deleted.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]p1The index of the first point of the edge to check. Can be an old index (positive) or a virtual index (negative).
[in]p2The index of the second point of the edge to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if successful, otherwise false.

◆ IsPointDeleted()

Bool IsPointDeleted ( C4DAtom op,
Int32  index 
)

Checks if the point at index has been deleted.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if the point has been deleted, otherwise false.

◆ IsFaceDeleted()

Bool IsFaceDeleted ( C4DAtom op,
Int32  index 
)

Checks if the N-gon at index has been deleted.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to check. Can be an old index (positive) or a virtual index (negative).
Returns
true if the face has been deleted, otherwise false.

◆ TranslateNgonIndex()

Int32 TranslateNgonIndex ( C4DAtom op,
Int32  index,
Bool  tovirtual = false 
)

Translates an N-gon index. Once an N-gon is accessed then a virtual clone is created for it, using these functions translate between the real index and its virtual index.

Note
This is not normally needed, all functions manage translations.
Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe original N-gon index.
[in]tovirtualIf true the conversion is done from real to virtual, otherwise from virtual to real.
Returns
The translated N-gon index.

◆ TranslatePointIndex()

Int32 TranslatePointIndex ( C4DAtom op,
Int32  index,
Bool  tovirtual = false 
)

Translates a point index. Once an point is accessed then a virtual clone is created for it, using these functions you can translate between the real index and its virtual index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe original point index.
[in]tovirtualIf true the conversion is done from real to virtual, otherwise from virtual to real.
Returns
The translated point index.

◆ GetFaceSelection()

Bool GetFaceSelection ( C4DAtom op,
BaseSelect select,
BaseSelect faceselect,
BaseSelect hidden = nullptr 
)

Converts a regular selection of polygons into the indices [polygons][ngons] used within the modeling kernel.

Note
This is not normally needed, all functions manage translations.
Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]selectA regular polygon selection. The caller owns the pointed selection.
[out]faceselectFilled with the translated polygon selection. The caller owns the pointed selection.
[out]hiddenOptionally filled with the hidden selection. The caller owns the pointed selection.
Returns
true if successful, otherwise false.

◆ GetEdgeSelection()

Bool GetEdgeSelection ( C4DAtom op,
BaseSelect select,
BaseSelect edgeselect,
BaseSelect hidden = nullptr 
)

Converts a regular selection of edges into the indices used within the modeling kernel.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]selectA regular edge selection. The caller owns the pointed selection.
[out]edgeselectFilled with the translated edge selection. The caller owns the pointed selection.
[out]hiddenOptionally filled with the hidden selection. The caller owns the pointed selection.
Returns
true if successful, otherwise false.

◆ GetEdgeSelectionArray()

Int32* GetEdgeSelectionArray ( C4DAtom op,
BaseSelect select,
Int32 ecnt,
BaseSelect hidden = nullptr,
Bool  tovirtual = true 
)

Converts a regular selection of edges into an array of the indices used within the modeling kernel.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]selectA regular edge selection. The caller owns the pointed selection.
[out]ecntAssigned the size of the returned edge index array.
[out]hiddenOptionally filled with the hidden selection. The caller owns the pointed selection.
[in]tovirtualIf true conversion is done from real to virtual, otherwise from virtual to real.
Returns
The array of edge indices. The size is given by ecnt. The caller owns the pointed array.
Use the modeling library FreeTable() function to free the data afterwards.

◆ GetLastError()

Int32 GetLastError ( C4DAtom op)

Retrieves the last error code from the modeling engine.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
Returns
The error code: MODELING_ERROR

◆ IsModified()

Bool IsModified ( C4DAtom op)

Checks if any editing has been done to the object (virtually).

Parameters
[in]opAn initialized object. The caller owns the pointed object.
Returns
true if op is modified, otherwise false.

◆ FreeTable()

void FreeTable ( C4DAtom op,
void *  table 
)

Frees tables created by the modeling engine.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[out]tableThe table to free.

◆ PointInFace() [1/2]

Bool PointInFace ( C4DAtom op,
Int32  index,
const Vector p 
)

Check if the point at p is within the boundaries of the N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the point to check. Can be an old index (positive) or a virtual index (negative).
[in]pThe point position.
Returns
true if p is in the N-gon, otherwise false.

◆ PointInFace() [2/2]

Bool PointInFace ( C4DAtom op,
const Ngon ngon,
const Vector p 
)

Check if the point at p is within the boundaries of the N-gon in ngon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]ngonThe N-gon to check.
[in]pThe point position.
Returns
true if p is in the N-gon, otherwise false.

◆ LineFaceIntersection() [1/2]

Bool LineFaceIntersection ( C4DAtom op,
Int32  index,
const Vector p1,
const Vector p2 
)

Checks if the line from p1 to p2 intersects the N-gon at index.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]indexThe index of the N-gon to check. Can be an old index (positive) or a virtual index (negative).
[in]p1The first point of the line.
[in]p2The second point of the line.
Returns
true if the line intersects the face at index, otherwise false.

◆ LineFaceIntersection() [2/2]

Bool LineFaceIntersection ( C4DAtom op,
const Ngon ngon,
const Vector p1,
const Vector p2 
)

Check if the line from p1 to p2 intersects the N-gon in ngon.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]ngonThe N-gon to check.
[in]p1The first point of the line.
[in]p2The second point of the line.
Returns
true if the line intersects the face in ngon, otherwise false.

◆ SetTriangulateHook()

void SetTriangulateHook ( C4DAtom op,
TriangulateHook  pHook,
void *  pData 
)

Sets a triangulation function to be used instead of the internal one.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[in]pHookThe new triangulation hook.
[in]pDataThe private data, passed to the hook.

◆ GetTriangulateHook()

void GetTriangulateHook ( C4DAtom op,
TriangulateHook ppHook,
void **  ppData 
)

Gets the current custom triangulation hook.

Parameters
[in]opAn initialized object. The caller owns the pointed object.
[out]ppHookAssigned the triangulation hook.
[out]ppDataAssigned the hook private data.

Member Data Documentation

◆ m_pBase

ModelingBase* m_pBase
private

◆ m_pKernelCache

ModelingKernel* m_pKernelCache
private

◆ m_pObjectCache

C4DAtom* m_pObjectCache
private