PolygonReduction Manual

内容表

关于

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) .

// This example creates a new PolygonReduction object. AutoAlloc<PolygonReduction> polyReduction;
if (polyReduction == nullptr ) return maxon::OutOfMemoryError( MAXON_SOURCE_LOCATION );

Init

A PolygonReduction object has to be initialized. It will pre-process the given PolygonObject .

The PolygonReductionData argument has these members:

注意
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 .
// This example configures the given PolygonReduction object and // reduces the given PolygonObject to 25%.

// set polygon reduction settings BaseContainer settings; 设置。 SetBool ( POLYREDUXOBJECT_PRESERVE_3D_BOUNDARY , true ); 设置。 SetBool ( POLYREDUXOBJECT_PRESERVE_UV_BOUNDARY , true ); PolygonReductionData data; data. _op = polyObject; data. _doc = doc; data. _settings = settings; data. _thread = nullptr ; // synchronous pre-processing and reduction

// pre process if (polyReduction-> PreProcess (data) == false ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "The function exited unexpectedly during data pre-processing." _s);

// reduce polyReduction-> SetReductionStrengthLevel (0.75);

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

PolygonReductionData::_thread member is set the pre-process is running asynchronously in a background thread.

注意
This asynchronous mode may be used e.g. in a generator object.
// This example initializes the given PolygonReduction object asynchronously. PolygonReductionData data; data. _op = polyObject; data. _doc = doc; data. _settings = settings; data. _thread = GeGetDummyThread (); // asynchronous pre-processing

// pre process if (polyReduction-> PreProcess (data) == false ) return maxon::UnexpectedError( MAXON_SOURCE_LOCATION , "The function exited unexpectedly during data pre-processing." _s); Int32 count = 0;

// wait until preprocessing has finished while (polyReduction-> IsPreprocessing ()) { ApplicationOutput ( "Pre Process..." ); GeSleep (100); count++; if (count > 100) { ApplicationOutput ( "Timeout!" ); polyReduction-> StopPreprocessing (); return maxon::UnknownError( MAXON_SOURCE_LOCATION ); } }

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:

注意
// This example reduces the PolygonObject to the given triangle count.

// return gracefully if the specified triangle count is smaller than the minimum number of triangles after reduction pre-processing if (triTargetCount < polyReduction->GetMinTriangleLevel()) return maxon::OK ;

// return gracefully if the specified triangle count is greater than the initial number of triangles if (triTargetCount > polyReduction-> GetMaxTriangleLevel ()) return maxon::OK ; polyReduction-> SetTriangleLevel (triTargetCount); const Int32 realTriangleResult = polyReduction-> GetTriangleLevel (); ApplicationOutput ( "Triangle Result: @" , realTriangleResult);

The vertex count is defined with:

注意
// This example reduces the PolygonObject to the given vertex count.

// return gracefully if the specified vertex count is smaller than the minimum number of vertexes after reduction pre-processing if (vertexTargetCount < polyReduction->GetMinVertexLevel()) return maxon::OK ;

// return gracefully if the specified vertex count is greater than the initial number of vertexes if (vertexTargetCount > polyReduction-> GetMaxVertexLevel ()) return maxon::OK ; polyReduction-> SetVertexLevel (vertexTargetCount); const Int32 realVertexResult = polyReduction-> GetVertexLevel (); ApplicationOutput ( "Vertex Result: @" , realVertexResult);

Finally the edge count can be defined:

注意
// This example reduces the given PolygonObject to the given edge count.

// return gracefully if the specified edges count is smaller than the remained number of edges after reduction pre-processing if (edgeTargetCount > polyReduction-> GetMaxRemainingEdgesLevel ()) return maxon::OK ; polyReduction-> SetRemainingEdgesLevel (edgeTargetCount); const Int32 realEdgeResult = polyReduction-> GetRemainingEdgesLevel (); ApplicationOutput ( "Edge Result: @" , realEdgeResult);

延伸阅读

PolygonReduction::SetTriangleLevel
Bool SetTriangleLevel(Int32 desiredLevel)
PolygonReductionData::_op
PolygonObject * _op
The polygon object to be reduced.
定义: lib_polygonreduction.h:57
PolygonReduction::GetTriangleLevel
Int32 GetTriangleLevel() const
GeGetDummyThread
BaseThread * GeGetDummyThread()
定义: c4d_thread.h:199
PolygonReductionData::_settings
BaseContainer _settings
The reduction constraints settings. See opolyreduxgen.h.
定义: lib_polygonreduction.h:59
PolygonReduction::SetVertexLevel
Bool SetVertexLevel(Int32 desiredLevel)
PolygonReductionData
定义: lib_polygonreduction.h:34
POLYREDUXOBJECT_PRESERVE_3D_BOUNDARY
@ POLYREDUXOBJECT_PRESERVE_3D_BOUNDARY
定义: opolyreduxgen.h:7
PolygonReduction::IsPreprocessing
Bool IsPreprocessing()
PolygonReduction::StopPreprocessing
void StopPreprocessing()
Aborts preprocessing if it is running in the background. Resets the interactive settings values.
PolygonReduction::GetMaxTriangleLevel
Int32 GetMaxTriangleLevel() const
maxon::OK
return OK
定义: apibase.h:2532
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
PolygonReduction::SetReductionStrengthLevel
Bool SetReductionStrengthLevel(Float strengthLevel)
BaseContainer::SetBool
void SetBool(Int32 id, Bool b)
定义: c4d_basecontainer.h:498
PolygonReduction::GetRemainingEdgesLevel
Int32 GetRemainingEdgesLevel() const
PolygonReduction::GetMaxVertexLevel
Int32 GetMaxVertexLevel() const
PolygonReduction::GetVertexLevel
Int32 GetVertexLevel() const
MSG_UPDATE
#define MSG_UPDATE
Must be sent if the bounding box has to be recalculated. (Otherwise use MSG_CHANGE....
定义: c4d_baselist.h:340
PolygonReduction::SetRemainingEdgesLevel
Bool SetRemainingEdgesLevel(Int32 desiredLevel)
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
ApplicationOutput
#define ApplicationOutput(formatString,...)
定义: debugdiagnostics.h:207
C4DAtom::Message
Bool Message(Int32 type, void *data=nullptr)
定义: c4d_baselist.h:1394
GeSleep
void GeSleep(Int32 milliseconds)
PolygonReductionData::_thread
BaseThread * _thread
The caller thread. Set to nullptr if synchronous pre-processing calculation is needed (e....
定义: lib_polygonreduction.h:58
AutoAlloc
定义: ge_autoptr.h:36
PolygonReduction::PreProcess
Bool PreProcess(const PolygonReductionData &data)
PolygonReductionData::_doc
BaseDocument * _doc
The document. Must not be nullptr.
定义: lib_polygonreduction.h:56
POLYREDUXOBJECT_PRESERVE_UV_BOUNDARY
@ POLYREDUXOBJECT_PRESERVE_UV_BOUNDARY
定义: opolyreduxgen.h:8
BaseContainer
定义: c4d_basecontainer.h:46
PolygonReduction::GetMaxRemainingEdgesLevel
Int32 GetMaxRemainingEdgesLevel() const

Copyright  © 2014-2025 乐数软件    

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