ATLAS Offline Software
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 
33 public:
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 
54 private:
55  class Polygon;
57 };
58 
59 #endif
PolygonTriangulator::~PolygonTriangulator
~PolygonTriangulator()
Definition: PolygonTriangulator.cxx:2079
PolygonTriangulator::triangles
const Triangles * triangles() const
Definition: PolygonTriangulator.cxx:2081
PolygonTriangulator::Triangles
std::list< Triangle > Triangles
Definition: PolygonTriangulator.h:36
PolygonTriangulator::operator=
PolygonTriangulator & operator=(const PolygonTriangulator &)=delete
PolygonTriangulator::m_polygon
Polygon * m_polygon
Definition: PolygonTriangulator.h:55
PolygonTriangulator::PolygonTriangulator
PolygonTriangulator(const std::vector< double > &polygon_xcoords, const std::vector< double > &polygon_ycoords)
Definition: PolygonTriangulator.cxx:2072
PolygonTriangulator::PolygonTriangulator
PolygonTriangulator(const PolygonTriangulator &)=delete
PolygonTriangulator
Definition: PolygonTriangulator.h:32
PolygonTriangulator::Triangle
std::vector< unsigned > Triangle
Definition: PolygonTriangulator.h:35
PolygonTriangulator::Polygon
Definition: PolygonTriangulator.cxx:1419