00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_SPLIT_GEOMETRY_ACTION_H
00025 #define _SO_SPLIT_GEOMETRY_ACTION_H
00026
00027 #include <Inventor/actions/SoSubAction.h>
00028 #include <Inventor/nodes/SoSeparator.h>
00029 #include <Inventor/nodes/SoIndexedShape.h>
00030
00031 class SoSplitGeometryAction;
00032
00040 typedef void SoSplitGeometryActionCB(const SoSplitGeometryAction* action, SoNode* objectToSplit, const int objectId,
00041 int divAlongX,int divAlongY,int divAlongZ, void* userData);
00042
00043
00079 class SoSplitGeometryAction : public SoAction
00080 {
00081 SO_ACTION_HEADER(SoSplitGeometryAction);
00082
00083 public :
00084
00093 SoSplitGeometryAction(int divAlongX,int divAlongY);
00094
00104 SoSplitGeometryAction(int divAlongX,int divAlongY, int divAlongZ);
00105
00114 void setNumDivisions(int numX, int numY);
00115
00124 void setNumDivisions(int numX, int numY, int numZ);
00125
00129 void getNumDivisions(int &numX, int &numY);
00130
00134 void getNumDivisions(int &numX, int &numY, int &numZ);
00135
00136
00137
00138 #ifndef HIDDEN_FROM_DOC
00139 virtual ~SoSplitGeometryAction();
00140 #endif // HIDDEN_FROM_DOC
00141
00147 void setDistinguishSplitParts(SbBool enable);
00148
00152 SbBool isDistinguishSplitParts(void);
00153
00154
00159 int getNumObjFound(void);
00160
00173 void setKeepOriginalGeometry(SbBool enable);
00174
00178 SbBool isKeepOriginalGeometry(void);
00179
00188 static void setSplitGeometryActionPreCB(SoSplitGeometryActionCB*, void*);
00189
00199 void setSmartSplitting(SbBool enable);
00200
00204 SbBool isSmartSplitting(void);
00210 void setTraverseAllSoSwitchChildren(SbBool enable);
00211
00215 int isTraverseAllSoSwitchChildren(void);
00216
00228 void setMaximumDivisionWarning(SbBool enable);
00229
00239 void setMaintainVertexOrdering(SbBool enable);
00240
00244 SbBool isMaintainVertexOrdering(void);
00245
00246 virtual void apply(SoNode *node);
00247 virtual void apply(SoPath *path) { SoAction::apply(path); };
00248 virtual void apply(const SoPathList &path_list,
00249 SbBool obeys_rules = FALSE) {
00250 SoAction::apply(path_list, obeys_rules); };
00251
00252 private:
00253 static void initClass();
00254 static void exitClass();
00255
00256 private:
00257 virtual void beginTraversal(SoNode *node);
00258 void increaseCurrentNumOfDiv(void);
00259 void resetCurrentNumOfDiv(void);
00260 int getCurrentNumOfDiv(void);
00261 SbBool isDivisionValueGood(SoIndexedShape*,float,int,float,int&);
00262 static void sortAxesAndDivValues(SoSplitGeometryAction*, int &, int&, int&, int&, int&, int&);
00263 void commonConstructor(void);
00264 int getNumberOfDivisions(void);
00265
00266
00267 private:
00268
00269 SoSplitGeometryAction(){};
00270
00271 static void splitStrip(SoAction*, SoNode*);
00272 static void splitFace(SoAction*, SoNode*);
00273 static void callDoAction(SoAction*, SoNode*);
00274 static void nullAction(SoAction*, SoNode*);
00275 static void beginSwitchTraversal(SoAction*, SoNode*);
00276
00277 void splitStrip1Dimension(SoNode* node,int div, int axe,float &lastRed,float &lastGreen, float &lastBlue);
00278 void splitFace1Dimension(SoNode* node,int div, int axe,float &lastRed,float &lastGreen, float &lastBlue);
00279
00280 void replaceNode(SoNode* substitute);
00281
00282 SbBool areEqual(float, float);
00283
00284
00285 int numDivX;
00286 int numDivY;
00287 int numDivZ;
00288
00289
00290 SoNode* result;
00291
00292
00293 SbBool enableMaterial;
00294
00295
00296 int currentNumOfDiv;
00297
00298
00299 int numObjFound;
00300
00301
00302 SbBool keepMyGeometry;
00303
00304
00305 SbBool keepVertexOrdering;
00306
00307
00308 static SoSplitGeometryActionCB *userCB;
00309 static void *userData;
00310
00311
00312 SbBool smartDivision;
00313
00314
00315 int whoHasToBeTraversed;
00316
00317
00318 SbBool splitIn3D;
00319
00320
00321 float epsilon;
00322
00323
00324 SbBool errorOn;
00325 };
00326
00327 #endif
00328
00329
00330