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