00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SBTESSELATOR_H
00021 #define COIN_SBTESSELATOR_H
00022
00023 #include <Inventor/SbBasic.h>
00024 #include <Inventor/lists/SbList.h>
00025 #include <Inventor/SbVec3f.h>
00026 #include <stddef.h>
00027
00028 struct SbTVertex;
00029 class SbHeap;
00030 class SbVec3f;
00031
00032 class COIN_DLL_API SbTesselator {
00033 public:
00034 SbTesselator(void (*callback)(void * v0, void * v1, void * v2,
00035 void * data) = NULL, void * userdata = NULL);
00036 ~SbTesselator(void);
00037
00038 void beginPolygon(SbBool keepVertices = FALSE,
00039 const SbVec3f & normal = SbVec3f(0.0f, 0.0f, 0.0f));
00040 void addVertex(const SbVec3f &v, void *data);
00041 void endPolygon(void);
00042 void setCallback(void (*callback)(void *v0, void *v1, void *v2, void *data),
00043 void *data);
00044
00045 private:
00046 struct SbTVertex *newVertex(void);
00047 void cleanUp(void);
00048
00049 int currVertex;
00050 SbList <struct SbTVertex*> vertexStorage;
00051 SbHeap *heap;
00052
00053 SbTVertex *headV,*tailV;
00054 int numVerts;
00055 SbVec3f polyNormal;
00056 int X,Y;
00057 int polyDir;
00058 void (*callback)(void *v0,void *v1,void *v2,void *data);
00059 void *callbackData;
00060 SbBool hasNormal;
00061 SbBool keepVertices;
00062
00063 void emitTriangle(SbTVertex *v);
00064 void cutTriangle(SbTVertex *t);
00065 void calcPolygonNormal(void);
00066
00067 SbBool circleCenter(const SbVec3f &a, const SbVec3f &b,
00068 const SbVec3f &c, float &cx, float &cy);
00069 float circleSize(const SbVec3f &a, const SbVec3f &b, const SbVec3f &c);
00070 float circleSize(SbTVertex *v);
00071 float dot2D(const SbVec3f &v1, const SbVec3f &v2);
00072 SbBool clippable(SbTVertex *v);
00073 SbBool isTriangle(SbTVertex *v);
00074 SbBool pointInTriangle(SbTVertex *p,SbTVertex *t);
00075 float area(SbTVertex *t);
00076
00077 static float heap_evaluate(void *v);
00078 };
00079
00080 #endif // COIN_SBTESSELATOR_H