ConvexHull Manual

内容表

关于

The maxon::ConvexHullInterface allows to compute a convex polygon hull that encapsulates a given set of points in 3D space.

ConvexHullInterface

The maxon::ConvexHullInterface class provides only one function that can either accept a maxon::ConvexHullData argument or several arrays:

The maxon::ConvexHullData structure contains these members:

// This example creates a convex polygon hull around the given array of points. // The created polygon data is copied to a PolygonObject.

// create ConvexHullRef const maxon::ConvexHullRef convexHull = maxon::ConvexHullRef::Create() iferr_return ;

// compute convex hull from the given array of points maxon ::ConvexHullData hullData; const maxon :: Float res = convexHull.ComputeConvexHull(points, 0.0, 0.0, hullData) iferr_return ; if (res < 0) return maxon :: OK ;

// create the PolygonObject

const Int32 polyCount = ( Int32 )hullData.faces. GetCount (); const Int32 vertexCount = ( Int32 )hullData.vertices. GetCount ();
PolygonObject * const polyObject = PolygonObject ::Alloc(vertexCount, polyCount); if (polyObject == nullptr ) return maxon ::OutOfMemoryError( MAXON_SOURCE_LOCATION );

// set polygons CPolygon * const polygons = polyObject->GetPolygonW(); Int32 polyCounter = 0; const maxon ::ConvEdge* lastEdge;

// loop over all faces for ( Int32 faceIndex = 0; faceIndex < polyCount; faceIndex++) { const maxon::ConvEdge * currentEdge = &hullData.edges[hullData.faces[faceIndex]]; lastEdge = currentEdge; const Int firstPoint = lastEdge-> _start ;

// loop over all edges for (currentEdge = &hullData.edges[lastEdge->_nextEdgeOfFace]; &hullData.edges[currentEdge-> _nextEdgeOfFace ] != &hullData.edges[hullData.faces[faceIndex]]; currentEdge = &hullData.edges[currentEdge-> _nextEdgeOfFace ]) { polygons[polyCounter] = CPolygon (( Int32 )firstPoint, ( Int32 )currentEdge-> _start , ( Int32 )currentEdge-> _end ); polyCounter++; lastEdge = currentEdge; } }

// set point positions 向量 * const polyPoints = polyObject->GetPointW(); for ( Int32 pointIndex = 0; pointIndex < vertexCount; pointIndex++) polyPoints[pointIndex] = hullData.vertices[pointIndex];

// insert polygon object into the scene polyObject->Message( MSG_UPDATE ); doc->InsertObject(polyObject, nullptr , nullptr );

延伸阅读

Int
maxon::Int Int
定义: ge_sys_math.h:62
maxon
The maxon namespace contains all declarations of the MAXON API.
定义: c4d_basedocument.h:15
maxon::ConvEdge::_start
Int _start
定义: convexhull.h:20
Float
maxon::Float Float
定义: ge_sys_math.h:64
CPolygon
Represents a polygon that can be either a triangle or a quadrangle.
定义: c4d_baseobject.h:43
maxon::ConvEdge::_nextEdgeOfFace
Int _nextEdgeOfFace
定义: convexhull.h:22
iferr_return
#define iferr_return
定义: resultbase.h:1434
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
MSG_UPDATE
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
定义: c4d_baselist.h:340
maxon::GetCount
Int GetCount(const ITERABLE &iterable)
定义: collection.h:37
OK
OK
Ok.
定义: ge_prepass.h:2
maxon::Vec3< maxon::Float64, 1 >
maxon::ConvEdge::_end
Int _end
定义: convexhull.h:21
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
PolygonObject
定义: c4d_baseobject.h:1597
maxon::ConvEdge
定义: convexhull.h:15

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1