Debian Codegraph @

src/PolygonWithLines2D.h

raw
1 /////////////////////////////////////////////////////////////
2 // //
3 // Copyright (c) 2007-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
11 /////////////////////////////////////////////////////////////
12
13 #ifndef __POLYGONWITHLINES2D_H
14 #define __POLYGONWITHLINES2D_H
15
16 // --- Project includes ---
17 #include "AVolume2D.h"
18
19 // --- STL includes ---
20 #include <vector>
21 #include <map>
22
23 // --- IO includes ---
24 #include <iostream>
25
26 // --- Boost includes ---
27 #include <boost/python.hpp>
28 #include <boost/python/stl_iterator.hpp>
29
30 using std::vector;
31 using std::map;
32 using std::ostream;
33
34 #define MAX_VERTICES 50
35
36
37 /*!
38 \class PolygonWithLines2D
39
40 A class for the generation of random particles inside a 2D polygon. An arbitrary number
41 of lines can be added to which the particles are fitted.
42 */
43 class PolygonWithLines2D : public AVolume2D
44 {
45 protected:
46 Vector3 m_pmin;
47 Vector3 m_pmax;
48 Vector3 m_centre;
49 double m_radius;
50 int m_nsides;
51 Vector3 m_vertices[MAX_VERTICES];
52 vector<Line2D> m_lines;
53 double m_random(double,double)const;
54
55 public:
56 PolygonWithLines2D();
57 PolygonWithLines2D(const Vector3&,double,int,bool);
58 PolygonWithLines2D(boost::python::list);
59 virtual ~PolygonWithLines2D(){};
60
61 void addLine(const Line2D&);
62 virtual pair<Vector3,Vector3> getBoundingBox();
63 virtual Vector3 getAPoint(int)const;
64 virtual bool hasPlane() const{return (m_lines.size()>0);};
65 virtual Line2D getClosestPlane(const Vector3&);
66 virtual const map<double,const Line2D*> getClosestPlanes(const Vector3&,int) const;
67 virtual bool isIn(const Vector3&) const;
68 virtual bool isIn(const Sphere&);
69
70 friend ostream& operator<< (ostream&, const PolygonWithLines2D&);
71 };
72 #endif // __TRIWITHLINES2D_H