SbTesselator(3)

πŸ“¦
version 4.0.10 Β· 4 versions
, in fedora 43, fedora 44

πŸ’… SbTesselator β€” the Coin manual page, bestie edition ✨

okay so welcome to SbTesselator(3), a page from the Coin manual set. yes the header says SbTesselator(3) and the collection is Coin, and yes I'm telling you that up front because it's literally the first line of the whole thing. πŸŽ€


🌸 NAME 🌸

SbTesselator β€” the SbTesselator class is used to tessellate polygons into triangles.

like. that's the whole job. polygon in, triangles out. iconic behavior honestly. πŸ¦‹


✨ SYNOPSIS ✨

#include <Inventor/SbTesselator.h>

🫢 Public Member Functions

SbTesselator (SbTesselatorCB *func=NULL, void *data=NULL)
~SbTesselator (void)
void beginPolygon (SbBool keepVertices=FALSE, const SbVec3f
    &normal=SbVec3f(0.0f, 0.0f, 0.0f))
void addVertex (const SbVec3f &v, void *data)
void endPolygon (void)
void setCallback (SbTesselatorCB *func, void *data)

πŸ‘‘ Detailed Description πŸ‘‘

The SbTesselator class is used to tessellate polygons into triangles.

ngl this class is the one Coin reaches for internally when it needs to split polygons into triangles. and the way it does it?? it handles concave polygons, it does Delaunay triangulation, and it avoids generating self-intersecting triangles. no cap, that's a lot of slay for one class. πŸ’œ

here's a simple example which shows how to tessellate a quad polygon with corners in <0, 0, 0>, <1, 0, 0>, <1, 1, 0> and <0, 1, 0>.

// Callback function for the tessellator. Called once for each
// generated triangle with the vertices.
static void
tess_cb(void * v0, void * v1, void * v2, void * cbdata)
{
  SbVec3f * vtx0 = (SbVec3f *)v0;
  SbVec3f * vtx1 = (SbVec3f *)v1;
  SbVec3f * vtx2 = (SbVec3f *)v2;
  (void) fprintf(stdout, "triangle: <%f, %f, %f> <%f, %f, %f> <%f, %f, %f>\n",
    (*vtx0)[0], (*vtx0)[1], (*vtx0)[2],
    (*vtx1)[0], (*vtx1)[1], (*vtx1)[2],
    (*vtx2)[0], (*vtx2)[1], (*vtx2)[2]);

  // Do stuff with triangle here.
}

static SbVec3f vertices[] = {
  SbVec3f(1, 0, 0), SbVec3f(1, 1, 0),
  SbVec3f(0, 1, 0), SbVec3f(0, 0, 0)
};

SbTesselator mytessellator(tess_cb, NULL);
mytessellator.beginPolygon();
for (int i=0; i < 4; i++) {
  mytessellator.addVertex(vertices[i], &vertices[i]);
}
mytessellator.endPolygon();

the call to SbTesselator::endPolygon() is what makes the SbTesselator spring into action, calling the tess_cb() function for each triangle it generates. it's giving main character energy, fr fr. πŸŽ€

and the reason we use 2 arguments to SbTesselator::addVertex() and pass void pointers for the vertices to the callback function?? it's so you can have more complex structures than just the coordinates themselves (like in the example above) β€” think material information, lighting information, or whatever other attributes your vertices have. your vertices can be carrying lore. πŸ™ˆ

heads up bestie: this class is not part of the original Open Inventor API. she's a Coin original. πŸ’…

another option for tessellating polygons is the tessellator of the GLU library. it has some features not part of SbTesselator (like handling hulls), but the GLU library is known to have bugs in various implementations and doesn't do Delaunay triangulation. if you however still prefer to use the GLU tessellator instead of this one, that can be forced by setting an environment variable:

(void) coin_setenv("COIN_PREFER_GLU_TESSELLATOR", "1", 1);

🧚 Constructor & Destructor Documentation 🧚

SbTesselator::SbTesselator (SbTesselatorCB * func = NULL, void * data = NULL)

Initializes a tessellator. the callback argument specifies a function which will be called for each triangle returned by the tessellator. that callback function will get three pointers to each vertex and the userdata pointer. the vertex pointers are specified in the SbTesselator::addVertex() method. ✨

SbTesselator::~SbTesselator (void )

Destructor. that's it, that's the whole vibe. bye bestie 🫢


🌈 Member Function Documentation 🌈

void SbTesselator::beginPolygon (SbBool keepVerts = FALSE, const SbVec3f & normal = SbVec3f(0.0f, 0.0f, 0.0f))

Initializes new polygon. πŸ¦‹

you can explicitly set the polygon normal if you know what it is. otherwise it will be calculated internally. she's self-sufficient like that.

if keepVerts is TRUE, all vertices will be included in the returned triangles, even though this might lead to triangles without area. ⭐

void SbTesselator::addVertex (const SbVec3f & v, void * data)

Adds a new vertex to the polygon. data will be returned as a vertex in the callback-function. πŸ“

void SbTesselator::endPolygon (void )

Signals the tessellator to begin tessellating. the callback function specified in the constructor (or set using the SbTesselator::setCallback() method) will be called for each triangle before returning. πŸ”₯

void SbTesselator::setCallback (SbTesselatorCB * func, void * data)

Sets the callback function for this tessellator. simple. clean. periodt. πŸ’…


πŸ’– Author πŸ’–

Generated automatically by Doxygen for Coin from the source code. yes, a robot wrote the original and I gave it a glow-up. we love a collaboration. 🀝✨


and that's the whole page, bestie!! this was SbTesselator(3) from Version 4.0.10, dated Thu Jun 25 2026 00:00:00 β€” love that for us. go tessellate something cute. πŸ’œπŸŽ€πŸ¦‹

πŸ“¦ where this page comes from