# SbTesselator.h

    00001 #ifndef COIN_SBTESSELATOR_H
    00002 #define COIN_SBTESSELATOR_H
    00003
    00004 /**************************************************************************\
    00005  *
    00006  *  This file is part of the Coin 3D visualization library.
    00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU General Public License
    00011  *  ("GPL") version 2 as published by the Free Software Foundation.
    00012  *  See the file LICENSE.GPL at the root directory of this source
    00013  *  distribution for additional information about the GNU GPL.
    00014  *
    00015  *  For using Coin with software that can not be combined with the GNU
    00016  *  GPL, and for taking advantage of the additional benefits of our
    00017  *  support services, please contact Systems in Motion about acquiring
    00018  *  a Coin Professional Edition License.
    00019  *
    00020  *  See <URL:http://www.coin3d.org> for  more information.
    00021  *
    00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
    00023  *  <URL:http://www.sim.no>.
    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