00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined _SB_EXTRUSION_GENERATOR_H_
00025 #define _SB_EXTRUSION_GENERATOR_H_
00026
00027 #include <Inventor/SbBox.h>
00028 #include <Inventor/SbMatrix.h>
00029 #include <Inventor/nodes/SoCoordinate3.h>
00030
00031 class SoShape;
00032 class SoCallbackAction;
00033 class SoPrimitiveVertex;
00034
00035
00056 class SbExtrusionGenerator
00057 {
00058
00059 public:
00060
00075 static SoShape* createFrom3DPoints ( const std::vector<SbVec3f>& pointsInWorld,
00076 SoPath* nodePath,
00077 const SbViewVolume& volume,
00078 const SbBox3f& bboxInLocal = SbBox3f() );
00079
00094 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
00095 SoPath* nodePath,
00096 const SbViewVolume& volume,
00097 const SbBox3f& bboxInLocal = SbBox3f() );
00098
00111 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
00112 const SbMatrix& localToCam,
00113 const SbBox3f& bboxInLocal = SbBox3f() );
00114
00128 static SoShape* createFrom2DPoints ( const std::vector<SbVec2f>& pointsInCam,
00129 const SbMatrix& camToLocal,
00130 float zMin = -1.0f,
00131 float zMax = 1.0f);
00132
00133 private:
00134
00136 SbExtrusionGenerator();
00137
00139 virtual ~SbExtrusionGenerator();
00140
00149 static void prepareLine( std::vector<SbVec2f>& polyline, std::vector<bool>& isCCW );
00150
00152 static void removeContiguousDuplicated( std::vector<SbVec2f>& polyline );
00153
00159 static void insertIntersectingPoints( std::vector<SbVec2f>& polyline );
00160
00169 static void findSelfIntersection( const std::vector<SbVec2f>& polyline, std::vector<bool>& intersect );
00170
00176 static bool getIntersection( const SbVec2f& A, const SbVec2f& B, const SbVec2f& A1, const SbVec2f& B1, SbVec2f& intersection );
00177
00184 static bool isStartCCW( const std::vector<SbVec2f>& polyline );
00185
00186
00198 static void distanceFromCam( const SbBox3f& bboxInSomeSpace,
00199 const SbMatrix& someSpaceToCam,
00200 float& zMin, float& zMax );
00201
00206 static void spaceChangeVector( const std::vector<SbVec3f>& lineInSpace1,
00207 const SbMatrix& space1ToSpace2,
00208 std::vector<SbVec3f>& lineInSpace2);
00209
00219 static SoShape* generateCylinder( const std::vector<SbVec3f>& nearLine,
00220 const std::vector<SbVec3f>& farLine,
00221 const std::vector<bool>& isCCW);
00222
00234 static SoShape* generateCone( const SbVec3f& origin,
00235 const std::vector<SbVec3f>& baseLine,
00236 const std::vector<bool>& isCCW);
00237
00242 static SoShape* generateShape( const std::vector<SbVec3f>& triangles);
00243
00250 static void tesselate( const std::vector<SbVec3f>& polygon,
00251 std::vector<SbVec3f>& triangles );
00252
00257 static void makeTrianglesCCW( std::vector<SbVec3f>& triangles, const SbVec3f& viewVector );
00258
00264 static void pushTriangleCallback( void* userData, SoCallbackAction*,
00265 const SoPrimitiveVertex* v1,
00266 const SoPrimitiveVertex* v2,
00267 const SoPrimitiveVertex* v3);
00268
00270 class TriangleCBData
00271 {
00272 public:
00273 TriangleCBData( std::vector<SbVec3f>& triangles )
00274 : m_epsilon(0.0f)
00275 , m_stopOnDegenerated(true)
00276 , m_containsDegenerated(false)
00277 , m_triangles(triangles)
00278 {}
00280 float m_epsilon;
00282 bool m_stopOnDegenerated;
00284 bool m_containsDegenerated;
00286 std::vector<SbVec3f>& m_triangles;
00287 private:
00288
00289 TriangleCBData& operator =(const TriangleCBData&){return *this;}
00290 };
00291
00292 };
00293
00294
00295 #endif // _SB_EXTRUSION_GENERATOR_H_
00296
00297
00298