ConvexHull Manual
The maxon::ConvexHullInterface allows to compute a convex polygon hull that encapsulates a given set of points in 3D space.
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:
// 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
// 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 );