Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
SceneOptimizer.h
Go to the documentation of this file.
1//! @file SceneOptimizer.h
2//! CSceneOptimizer handles an advanced multi-object optimization in different ways
3//!
4///////////////////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_PAIRPOINT_H__D524AB81_02DE_11D2_A0E7_000000000000__INCLUDED_)
7#define AFX_PAIRPOINT_H__D524AB81_02DE_11D2_A0E7_000000000000__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#ifndef MOOTOOLS_CRUNCHERSDK
14# include "ProgressBar.h"
15#endif
16
18#include "3DFaceList.h"
20#include "MRCommon.h"
21
22#ifndef MOOTOOLS_NO_MR
23#include "MRManager.h"
24#endif
25
26BEGIN_MOOTOOLS_NAMESPACE
27
28#define MIN_PAIR_VALUE ((real)-3.402823466E+38)
29
30// Change id when changing the order of setting flags
31#define CURRENT_POLYGON_CRUNCHER_SETTINGS_VERSION 2
32#define OPTIMIZE_NO_CONSTRAINT -1.0f
33#define OPTIMIZE_UNDEFINED_TOLERANCE (-1.0f)
34
35//! @enum OptimizerResult
36//! These flags are used in CSceneOptimizer::GetScene to obtain the result optimization
37typedef enum OptimizerResult
38{
39 ORIGINAL_OBJECT = 0x01, //!< Internal purpose: get the original scene (not optimized), if possible. When it's possible, don't free returned scene
40 OPTIMIZED_OBJECT_FOR_DISPLAY = 0x02, //!< Internal purpose: get a scene which has invalid face. For OpenGL display purpose only. Don't free returned scene
41 OPTIMIZED_OBJECT_CLEANED = 0x04, //!< Get a cleaned scene which can be used outside Polygon Cruncher. Use for converting or saving the optimization result. Don't free returned scene unless OPTIMIZED_COPY_SCENE is used. To be used with static optimization. Cf. #OPTIMIZATION
42 OPTIMIZED_CURRENT_SCENE = 0x08, //!< Internal purpose: returns the original scene (if no Optimize not already called) or potentialy optimized (if it has been optimized and if SCENEOPTIMIZER_INTERACTIVE_MODE is not set). Don't free returned scene unless OPTIMIZED_COPY_SCENE used.
43 OPTIMIZED_MULTIRESOLUTION_SCENE = 0x10, //!< Return a scene containing multiresolution object (compute this scene if needed). Free returned scene if OPTIMIZED_COPY_SCENE set. cf. #OPTIMIZATION_DYNAMIC
44 OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE = 0x20, //!< Returns a cleaned scene from the current multiresolution scene ratio. The multiresolution scene is frozen and ratio can't be changed anymore unless OPTIMIZED_COPY_SCENE is set. In that case, caller must free the returned scene if OPTIMIZED_COPY_SCENE is set.
45 OPTIMIZED_APPLY_TO_SCENE = 0x40, //!< Internal purpose: returns the scene or the multiresolution scene. Don't free the returned scene. The flag is used alone. No copy is possible.
46 OPTIMIZED_COPY_SCENE = 0x100, //!< Return a copy of the scene. To be use in special case only with OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE (duplicate memory)
47 OPTIMIZED_DELETE_ORIGINAL_SCENE = 0x200, //!< Delete the original scene which is the scene provided to CSceneOptimizer::SetScene. To be used with OPTIMIZED_MULTIRESOLUTION_SCENE or OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE mode.
48 OPTIMIZED_COPY_SELECTION = 0x400, //!< Internal purpose: returns a copy of the selected node in the scene, or the whole scene if no selection exists. To be used in special case only with OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE (duplicate memory)
50
51//! @enum SCENEOPTIMIZER_FLAGS
52//! Defines the way CSceneOptimizer mode and if you'll use static / dynamic / interactive mode.
53//!
54//! static: nor SCENEOPTIMIZER_TRACK_CHANGES nor SCENEOPTIMIZER_TRACK_CHANGES must be set. There no multiresolution scene.\n
55//! dynamic: SCENEOPTIMIZER_TRACK_CHANGES only must be set. A multiresolution scene can be get and you can change the ratio as you want.\n
56//! interactive: both SCENEOPTIMIZER_TRACK_CHANGES and SCENEOPTIMIZER_TRACK_CHANGES must be set. A multiresolution scene can be get and you can change the ratio as you want and modify the optimization mode if needed.
58{
59 SCENEOPTIMIZER_OPTIMIZATION_FLAGS = 0x0000FFFF,
60 //////////////////////////////
61 //! @name Running flags
62 //!
63 //! These flags modify the way optimizer perform optimization
64 //! It could be modified whenever its needed
65 //! @{
66 SCENEOPTIMIZER_NONE = 0x00,
67 SCENEOPTIMIZER_EXCLUDE_HIDDEN_NODES = 0x01, //!< The optimizer excludes hidden nodes
68 SCENEOPTIMIZER_HIDE_FROZEN_FACES = 0x02, //!< The optimizer only displays the face to be optimized, hides the frozen faces
69 SCENEOPTIMIZER_PROGRESSIVE_RATIO = 0x04, //!< When optimizing several meshes with great differences in the number of faces, that flag makes the ratio progressive depending on the number of face of each object.\n Doing that, objects with many faces are optimized more than objects with few faces using the same optimize ratio.
70
71 //! @}
72
73 //////////////////////////////
74 //! @name Initialization flags
75 //! Should be called just after the SceneOptimizer creation and before CSceneOptimizer::SetScene
76 //!
77 //! The optimizer is used through an user interaction. This is the case if we need both optimization and optimization mode changes with the same provided scene.
78 //! Dynamic or interactive optimization implies to keep the original faces and points somewhere and increase the memory requirements
79 //! @{
80 SCENEOPTIMIZER_INITIALIZATION_FLAGS = 0x00FF0000,
81 SCENEOPTIMIZER_INTERACTIVE_MODE = 0x00010000, //!< Interactive mode is to be used with SCENEOPTIMIZER_TRACK_CHANGES when you need to get a multiresolution scene and change the optimization settings. Cf. #OPTIMIZATION_INTERACTIVE
82 SCENEOPTIMIZER_TRACK_CHANGES = 0x00020000, //!< Dynamic mode which allows to produce a multiresolution scene, by keeping trace of each optimization steps. Cf. #OPTIMIZATION_DYNAMIC
83
84 //! @}
85
86 //////////////////////////////
87 //! @name Internal flags
88 //!
89 //! @{
90 SCENEOPTIMIZER_INTERNAL_FLAGS = 0xFF000000,
91 SCENEOPTIMIZER_DELETE_SCENE = 0x01000000, //!< Set by CSceneOptimizer::SetScene. The optimizer will delete automatically the provided scene to be optimized. If a multiresolution scene has been required, it is always automatically deleted by the optimizer.
92 SCENEOPTIMIZER_NEW_SCENE_LOADED = 0x02000000, //!< Private. A new scene has been set (using the load menu for example)
93
94 //! @}
96
97class CMRWriter;
98class CMRReader;
100class C3DExtObject;
104
105#ifdef MOOTOOLS_CRUNCHERSDK
106#define COptimizerWnd CWnd
107#endif
108
109#ifdef PLY_MAGICCRUNCHER_COMP
110typedef void (*OptimizerRatioCallback)(double ratio, void *data);
111#endif
112
113// void ShowSelectedFaces(bool showOnlySelected, C3DFaceList *faces, CMaterialHashMap& excludedMaterials);
114//! @class CSceneOptimizer
115//! @brief CSceneOptimizer is the main entry to optimize a scene. There are various optimization modes and which includes keeping UV or not, keeping vertex colors or not...
116//! @details Object optimization mode is set using CSCeneOptimizer::SetOptimizeMode. This is usually called once before calling CSceneOptimizer::Optimize. Changing it using the same optimizer requires to use the interactive mode.
117//!
118//! The scene optimizer contains a set of C3DExtObject. You can convert an usual C3DScene to a scene usuable by CSceneOptimizer using C3DPolygonCruncherObjectCreator.\n
119//!
120//! Optimization is a process that might requires a large amount of memory.\n
121//! The scene optimizer can run itself in different mode that can be set using CSCeneOptimizer::SetFlag\n
122//!
123//! * **Static:** you need to optimize the scene once at a given ratio, or several time using a decreasing ratio.\n
124//! This means CSCeneOptimizer::Optimize can be called multiple time with values going from 1.0 to 0.0f.
125//! * **Dynamic:** you need to change optimization ratio in any way and multiple times. Uses SCENEOPTIMIZER_TRACK_CHANGES.\n
126//! A multiresolution scene is computed. You can get it using CSCeneOptimizer::GetScene(OPTIMIZED_MULTIRESOLUTION_SCENE) and then change the ratio using CSCeneOptimizer::SetMultiresolutionRatio.
127//! * **Interactive:** you need to change optimization ratio in any way and multiple times, and also may changes the object optimization mode using the same input scene. Uses SCENEOPTIMIZER_TRACK_CHANGES|SCENEOPTIMIZER_INTERACTIVE_MODE.\n
128//! A multiresolution scene is computed. You need to release it each time you changed object optimization mode.
129//!
130//! SCENEOPTIMIZER_PROGRESSIVE_RATIO can be combined with theses modes. It offers to modulate the optimize ratio between the different objects of the CSceneOptimizer depending on their number of faces.\n
131//! Doing this makes objects sorted by face number. Objects with many faces are optimized first, while objects with less faces begin to be optimized as the ratio decrease.\n
132//! The goal is that CSceneOptimizer produces object with similar number of faces.
133//!
134//! Memory requirements is the lowest for static mode and the highest for interactive mode.\n
135//! CSceneOptimizer::Optimize will compute the optimization up to the provided ratio.\n
136//! SCENEOPTIMIZER_TRACK_CHANGES record this computing giving you access to multiresolution scene where you can play with the ratio as you want, through an user interaction or camera distance for example.
137//! CSCeneOptimizer::GetScene gives you access to the result (static: OPTIMIZED_OBJECT_CLEANED, dynamic: OPTIMIZED_MULTIRESOLUTION_SCENE/OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE).
138//!
139//! CSceneOptimizer (in dynamic/interactive mode) offers **MagicCruncher** feature, which allows computing automatically the best optimization ratio giving always appropriate results.\n
140//! For example if you optimize some cubic objects which are not highly optimizable, MagicCruncher will stop optimization before object 'destruction' will occurs.\n
141//! When the scene has several objects, MagicCruncher will set a different ratio, so that each object is properly optimized depending on its optimizable capabilities.\n
142//!
143//! MagicCruncher can take a while, and if time is important, OPTIMIZE_USE_PREDICTIVE_RATIO with CSceneOptimizer::Optimize or CSceneOptimizer::SetMultiresolutionRatio is a faster but not optimal way to compute a reasonable and not destructive high ratio.
144//! CSceneOptimizer provides a default method for computing this empiric predictive ratio, but you can provide your own with CSceneOptimizer::SetPredictiveCallback
145//!
146class DLLFUNCTION CSceneOptimizer
147{
148public:
149 //! @enum OptimizableObjectInfo
150 //! GetOptimizableObjects gives a way to return an array of C3DExtObject or CMultiresolutionObject depending on the type of optimization.
152 {
153 CMultiresolutionObject *multires;
154 C3DExtObject *object;
155 C3DSceneNode *node;
157
158 typedef enum
159 {
160 APPLY_TO_SCENE = 0x0, // The whole scene is concerned by the operation
161 APPLY_TO_SELECTED_NODES = 0x01, // Only nodes which have SCENE_NODE_SELECTED flags are concerned by the operation
162 EXCLUDE_LOCKED_NODES = 0x02, // Only nodes which have their ratio unlocked are concerned by the operation. This flag is not always supported, as it as no meaning in most of case.
163 } ApplyTo;
164
165 //! @enum ModifySceneMode
166 //! Advanced usage only
167 typedef enum ModifySceneMode
168 {
169 BEGIN_SCENE_MODIFICATION = 0x01,
170 CANCEL_SCENE_MODIFICATION = 0x02,
171 APPLY_SCENE_MODIFICATION = 0x04, //!< The above flags are called sequencelly BEGIN_SCENE_MODIFICATION/APPLY_SCENE_MODIFICATION or CANCEL_SCENE_MODIFICATION
172 VALIDATE_SCENE_MODIFICATION = 0x08, //!< This flag is used alone once the initial scene has been modified globally in a command. This flush the modified scene and reset the optimization
173 } ModifySceneMode;
174
175 //! @enum MagicCruncherMode
176 //! Flags defining the way MagicCruncher runs.
177 typedef enum MagicCruncherMode
178 {
179 MAGICCRUNCHER_DEFAULT = 0x00,
180 MAGICCRUNCHER_INCLUDE_LOCKED_RATIO = 0x01, //!< By default mesh that are locked are excluded from the MagicCruncher process. Locking an object can be done using CMultiresolutionObject::LockRatio
181 MAGICCRUNCHER_INCLUDE_HIDDEN_NODE = 0x02, //!< By default mesh that are hidden are excluded from the MagicCruncher process.
182 MAGICCRUNCHER_INCLUDE_SELNODES_ONLY = 0x04, //!< MagicCrunching is applied only to node which have SCENE_NODE_IS_SELECTED. This is a way to only apply MagicCruncher on a part of the scene.
183 MAGICCRUNCHER_INCLUDE_ALL_NODES = MAGICCRUNCHER_INCLUDE_LOCKED_RATIO|MAGICCRUNCHER_INCLUDE_HIDDEN_NODE,
184 MAGICCRUNCHER_WHOLE_SCENE = 0x10, //!< Internal flag - MagicCrunching is applied to the whole scene instead of node by node. Other flags are ignored it this settings applied, and the optimizer mode is used (ie. SCENEOPTIMIZER_EXCLUDE_HIDDEN_NODES)
185 MAGICCRUNCHER_ULTRA_MODE = 0x20, //!< Mode ultra: change the way hausdorff measure is normalized
186
187 //! @name Reaching the optimal results
188 //! The following flags determine how much close to the optimal object we want to be.\n
189 //! We always manage to be under the provided similarity threshold, but we then continue investigation to reach the closer ratio to the optimal optimization.\n
190 //! * in draft mode, we approximate we allow an error of 5% on the optimal ratio
191 //! * in medium mode we approximate the optimal ratio to 2500 points
192 //! * in draft mode we approximate the optimal ratio to 500 points
193 //! @{
194 MAGICCRUNCHER_DRAFT_DICHO = 0x100,
195 MAGICCRUNCHER_MEDIUM_DICHO = 0x200, // default choice if nothing specified
196 MAGICCRUNCHER_ACCURATE_DICHO = 0x400,
197 MAGICCRUNCHER_DICHO_LEVEL = MAGICCRUNCHER_DRAFT_DICHO | MAGICCRUNCHER_MEDIUM_DICHO | MAGICCRUNCHER_ACCURATE_DICHO,
198
199 //! @}
200 } MagicCruncherMode;
201
202 //! @enum MagicCruncherResult
203 //! Value return in MagicCruncherParams::resultCode after performing MagicCruncher
205 {
206 MAGICCRUNCHER_VALID = 0x00, // The magicCruncher result is valid
207 MAGICCRUNCHER_ERROR = 0x01, // The magicCruncher result is not valid
208 MAGICCRUNCHER_CANCEL = 0x02, // User cancel
209 MAGICCRUNCHER_TIMEOUT = 0x04, // The progress is too slow
210 } MagicCruncherResult;
211
212 //! @enum MagicCruncherParams
213 //! Allows to have an advanced control on MagicCruncher getting a progress callback or set a time out limit.
214 typedef struct MagicCruncherParams
215 {
216 // Input settings
217 CruncherProgressCallback callback; //!< Define a progress callback
218 void *callbackData; //!< Your own data provided when the progress callback is called
219 unsigned int timeOut; //!< timeOut value in ms
220 bool useExternalApplication; //!< Internal only
221
222 // Output results
223 unsigned int resultCode; // MagicCruncher result value. Cf. MagicCruncherResult
224
226 {
227 callback = NULL;
228 callbackData = NULL;
229 timeOut = -1; // no timeout
230 useExternalApplication = false; // Default built-in and fast process
231
232 resultCode = MAGICCRUNCHER_VALID;
233 };
234 } MagicCruncherParams;
235
236 typedef double (*PredictiveCallback)(C3DObject *object);
237 typedef enum {
238 MAGICCRUNCHER_SIMILARITY_COUNT = 4,
239 MAGICCRUNCHER_DEFAULT_SIMILARITY_INDEX = 1, // 0.005
240 } MagicCruncherSimilarityCount;
241
242 //! @enum MultiresolutionInfo
243 //! Allows to have an advanced control on MagicCruncher getting a progress callback or set a time out limit.
244 typedef enum
245 {
246 MULTIRES_MIN_FACES = 0, //!< Get the smaller number of face of the multiresolution mesh, when SetObjectRatio = 0.0
247 MULTIRES_MIN_POINTS, //!< same for points number
248 MULTIRES_MAX_FACES, //!< Get the maximal number of face of the multiresolution mesh, when SetObjectRatio = 1.0
249 MULTIRES_MAX_POINTS, //!< same for points number
250 MULTIRES_CUR_FACES, //!< Get the current number of face of the multiresolution mesh, corresponding to the ratio used in the last SetObjectRatio call
251 MULTIRES_CUR_POINTS, //!< same for points number
252 } MultiresolutionInfo;
253
254 //! @enum LockRatioStatus
255 //! CSceneOptimizer::GetLockedRatioStatus allows to know if none, one or all the object have been locked using CMultiresolution::LockRatio
256 typedef enum LockRatioStatus
257 {
258 NONE_LOCKED = 0,
259 SOME_LOCKED,
260 ALL_LOCKED
261 } LockRatioStatus;
262
263protected:
264 unsigned int flags;
265 CruncherProgressInfo progressInfo;
266 CruncherProgressCallback progressCallback;
267 PredictiveCallback predictiveCallback;
268 void *progressCallbackData;
269 void *ompLock;
270
271 C3DScene *scene; // initial face not triangulate
272 C3DScene *multiResolutionScene; // multi resolution scene
273
274 bool lockOptimizeReentrance, lockMagicReetrance;
275 int lockInit; // lock initialization for objects (allow to prevent display of dialog box in scene optimizer)
276
277 unsigned int GetSrcExtObjects(CXArray<OptimizableObjectInfo>& objects, bool onlyOptimizable = true) const; // Retrieve all optimizable objects from the original scene (don't care about active multiresolution)
278 CMultiresolutionObject *GetMultiresolutionObject(C3DSceneNode *node, bool onlyOptimizable = true) const; // Return the associated multiresolution if possible. If onlyOptimizable = true, then we check CanOptimizeNode status
279 C3DExtObject *GetExtObject(C3DSceneNode *node, bool checkIfOptimizable = true) const; // Return the associated ext object if possible. If checkIfOptimizable = true, then we check CanOptimizeNode status
280 bool SetOptimizeModeOrExtMode(longuint mode, bool extendedMode, bool cleanNotNeedParameters);
281 longuint GetOptimizeModeOrExtMode(bool extMode) const;
282
283#ifndef MOOTOOLS_CRUNCHERSDK
284 unsigned int MRGetLayerRange(unsigned int& minlayer, unsigned int& maxlayer);
285 unsigned int MRGetLayerNodes(C3DNodeArray& nodes, unsigned int layernbr, float *bbox);
287 static void AddTrackPoint(SceneOptimizerParsingInfo *info, int ptindex);
291 static void AddUVTrackPoint(SceneOptimizerParsingInfo *info, unsigned char channel, int uvindex);
292 static void AddChangeFaceIndex(SceneOptimizerParsingInfo *buildinfo, int index, unsigned char flag);
293#endif
294
295 int GetMultiresolutionInfo(MultiresolutionInfo info, const CMultiresolutionObject *object) const;
296 C3DScene *ComputeMultiresolutionScene();
297
298public:
299 // Initialisation
301 virtual ~CSceneOptimizer();
302
303 void Clean(); //!< Delete input scene and multiresolution scene
304
305 static double ComputeProgressiveThreshold(int objectPtNbr, int maxSceneObjectPtNbr); //!< Return the progressive threshold to be used. objectPtNbr is the object point nbr, and maxSceneObjectPtNbr is the maximum object point number among all objects in the scene
306 static double GetObjectRatioFromGlobalRatio(bool progressive, double globalRatio, double objectProgressiveThreshold, unsigned int ratioMode, bool& leftUnoptimized); //!< Return the progressive ratio value from the global ratio value for a given object
307 static double DefaultPredictiveRatio(C3DObject * object);
308 double ComputePredictiveRatio(C3DObject * object) const; //!< return an heuristic ratio to be used to optimized the mesh. Comparatively to MagicCruncher the ratio is computed in a very fast way, but it gives a mesh optimization which is not optimal.
309 void SetPredictiveCallback(PredictiveCallback callback); //!< This method allows to provide you own predictive callback method when you use OPTIMIZE_USE_PREDICTIVE_RATIO. Giving an object, the callback returns the optimal ratio.
310
311 C3DScene *DetachScene(); //!< The scene provided using SetScene, does not belong any more to the optimizer
312 void DeleteScene(); //!< The scene provided to the optimizer is deleted (only if it has been allowed using SetScene)
313 void SetScene(C3DScene& scene, bool optimizerHandleDeletion); //!< Sets the scene to optimize. If optimizerHandleDeletion = true, the optimizer will delete the scene at destroy, using DeleteScene or if another scene is provided using SetScene.
314
315 //! @brief Get the optimization result.
316 //! @details CLEAN modes removes any invalid faces that are progressively set while optimization occurs.
317 //! When you ask for a cleaned scene you cannot used anymore CSceneOptimizer::Optimize or CSceneOptimize::SetMultiresolutionRatio, unless you use OPTIMIZED_COPY_SCENE.\n
318 //! In that case you'll have to delete the return scene when no longer need it.\n\n
319 //! When using OPTIMIZED_MULTIRESOLUTION_SCENE or OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE, the scene return has the CMultiresolutionScene class.\n
320 //! You can traverse the scene and set the ratio for each objects independently.\n\n
321 //! When using dynamic mode, you can delete the source scene using DeleteScene() once you have the multiresolution scene to reduce memory needs. You can also GetScene do this using OPTIMIZED_MULTIRESOLUTION_SCENE|OPTIMIZED_DELETE_ORIGINAL_SCENE.
322 //! If you have set SCENEOPTIMIZER_INTERACTIVE_MODE, the source scene must be kept as a new optimization computation (CsceneOptimizer::Optimize) each time you modify SetOptimizeMode.
324
325#ifndef MOOTOOLS_NO_MR
326#ifndef MOOTOOLS_CRUNCHERSDK
327 void MRCleanSceneBeforeOptimization(C3DScene * scene, unsigned int optimizationMode);
328 bool SaveMR(const CXString& mrFullPath, unsigned int shellFileClass, CMRWriter& mrManager, bool saveInDifferentLayers = false); // Save MR Data process
329#endif
330 C3DScene *LoadMRFile(const CXString& filename, bool addToCurrentScene, unsigned int mrflags = MRMGR_NONE, const CXString& mrZipFile = CXString(), const CXString& extractDirectory = CXString(), CMRReader *customMgr = NULL); // Load MR Data process. The returned scene belong to the optimizer. Flags is one of the MRMGR_FLAGS loading flags
331#endif
332
333 static double GetDefaultSimilarity(); //!< Return a default similarity value that can be used as default for MagicCruncher
334 static int GetClosestSimilarityIndex(double similarity); //!< Return the closest index in the GetDefaultSimilarityValues array based on the provide similarity value
335 static const double *GetDefaultSimilarityValues(int& size); //!< Return #size default values to be use with MagicCruncherOptimization. These default are ordered from the lowest similarities to the highest one.
336 static double MagicCruncherOptimization(const CXArray<CMultiresolutionObject*> *objects, unsigned int magicCruncherMode, double hausdorffThreshold, MagicCruncherParams *params = NULL); //!< This method can be called when we only have CMultiresolutionObject* objets without the CSceneOptimizer that allow to compute it
337 double MagicCruncherOptimization(unsigned int magicMode, double similarityThreshold, ApplyTo applyTo = APPLY_TO_SCENE, MagicCruncherParams* params = NULL); //!< Find optimal optimization with an optimal ratio for each objects, return the global ratio (1.0 is nothing done). magicMode is a combination of MagicCruncherMode flags
338
339 //! @name Working with the computed multiresolution scene
340 //! @details When using SCENEOPTIMIZER_TRACK_CHANGES, CSceneOptimizer::Optimize pre-compute optimization and allows dynamic access to optimization through a multiresolution scene (CMultiresolutionScene)
341 //! These methods give access to the multiresolution scene which contains CMultiresolutionObject\n
342 //! The node ID are kept between the original scene and the multiresolution scene. This property can be used for specific purpose.\n
343 //! @{
344 void CleanMultiresolutionScene(); //!< Delete an already computed multiresolution scene. This is automatically called on destroy but might be required on interactive optimization. Cf. usage in #OPTIMIZATION_INTERACTIVE
345 bool HasMultiresolutionScene() const; //!< Return true if a multiresolution scene is available (this occurs if GetScene(OPTIMIZED_MULTIRESOLUTION_SCENE) has been called.
346 //! @brief Modify the ratio of the multiresolution scene (CMultiresolutionScene) by calling each CMultiresolutionObject::SetObjectRatio independently.
347 //! @param ratio Define the target ratio if OPTIMIZE_TO_RATIO set.
348 //! @param requiredElement If OPTIMIZE_TO_NBR set, requiredElement is the target number of points (OPTIMIZE_TO_POINT) or faces (OPTIMIZE_TO_FACE).
349 //! @param mode Can be OPTIMIZE_TO_POINT|OPTIMIZE_TO_NBR, OPTIMIZE_TO_FACE|OPTIMIZE_TO_NBR, OPTIMIZE_TO_POINT|OPTIMIZE_TO_RATIO, OPTIMIZE_TO_FACE|OPTIMIZE_TO_RATIO
350 //! @param applyTo Could be APPLY_TO_SCENE or APPLY_TO_SELECTED_NODES. Object which ratio is locked is not taken into account, unless OPTIMIZE_UNLOCK_RATIO is defined.
351 bool SetMultiresolutionRatio(double ratio, int requiredElement, unsigned int mode, ApplyTo applyTo = APPLY_TO_SCENE);
352
353 //! @}
354
355 bool OptimizerHandleDeletion() const { return IsFlagSet(SCENEOPTIMIZER_DELETE_SCENE); }
356 bool IsNewScene() const { return IsFlagSet(SCENEOPTIMIZER_NEW_SCENE_LOADED); }
357
358 bool HasSameRatio(ApplyTo applyTo) const; //!< Return true if all the nodes concerned by applyTo has same optimization ratio. return true, if no multiresolution scene were computed
359 double GetMaxThresholdFromSelection(ApplyTo mode) const;
360 bool IsProgressiveRatioEnabled() const; //!< Return true if SCENEOPTIMIZER_PROGRESSIVE_RATIO is set and if there is more than one node to optimize
361
362 void ModifyScene(ModifySceneMode mode); //!< Advanced usage only. Provide a way to modify the internal scene for performing some changes on it (point welding, collapsing...)
363
364 //! Optimize compute optimization up to ratio
365 //! * If SCENEOPTIMIZER_TRACK_CHANGES is set, it computes a multiresolution scene up to the ratio provided.\n
366 //! Using GetScene(OPTIMIZED_MULTIRESOLUTION_SCENE), allows to play dynamically with the optimization ratio, using the CMultiresolutionObject
367 //! * If SCENEOPTIMIZER_TRACK_CHANGES is false then Optimize should be called any time you need to get an optimization of the scene.
368 //! It is slower as a change of ratio recomputes all but it requires less memory.
369 //! @note in any case if SCENEOPTIMIZER_INTERACTIVE_MODE is not defined, Optimize must be called only with decreasing ratio.
370 int Optimize(double ratio, bool& userCancel, unsigned int ratioMode = OPTIMIZE_TO_RATIO|OPTIMIZE_TO_FACE);
371 double GetObjectRatioFromGlobalRatio(double globalRatio, double objectProgressiveThreshold, unsigned int ratioMode, bool& leftUnoptimized) const; //!< Returns the progressive ratio value from the global ratio value for a given object. leftUnoptimized is return to true, if the ratio is above the thresholdRatio in case of progressive optimization
372
373 ///////////////////////////
374 // Scene optimizer flags (among SCENEOPTIMIZER_OPTIMIZATION_FLAGS flags)
375 inline bool IsFlagSet(SCENEOPTIMIZER_FLAGS flag) const
376 {
377 return ((flags & flag) == flag) ? true : false;
378 }
379
380 unsigned int SaveFlags() const // Returns only SCENEOPTIMIZER_OPTIMIZATION_FLAGS, for saving scene optimizer mode
381 {
382 return (flags & SCENEOPTIMIZER_OPTIMIZATION_FLAGS);
383 };
384
385 void LoadFlags(unsigned int flags) // Returns only SCENEOPTIMIZER_OPTIMIZATION_FLAGS, for restoring a previously save scene optimizer mode
386 {
387 SetFlags(flags & SCENEOPTIMIZER_OPTIMIZATION_FLAGS, true);
388 };
389
390 void SetFlags(unsigned int newflags, bool set);
391 void SetFlag(SCENEOPTIMIZER_FLAGS flag, bool set);
392
393 ///////////////////////////
394 //! @name Object optimization mode
395 //! It's better to use LockInitialization, modify the optimization mode in the way you want then called UnlockInitialization to take avantage of multithreading.
396 //! @{
397 longuint GetOptimizeMode() const; //!< Return combination of OPTIMIZE_MODE used by the optimizer. As each object might have a different mode (if C3DExtObject::SetOptimizeMode has been called independently), it returns a combination of all C3DExtObject::GetOptimizeMode object flags.
398 longuint GetOptimizeExtMode() const; //!< Return combination of OPTIMIZE_EXTMODE. Same remark than above.
399 bool SetOptimizeExtMode(longuint optimizeExtModeFlags, bool cleanNotNeedParameters); //!< Set one or more OPTIMIZE_EXTMODE flags of each scene optimizer objects
400 bool SetOptimizeMode(longuint optimizeModeFlags, bool cleanNotNeedParameters); //!< Set one or more OPTIMIZE_MODE flags of each scene optimizer objects
401 bool SetOptimizeMode(C3DExtObject *object, OPTIMIZE_MODE newflag, bool set); //!< Modify one OPTIMIZE_MODE flag one of each scene optimizer objects
402 // void ShowSelectedFaces(bool hideFrozenFaces);
403 void LockInitialization(); //!< As changing the object's optimisation mode can lead to a reset, LockInitialization and UnlockInitialization can be used to postpone this reset, reduce the calculations required and parallelise the process.
404 void UnlockInitialization(); //!< Unlock a previously locked initalization.
405
406 //! @}
407
408 int LockOptimizeRatio(bool lock, ApplyTo mode = APPLY_TO_SCENE); //!< Prevent multiresolution object ratio to be changed, by calling appropriate CMultiresolutionObject::LockRatio methods. Return the number of object which status changed (were unlocked, get lock or were locked, get unlocked). applyTo could be APPLY_TO_SCENE or APPLY_TO_SELECTED_NODES
409
410#ifdef MOOTOOLS_PRODUCT_BUILD
411 unsigned int GetFrozenObjects(CXArray<OptimizableObjectInfo>& objects, unsigned int applyToMode) const;
412 int GetFrozenInfo(MultiresolutionInfo info, ApplyTo applyTo) const;
413 LockRatioStatus HasFrozenMultiresolutionObjects(ApplyTo mode = APPLY_TO_SCENE) const; //!< Return NONE_LOCKED, SOME_LOCKED, ALL_LOCKED were LOCKED means FROZEN
414 int UnfreezeMultiresolutionObjects(ApplyTo mode = APPLY_TO_SCENE);
415#endif
416
417 //! @brief Node locking status
418 //! @details When the multiresolution scene has been computed, this is possible to froze a multiresolution object, using CMultiresolution::LockRatio
419 //! The following methods, check if none/some/all object are locked
420 LockRatioStatus GetLockedRatioStatus(ApplyTo mode = APPLY_TO_SCENE) const;
421 //bool HasLockedRatio() const; // Determine if one of the multiresolution SetConstraintRatio
422
423 bool SetConstraintRatio(float constraint); //!< This can be use to limit the optimization to a given constraint ratio. This is mainly for internal purpose
424 float GetConstraintRatio() const; //!< Retrieved the ratio set using
425
426 bool SetUVWTolerance(float tolerance); //!< Set the UVW tolerance for all scene optimizer objects
427 float GetUVWTolerance() const; //!< Set the UVW tolerance for all scene optimizer objects
428 bool SetVCTolerance(int tolerance); //!< Set the UVW tolerance for all scene optimizer objects
429 int GetVCTolerance() const; //!< Set the UVW tolerance for all scene optimizer objects
430 bool SetNormalThreshold(double radianThreshold); //!< Set the UVW tolerance for all scene optimizer objects
431 double GetNormalThreshold() const; //!< Set the UVW tolerance for all scene optimizer objects
432 bool SetSymetryTolerance(float tolerance); //!< Set the UVW tolerance for all scene optimizer objects
433 float GetSymetryTolerance() const; //!< Set the UVW tolerance for all scene optimizer objects
434 bool ContainMaterialFrontier(); //!< Returns true if at least one object has a material frontier. A material frontier means that one point of the object is connected to faces which have a different material.\n This allows to know if setting one of the OPTIMIZE_MATERIAL_FRONTIER_MASK optimization mode has some meaning.
435 bool ContainUVWInfo(C3DScene *scene = NULL); //!< Returns true if at least one of the object have UVW (UVW_CHANNEL). Check on the provided scene, otherwise check in the optimizer attached scene.\n This allows to know if setting one of the OPTIMIZE_UV_MASK optimization mode has some meaning.
436 bool ContainVCInfo(C3DScene* scene = NULL); //!< Returns true if at least one of the object have verter colors (VC_CHANNEL). The check is performed on the provided scene, otherwise check is done on scene optimizer.\n This allows to know if setting one of the OPTIMIZE_VC_MASK optimization mode has some meaning.
437 bool ContainNormalInfo(C3DScene* scene = NULL); //!< Returns true if at least one of the object have specified normals (SPEC_NORMAL_CHANNEL). The check is performed on the provided scene, otherwise check is done on scene optimizer.\n This allows to know if setting one of the OPTIMIZE_NORMALS_MASK optimization mode has some meaning.
438
439 int GetSymetricPairsNumber() const; //!< Return the number of symetric points found, which is the sum of symetrical points of each optimizer objects.
440
441 // Materials optimisations
442 bool SelectMaterial(C3DExtObject *object, MaterialID id, bool optimised);
443
444 // Optimisation information
445 bool HasLockedNodes() const;
446 unsigned int GetOptimizableObjects(CXArray<OptimizableObjectInfo>& objects, unsigned int applyToMode, bool onlyOptimizable = true) const; //!< Get ExtObject or CMultiresolutionObject from the scene (optimizable scene or multiresolution scene).
447 bool CanOptimizeNode(const C3DSceneNode *node) const;
448
449 ApplyTo GetApplyToMode() const; //!< return APPLY_TO_SCENE if none or all optimizable meshes are selected, APPLY_TO_SELECTION otherwise.
450
451 //! @name Get point / face number information
452 //! Retrieve information on the removable (optimizable) point / face number and on the optimized point / face number.
453 //! @note
454 //! Depending on SetOptimizeMode not all the object point are removable. For example OPTIMIZE_EXCLUDE_BORDER will exclude some points from the optimization process.\n
455 //! The optimization ratio use the removable point / face to compute the optimized number of points.
456 //!
457 //! @{
458 int GetMultiresolutionInfo(MultiresolutionInfo info, ApplyTo applyMode = APPLY_TO_SCENE) const; //!< Get information on the number of optimized / optimizable / total points or faces number for the whole scene or the selection. applyTo could be any values
459 int GetInitialRemovableElementNumber(bool faceNbr) const; //!< Return number of removable faces (or points if !faceNbr)
460 int GetRemovedElementNumber(bool faceNbr) const; //!< Return number of removed faces (or points if !faceNbr)
461
462 int GetInitialRemovableFacesNumber() const; //!< Returns the number of faces that can be removed.
463 int GetInitialRemovablePointsNumber() const; //!< Returns the number of points that can be removed
464 int GetRemovedFacesNumber() const; //!< Returns the number of faces that have been removed
465 int GetRemovedPointsNumber() const; //!< Returns the number of points that have been removed
466
467 //! @}
468
469 //! @name Callbacks
470 //! These method give a way to provide feedback to an user through a dialog box
471 //! @{
472 void SetProgressCallback(CruncherProgressCallback callback, void *data); //!< Set a progress callback if you want to give some feedback to an user
473 void CancelProgress(); //!< Force progress to cancel
474 bool CheckCancelButton();
475 void SetMeshPos(unsigned int curmesh);
476
477 void AddProgressPos(unsigned int value);
478 void SetProgressPos(unsigned int pos);
479
480 void SetProgressMeshRange(unsigned int meshnbr);
481 void SetProgressRange(unsigned int min, unsigned int max);
482 void AddProgressRange(unsigned int value);
483
484 void SetProgressStatus(const CXString& status);
485 void ShowInformation(bool show, int textid = -1);
486
487 //! @}
488
489 //! @name Multithreading
490 //! These methods controls the number of thread allowed to the CSceneOptimizer.\n
491 //! This is equivalent to calling OMPSetMaxThreadCount / OMPGetMaxThreadCount directly.
492 //! @{
493 void SetMaxThreadCount(unsigned int count); //!< Set the maximum parallel threads for task that are computed in parallel (ie MagicCruncher features)
494 unsigned int GetMaxThreadCount() const; //!< Get the maximum parallel threads
495
496 //! @}
497
498#ifdef PLY_ALPHA_FEATURE
499 bool SetStrength(OPTIMIZE_STRENGTH_TYPE type, float powerStrength); // power is a value > 0.0f, 1.0f is default
500 float GetStrength(OPTIMIZE_STRENGTH_TYPE type) const; // power is a value > 0.0f, 1.0f is default
501
502#ifdef PLY_WEIGHT
503 bool ContainWeightInfo();
504#endif
505#endif
506
507#ifdef _DEBUG
508 void DumpOptimizationMode() const;
509#endif
510
511#ifndef MOOTOOLS_CRUNCHERSDK
512 // UI
513protected:
514 unsigned int infoCount, progressCount;
518
519public:
521 CWnd *GetOptimizerWnd() { return pOptimizerWnd; };
522 static bool DefaultProgressCallback(unsigned int flags, const CruncherProgressInfo& info, void *data);
523
524#ifdef PLY_MAGICCRUNCHER_COMP
525 protected:
527 void *ratioCallbackData;
528 C3DScene *switchedMultiResolutionScene; // multi resolution scene
529
530 public:
531 void SetRatioCallback(OptimizerRatioCallback callback, void *data);
533 double MagicCruncherGlobalOptimizationWithExternalApp(double similarityThreshold, bool accurate, double& resultingHausdorff); // Find optimal optimization globally with a single ratio, return the ratio (1.0 is nothing done)
535#endif
536#elif defined(PLY_MAGICCRUNCHER_COMP)
537 #pragma error("PLY_MAGICCRUNCHER_COMP should not be defined")
538#endif
539};
540
541END_MOOTOOLS_NAMESPACE
542
543#endif // !defined(AFX_PAIRPOINT_H__D524AB81_02DE_11D2_A0E7_000000000000__INCLUDED_)
C3DFaceList class definition which is a list of C3DFace.
Defines some class for batch optimization and scene conversion for CSceneOptimizer.
bool(* CruncherProgressCallback)(unsigned int cruncherProgressFlags, const CruncherProgressInfo &info, void *data)
Progress callback. cruncherProgressFlags is a combination of CruncherProgress flags which inform abou...
Definition PolygonCruncherInterface.h:310
OPTIMIZE_MODE
Definition PolygonCruncherType.h:53
SCENEOPTIMIZER_FLAGS
Definition SceneOptimizer.h:58
@ SCENEOPTIMIZER_HIDE_FROZEN_FACES
The optimizer only displays the face to be optimized, hides the frozen faces.
Definition SceneOptimizer.h:68
@ SCENEOPTIMIZER_PROGRESSIVE_RATIO
When optimizing several meshes with great differences in the number of faces, that flag makes the rat...
Definition SceneOptimizer.h:69
@ SCENEOPTIMIZER_EXCLUDE_HIDDEN_NODES
The optimizer excludes hidden nodes.
Definition SceneOptimizer.h:67
@ SCENEOPTIMIZER_TRACK_CHANGES
Dynamic mode which allows to produce a multiresolution scene, by keeping trace of each optimization s...
Definition SceneOptimizer.h:82
@ SCENEOPTIMIZER_DELETE_SCENE
Set by CSceneOptimizer::SetScene. The optimizer will delete automatically the provided scene to be op...
Definition SceneOptimizer.h:91
@ SCENEOPTIMIZER_NEW_SCENE_LOADED
Private. A new scene has been set (using the load menu for example)
Definition SceneOptimizer.h:92
@ SCENEOPTIMIZER_INTERACTIVE_MODE
Interactive mode is to be used with SCENEOPTIMIZER_TRACK_CHANGES when you need to get a multiresoluti...
Definition SceneOptimizer.h:81
OptimizerResult
Definition SceneOptimizer.h:38
@ OPTIMIZED_OBJECT_CLEANED
Get a cleaned scene which can be used outside Polygon Cruncher. Use for converting or saving the opti...
Definition SceneOptimizer.h:41
@ OPTIMIZED_CURRENT_SCENE
Internal purpose: returns the original scene (if no Optimize not already called) or potentialy optimi...
Definition SceneOptimizer.h:42
@ OPTIMIZED_COPY_SCENE
Return a copy of the scene. To be use in special case only with OPTIMIZED_CLEANED_MULTIRESOLUTION_SCE...
Definition SceneOptimizer.h:46
@ OPTIMIZED_COPY_SELECTION
Internal purpose: returns a copy of the selected node in the scene, or the whole scene if no selectio...
Definition SceneOptimizer.h:48
@ OPTIMIZED_MULTIRESOLUTION_SCENE
Return a scene containing multiresolution object (compute this scene if needed). Free returned scene ...
Definition SceneOptimizer.h:43
@ OPTIMIZED_CLEANED_MULTIRESOLUTION_SCENE
Returns a cleaned scene from the current multiresolution scene ratio. The multiresolution scene is fr...
Definition SceneOptimizer.h:44
@ OPTIMIZED_OBJECT_FOR_DISPLAY
Internal purpose: get a scene which has invalid face. For OpenGL display purpose only....
Definition SceneOptimizer.h:40
@ ORIGINAL_OBJECT
Internal purpose: get the original scene (not optimized), if possible. When it's possible,...
Definition SceneOptimizer.h:39
@ OPTIMIZED_DELETE_ORIGINAL_SCENE
Delete the original scene which is the scene provided to CSceneOptimizer::SetScene....
Definition SceneOptimizer.h:47
@ OPTIMIZED_APPLY_TO_SCENE
Internal purpose: returns the scene or the multiresolution scene. Don't free the returned scene....
Definition SceneOptimizer.h:45
CXTString< TCHAR > CXString
CXString depend on the target OS. Could be CXStringW (Windows) or CXStringA (Linux / Macos)
Definition XString.h:118
This class handles static optimization of an object.
Definition 3DExtObject.h:66
This is the base class for any object containing geometry (curve, polygonal object,...
Definition 3DGeomObject.h:49
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
A node matches one element that is part of the C3DScene graph. It references a C3DBaseObject and has ...
Definition 3DSceneNode.h:64
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CMultiresolutionObject is the base class for multiresolution object. There is two kind of multiresolu...
Definition MultiresolutionObject.h:33
CSceneOptimizer is the main entry to optimize a scene. There are various optimization modes and which...
Definition SceneOptimizer.h:147
bool HasSameRatio(ApplyTo applyTo) const
Return true if all the nodes concerned by applyTo has same optimization ratio. return true,...
void SetMaxThreadCount(unsigned int count)
Set the maximum parallel threads for task that are computed in parallel (ie MagicCruncher features)
unsigned int GetOptimizableObjects(CXArray< OptimizableObjectInfo > &objects, unsigned int applyToMode, bool onlyOptimizable=true) const
Get ExtObject or CMultiresolutionObject from the scene (optimizable scene or multiresolution scene).
C3DScene * DetachScene()
The scene provided using SetScene, does not belong any more to the optimizer.
bool SetOptimizeMode(longuint optimizeModeFlags, bool cleanNotNeedParameters)
Set one or more OPTIMIZE_MODE flags of each scene optimizer objects.
double ComputePredictiveRatio(C3DObject *object) const
return an heuristic ratio to be used to optimized the mesh. Comparatively to MagicCruncher the ratio ...
double MagicCruncherOptimization(unsigned int magicMode, double similarityThreshold, ApplyTo applyTo=APPLY_TO_SCENE, MagicCruncherParams *params=NULL)
Find optimal optimization with an optimal ratio for each objects, return the global ratio (1....
longuint GetOptimizeExtMode() const
Return combination of OPTIMIZE_EXTMODE. Same remark than above.
unsigned int GetMaxThreadCount() const
Get the maximum parallel threads.
bool SetConstraintRatio(float constraint)
This can be use to limit the optimization to a given constraint ratio. This is mainly for internal pu...
int GetRemovedFacesNumber() const
Returns the number of faces that have been removed.
static double GetObjectRatioFromGlobalRatio(bool progressive, double globalRatio, double objectProgressiveThreshold, unsigned int ratioMode, bool &leftUnoptimized)
Return the progressive ratio value from the global ratio value for a given object.
void CleanMultiresolutionScene()
Delete an already computed multiresolution scene. This is automatically called on destroy but might b...
bool HasMultiresolutionScene() const
void SetProgressCallback(CruncherProgressCallback callback, void *data)
Set a progress callback if you want to give some feedback to an user.
static double ComputeProgressiveThreshold(int objectPtNbr, int maxSceneObjectPtNbr)
Return the progressive threshold to be used. objectPtNbr is the object point nbr, and maxSceneObjectP...
static int GetClosestSimilarityIndex(double similarity)
Return the closest index in the GetDefaultSimilarityValues array based on the provide similarity valu...
bool SetOptimizeMode(C3DExtObject *object, OPTIMIZE_MODE newflag, bool set)
Modify one OPTIMIZE_MODE flag one of each scene optimizer objects.
int GetInitialRemovableElementNumber(bool faceNbr) const
Return number of removable faces (or points if !faceNbr)
bool IsProgressiveRatioEnabled() const
Return true if SCENEOPTIMIZER_PROGRESSIVE_RATIO is set and if there is more than one node to optimize...
LockRatioStatus GetLockedRatioStatus(ApplyTo mode=APPLY_TO_SCENE) const
Node locking status.
float GetConstraintRatio() const
Retrieved the ratio set using.
void SetScene(C3DScene &scene, bool optimizerHandleDeletion)
Sets the scene to optimize. If optimizerHandleDeletion = true, the optimizer will delete the scene at...
static double MagicCruncherOptimization(const CXArray< CMultiresolutionObject * > *objects, unsigned int magicCruncherMode, double hausdorffThreshold, MagicCruncherParams *params=NULL)
This method can be called when we only have CMultiresolutionObject* objets without the CSceneOptimize...
bool SetVCTolerance(int tolerance)
Set the UVW tolerance for all scene optimizer objects.
void LockInitialization()
As changing the object's optimisation mode can lead to a reset, LockInitialization and UnlockInitiali...
bool ContainUVWInfo(C3DScene *scene=NULL)
Returns true if at least one of the object have UVW (UVW_CHANNEL). Check on the provided scene,...
int GetInitialRemovableFacesNumber() const
Returns the number of faces that can be removed.
void SetPredictiveCallback(PredictiveCallback callback)
This method allows to provide you own predictive callback method when you use OPTIMIZE_USE_PREDICTIVE...
void DeleteScene()
The scene provided to the optimizer is deleted (only if it has been allowed using SetScene)
double GetObjectRatioFromGlobalRatio(double globalRatio, double objectProgressiveThreshold, unsigned int ratioMode, bool &leftUnoptimized) const
Returns the progressive ratio value from the global ratio value for a given object....
bool SetOptimizeExtMode(longuint optimizeExtModeFlags, bool cleanNotNeedParameters)
Set one or more OPTIMIZE_EXTMODE flags of each scene optimizer objects.
void ModifyScene(ModifySceneMode mode)
Advanced usage only. Provide a way to modify the internal scene for performing some changes on it (po...
MagicCruncherMode
Definition SceneOptimizer.h:178
int GetVCTolerance() const
Set the UVW tolerance for all scene optimizer objects.
int GetMultiresolutionInfo(MultiresolutionInfo info, ApplyTo applyMode=APPLY_TO_SCENE) const
Get information on the number of optimized / optimizable / total points or faces number for the whole...
ApplyTo GetApplyToMode() const
return APPLY_TO_SCENE if none or all optimizable meshes are selected, APPLY_TO_SELECTION otherwise.
int GetRemovedElementNumber(bool faceNbr) const
Return number of removed faces (or points if !faceNbr)
float GetSymetryTolerance() const
Set the UVW tolerance for all scene optimizer objects.
int GetRemovedPointsNumber() const
Returns the number of points that have been removed.
MultiresolutionInfo
Definition SceneOptimizer.h:245
@ MULTIRES_CUR_FACES
Get the current number of face of the multiresolution mesh, corresponding to the ratio used in the la...
Definition SceneOptimizer.h:250
@ MULTIRES_CUR_POINTS
same for points number
Definition SceneOptimizer.h:251
@ MULTIRES_MIN_POINTS
same for points number
Definition SceneOptimizer.h:247
@ MULTIRES_MAX_FACES
Get the maximal number of face of the multiresolution mesh, when SetObjectRatio = 1....
Definition SceneOptimizer.h:248
@ MULTIRES_MAX_POINTS
same for points number
Definition SceneOptimizer.h:249
int LockOptimizeRatio(bool lock, ApplyTo mode=APPLY_TO_SCENE)
Prevent multiresolution object ratio to be changed, by calling appropriate CMultiresolutionObject::Lo...
longuint GetOptimizeMode() const
Return combination of OPTIMIZE_MODE used by the optimizer. As each object might have a different mode...
bool SetNormalThreshold(double radianThreshold)
Set the UVW tolerance for all scene optimizer objects.
bool SetUVWTolerance(float tolerance)
Set the UVW tolerance for all scene optimizer objects.
int GetSymetricPairsNumber() const
Return the number of symetric points found, which is the sum of symetrical points of each optimizer o...
bool SetSymetryTolerance(float tolerance)
Set the UVW tolerance for all scene optimizer objects.
LockRatioStatus
Definition SceneOptimizer.h:257
float GetUVWTolerance() const
Set the UVW tolerance for all scene optimizer objects.
bool ContainVCInfo(C3DScene *scene=NULL)
Returns true if at least one of the object have verter colors (VC_CHANNEL). The check is performed on...
ModifySceneMode
Definition SceneOptimizer.h:168
int Optimize(double ratio, bool &userCancel, unsigned int ratioMode=OPTIMIZE_TO_RATIO|OPTIMIZE_TO_FACE)
double GetNormalThreshold() const
Set the UVW tolerance for all scene optimizer objects.
void UnlockInitialization()
Unlock a previously locked initalization.
bool ContainMaterialFrontier()
Returns true if at least one object has a material frontier. A material frontier means that one point...
MagicCruncherResult
Definition SceneOptimizer.h:205
bool SetMultiresolutionRatio(double ratio, int requiredElement, unsigned int mode, ApplyTo applyTo=APPLY_TO_SCENE)
Modify the ratio of the multiresolution scene (CMultiresolutionScene) by calling each CMultiresolutio...
static double GetDefaultSimilarity()
Return a default similarity value that can be used as default for MagicCruncher.
C3DScene * GetScene(unsigned int optimizerResultFlags)
Get the optimization result.
void CancelProgress()
Force progress to cancel.
void Clean()
Delete input scene and multiresolution scene.
int GetInitialRemovablePointsNumber() const
Returns the number of points that can be removed.
bool ContainNormalInfo(C3DScene *scene=NULL)
Returns true if at least one of the object have specified normals (SPEC_NORMAL_CHANNEL)....
static const double * GetDefaultSimilarityValues(int &size)
Return #size default values to be use with MagicCruncherOptimization. These default are ordered from ...
This class provides information about computation progress to the different progress callback.
Definition PolygonCruncherInterface.h:41
Definition SceneOptimizer.h:215
unsigned int timeOut
timeOut value in ms
Definition SceneOptimizer.h:219
void * callbackData
Your own data provided when the progress callback is called.
Definition SceneOptimizer.h:218
bool useExternalApplication
Internal only.
Definition SceneOptimizer.h:220
CruncherProgressCallback callback
Define a progress callback.
Definition SceneOptimizer.h:217
Definition SceneOptimizer.h:152