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
00094 class SoGlobalSimplifyAction : public SoSimplifyAction
00095 {
00096 SO_ACTION_HEADER(SoGlobalSimplifyAction);
00097
00098 public:
00099
00104 SoGlobalSimplifyAction (SoSimplifier *_simplifier) ;
00105
00109 ~SoGlobalSimplifyAction();
00110
00112 virtual void clearApplyResult();
00113
00115 enum Strategy {
00121 SIMPLIFY_GLOBALLY,
00126 SIMPLIFY_BY_SUBGROUP
00127 };
00128
00129 virtual void apply(SoNode *node);
00130 virtual void apply(SoPath *path);
00131 virtual void apply(const SoPathList &path_list, SbBool obeys_rules = FALSE);
00132
00138 void setSimplificationStrategy(Strategy st) { simplificationStrategy = st;}
00143 Strategy getSimplificationStrategy() const { return simplificationStrategy ;}
00144
00148 SoSeparator *getSimplifiedSceneGraph() const { return simplifiedRoot; }
00149
00155 void generateNormals(SbBool g) { generateNormal = g;}
00160 SbBool areNormalGenerated() const { return generateNormal ;}
00161
00167 void setCatchAllShapesFlag(SbBool c) { catchAllShapes = c;}
00171 SbBool areAllShapesCatched() const { return catchAllShapes ;}
00172
00178 void addShapeHintsNode(SbBool a) { addShapeHints = a;}
00182 SbBool isShapeHintAdded() const { return addShapeHints ;}
00183
00184 private:
00185 static void initClass();
00186 static void exitClass();
00187
00188 private:
00189 virtual void beginTraversal(SoNode *) { beginTraversal();}
00190 virtual void endTraversal (SoNode *) { endTraversal() ;}
00191
00192 private:
00193
00194 virtual void prepareAction (SoCallbackAction &action);
00195
00196 virtual void beginTraversal();
00197 virtual void endTraversal ();
00198
00199 SbBool collectTriangles;
00200
00201
00202 Strategy simplificationStrategy;
00203
00204
00205 SoSeparator *simplifiedRoot;
00206
00207
00208 SbBool generateNormal;
00209
00210
00211
00212 SbBool catchAllShapes;
00213
00214
00215
00216
00217
00218
00219
00220 SbBool addShapeHints;
00221
00222
00223 SoMaterial *lastMaterial;
00224
00225 static SoCallbackAction::Response
00226 catchShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00227 { return ((SoGlobalSimplifyAction*) object)->catchShape (action, node); }
00228
00229 SoCallbackAction::Response
00230 catchShape ( SoCallbackAction* action, const SoNode* node) ;
00231
00232 static SoCallbackAction::Response
00233 catchEndShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00234 { return ((SoGlobalSimplifyAction*) object)->catchEndShape (action, node); }
00235
00236 SoCallbackAction::Response
00237 catchEndShape ( SoCallbackAction* action, const SoNode* node) ;
00238
00239 static SoCallbackAction::Response
00240 catchShapeAttrCB( void* object, SoCallbackAction* action, const SoNode* node)
00241 { return ((SoGlobalSimplifyAction*) object)->catchShapeAttr (action, node); }
00242
00243 SoCallbackAction::Response
00244 catchShapeAttr ( SoCallbackAction* action, const SoNode* node) ;
00245
00246 static SoCallbackAction::Response
00247 catchGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00248 { return ((SoGlobalSimplifyAction*) object)->catchGroupNodes (action, node); }
00249
00250 SoCallbackAction::Response
00251 catchGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00252
00253 void addTriangle (SoCallbackAction *action,
00254 const SoPrimitiveVertex *vertex1,
00255 const SoPrimitiveVertex *vertex2,
00256 const SoPrimitiveVertex *vertex3);
00257
00258 static void addTriangleCB (void *userData,
00259 SoCallbackAction *action,
00260 const SoPrimitiveVertex *vertex1,
00261 const SoPrimitiveVertex *vertex2,
00262 const SoPrimitiveVertex *vertex3)
00263 { ((SoGlobalSimplifyAction*) userData)->addTriangle (action, vertex1, vertex2, vertex3); }
00264
00265
00266 };
00267
00268
00269 #endif // _SO_GLOBAL_SIMPLIFY_ACTION_
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279