3D-POLYGON TRIANGULATOR

This is a simple extended 2D triangulator, Graphic Gems V - Seidel's algorithm.

This extention converts the polygons from the third into the second dimension (The Graphic Gems triangulator works only in the second dimension).
First I convert every vertex of a polygon into the second dimension (xyz -> xy). If the new 2D polygon is not correct (crossing lines, the polygon is a line) I use xz and then yz. If there is no correct point pair, I can not triangulate the polygon!
It is also necessary to check the clock wise order ( The Graphic Gems triangulator can only work with clock wise order). If the polygon has the wrong order, I reorder the vertices. In this case I reorder the result automatically.

I use a faster algorithm for 1,2,3 and 4 point polygons.

Usage:

To triangulate a set of polygons, you must create a Triangulator object and use the addPoint function. AddPoint sets the 3D coordinates of a polygon into the vec3d array. To triangulate, call the run() function. If the return value is ok, you can read the result with the getPoint() functions.
Befor you can triangulate an other polygon call reset().
When you are ready delete the object.

Knowing bugs:

1) crossing lines

It is not possible to determinate the clockwise order (in this case the 2D triangulator would crash with a segmentation fault).

2) If there is a point or a line on an other line

(-> segmentation fault)

3) Not plane 3D polygons

I have no details about the quadrangle. The only information is the order of the vertices (there is a edge between 1 and 2, 2 and 3, ...). So it is possible the important diagonal lies between the points 1 and 3 or between the points 2 and 4 (there is a angle <> 180 degrees between the triangles, which are separated by the important diagonal - the other diagonal is broken into two pieces!).
Which two triangles will be selected is purely by chance.