00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _SO_GLOBAL_SIMPLIFY_ACTION_
00026 #define _SO_GLOBAL_SIMPLIFY_ACTION_
00027
00028
00029
00030
00031
00032 #include <Inventor/actions/SoAction.h>
00033 #include <Inventor/actions/SoSubAction.h>
00034 #include <Inventor/actions/SoCallbackAction.h>
00035 #include <Inventor/actions/SoSimplifyAction.h>
00036 #include <Inventor/nodes/SoMaterial.h>
00037 #include <Inventor/nodes/SoBaseColor.h>
00038 #include <Inventor/fields/SoMFFloat.h>
00039
00040 #include <Inventor/SoType.h>
00041
00042 class SoSimplifier;
00043
00095 class SoGlobalSimplifyAction : public SoSimplifyAction
00096 {
00097 SO_ACTION_HEADER(SoGlobalSimplifyAction);
00098
00099 public:
00100
00105 SoGlobalSimplifyAction (SoSimplifier *_simplifier) ;
00106
00110 ~SoGlobalSimplifyAction();
00111
00113 virtual void clearApplyResult();
00114
00116 enum Strategy {
00122 SIMPLIFY_GLOBALLY,
00127 SIMPLIFY_BY_SUBGROUP
00128 };
00129
00130 virtual void apply(SoNode *node);
00131 virtual void apply(SoPath *path);
00132 virtual void apply(const SoPathList &path_list, SbBool obeys_rules = FALSE);
00133
00139 void setSimplificationStrategy(Strategy st) { simplificationStrategy = st;}
00144 Strategy getSimplificationStrategy() const { return simplificationStrategy ;}
00145
00149 SoSeparator *getSimplifiedSceneGraph() const { return simplifiedRoot; }
00150
00156 void generateNormals(SbBool g) { generateNormal = g;}
00161 SbBool areNormalGenerated() const { return generateNormal ;}
00162
00168 void setCatchAllShapesFlag(SbBool c) { catchAllShapes = c;}
00172 SbBool areAllShapesCatched() const { return catchAllShapes ;}
00173
00179 void addShapeHintsNode(SbBool a) { addShapeHints = a;}
00183 SbBool isShapeHintAdded() const { return addShapeHints ;}
00184
00185 private:
00186 static void initClass();
00187 static void exitClass();
00188
00189 private:
00190 virtual void beginTraversal(SoNode *) { beginTraversal();}
00191 virtual void endTraversal (SoNode *) { endTraversal() ;}
00192
00193 private:
00194
00195 virtual void prepareAction (SoCallbackAction &action);
00196
00197 virtual void beginTraversal();
00198 virtual void endTraversal ();
00199
00200 SbBool collectTriangles;
00201
00202
00203 Strategy simplificationStrategy;
00204
00205
00206 SoSeparator *simplifiedRoot;
00207
00208
00209 SbBool generateNormal;
00210
00211
00212
00213 SbBool catchAllShapes;
00214
00215
00216
00217
00218
00219
00220
00221 SbBool addShapeHints;
00222
00223
00224 SoMaterial *lastMaterial;
00225
00226 static SoCallbackAction::Response
00227 catchShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00228 { return ((SoGlobalSimplifyAction*) object)->catchShape (action, node); }
00229
00230 SoCallbackAction::Response
00231 catchShape ( SoCallbackAction* action, const SoNode* node) ;
00232
00233 static SoCallbackAction::Response
00234 catchEndShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00235 { return ((SoGlobalSimplifyAction*) object)->catchEndShape (action, node); }
00236
00237 SoCallbackAction::Response
00238 catchEndShape ( SoCallbackAction* action, const SoNode* node) ;
00239
00240 static SoCallbackAction::Response
00241 catchShapeAttrCB( void* object, SoCallbackAction* action, const SoNode* node)
00242 { return ((SoGlobalSimplifyAction*) object)->catchShapeAttr (action, node); }
00243
00244 SoCallbackAction::Response
00245 catchShapeAttr ( SoCallbackAction* action, const SoNode* node) ;
00246
00247 static SoCallbackAction::Response
00248 catchGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00249 { return ((SoGlobalSimplifyAction*) object)->catchGroupNodes (action, node); }
00250
00251 SoCallbackAction::Response
00252 catchGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00253
00254 void addTriangle (SoCallbackAction *action,
00255 const SoPrimitiveVertex *vertex1,
00256 const SoPrimitiveVertex *vertex2,
00257 const SoPrimitiveVertex *vertex3);
00258
00259 static void addTriangleCB (void *userData,
00260 SoCallbackAction *action,
00261 const SoPrimitiveVertex *vertex1,
00262 const SoPrimitiveVertex *vertex2,
00263 const SoPrimitiveVertex *vertex3)
00264 { ((SoGlobalSimplifyAction*) userData)->addTriangle (action, vertex1, vertex2, vertex3); }
00265
00266
00267 };
00268
00269
00270 #endif // _SO_GLOBAL_SIMPLIFY_ACTION_
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280