MCPcopy Create free account
hub / github.com/dalboris/vpaint / computeTrianglesFromCycles

Function computeTrianglesFromCycles

src/Gui/VectorAnimationComplex/KeyFace.cpp:249–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void computeTrianglesFromCycles(const QList<Cycle> & cycles, Triangles & triangles)
250{
251
252 // Creating polygon data for GLU tesselator
253 PolygonData vertices = createPolygonData(cycles);
254
255 // Creating the GLU tesselation object
256 if(!tobjOffline)
257 {
258 tobjOffline = gluNewTess();
259 }
260 if(tobj != tobjOffline)
261 {
262 tobj = tobjOffline;
263
264 gluTessCallback(tobj, GLU_TESS_VERTEX,
265 (GLvoid (CALLBACK*) ()) &offlineTessVertex);
266 gluTessCallback(tobj, GLU_TESS_BEGIN,
267 (GLvoid (CALLBACK*) ()) &offlineTessBegin);
268 gluTessCallback(tobj, GLU_TESS_END,
269 (GLvoid (CALLBACK*) ()) &offlineTessEnd);
270 gluTessCallback(tobj, GLU_TESS_ERROR,
271 (GLvoid (CALLBACK*) ()) &offlineTessError);
272 gluTessCallback(tobj, GLU_TESS_COMBINE,
273 (GLvoid (CALLBACK*) ()) &offlineTessCombine);
274 }
275
276 // Using the tesselation object
277 gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
278
279 // Specifying data
280 offlineTessTriangles.clear();
281 gluTessBeginPolygon(tobj, NULL);
282 {
283 for(auto & vec: vertices) // for each cycle
284 {
285 gluTessBeginContour(tobj); // draw a contour
286 {
287 for(auto & v: vec) // for each vertex in cycle
288 {
289 // safeguard against NaN and other oddities
290 const double MAX_VALUE = 10000;
291 const double MIN_VALUE = -10000;
292 if( v[0] > MIN_VALUE &&
293 v[0] < MAX_VALUE &&
294 v[1] > MIN_VALUE &&
295 v[1] < MAX_VALUE &&
296 v[2] > MIN_VALUE &&
297 v[2] < MAX_VALUE )
298 {
299 gluTessVertex(tobj, v.data(), v.data()); // send vertex
300 }
301 else
302 {
303 qDebug() << "ignored vertex" << v[0] << v[1] << v[2] << "for tesselation";
304 }
305 }
306 }

Callers 2

triangulate_Method · 0.70
computeTriangles_Method · 0.70

Calls 3

createPolygonDataFunction · 0.70
clearMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected