Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoCSGShape.h
Go to the documentation of this file.
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-2017 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Thibaut Andrieu (Jan 2011)
22**=======================================================================*/
23
24#if !defined _SO_CSG_SHAPE_H_
25#define _SO_CSG_SHAPE_H_
26
32
33class SoFaceSet;
36class SoCache;
37class CachedElement;
38
40namespace GetCacheDeps {
41class CachedElementsVector;
42}
45//@TOBEWRAPPED
129class SoCSGShape : public SoShape
130{
132
133public:
134
137
156
159
162
167
181
199 void setMaxAttempt( int maxAttempt );
200
206
212
213private:
214 // Implement actions
215
217 virtual void doAction( SoAction *action );
218
220 virtual void callback( SoCallbackAction *action );
221
223 virtual void GLRender( SoGLRenderAction *action );
224
226 virtual void rayPick( SoRayPickAction *action );
227
229 virtual void computeBBox( SoAction *action, SbBox3f &box, SbVec3f &center );
230
232 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d &center);
233
235 virtual void getPrimitiveCount( SoGetPrimitiveCountAction *action );
236
237private:
238
240 static void initClass();
241
243 static void exitClass();
244
246 virtual void notify( SoNotList *list );
247
248private:
250 virtual ~SoCSGShape();
251
253 virtual void generatePrimitives ( SoAction *action );
254
255private:
256
266 void collapse(const std::vector<SoPrimitiveVertex>& points, float eps, std::vector<SbVec3f*>& indexedPoints, std::vector<SbVec3f>& remainingPoints) const;
267
270 void shake(std::vector<SbVec3f>& points, float shift) const;
271
275 SoFaceSet* getShape(SoState* state);
276
282 bool getCacheDependencies(SoAction* action, SoNode* node, GetCacheDeps::CachedElementsVector& elements);
283
285 void updateCache( SoState *state, const GetCacheDeps::CachedElementsVector& dependencies, SoCache*& cache );
286
288 bool isCacheValid( SoState *state, SoCache* cache ) const;
289
294 bool generateTriangles(SoAction* action, SoNode* node, std::vector<SoPrimitiveVertex>& triangles, SoTransformation* transform = NULL );
295
302 void updateResult();
303
305 static void pushTriangleCallback(void* vec,
306 SoCallbackAction* cb,
307 const SoPrimitiveVertex* v1,
308 const SoPrimitiveVertex* v2,
309 const SoPrimitiveVertex* v3);
310
315 static CsgStatus computeCSG(const std::vector<SoPrimitiveVertex>& trianglesLeft,
316 const std::vector<SoPrimitiveVertex>& trianglesRight,
317 const CsgOperationType& operation,
318 std::vector<SoPrimitiveVertex>& trianglesResult);
319
320
323 std::vector<SoPrimitiveVertex> m_trianglesLeft;
324
327 std::vector<SoPrimitiveVertex> m_trianglesRight;
328
331 SoCache* m_leftCache;
332
335 SoCache* m_rightCache;
336
339 SoCache* m_resultCache;
340
347 bool m_expressedInWolrdSpace;
348
354 std::vector<SoPrimitiveVertex> m_triangles;
355
365 SoFaceSet* m_shape;
366
369 CsgStatus m_csgStatus;
370
372 mutable SbThreadMutex m_mutex;
373
375 int m_maxAttempt;
376
378 static CsgOperationType s_rescueOp;
379
380};
381
382#endif // _SO_CSG_SHAPE_H_
383
384
#define SO_NODE_HEADER(className)
Definition SoSubNode.h:151
3D box class.
Definition SbBox.h:649
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
3D vector class.
Definition SbVec.h:932
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box with an a...
Definition SbBox.h:1513
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Shape defined by...
Definition SoCSGShape.h:130
CsgStatus getStatus()
Returns status of csg operation.
SoSFNode rightOperand
Geometry scene graph to be used as right operand for the Boolean operation.
Definition SoCSGShape.h:161
SoCSGShape()
Constructor.
SoSFNode leftOperand
Geometry scene graph to be used as left operand for the Boolean operation.
Definition SoCSGShape.h:158
void setMaxAttempt(int maxAttempt)
If the CSG Operation failed for any reason, it will be retried by applying a small random transformat...
SoSFEnum csgOperation
CSG boolean operation to apply.
Definition SoCSGShape.h:166
static void setRescueOperation(CsgOperationType op)
Set operation to use if the CSG operation fails or CSGLib is not available.
CsgOperationType
CSG operation to be used.
Definition SoCSGShape.h:140
@ RIGHT_ONLY
Keep only rightOperand.
Definition SoCSGShape.h:150
@ LEFT_ONLY
Keep only leftOperand.
Definition SoCSGShape.h:148
@ ADD
leftOperand union rightOperand.
Definition SoCSGShape.h:142
@ NOTHING
Keep nothing (result will be empty).
Definition SoCSGShape.h:152
@ INTERSECTION
LeftOperand intersect rightOperand.
Definition SoCSGShape.h:146
@ ALL
Keep left and right primitives (concatenate all resulting faces).
Definition SoCSGShape.h:154
@ SUB
LeftOperand - rightOperand.
Definition SoCSGShape.h:144
CsgStatus
Status of CSG operation.
Definition SoCSGShape.h:173
@ CSG_NO_ERROR
No error.
Definition SoCSGShape.h:175
@ CSG_LIB_NOT_AVAILABLE
CSGLib is not available.
Definition SoCSGShape.h:177
@ CSG_ERROR
an error occurred
Definition SoCSGShape.h:179
Performs a generic traversal of a scene graph or path.
Polygonal face shape node.
Definition SoFaceSet.h:229
Renders a scene graph using Open Inventor's Render Engine.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
Abstract base class for all database nodes.
Definition SoNode.h:145
Represents a vertex of a generated primitive.
Intersects objects with a ray cast into scene.
Field containing an enumerated value.
Definition SoSFEnum.h:89
Field containing a a node.
Definition SoSFNode.h:97
Abstract base class for all shape nodes.
Definition SoShape.h:115
Traversal state.
Definition SoState.h:74
Abstract base class for all geometric transformation nodes.