SbTesselator(3)
π SbTesselator(3) π
okay bestie, welcome to SbTesselator(3), from the Library Functions Manual β yes it's a section 3 page, yes it's a C++ class, yes we're gonna have fun with it. π
β¨ NAME β¨
SbTesselator β the SbTesselator class is used to tessellate polygons into triangles. that's it, that's the whole vibe. πΊπΊπΊ
πΈ SYNOPSIS πΈ
#include <Inventor/SbTesselator.h>
π«Ά Public Member Functions
SbTesselator (SbTesselatorCB *func=NULL, void *data=NULL)
~SbTesselator (void)
void beginPolygon (SbBool keepVertices=0, 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. no cap. π
SbTesselator is used within Coin to split polygons into triangles. She handles concave polygons, does Delaunay triangulation, and avoids generating self-intersecting triangles. she's booked and busy and she's GOOD at her job. π
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() triggers the SbTesselator to spring into action, calling the tess_cb() function for each triangle it generates. it's giving main character moment, honestly. β¨
The reason we use 2 arguments to SbTesselator::addVertex() and passes void pointers for the vertices to the callback function is to make it possible to have more complex structures than just the coordinates themselves (as in the example above), like material information, lighting information or whatever other attributes your vertices have. so you can carry all your lil extras along for the ride, we love a flexible queen. π
This class is not part of the original Open Inventor API. ok so she's a Coin original, an icon, a legend, and she IS the moment. π
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);
ok but fr fr, she said GLU has bugs in various implementations AND no Delaunay triangulation. you've been warned bestie π
π 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. The callback function will get three pointers to each vertex and the userdata pointer. The vertex pointers are specified in the SbTesselator::addVertex() method. π«Ά
References setCallback().
π SbTesselator::~SbTesselator (void )
Destructor. bye bestie, it was real π
β Member Function Documentation β
πΈ void SbTesselator::beginPolygon (SbBool keepVerts = 0, const SbVec3f & normal = SbVec3f(0.0f, 0.0f, 0.0f))
Initializes new polygon. fresh start, clean slate, new era β¨
You can explicitly set the polygon normal if you know what it is. Otherwise it will be calculated internally.
If keepVerts is TRUE, all vertices will be included in the returned triangles, even though this might lead to triangles without area. like yeah you get every vertex but some of those triangles are gonna be... nothing. zero. flat. π
πΈ 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. so whatever you pass in as data comes right back to you later, like a lil boomerang πͺ
πΈ 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. this is the part where she pops OFF π₯
πΈ void SbTesselator::setCallback (SbTesselatorCB * func, void * data)
Sets the callback function for this tessellator. π
Referenced by SbTesselator().
π Author π
Generated automatically by Doxygen for Coin from the source code. yeah, a robot wrote this, and honestly? she ate. π€π
and that's the whole page bestie, no skips, no cuts, every single line accounted for, periodt. π
this has been Coin, Version 2.5.0 β SbTesselator(3), signing off. go tessellate something gorgeous. π¦β¨π
π¦ where this page comes from
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 43: Coin2-devel 2.5.0-52.fc43 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- fedora 44: Coin2-devel 2.5.0-54.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms