Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SbExtrusionGenerator.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 : Thibaut Andrieu (Jan 2011)
22**=======================================================================*/
23
24#if !defined _SB_EXTRUSION_GENERATOR_H_
25#define _SB_EXTRUSION_GENERATOR_H_
26
27#include <Inventor/SbBox.h>
28#include <Inventor/SbMatrix.h>
29#include <Inventor/nodes/SoCoordinate3.h>
30
31class SoShape;
34
35//@TOBEWRAPPED
59{
60
61public:
62
77 static SoShape* createFrom3DPoints ( const std::vector<SbVec3f>& pointsInWorld,
78 SoPath* nodePath,
79 const SbViewVolume& volume,
80 const SbBox3f& bboxInLocal = SbBox3f() );
81
96 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
97 SoPath* nodePath,
98 const SbViewVolume& volume,
99 const SbBox3f& bboxInLocal = SbBox3f() );
100
113 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
114 const SbMatrix& localToCam,
115 const SbBox3f& bboxInLocal = SbBox3f() );
116
130 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
131 const SbMatrix& camToLocal,
132 float zMin = -1.0f,
133 float zMax = 1.0f);
134
135private:
136
139
141 virtual ~SbExtrusionGenerator();
142
151 static void prepareLine( std::vector<SbVec2f>& polyline, std::vector<bool>& isCCW );
152
154 static void removeContiguousDuplicated( std::vector<SbVec2f>& polyline );
155
161 static void insertIntersectingPoints( std::vector<SbVec2f>& polyline );
162
171 static void findSelfIntersection( const std::vector<SbVec2f>& polyline, std::vector<bool>& intersect );
172
178 static bool getIntersection( const SbVec2f& A, const SbVec2f& B, const SbVec2f& A1, const SbVec2f& B1, SbVec2f& intersection );
179
186 static bool isStartCCW( const std::vector<SbVec2f>& polyline );
187
188
200 static void distanceFromCam( const SbBox3f& bboxInSomeSpace,
201 const SbMatrix& someSpaceToCam,
202 float& zMin, float& zMax );
203
208 static void spaceChangeVector( const std::vector<SbVec3f>& lineInSpace1,
209 const SbMatrix& space1ToSpace2,
210 std::vector<SbVec3f>& lineInSpace2);
211
221 static SoShape* generateCylinder( const std::vector<SbVec3f>& nearLine,
222 const std::vector<SbVec3f>& farLine,
223 const std::vector<bool>& isCCW);
224
236 static SoShape* generateCone( const SbVec3f& origin,
237 const std::vector<SbVec3f>& baseLine,
238 const std::vector<bool>& isCCW);
239
244 static SoShape* generateShape( const std::vector<SbVec3f>& triangles);
245
252 static void tesselate( const std::vector<SbVec3f>& polygon,
253 std::vector<SbVec3f>& triangles );
254
259 static void makeTrianglesCCW( std::vector<SbVec3f>& triangles, const SbVec3f& viewVector );
260
266 static void pushTriangleCallback( void* userData, SoCallbackAction*,
267 const SoPrimitiveVertex* v1,
268 const SoPrimitiveVertex* v2,
269 const SoPrimitiveVertex* v3);
270
272 class TriangleCBData
273 {
274 public:
275 TriangleCBData( std::vector<SbVec3f>& triangles )
276 : m_epsilon(0.0f)
277 , m_stopOnDegenerated(true)
278 , m_containsDegenerated(false)
279 , m_triangles(triangles)
280 {}
282 float m_epsilon;
284 bool m_stopOnDegenerated;
286 bool m_containsDegenerated;
288 std::vector<SbVec3f>& m_triangles;
289 private:
290 // forbid copy and remove C4512 error
291 TriangleCBData& operator =(const TriangleCBData&){return *this;}
292 };
293
294};
295
296
297#endif // _SB_EXTRUSION_GENERATOR_H_
298
299
3D box class.
Definition SbBox.h:649
Factory that generates an extruded mesh from a polyline.
static SoShape * createFrom2DPoints(const std::vector< SbVec2f > &pointsInCam, const SbMatrix &camToLocal, float zMin=-1.0f, float zMax=1.0f)
Create an extruded shape from points in camera space.
static SoShape * createFrom3DPoints(const std::vector< SbVec3f > &pointsInWorld, SoPath *nodePath, const SbViewVolume &volume, const SbBox3f &bboxInLocal=SbBox3f())
Create an extruded shape from points in world space.
static SoShape * createFrom2DPoints(const std::vector< SbVec2f > &pointsInCam, SoPath *nodePath, const SbViewVolume &volume, const SbBox3f &bboxInLocal=SbBox3f())
Create an extruded shape from points in camera space.
static SoShape * createFrom2DPoints(const std::vector< SbVec2f > &pointsInCam, const SbMatrix &localToCam, const SbBox3f &bboxInLocal=SbBox3f())
Create an extruded shape from points in camera space.
4x4 matrix class.
Definition SbMatrix.h:309
2D vector class.
Definition SbVec.h:76
3D vector class.
Definition SbVec.h:932
3D viewing volume class.
Performs a generic traversal of a scene graph or path.
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Represents a vertex of a generated primitive.
Abstract base class for all shape nodes.
Definition SoShape.h:116