Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoSplitGeometryAction.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Jerome Hummel (Nov 2001)
22**=======================================================================*/
23
24#ifndef _SO_SPLIT_GEOMETRY_ACTION_H
25#define _SO_SPLIT_GEOMETRY_ACTION_H
26
27#include <Inventor/actions/SoSubAction.h>
28#include <Inventor/nodes/SoSeparator.h>
29#include <Inventor/nodes/SoIndexedShape.h>
30
32
43typedef void SoSplitGeometryActionCB(const SoSplitGeometryAction* action, SoNode* objectToSplit, const int objectId,
44 int divAlongX,int divAlongY,int divAlongZ, void* userData);
45
46
83{
84 SO_ACTION_HEADER(SoSplitGeometryAction);
85
86 public :
87
96 SoSplitGeometryAction(int divAlongX,int divAlongY);
97
107 SoSplitGeometryAction(int divAlongX,int divAlongY, int divAlongZ);
108
117 void setNumDivisions(int numX, int numY);
118
127 void setNumDivisions(int numX, int numY, int numZ);
128
132 void getNumDivisions(int &numX, int &numY);
133
137 void getNumDivisions(int &numX, int &numY, int &numZ);
138
139
140 //destructor
141#ifndef HIDDEN_FROM_DOC
142 virtual ~SoSplitGeometryAction();
143#endif // HIDDEN_FROM_DOC
144
151
156
157
162 int getNumObjFound(void);
163
177
182
192
203
214
219
232
243
248
249 virtual void apply(SoNode *node);
250 virtual void apply(SoPath *path) { SoAction::apply(path); }; // no warning
251 virtual void apply(const SoPathList &path_list,
252 SbBool obeys_rules = FALSE) {
253 SoAction::apply(path_list, obeys_rules); }; // no warning
254
255 private:
256 static void initClass();
257 static void exitClass();
258
259 private:
260 virtual void beginTraversal(SoNode *node);
261 void increaseCurrentNumOfDiv(void);
262 void resetCurrentNumOfDiv(void);
263 int getCurrentNumOfDiv(void);
264 SbBool isDivisionValueGood(SoIndexedShape*,float,int,float,int&);
265 static void sortAxesAndDivValues(SoSplitGeometryAction*, int &, int&, int&, int&, int&, int&);
266 void commonConstructor(void);
267 int getNumberOfDivisions(void);
268
269
270 private:
271 //private constructor to not use it!
273
274 static void splitStrip(SoAction*, SoNode*);
275 static void splitFace(SoAction*, SoNode*);
276 static void callDoAction(SoAction*, SoNode*);
277 static void nullAction(SoAction*, SoNode*);
278 static void beginSwitchTraversal(SoAction*, SoNode*);
279
280 void splitStrip1Dimension(SoNode* node,int div, int axe,float &lastRed,float &lastGreen, float &lastBlue);
281 void splitFace1Dimension(SoNode* node,int div, int axe,float &lastRed,float &lastGreen, float &lastBlue);
282
283 void replaceNode(SoNode* substitute);
284
285 SbBool areEqual(float, float);
286
287 //number of subdivision
288 int numDivX;
289 int numDivY;
290 int numDivZ;
291
292 //this node contains the result of the action.
293 SoNode* result;
294
295 //This boolean tells us if the user wants to add some materials for the different parts.
296 SbBool enableMaterial;
297
298 //current number of subdivision in the set the action is splitting.
299 int currentNumOfDiv;
300
301 //number of objects found during the traversal of the action.
302 int numObjFound;
303
304 //the user wants to keep the initial geometry or not.
305 SbBool keepMyGeometry;
306
307 //boolean for veretxOrdering
308 SbBool keepVertexOrdering;
309
310 //pre callback for user
311 static SoSplitGeometryActionCB *userCB;
312 static void *userData;
313
314 //boolean for a smart division
315 SbBool smartDivision;
316
317 //for the switch node
318 int whoHasToBeTraversed;
319
320 //split in 3d or not depending on the constructor used.
321 SbBool splitIn3D;
322
323 //to compare 2 floating values.
324 float epsilon;
325
326 //turn error on/off :
327 SbBool errorOn;
328};
329
330#endif
331
332
Abstract base class for all actions.
Definition SoAction.h:132
virtual void apply(SoNode *node)
Initiates an action on the graph defined by a node.
Abstract base class for all indexed vertex-based shapes.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Maintains a list of pointers to paths.
Definition SoPathList.h:81
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Split large geom...
void setMaintainVertexOrdering(SbBool enable)
If the initial geometry is composed of SoIndexedTriangleStripSet and uses an SoShapeHints with a know...
int getNumObjFound(void)
Returns how many objects the action has split.
void setMaximumDivisionWarning(SbBool enable)
There is a maximum number of division to divide an object because this object is composed by some pri...
void setNumDivisions(int numX, int numY)
Specifies the number of divisions for splitting an object in 2D.
void getNumDivisions(int &numX, int &numY)
Returns the current division values to split an object in 2D.
SbBool isSmartSplitting(void)
Returns TRUE if smart splitting is enabled.
int isTraverseAllSoSwitchChildren(void)
Returns TRUE if traverse all SoSwitch children is enabled.
SbBool isMaintainVertexOrdering(void)
Returns TRUE if the option to maintain initial vertex ordering is on.
SoSplitGeometryAction(int divAlongX, int divAlongY)
SbBool isDistinguishSplitParts(void)
Returns TRUE if distinguish split parts is enabled.
void SoSplitGeometryActionCB(const SoSplitGeometryAction *action, SoNode *objectToSplit, const int objectId, int divAlongX, int divAlongY, int divAlongZ, void *userData)
User pre-split callback.
SbBool isKeepOriginalGeometry(void)
Returns TRUE if keep original geometry is enabled.
void setKeepOriginalGeometry(SbBool enable)
By default, the action modifies the scene graph by replacing the original node it has split with a ne...
static void setSplitGeometryActionPreCB(SoSplitGeometryActionCB *, void *)
These add a callback function to call when a node of the given type is encountered during traversal.
void setDistinguishSplitParts(SbBool enable)
Calling this method before applying the action allows you to see how the action has split the objects...
void setTraverseAllSoSwitchChildren(SbBool enable)
By default the action will only traverse the active child of SoSwitch nodes.
virtual void apply(SoNode *node)
Initiates an action on the graph defined by a node.
virtual void apply(const SoPathList &path_list, SbBool obeys_rules=FALSE)
Initiates an action on the graph defined by a list of paths.
void setSmartSplitting(SbBool enable)
If this option is set before the action is applied, objects will be split by dividing the greatest bo...
virtual void apply(SoPath *path)
Initiates an action on the graph defined by a path.
SoSplitGeometryAction(int divAlongX, int divAlongY, int divAlongZ)
void setNumDivisions(int numX, int numY, int numZ)
Specifies the number of divisions for splitting an object in 3D.
void getNumDivisions(int &numX, int &numY, int &numZ)
Returns the current division values to split an object in 3D.
int SbBool
Boolean type.
Definition SbBase.h:87