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_SHAPE_SIMPLIFY_ACTION_
00026 #define _SO_SHAPE_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/SoLevelOfSimplification.h>
00037 #include <Inventor/nodes/SoMaterial.h>
00038 #include <Inventor/nodes/SoGroup.h>
00039 #include <Inventor/fields/SoMFFloat.h>
00040 #include <Inventor/nodes/SoIndexedFaceSet.h>
00041 #include <Inventor/SoLists.h>
00042
00043 #include <Inventor/SoType.h>
00044
00045 class SoSimplifier;
00046
00065 class SoShapeSimplifyAction : public SoSimplifyAction
00066 {
00067 SO_ACTION_HEADER(SoShapeSimplifyAction);
00068
00069 public:
00070
00078 SoShapeSimplifyAction (SoSimplifier *_simplifier) ;
00079
00083 ~SoShapeSimplifyAction();
00084
00088 virtual void apply(SoNode *node);
00092 virtual void apply(SoPath *path);
00105 virtual void apply(const SoPathList &path_list, SbBool obeys_rules=FALSE);
00106
00107 private:
00108
00109 static void initClass();
00110 static void exitClass();
00111 SbBool isDecimated() { return wasDecimated; }
00112
00113 private:
00114
00115 virtual void beginTraversal(SoNode *) { beginTraversal();}
00116 virtual void endTraversal (SoNode *) { endTraversal() ;}
00117
00118 private:
00119
00120
00121
00122 int enabledElementsCounter;
00123
00124 SbBool wasDecimated;
00125 virtual void prepareAction (SoCallbackAction &action);
00126
00127 virtual void beginTraversal();
00128 virtual void endTraversal ();
00129
00130 SoNodeList groupStack;
00131 SoNodeList deletedNodes;
00132 SoNodeList multInstNodes;
00133 SoNodeList newNodes;
00134
00135 SbBool collectTriangles;
00136 SbBool hasNormals;
00137 SbBool hasColors;
00138
00139 void pushGroup(const SoNode *node){ groupStack.append(const_cast<SoNode *>(node));}
00140 void popGroup () { groupStack.remove(groupStack.getLength()-1);}
00141 SoNode *getGroup () const { return groupStack[groupStack.getLength()-1];}
00142
00143 static SoCallbackAction::Response
00144 catchShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00145 { return ((SoShapeSimplifyAction*) object)->catchShape (action, node); }
00146
00147 SoCallbackAction::Response
00148 catchShape ( SoCallbackAction* action, const SoNode* node) ;
00149
00150 static SoCallbackAction::Response
00151 catchEndShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00152 { return ((SoShapeSimplifyAction*) object)->catchEndShape (action, node); }
00153
00154 SoCallbackAction::Response
00155 catchEndShape ( SoCallbackAction* action, const SoNode* node) ;
00156
00157 static SoCallbackAction::Response
00158 catchGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00159 { return ((SoShapeSimplifyAction*) object)->catchGroupNodes (action, node); }
00160
00161 SoCallbackAction::Response
00162 catchGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00163
00164 static SoCallbackAction::Response
00165 catchEndGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00166 { return (static_cast<SoShapeSimplifyAction*>(object))->catchEndGroupNodes (action, node); }
00167
00168 SoCallbackAction::Response
00169 catchEndGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00170
00171 void addTriangle (SoCallbackAction *action,
00172 const SoPrimitiveVertex *vertex1,
00173 const SoPrimitiveVertex *vertex2,
00174 const SoPrimitiveVertex *vertex3);
00175
00176 static void addTriangleCB (void *userData,
00177 SoCallbackAction *action,
00178 const SoPrimitiveVertex *vertex1,
00179 const SoPrimitiveVertex *vertex2,
00180 const SoPrimitiveVertex *vertex3) {
00181 (static_cast<SoShapeSimplifyAction*>(userData))->addTriangle (action, vertex1, vertex2, vertex3);
00182 }
00183
00184 };
00185
00186 #endif // _SO_SHAPE_SIMPLIFY_ACTION_
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196