Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoGlobalSimplifyAction.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-2019 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Pascal DOUX (Jan 1998)
22**=======================================================================*/
23
24
25#ifndef _SO_GLOBAL_SIMPLIFY_ACTION_
26#define _SO_GLOBAL_SIMPLIFY_ACTION_
27
28
29//------------------------------------------------------------------------------
30// Includes
31
32#include <Inventor/actions/SoAction.h>
33#include <Inventor/actions/SoSubAction.h>
34#include <Inventor/actions/SoCallbackAction.h>
35#include <Inventor/actions/SoSimplifyAction.h>
36#include <Inventor/nodes/SoMaterial.h>
37#include <Inventor/nodes/SoBaseColor.h>
38#include <Inventor/fields/SoMFFloat.h>
39
40#include <Inventor/SoType.h>
41
42class SoSimplifier;
43
95{
96 SO_ACTION_HEADER(SoGlobalSimplifyAction);
97
98public:
99
105
110
112 virtual void clearApplyResult();
113
128
129 virtual void apply(SoNode *node);
130 virtual void apply(SoPath *path);
131 virtual void apply(const SoPathList &path_list, SbBool obeys_rules = FALSE);
132
138 void setSimplificationStrategy(Strategy st) { simplificationStrategy = st;}
143 Strategy getSimplificationStrategy() const { return simplificationStrategy ;}
144
148 SoSeparator *getSimplifiedSceneGraph() const { return simplifiedRoot; }
149
155 void generateNormals(SbBool g) { generateNormal = g;}
160 SbBool areNormalGenerated() const { return generateNormal ;}
161
167 void setCatchAllShapesFlag(SbBool c) { catchAllShapes = c;}
171 SbBool areAllShapesCatched() const { return catchAllShapes ;}
172
178 void addShapeHintsNode(SbBool a) { addShapeHints = a;}
182 SbBool isShapeHintAdded() const { return addShapeHints ;}
183
184 private:
185 static void initClass();
186 static void exitClass();
187
188private:
189 virtual void beginTraversal(SoNode *) { beginTraversal();}
190 virtual void endTraversal (SoNode *) { endTraversal() ;}
191
192private:
193
194 virtual void prepareAction (SoCallbackAction &action);
195
196 virtual void beginTraversal();
197 virtual void endTraversal ();
198
199 SbBool collectTriangles;
200
201 // how to handle decimation
202 Strategy simplificationStrategy;
203
204 // new scene graph
205 SoSeparator *simplifiedRoot;
206
207 // generate per-vertex normals
208 SbBool generateNormal;
209
210 // catch all shapes flag: TRUE by default.
211 // if FALSE, only complex shapes are catched, others are ignored
212 SbBool catchAllShapes;
213
214 // if TRUE, adds a ShapeHint node with two sided lighting on.
215 // when generateNormals is FALSE, the shape hints crease angle is
216 // set to 0.55 thus objects will appear smooth even witouh normals.
217 // This should be used carefully since it may slow down drawing but
218 // it can improve rendering aspect when normals are not computed
219 // default FALSE
220 SbBool addShapeHints;
221
222 // last material added into simplified scenegraph
223 SoMaterial *lastMaterial;
224
226 catchShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
227 { return ((SoGlobalSimplifyAction*) object)->catchShape (action, node); }
228
230 catchShape ( SoCallbackAction* action, const SoNode* node) ;
231
233 catchEndShapeCB ( void* object, SoCallbackAction* action, const SoNode* node)
234 { return ((SoGlobalSimplifyAction*) object)->catchEndShape (action, node); }
235
237 catchEndShape ( SoCallbackAction* action, const SoNode* node) ;
238
240 catchShapeAttrCB( void* object, SoCallbackAction* action, const SoNode* node)
241 { return ((SoGlobalSimplifyAction*) object)->catchShapeAttr (action, node); }
242
244 catchShapeAttr ( SoCallbackAction* action, const SoNode* node) ;
245
247 catchGroupNodesCB ( void* object, SoCallbackAction* action, const SoNode* node)
248 { return ((SoGlobalSimplifyAction*) object)->catchGroupNodes (action, node); }
249
251 catchGroupNodes ( SoCallbackAction* action, const SoNode* node) ;
252
253 void addTriangle (SoCallbackAction *action,
254 const SoPrimitiveVertex *vertex1,
255 const SoPrimitiveVertex *vertex2,
256 const SoPrimitiveVertex *vertex3);
257
258 static void addTriangleCB (void *userData,
259 SoCallbackAction *action,
260 const SoPrimitiveVertex *vertex1,
261 const SoPrimitiveVertex *vertex2,
262 const SoPrimitiveVertex *vertex3)
263 { ((SoGlobalSimplifyAction*) userData)->addTriangle (action, vertex1, vertex2, vertex3); }
264
265
266};
267
268
269#endif // _SO_GLOBAL_SIMPLIFY_ACTION_
270
271
272
273
274
275
276
277
278
Performs a generic traversal of a scene graph or path.
Response
Possible responses from a pre or post callback.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Traverses the sc...
void generateNormals(SbBool g)
Sets the normal generation flag.
SbBool isShapeHintAdded() const
Gets whether a shape hints node will be added.
virtual void clearApplyResult()
When applied, an action may reference nodes or create objects (e.g.
void setSimplificationStrategy(Strategy st)
Sets the strategy used to determine how to group triangles into the simplified shapes.
SoGlobalSimplifyAction(SoSimplifier *_simplifier)
Constructor.
void setCatchAllShapesFlag(SbBool c)
Sets the flag that specifies whether simple shapes are simplified.
@ SIMPLIFY_BY_SUBGROUP
Triangles are stored in multiple lists based on material, texture and Separator.
@ SIMPLIFY_GLOBALLY
All triangles are stored in a single list and decimated globally.
SbBool areAllShapesCatched() const
Gets the flag that specifies whether simple shapes are simplified.
SoSeparator * getSimplifiedSceneGraph() const
This returns the new scene graph which contains the simplified result.
Strategy getSimplificationStrategy() const
Gets the strategy used to determine how to group triangles into the simplified shapes.
virtual void apply(SoNode *node)
Initiates an action on the graph defined by a node.
SbBool areNormalGenerated() const
Gets the normal generation flag.
void addShapeHintsNode(SbBool a)
Sets whether a shape hints node is added.
~SoGlobalSimplifyAction()
Destructor.
virtual void apply(const SoPathList &path_list, SbBool obeys_rules=FALSE)
Initiates an action on the graph defined by a list of paths.
virtual void apply(SoPath *path)
Initiates an action on the graph defined by a path.
Surface material definition node.
Definition SoMaterial.h:173
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
Represents a vertex of a generated primitive.
Group node that saves and restores traversal state.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
int SbBool
Boolean type.
Definition SbBase.h:87