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 (Cinema API).
- PolygonReduction::Alloc(): Creates a new PolygonReduction object.
- PolygonReduction::Free(): Deletes the given PolygonReduction object.
AutoAlloc<PolygonReduction> polyReduction;
if (polyReduction == nullptr)
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
Init
A PolygonReduction object has to be initialized. It will pre-process the given PolygonObject.
- PolygonReduction::PreProcess(): Pre-processes the PolygonObject defined in the given PolygonReductionData argument.
The PolygonReductionData argument has these members:
- PolygonReductionData::_doc: The BaseDocument hosting the PolygonObject.
- PolygonReductionData::_op: The target PolygonObject.
- PolygonReductionData::_thread: The caller thread. If set to nullptr, the PolygonReduction object will pre-process the PolygonObject synchronously.
- PolygonReductionData::_settings: A BaseContainer for further settings. See the parameter IDs in
opolyreduxgen.h
.
- 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.
BaseContainer settings;
PolygonReductionData data;
data._op = polyObject;
data._settings = settings;
data._thread = nullptr;
if (polyReduction->PreProcess(data) == false)
return maxon::UnexpectedError(
MAXON_SOURCE_LOCATION,
"The function exited unexpectedly during data pre-processing."_s);
polyReduction->SetReductionStrengthLevel(0.75);
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
Definition: c4d_baselist.h:372
@ 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.
- PolygonReduction::IsPreprocessing(): Returns true if the pre-process is running.
- PolygonReduction::StopPreprocessing(): Aborts preprocessing.
- PolygonReduction::Reset(): Aborts preprocessing and frees all temporary data.
- Note
- This asynchronous mode may be used e.g. in a generator object.
PolygonReductionData data;
data._op = polyObject;
data._settings = settings;
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
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
BaseThread * GeGetDummyThread()
Definition: c4d_thread.h:201
void GeSleep(Int32 milliseconds)
maxon::Int32 Int32
Definition: ge_sys_math.h:51
After the pre-process the PolygonReduction object is ready:
- PolygonReduction::IsValid(): Returns true if a valid object and a valid document are associated with the object.
- PolygonReduction::GetData(): Returns the PolygonReductionData associated with the object.
Reduce
The linked PolygonObject can be reduced by defining the overall reduction strength or the target triangle, vertex or edge count.
- PolygonReduction::GetMaxReductionStrengthLevel(): Returns the maximum reduction strength (1.0)
- PolygonReduction::SetReductionStrengthLevel(): Sets the overall reduction strength.
- PolygonReduction::GetReductionStrengthLevel(): Returns the current overall reduction strength.
The desired triangle count is defined with:
- PolygonReduction::SetTriangleLevel(): Sets the desired triangle count.
- Note
- The desired triangle count must be between the Max and Min values retrieve with:
- PolygonReduction::GetMaxTriangleLevel(): Returns the maximum number of triangles possible.
- PolygonReduction::GetMinTriangleLevel(): Returns the minimum number of triangles possible.
- The actual triangle count can be retrieve with:
- PolygonReduction::GetTriangleLevel(): Returns the actual current triangle count.
if (triTargetCount < polyReduction->GetMinTriangleLevel())
if (triTargetCount > polyReduction->GetMaxTriangleLevel())
polyReduction->SetTriangleLevel(triTargetCount);
const Int32 realTriangleResult = polyReduction->GetTriangleLevel();
return OK
Definition: apibase.h:2740
The vertex count is defined with:
- PolygonReduction::SetVertexLevel(): Sets the desired vertex count.
- Note
- The desired vertex count must be between the Max and Min values retrieve with:
- PolygonReduction::GetMaxVertexLevel(): Returns the maximum number of vertices possible.
- PolygonReduction::GetMinVertexLevel(): Returns the minimum number of vertices possible.
- The actual vertex count can be retrieve with:
- PolygonReduction::GetVertexLevel(): Returns the actual current vertex count.
if (vertexTargetCount < polyReduction->GetMinVertexLevel())
if (vertexTargetCount > polyReduction->GetMaxVertexLevel())
polyReduction->SetVertexLevel(vertexTargetCount);
const Int32 realVertexResult = polyReduction->GetVertexLevel();
Finally the edge count can be defined:
- PolygonReduction::SetRemainingEdgesLevel(): Sets the desired edge count.
- Note
- The desired edge count must be less than the Max value retrieve with:
- PolygonReduction::GetMaxRemainingEdgesLevel(): Returns the number of remaining edges.
- The actual edge count can be retrieve with:
- PolygonReduction::GetRemainingEdgesLevel(): Returns the actual edge count.
if (edgeTargetCount > polyReduction->GetMaxRemainingEdgesLevel())
polyReduction->SetRemainingEdgesLevel(edgeTargetCount);
const Int32 realEdgeResult = polyReduction->GetRemainingEdgesLevel();
Further Reading