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

SbClip Class Reference
[Base classes]

The SbClip class is a generic polygon clipper class.

It is used by first adding all vertices in the polygon, and then clipping against any number of planes. If you need to supply additional information per vertex (e.g. texture coordinates), you should supply a callback in the constructor, and a pointer to your vertex structure in addVertex(). For every new vertex created, the callback is called with the line being clipped, including the pointers to your vertex structures and the position of the new (clipped against some plane) vertex. You should then create a new vertex structure, calculate your data (e.g. a new texture coordinate) and return a pointer to this structure. More...

#include <include/Inventor/base/SbClip.h>

List of all members.

Public Member Functions

 SbClip (SbClipCallback *callback=NULL, void *userdata=NULL)
void addVertex (const SbVec3f &v, void *vdata=NULL)
void reset (void)
void clip (const SbPlane &plane)
int getNumVertices (void) const
void getVertex (const int idx, SbVec3f &v, void **vdata=NULL) const
void * getVertexData (const int idx) const


Detailed Description

The SbClip class is a generic polygon clipper class.

It is used by first adding all vertices in the polygon, and then clipping against any number of planes. If you need to supply additional information per vertex (e.g. texture coordinates), you should supply a callback in the constructor, and a pointer to your vertex structure in addVertex(). For every new vertex created, the callback is called with the line being clipped, including the pointers to your vertex structures and the position of the new (clipped against some plane) vertex. You should then create a new vertex structure, calculate your data (e.g. a new texture coordinate) and return a pointer to this structure.

Be aware that this class is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.

Since:
Coin 2.0

Constructor & Destructor Documentation

SbClip::SbClip ( SbClipCallback *  callback = NULL,
void *  userdata = NULL 
)

A constructor. Supply a callback if you need to handle additional data per vertex.


Member Function Documentation

void SbClip::addVertex ( const SbVec3f v,
void *  vdata = NULL 
)

Adds a polygon vertex. vdata could be a pointer to your vertex structure.

References SbList< Type >::append().

void SbClip::reset ( void   ) 

Resets the clipper. This should be called before adding any vertices when reusing an SbClip instance.

References SbList< Type >::truncate().

void SbClip::clip ( const SbPlane plane  ) 

Clip polygon against plane. This might change the number of vertices in the polygon. For each time a new vertex is created, the callback supplied in the constructor (if != NULL) is called with the line being clipped and the new vertex calculated. The callback should return a new void pointer to be stored by the clipper.

References SbList< Type >::append(), SbVec3f::dot(), SbPlane::getDistance(), SbList< Type >::getLength(), SbPlane::getNormal(), SbVec3f::normalize(), and SbList< Type >::truncate().

int SbClip::getNumVertices ( void   )  const

Returns the number of vertices in the polygon.

See also:
SbClip::getVertex()

References SbList< Type >::getLength().

void SbClip::getVertex ( const int  idx,
SbVec3f v,
void **  vdata = NULL 
) const

Returns the vertex at index idx.

See also:
SbClip::getNumVertices()

void * SbClip::getVertexData ( const int  idx  )  const

Return the vertex data at index idx.


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

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

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