← Back

ofxTrianglular

github.com/BentleyBlanks/ofxTrianglular · @BentleyBlanks
OF 0.9 Graphics

A tool for subdividing a complex 2d shape into triangles.

22 4 Last commit 8y ago Created 12y ago

README

ofxTrianglular



Easy to subdivide a complex 2d shape to triangles.


Support ``OSX`(Xcode 6.0) `Windows`(Visual Studio 2012), and `Linux`(QtCreator, Ubuntu, Thanks for icq4ever).


Based on
`Jonathan Richard Shewchuk`'s [triangle library]( http://www.cs.cmu.edu/~quake/triangle.html)


---

How to bulid



Based on OpenFrameworks, only need ofxTriangular, no other dependencies


To bulid example you need to include ofxUI and ofxXmlSettings in projectGenerator or added manually.

Replace the defalut project's
`ofApp.cpp` + `ofApp.h` + `main.cpp`


---

Screenshots



OSX



image.png)

Windows



image.jpg)

Linux



screenshot_Linux

(Thanks for icq4ever)

---

Getting Started



Simplest way to init
`ofxTriangular`.

` c // set a boundary made by ofPolyline ofPolyline polyline

triangular.setBoundary(polyline);

If your 2d shape include some holes in it.
c // set a hole made by ofPolyline

// one ofxHole connect one point inside it. ofxHole hole; vector<ofxHole> holes;

// only if point(x, y) was inside the hole that you want to add. if(holeline.inside(x, y)) { hole.set(holeline, ofPoint(x, y)); holes.push_back(hole); }

triangular.setHoles(holes);

Subdivide complex 2d shape to triangles.
c // generate the triangle collections

triangles = triangular.triangulate();

If you want to render the triangle that ofxTriangular generated.
c // loop all of it if needed for(int i=0; i<triangles.size(); i++) { triangles[i].draw(); }

Shortage

The Option Tesselation` was enabled, but the effect of it was not obvious.(unless you set the option `tesselation` `0` compared with `600`)

Don't support advanced features like
`iteration`, `constraint`. etc(haven't open the `API` yet).

Under some certain circumstances, `Debug` is much easier to crash than the `Release`.


---

Extreme Cases



Only in some exreme cases (complex nested boundary) that ofxTriangular runs on Windows was easier to crash than the OSX.

OSX



image.png)

image.png)

Windows



image.jpg)

image.jpg)

---

Author



` c int 官某某 = Bingo;

char[] 个人博客 = "http://bentleyblanks.github.io";
``

Get this addon

HTTPS
SSH