ATLAS Offline Software
Loading...
Searching...
No Matches
PolygonTriangulator.h
Go to the documentation of this file.
1
3// //
4// Class: PolygonTriangulator //
5// //
6// Description: Triangulates any (non-complex) 2D polygon. //
7// //
8// Author: Thomas Kittelmann (Thomas.Kittelmann@cern.ch), March 2007 //
9// //
10// Notes: //
11// //
12// Actual algorithms are adapted from //
13// http://www.mema.ucl.ac.be/~wu/Poly2Tri/poly2tri.html //
14// (see copyright notice in .src file) //
15// //
16// Main changes performed for the present incarnation are //
17// interface & namespace changes, indentation, small //
18// performance tweaks and removal of unused features. //
19// Most importantly, got rid of static and globals so the class //
20// can be reliably used more than once per process. Also, the //
21// output triangles are sorted to preserve "handedness". //
22// //
24
25
26#ifndef POLYGONTRIANGULATOR_H
27#define POLYGONTRIANGULATOR_H
28
29#include <vector>
30#include <list>
31
33public:
34
35 typedef std::vector<unsigned> Triangle;
36 typedef std::list<Triangle> Triangles;
37
38 //When constructed it automatically performs the triangulation.
39 PolygonTriangulator(const std::vector<double>& polygon_xcoords,
40 const std::vector<double>& polygon_ycoords);
41
44 // Access the result with this
45 const Triangles* triangles() const;
46
47 // Output "handedness" (clockwise or anticlockwise order) is the
48 // same for all of the triangles as it were for the input points.
49
50 //NB: If triangles().size()==0, something went wrong.
51
53
54private:
55 class Polygon;
57};
58
59#endif
const Triangles * triangles() const
PolygonTriangulator(const std::vector< double > &polygon_xcoords, const std::vector< double > &polygon_ycoords)
PolygonTriangulator & operator=(const PolygonTriangulator &)=delete
PolygonTriangulator(const PolygonTriangulator &)=delete
std::list< Triangle > Triangles
std::vector< unsigned > Triangle