Delaunay 3D Manual

About

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.

Note
This class is used inside the maxon::Voronoi3DInterface, see 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:

Example

// 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]);
}
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<Vector>& 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();
Vector* 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->Message(MSG_UPDATE);
// create random color
auto GetRandomColor = [&randomGen]() -> maxon::Vector
{
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
// insert object into the scene
doc->InsertObject(polyObject, nullptr, nullptr);
}
}
}
Py_ssize_t i
Definition: abstract.h:645
const char ** buffer
Definition: abstract.h:327
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Bool Message(Int32 type, void *data=nullptr)
Definition: c4d_baselist.h:1458
A class to construct a bounding box around points.
Definition: c4d_tools.h:530
const Vector64 & GetMin() const
Definition: c4d_tools.h:613
void AddPoint(const Vector64 &p)
Definition: c4d_tools.h:562
const Vector64 & GetMax() const
Definition: c4d_tools.h:626
Vector * GetPointW()
Definition: c4d_baseobject.h:1593
Definition: c4d_baseobject.h:1765
CPolygon * GetPolygonW()
Definition: c4d_baseobject.h:1912
static PolygonObject * Alloc(Int32 pcnt, Int32 vcnt)
Definition: range.h:26
T maxValue
The inclusive maximum boundary of this range. If the minimum boundary is not less than or equal to th...
Definition: range.h:257
T minValue
The inclusive minimum boundary of this range.
Definition: range.h:256
for(i=0;i< length;i++)
Definition: unicodeobject.h:61
maxon::Float32 Float32
Definition: ge_sys_math.h:68
maxon::Int Int
Definition: ge_sys_math.h:64
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:213
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:206
int32_t Int32
32 bit signed integer datatype.
Definition: apibase.h:201
static auto Create(ARGS &&... args)
Definition: apibase.h:2830
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:359
#define ConstDescID(...)
Definition: lib_description.h:594
The maxon namespace contains all declarations of the MAXON API.
Definition: autoweight.h:14
@ ID_BASEOBJECT_USECOLOR
Definition: obase.h:19
@ ID_BASEOBJECT_USECOLOR_ALWAYS
Definition: obase.h:22
@ ID_BASEOBJECT_COLOR
Definition: obase.h:24
const char * doc
Definition: pyerrors.h:226
#define iferr_return
Definition: resultbase.h:1521
Represents a polygon that can be either a triangle or a quadrangle.
Definition: c4d_baseobject.h:44
Int32 d
Index of the fourth point in the polygon.
Definition: c4d_baseobject.h:48
Int32 b
Index of the second point in the polygon.
Definition: c4d_baseobject.h:46
Int32 c
Index of the third point in the polygon.
Definition: c4d_baseobject.h:47
Int32 a
Index of the first point in the polygon.
Definition: c4d_baseobject.h:45
Represents a level within a DescID.
Definition: lib_description.h:298
Definition: tetrahedron.h:19
T y
Definition: vec.h:40
T x
Definition: vec.h:39
T z
Definition: vec.h:41

Further Reading