openscenegraph
osgUtil::Tessellator Class Reference

#include <Tessellator>

Inheritance diagram for osgUtil::Tessellator:
osg::Referenced

Classes

struct  Prim
struct  Vec3d
struct  NewVertex

Public Types

enum  WindingType {
  TESS_WINDING_ODD = GLU_TESS_WINDING_ODD , TESS_WINDING_NONZERO = GLU_TESS_WINDING_NONZERO , TESS_WINDING_POSITIVE = GLU_TESS_WINDING_POSITIVE , TESS_WINDING_NEGATIVE = GLU_TESS_WINDING_NEGATIVE ,
  TESS_WINDING_ABS_GEQ_TWO = GLU_TESS_WINDING_ABS_GEQ_TWO
}
enum  TessellationType { TESS_TYPE_GEOMETRY , TESS_TYPE_DRAWABLE , TESS_TYPE_POLYGONS }
typedef std::vector< osg::ref_ptr< Prim > > PrimList

Public Member Functions

 Tessellator ()
 ~Tessellator ()
void setBoundaryOnly (const bool tt)
bool getBoundaryOnly ()
void setWindingType (const WindingType wt)
WindingType getWindingType ()
void setTessellationType (const TessellationType tt)
TessellationType getTessellationType ()
void retessellatePolygons (osg::Geometry &cxgeom)
void setTessellationNormal (const osg::Vec3 norm)
osg::Geometry::PrimitiveSetList getContours ()
virtual void beginTessellation ()
void beginContour ()
void addVertex (osg::Vec3 *vertex)
void endContour ()
void endTessellation ()
PrimListgetPrimList ()
void reset ()
Public Member Functions inherited from osg::Referenced
 Referenced ()
 Referenced (bool threadSafeRefUnref)
 Referenced (const Referenced &)
Referencedoperator= (const Referenced &)
virtual void setThreadSafeRefUnref (bool)
bool getThreadSafeRefUnref () const
OpenThreads::MutexgetRefMutex () const
int ref () const
int unref () const
int unref_nodelete () const
int referenceCount () const
ObserverSetgetObserverSet () const
ObserverSetgetOrCreateObserverSet () const
void addObserver (Observer *observer) const
void removeObserver (Observer *observer) const

Protected Types

typedef std::map< osg::Vec3 *, unsigned int > VertexPtrToIndexMap
typedef std::vector< NewVertexNewVertexList
typedef std::vector< Vec3d * > Vec3dList

Protected Member Functions

void reduceArray (osg::Array *cold, const unsigned int nnu)
void collectTessellation (osg::Geometry &cxgeom, unsigned int originalIndex)
void addContour (GLenum mode, unsigned int first, unsigned int last, osg::Vec3Array *vertices)
void addContour (osg::PrimitiveSet *primitive, osg::Vec3Array *vertices)
void handleNewVertices (osg::Geometry &geom, VertexPtrToIndexMap &vertexPtrToIndexMap)
void begin (GLenum mode)
void vertex (osg::Vec3 *vertex)
void combine (osg::Vec3 *vertex, void *vertex_data[4], GLfloat weight[4])
void end ()
void error (GLenum errorCode)
Protected Member Functions inherited from osg::Referenced
virtual ~Referenced ()
void signalObserversAndDelete (bool signalDelete, bool doDelete) const
void deleteUsingDeleteHandler () const

Static Protected Member Functions

static void CALLBACK beginCallback (GLenum which, void *userData)
static void CALLBACK vertexCallback (GLvoid *data, void *userData)
static void CALLBACK combineCallback (GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], void **outData, void *useData)
static void CALLBACK endCallback (void *userData)
static void CALLBACK errorCallback (GLenum errorCode, void *userData)

Protected Attributes

osg::GLUtesselator * _tobj
PrimList _primList
Vec3dList _coordData
NewVertexList _newVertexList
GLenum _errorCode
WindingType _wtype
TessellationType _ttype
bool _boundaryOnly
unsigned int _numberVerts
osg::Geometry::PrimitiveSetList _Contours
unsigned int _index
osg::Vec3 tessNormal
unsigned int _extraPrimitives
Protected Attributes inherited from osg::Referenced
OpenThreads::AtomicPtr _observerSet
OpenThreads::Atomic _refCount

Additional Inherited Members

Static Public Member Functions inherited from osg::Referenced
static OpenThreads::MutexgetGlobalReferencedMutex ()
static void setDeleteHandler (DeleteHandler *handler)
static DeleteHandlergetDeleteHandler ()

Detailed Description

Originally a simple class for tessellating a single polygon boundary. Using old style glu tessellation functions for portability. Upgraded Jan 2004 to use the modern glu tessellation functions.

Member Typedef Documentation

◆ NewVertexList

typedef std::vector<NewVertex> osgUtil::Tessellator::NewVertexList
protected

◆ PrimList

◆ Vec3dList

typedef std::vector<Vec3d*> osgUtil::Tessellator::Vec3dList
protected

◆ VertexPtrToIndexMap

typedef std::map<osg::Vec3*,unsigned int> osgUtil::Tessellator::VertexPtrToIndexMap
protected

Member Enumeration Documentation

◆ TessellationType

we interpret all contours in the geometry as a single set to be tessellated or each separate drawable's contours needs to be tessellated.

Enumerator
TESS_TYPE_GEOMETRY 
TESS_TYPE_DRAWABLE 
TESS_TYPE_POLYGONS 

◆ WindingType

The winding rule, see red book ch 11.

Enumerator
TESS_WINDING_ODD 
TESS_WINDING_NONZERO 
TESS_WINDING_POSITIVE 
TESS_WINDING_NEGATIVE 
TESS_WINDING_ABS_GEQ_TWO 

Constructor & Destructor Documentation

◆ Tessellator()

osgUtil::Tessellator::Tessellator ( )

◆ ~Tessellator()

osgUtil::Tessellator::~Tessellator ( )

Member Function Documentation

◆ addContour() [1/2]

void osgUtil::Tessellator::addContour ( GLenum mode,
unsigned int first,
unsigned int last,
osg::Vec3Array * vertices )
protected

◆ addContour() [2/2]

void osgUtil::Tessellator::addContour ( osg::PrimitiveSet * primitive,
osg::Vec3Array * vertices )
protected

◆ addVertex()

void osgUtil::Tessellator::addVertex ( osg::Vec3 * vertex)

Add a vertex to the current contour, see gluTessVertex for details. Note the vertex pointer is returned at the end of tessellation and must not be left dangling or be overwritten until all results are collected.

References vertex().

◆ begin()

void osgUtil::Tessellator::begin ( GLenum mode)
protected

◆ beginCallback()

void CALLBACK osgUtil::Tessellator::beginCallback ( GLenum which,
void * userData )
staticprotected

References CALLBACK.

◆ beginContour()

void osgUtil::Tessellator::beginContour ( )

◆ beginTessellation()

virtual void osgUtil::Tessellator::beginTessellation ( )
virtual

◆ collectTessellation()

void osgUtil::Tessellator::collectTessellation ( osg::Geometry & cxgeom,
unsigned int originalIndex )
protected

◆ combine()

void osgUtil::Tessellator::combine ( osg::Vec3 * vertex,
void * vertex_data[4],
GLfloat weight[4] )
protected

References vertex().

◆ combineCallback()

void CALLBACK osgUtil::Tessellator::combineCallback ( GLdouble coords[3],
void * vertex_data[4],
GLfloat weight[4],
void ** outData,
void * useData )
staticprotected

References CALLBACK.

◆ end()

void osgUtil::Tessellator::end ( )
protected

◆ endCallback()

void CALLBACK osgUtil::Tessellator::endCallback ( void * userData)
staticprotected

References CALLBACK.

◆ endContour()

void osgUtil::Tessellator::endContour ( )

◆ endTessellation()

void osgUtil::Tessellator::endTessellation ( )

◆ error()

void osgUtil::Tessellator::error ( GLenum errorCode)
protected

◆ errorCallback()

void CALLBACK osgUtil::Tessellator::errorCallback ( GLenum errorCode,
void * userData )
staticprotected

References CALLBACK.

◆ getBoundaryOnly()

bool osgUtil::Tessellator::getBoundaryOnly ( )
inline

References _boundaryOnly.

◆ getContours()

osg::Geometry::PrimitiveSetList osgUtil::Tessellator::getContours ( )
inline

References _Contours.

◆ getPrimList()

PrimList & osgUtil::Tessellator::getPrimList ( )
inline

References _primList.

◆ getTessellationType()

TessellationType osgUtil::Tessellator::getTessellationType ( )
inline

References _ttype.

◆ getWindingType()

WindingType osgUtil::Tessellator::getWindingType ( )
inline

References _wtype.

◆ handleNewVertices()

void osgUtil::Tessellator::handleNewVertices ( osg::Geometry & geom,
VertexPtrToIndexMap & vertexPtrToIndexMap )
protected

◆ reduceArray()

void osgUtil::Tessellator::reduceArray ( osg::Array * cold,
const unsigned int nnu )
protected

remove unused parts of the array, eg for when retessellating tessellation can introduce extra vertices for concave or crossing boundaries, these will leak memory if not removed when retessellating.

◆ reset()

void osgUtil::Tessellator::reset ( )

◆ retessellatePolygons()

void osgUtil::Tessellator::retessellatePolygons ( osg::Geometry & cxgeom)

Change the contours lists of the geometry into tessellated primitives (the list of primitives in the original geometry is stored in the Tessellator for possible re-use. The name remains retessellatePolygons although it now handles trifans, strips, quads etc. as well as Polygons so as to not break old codes relying on this function name.

◆ setBoundaryOnly()

void osgUtil::Tessellator::setBoundaryOnly ( const bool tt)
inline

Set and get tessellation request boundary only on/off

References _boundaryOnly.

◆ setTessellationNormal()

void osgUtil::Tessellator::setTessellationNormal ( const osg::Vec3 norm)
inline

Define the normal to the tessellated polygon - this provides a hint how to tessellate the contours; see gluTessNormal in red book or man pages. GWM July 2005. Can improve teselation "For example, if you know that all polygons lie in the x-y plane, call gluTessNormal(tess, 0.0, 0.0, 1.0) before rendering any polygons."

References tessNormal.

◆ setTessellationType()

void osgUtil::Tessellator::setTessellationType ( const TessellationType tt)
inline

Set and get tessellation type

References _ttype.

◆ setWindingType()

void osgUtil::Tessellator::setWindingType ( const WindingType wt)
inline

Set and get tessellation windong rule

References _wtype.

◆ vertex()

void osgUtil::Tessellator::vertex ( osg::Vec3 * vertex)
protected

References vertex().

Referenced by addVertex(), combine(), and vertex().

◆ vertexCallback()

void CALLBACK osgUtil::Tessellator::vertexCallback ( GLvoid * data,
void * userData )
staticprotected

References CALLBACK.

Member Data Documentation

◆ _boundaryOnly

bool osgUtil::Tessellator::_boundaryOnly
protected

Referenced by getBoundaryOnly(), and setBoundaryOnly().

◆ _Contours

osg::Geometry::PrimitiveSetList osgUtil::Tessellator::_Contours
protected

List of primitives that define the contours

Referenced by getContours().

◆ _coordData

Vec3dList osgUtil::Tessellator::_coordData
protected

◆ _errorCode

GLenum osgUtil::Tessellator::_errorCode
protected

◆ _extraPrimitives

unsigned int osgUtil::Tessellator::_extraPrimitives
protected

count of number of extra primitives added

◆ _index

unsigned int osgUtil::Tessellator::_index
protected

count number of primitives in a geometry to get right no. of norms/colurs etc for per_primitive attributes.

◆ _newVertexList

NewVertexList osgUtil::Tessellator::_newVertexList
protected

◆ _numberVerts

unsigned int osgUtil::Tessellator::_numberVerts
protected

number of vertices that are part of the 'original' set of contours

◆ _primList

PrimList osgUtil::Tessellator::_primList
protected

Referenced by getPrimList().

◆ _tobj

osg::GLUtesselator* osgUtil::Tessellator::_tobj
protected

◆ _ttype

TessellationType osgUtil::Tessellator::_ttype
protected

tessellation rule, which parts will become solid

Referenced by getTessellationType(), and setTessellationType().

◆ _wtype

WindingType osgUtil::Tessellator::_wtype
protected

winding rule, which parts will become solid

Referenced by getWindingType(), and setWindingType().

◆ tessNormal

osg::Vec3 osgUtil::Tessellator::tessNormal
protected

the gluTessNormal for tessellation hint

Referenced by setTessellationNormal().


The documentation for this class was generated from the following file: