Coin Logo http://www.sim.no
http://www.coin3d.org

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-2007 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 http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
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 typedef void SbTesselatorCB(void * v0, void * v1, void * v2, void * data);
00037 
00038 class COIN_DLL_API SbTesselator {
00039 public:
00040   SbTesselator(SbTesselatorCB * func = NULL, void * data = NULL);
00041   ~SbTesselator(void);
00042 
00043   void beginPolygon(SbBool keepVertices = FALSE,
00044                     const SbVec3f & normal = SbVec3f(0.0f, 0.0f, 0.0f));
00045   void addVertex(const SbVec3f &v, void * data);
00046   void endPolygon(void);
00047   void setCallback(SbTesselatorCB * func, 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   static int heap_compare(void * v0, void * v1);
00083 };
00084 
00085 #endif // !COIN_SBTESSELATOR_H

Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.

Generated on Mon Feb 23 16:33:09 2009 for Coin by Doxygen. 1.5.8