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)
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.
return maxon::UnexpectedError(
MAXON_SOURCE_LOCATION,
"The function exited unexpectedly during data pre-processing."_s);
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.
return maxon::UnexpectedError(
MAXON_SOURCE_LOCATION,
"The function exited unexpectedly during data pre-processing."_s);
{
count++;
if (count > 100)
{
}
}
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())
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())
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:
Further Reading