About
The PolygonReduction class allows to reduce the polygon count of a given PolygonObject while retaining its overall shape. The class gives access to the functionality used within the "Polygon Reduction" generator. It is defined in the lib_polygonreduction.h
header file.
Allocation/Deallocation
A PolygonReduction object can be created with the usual tools, see Entity Creation and Destruction Manual (Classic).
if (polyReduction == nullptr)
Definition: ge_autoptr.h:37
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
Init
A PolygonReduction object has to be initialized. It will pre-process the given PolygonObject.
The PolygonReductionData argument has these members:
- Note
- In order to be able to abort the reduction operation and to retain the original mesh, it is advised to operate on a copy of the original PolygonObject.
if (polyReduction->PreProcess(data) == false)
return maxon::UnexpectedError(
MAXON_SOURCE_LOCATION,
"The function exited unexpectedly during data pre-processing."_s);
polyReduction->SetReductionStrengthLevel(0.75);
Definition: c4d_basecontainer.h:47
void SetBool(Int32 id, Bool b)
Definition: c4d_basecontainer.h:498
Definition: lib_polygonreduction.h:35
PolygonObject * _op
The polygon object to be reduced.
Definition: lib_polygonreduction.h:57
BaseDocument * _doc
The document. Must not be nullptr.
Definition: lib_polygonreduction.h:56
BaseThread * _thread
The caller thread. Set to nullptr if synchronous pre-processing calculation is needed (e....
Definition: lib_polygonreduction.h:58
BaseContainer _settings
The reduction constraints settings. See opolyreduxgen.h.
Definition: lib_polygonreduction.h:59
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:341
@ POLYREDUXOBJECT_PRESERVE_3D_BOUNDARY
Definition: opolyreduxgen.h:7
@ POLYREDUXOBJECT_PRESERVE_UV_BOUNDARY
Definition: opolyreduxgen.h:8
const char * doc
Definition: pyerrors.h:226
If the PolygonReductionData::_thread member is set the pre-process is running asynchronously in a background thread.
- Note
- This asynchronous mode may be used e.g. in a generator object.
if (polyReduction->PreProcess(data) == false)
return maxon::UnexpectedError(
MAXON_SOURCE_LOCATION,
"The function exited unexpectedly during data pre-processing."_s);
while (polyReduction->IsPreprocessing())
{
{
polyReduction->StopPreprocessing();
}
}
Py_ssize_t count
Definition: abstract.h:640
void GeSleep(Int32 milliseconds)
BaseThread * GeGetDummyThread()
Definition: c4d_thread.h:201
maxon::Int32 Int32
Definition: ge_sys_math.h:60
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
After the pre-process the PolygonReduction object is ready:
Reduce
The linked PolygonObject can be reduced by defining the overall reduction strength or the target triangle, vertex or edge count.
The desired triangle count is defined with:
- Note
- The desired triangle count must be between the Max and Min values retrieve with:
- The actual triangle count can be retrieve with:
if (triTargetCount < polyReduction->GetMinTriangleLevel())
if (triTargetCount > polyReduction->GetMaxTriangleLevel())
polyReduction->SetTriangleLevel(triTargetCount);
const Int32 realTriangleResult = polyReduction->GetTriangleLevel();
return OK
Definition: apibase.h:2667
The vertex count is defined with:
- Note
- The desired vertex count must be between the Max and Min values retrieve with:
- The actual vertex count can be retrieve with:
if (vertexTargetCount < polyReduction->GetMinVertexLevel())
if (vertexTargetCount > polyReduction->GetMaxVertexLevel())
polyReduction->SetVertexLevel(vertexTargetCount);
const Int32 realVertexResult = polyReduction->GetVertexLevel();
Finally the edge count can be defined:
- Note
- The desired edge count must be less than the Max value retrieve with:
- The actual edge count can be retrieve with:
if (edgeTargetCount > polyReduction->GetMaxRemainingEdgesLevel())
polyReduction->SetRemainingEdgesLevel(edgeTargetCount);
const Int32 realEdgeResult = polyReduction->GetRemainingEdgesLevel();
Further Reading