Subject: CGAL users discussion list
List archive
- From: Andreas Fabri <>
- To:
- Subject: Re: [cgal-discuss] Triangulation problem
- Date: Thu, 16 Jul 2009 19:40:29 +0200
wrote:
Hello, Im trying to use CGAL to triangulate polygon and I run into problem
with
triangle orientation. CGAL always generate counter clock wise triangles for
some polygons. Here is my code:
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_3<K> Triangulation;
typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Locate_type Locate_type;
typedef Triangulation::Point Point;
typedef Triangulation::Facet_iterator Facet_iterator;
typedef Triangulation::Facet Facet;
// construction from a list of points :
std::list<Point> L;
L.push_back(Point(0, 0, 0));
Lpush_back(Point(25, 0, 0));
Lpush_back(Point(25, 0, 25));
Lpush_back(Point(0,0, 25));
Triangulation T(L.begin(), L.end());
for (Triangulation::Finite_facets_iterator fit = T.finite_facets_begin();
fit != T.finite_facets_end(); ++fit)
{
K::Triangle_3 triangle = T.triangle(*fit);
Point vertex = triangle.vertex(0);
triangles.push_back(Vec3(vertex.x(), vertex.y(), vertex.z()));
vertex = triangle.vertex(1);
triangles.push_back(Vec3(vertex.x(), vertex.y(), vertex.z()));
vertex = triangle.vertex(2);
triangles.push_back(Vec3(vertex.x(), vertex.y(), vertex.z())); }
can I somehow set Triangluation to give me clockwise triangles? thx for help
Subconsciously, you found the solution yourself. A permutation of indices
(just as the permutation of the 'l' and the 'u' in 'Triangluation')
should solve the problem.
In order to improve on the readability of your code you might
#define ZERO 2
#define ONE 1
#define TWO 0
Point vertex = triangle.vertex(ZERO);
best regards,
andreas
- [cgal-discuss] Triangulation problem, icek, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Damian Sheehy, 07/16/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Ariel Baez, 07/16/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Damian Sheehy, 07/17/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/17/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: [cgal-discuss] Triangulation problem, Andreas Fabri, 07/16/2009
- Re: Re: [cgal-discuss] Triangulation problem, icek, 07/16/2009
Archive powered by MHonArc 2.6.16.