Delaunay 3D Manual

内容表

关于

A Delaunay triangulation connects a set of points with lines so that a given point is connected to its neighbors. The 3D extension maxon::Delaunay3DInterface allows to fill the space between points with tetrahedrons.

注意
This class is used inside the maxon::Voronoi3DInterface ,见 Voronoi 3D Manual .

Delaunay3DInterface

The maxon::Delaunay3DInterface collects the given points and computes the tetrahedrons filling the space between these points.

An object is initialized with:

Points are added to the object with:

The calculation of the tetrahedrons is performed with:

The resulting geometry data is accessed with:

The tetrahedron containing a given point can be obtained with:

Miscellaneous functions are:

Tetrahedron

A maxon::Tetrahedron object represents a tetrahedron filling the space between the points of the Delaunay object. The class gives access to the tetrahedron's points and faces:

Further functions are:

范例

// This example fills the space between the given points with // tetrahedron polygons using the Delaunay triangulation. // The resulting geometry is copied to PolygonObjects.

// calculate size of the workspace which covers all points

MinMax mm; for ( maxon::Int i = 0; i != points.GetCount(); ++i) { mm. AddPoint (points[i]); }
maxon::Range<maxon::Vector> workspace; const maxon::Vector buffer { 100.0, 100.0, 100.0 }; workspace. _minValue = mm. GetMin () - buffer; workspace. _maxValue = mm. GetMax () + buffer;

// create Delaunay3DRef and perform tetrahedralization maxon::Delaunay3DRef delaunay3D = maxon::Delaunay3DRef::Create() iferr_return ; delaunay3D.Init(workspace) iferr_return ; delaunay3D.AddPointsIntoTetrahedralization(points) iferr_return ; delaunay3D.CalculateDelaunayTetrahedralization() iferr_return ;

// access resulting geometry const maxon ::BaseArray< maxon ::Tetrahedron>& tetrahedrons = delaunay3D.GetTetrahedrons(); const maxon ::BaseArray< 向量 >& pointsArray = delaunay3D.GetPoints(); maxon ::LinearCongruentialRandom< maxon :: Float32 > randomGen; // random generator for object colors const maxon :: Int tetrahedronPoints = 4; const maxon :: Int tetrahedronFaces = 4;

// for each tetrahedron create a PolygonObject for (const maxon ::Tetrahedron& tetrahedron : tetrahedrons) { // ignore tetrahedron that includes "internal" points (0 - 3) auto CheckTetra = [=]( const maxon::Tetrahedron & tetra) -> maxon::Bool { const maxon::Int internalVertice = 4; for ( maxon::Int i = 0; i < tetrahedronPoints; ++i) { if (tetra.points[i] < internalVertice) return false ; } return true ; };

// create PolygonObject for the given tetrahedron if (CheckTetra(tetrahedron)) { // alloc PolygonObject PolygonObject * const polyObject = PolygonObject::Alloc (tetrahedronPoints, tetrahedronFaces); if (polyObject != nullptr ) { CPolygon * const polygons = polyObject-> GetPolygonW (); 向量 * const polyPoints = polyObject-> GetPointW (); if (polygons && polyPoints) { // set vertices for ( maxon::Int i = 0; i < tetrahedronPoints; ++i) { const maxon::Int pointIndex = tetrahedron.points[i]; polyPoints[i] = pointsArray[pointIndex]; }

// set polygons for ( maxon::Int32 i = 0; i < tetrahedronFaces; ++i) { // get global face points maxon::IntVector32 tetraPoints; tetrahedron.GetFacePoints(i, tetraPoints); // set local points polygons[i]. a = tetrahedron.GetPointIndexOfPoint(tetraPoints. x ); polygons[i]. b = tetrahedron.GetPointIndexOfPoint(tetraPoints. y ); polygons[i]. c = tetrahedron.GetPointIndexOfPoint(tetraPoints. z ); polygons[i]. d = tetrahedron.GetPointIndexOfPoint(tetraPoints. z ); } }

// update geometry polyObject-> 消息 ( MSG_UPDATE );

// create random color auto GetRandomColor = [&randomGen]() -> maxon::Vector { maxon::Vector color; color. x = (randomGen.Get01() * 0.5) + 0.5; color. y = (randomGen.Get01() * 0.5) + 0.5; color. z = (randomGen.Get01() * 0.5) + 0.5; return color; };

// set object color polyObject-> SetParameter ( ID_BASEOBJECT_USECOLOR , ID_BASEOBJECT_USECOLOR_ALWAYS , DESCFLAGS_SET::NONE ); polyObject-> SetParameter ( ID_BASEOBJECT_COLOR , GetRandomColor(), DESCFLAGS_SET::NONE ); // insert object into the scene doc->InsertObject(polyObject, nullptr , nullptr ); } } }

延伸阅读

PointObject::GetPointW
Vector * GetPointW(void)
定义: c4d_baseobject.h:1432
LMinMax::GetMin
const Vector64 & GetMin(void) const
定义: c4d_tools.h:573
ID_BASEOBJECT_USECOLOR
@ ID_BASEOBJECT_USECOLOR
定义: obase.h:16
Int
maxon::Int Int
定义: ge_sys_math.h:62
CPolygon::b
Int32 b
Index of the second point in the polygon.
定义: c4d_baseobject.h:46
maxon
The maxon namespace contains all declarations of the MAXON API.
定义: c4d_basedocument.h:15
maxon::Tetrahedron
定义: tetrahedron.h:18
PolygonObject::GetPolygonW
CPolygon * GetPolygonW(void)
定义: c4d_baseobject.h:1745
ID_BASEOBJECT_COLOR
@ ID_BASEOBJECT_COLOR
定义: obase.h:21
Float32
maxon::Float32 Float32
定义: ge_sys_math.h:66
CPolygon
Represents a polygon that can be either a triangle or a quadrangle.
定义: c4d_baseobject.h:43
LMinMax::AddPoint
void AddPoint(const Vector64 &p)
定义: c4d_tools.h:505
CPolygon::d
Int32 d
Index of the fourth point in the polygon.
定义: c4d_baseobject.h:48
maxon::Bool
bool Bool
boolean type, possible values are only false/true, 8 bit
定义: apibase.h:177
iferr_return
#define iferr_return
定义: resultbase.h:1434
LMinMax
A class to construct a bounding box around points.
定义: c4d_tools.h:472
DESCFLAGS_SET::NONE
@ NONE
None.
maxon::Vec3::z
T z
定义: vec.h:34
MSG_UPDATE
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
定义: c4d_baselist.h:340
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
maxon::Vec3< Float, 1 >
maxon::Int32
int32_t Int32
32 bit signed integer datatype.
定义: apibase.h:172
maxon::Vec3::x
T x
定义: vec.h:32
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
定义: apibase.h:184
PolygonObject::Alloc
static PolygonObject * Alloc(Int32 pcnt, Int32 vcnt)
maxon::Vec3::y
T y
定义: vec.h:33
LMinMax::GetMax
const Vector64 & GetMax(void) const
定义: c4d_tools.h:586
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
定义: c4d_baselist.h:1394
maxon::Range::_minValue
T _minValue
The inclusive minimum boundary of this range.
定义: range.h:256
PolygonObject
定义: c4d_baseobject.h:1597
CPolygon::c
Int32 c
Index of the third point in the polygon.
定义: c4d_baseobject.h:47
maxon::Range
定义: range.h:25
maxon::Range::_maxValue
T _maxValue
The inclusive maximum boundary of this range. If the minimum boundary is not less than or equal to th...
定义: range.h:257
CPolygon::a
Int32 a
Index of the first point in the polygon.
定义: c4d_baseobject.h:45
ID_BASEOBJECT_USECOLOR_ALWAYS
@ ID_BASEOBJECT_USECOLOR_ALWAYS
定义: obase.h:19

Copyright  © 2014-2025 乐数软件    

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