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 class SoVRMLIndexedFaceSet;
00047
00067 class SoShapeSimplifyAction : public SoSimplifyAction
00068 {
00069 SO_ACTION_HEADER(SoShapeSimplifyAction);
00070
00071 public:
00072
00080 SoShapeSimplifyAction (SoSimplifier *_simplifier) ;
00081
00085 ~SoShapeSimplifyAction();
00086
00090 virtual void apply(SoNode *node);
00094 virtual void apply(SoPath *path);
00107 virtual void apply(const SoPathList &path_list, SbBool obeys_rules=FALSE);
00108
00109 private:
00110
00111 static void initClass();
00112 static void exitClass();
00113 SbBool isDecimated() { return wasDecimated; }
00114
00115 private:
00116
00117 virtual void beginTraversal(SoNode *) { beginTraversal();}
00118 virtual void endTraversal (SoNode *) { endTraversal() ;}
00119
00120 private:
00121
00122
00123
00124 int enabledElementsCounter;
00125
00126 SbBool wasDecimated;
00127 virtual void prepareAction (SoCallbackAction &action);
00128
00129 virtual void beginTraversal();
00130 virtual void endTraversal ();
00131
00132 SoNodeList groupStack;
00133 SoNodeList deletedNodes;
00134 SoNodeList multInstNodes;
00135 SoNodeList newNodes;
00136
00137 SbBool collectTriangles;
00138 SbBool hasNormals;
00139 SbBool hasColors;
00140
00141 void pushGroup(const SoNode *node){ groupStack.append((SoNode *)node);}
00142 void popGroup () { groupStack.remove(groupStack.getLength()-1);}
00143 SoNode *getGroup () const { return groupStack[groupStack.getLength()-1];}
00144
00145 static SoCallbackAction::Response
00146 catchShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00147 { return ((SoShapeSimplifyAction*) object)->catchShape (action, node); }
00148
00149 SoCallbackAction::Response
00150 catchShape ( SoCallbackAction* action, const SoNode* node) ;
00151
00152 static SoCallbackAction::Response
00153 catchEndShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
00154 { return ((SoShapeSimplifyAction*) object)->catchEndShape (action, node); }
00155
00156 SoCallbackAction::Response
00157 catchEndShape ( SoCallbackAction* action, const SoNode* node) ;
00158
00159 static SoCallbackAction::Response
00160 catchGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00161 { return ((SoShapeSimplifyAction*) object)->catchGroupNodes (action, node); }
00162
00163 SoCallbackAction::Response
00164 catchGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00165
00166 static SoCallbackAction::Response
00167 catchEndGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
00168 { return (static_cast<SoShapeSimplifyAction*>(object))->catchEndGroupNodes (action, node); }
00169
00170 SoCallbackAction::Response
00171 catchEndGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
00172
00173 void addTriangle (SoCallbackAction *action,
00174 const SoPrimitiveVertex *vertex1,
00175 const SoPrimitiveVertex *vertex2,
00176 const SoPrimitiveVertex *vertex3);
00177
00178 static void addTriangleCB (void *userData,
00179 SoCallbackAction *action,
00180 const SoPrimitiveVertex *vertex1,
00181 const SoPrimitiveVertex *vertex2,
00182 const SoPrimitiveVertex *vertex3) {
00183 (static_cast<SoShapeSimplifyAction*>(userData))->addTriangle (action, vertex1, vertex2, vertex3);
00184 }
00185
00186 SoVRMLIndexedFaceSet *convertToVRML2Form(const SoVRMLIndexedFaceSet * node,
00187 SoIndexedFaceSet * newNode);
00188
00189 };
00190
00191 #endif // _SO_SHAPE_SIMPLIFY_ACTION_
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201