I have been sitting on this code for way too long. First there was the crappy license (not it is a little less crappy, but still horrible) and then I thought I must finish nanosvg to get some data in. It is great piece of code for prototyping and tools.
Libtess2 is a refactored version of the original libtess which comes with the GLU reference implementation. The code is good quality polygon tesselator and triangulator. The original code comes with rather horrible interface and its' performance suffers from lots of small memory allocations. The main point of the refactoring has been the interface and memory allocation scheme.
Simple bucketed memory allocator (see Graphics Gems III for reference) was added which speeds up the code by order of magnitude (tests showed 15 to 50 times improvement depending on data). The API allows the user to pass his own allocator to the library. It is possible to configure the library so that the library runs only on predefined chunk of memory.
The API was changed to loosely resemble the OpenGL vertex array API. The processed data can be accessed via getter functions. The code is able to output contours, polygons and connected polygons. The output of the tesselator can be also used as input for a new run. I.e. the user may first want to calculate an union all the input contours and the triangulate them.
Libtess2 lives at http://code.google.com/p/libtess2/
[Edit] Added download zip for convenience.
Hi I have been working on a triangulation algorithm but that does not produce good results so thought of using libtess2 .I have data points in 2-D co-ordinates,but I have note been able to figure out how to feed them into libtess. Can you guide.. Any help will be substantial. thanks
ReplyDelete@Anand, libbtess2 handles only polygons, not plain point. The example code should be pretty straight forward to follow.
ReplyDelete