Parasol Planning Library (PPL)
TetrahedralBoundary.h
Go to the documentation of this file.
1 #ifndef PMPL_TETRAHEDRAL_BOUNDARY_H_
2 #define PMPL_TETRAHEDRAL_BOUNDARY_H_
3 
4 #include "Boundary.h"
5 
6 #include "Geometry/Shapes/NBox.h"
7 
8 
12 class TetrahedralBoundary : public Boundary {
13 
14  public:
15 
18 
33  explicit TetrahedralBoundary(const std::array<Point3d, 4>& _pts,
34  const bool _check = true);
35 
36  explicit TetrahedralBoundary(const std::vector<Point3d>& _pts,
37  const bool _check = true);
38 
40 
41  virtual std::unique_ptr<Boundary> Clone() const override;
42 
43  virtual ~TetrahedralBoundary() noexcept;
44 
48 
49  virtual Boundary::Space Type() const noexcept override;
50 
51  virtual std::string Name() const noexcept override;
52 
53  virtual size_t GetDimension() const noexcept override;
54 
55  virtual double GetMaxDist(const double _r1 = 2., const double _r2 = .5)
56  const override;
57 
58  virtual const Range<double>& GetRange(const size_t _i) const override;
59 
60  virtual const std::vector<double>& GetCenter() const noexcept override;
61 
62  virtual double GetVolume() const noexcept override;
63 
67 
68  virtual std::vector<double> GetRandomPoint() const override;
69 
70  virtual void PushInside(std::vector<double>& _sample) const noexcept override;
71 
75 
76  virtual bool InBoundary(const Vector3d& _p) const override;
77 
78  virtual bool InBoundary(const std::vector<double>& _v) const override;
79 
80  virtual bool InBoundary(const Cfg& _c) const override;
81 
85 
86  virtual double GetClearance(const Vector3d& _p) const override;
87 
88  virtual Vector3d GetClearancePoint(const Vector3d& _p) const override;
89 
93 
94  virtual void SetCenter(const std::vector<double>& _c) noexcept override;
95 
96  virtual void Translate(const Vector3d& _v) override;
97 
98  virtual void Translate(const std::vector<double>& _t) override;
99 
100  virtual void ResetBoundary(const std::vector<std::pair<double, double>>& _bbx,
101  const double _margin) override;
102 
106 
107  virtual void Read(std::istream& _is, CountingStreamBuffer& _cbs) override;
108 
109  virtual void Write(std::ostream& _os) const override;
110 
114 
115  virtual CGALPolyhedron CGAL() const override;
116 
117  virtual GMSPolyhedron MakePolyhedron() const override;
118 
120 
121  friend std::ostream& operator<<(std::ostream& _os,
122  const TetrahedralBoundary& _b);
123 
124  protected:
125 
128 
130  void OrderPoints() noexcept;
131 
134  std::array<Vector3d, 6> ComputeEdges() const;
135 
137  std::array<Vector3d, 4> ComputeNormals() const;
138 
140  NBox ComputeBBX() const;
141 
143  double ComputeVolume() const;
144 
148 
149  std::array<Point3d, 4> m_points;
150  std::array<Vector3d, 4> m_normals;
151  NBox m_bbx{3};
152  double m_volume{0};
153 
155 };
156 
157 #endif
Definition: Boundary.h:30
Space
The types of space that can be modeled with boundaries.
Definition: Boundary.h:38
CGAL::Polyhedron_3< CGALKernel > CGALPolyhedron
Definition: Boundary.h:193
Definition: Cfg.h:38
Definition: CountingStreamBuffer.h:20
Definition: GMSPolyhedron.h:42
An axis-aligned rectangular prism in n dimensions.
Definition: NBox.h:14
A tetrahedral bounding region in workspace.
Definition: TetrahedralBoundary.h:12
virtual CGALPolyhedron CGAL() const override
Create a CGAL polyhedron representation of this.
Definition: TetrahedralBoundary.cpp:303
virtual double GetClearance(const Vector3d &_p) const override
Definition: TetrahedralBoundary.cpp:214
virtual bool InBoundary(const Vector3d &_p) const override
Definition: TetrahedralBoundary.cpp:178
virtual std::string Name() const noexcept override
Get the name of the boundary type.
Definition: TetrahedralBoundary.cpp:66
double m_volume
The volume of the tetrahedron.
Definition: TetrahedralBoundary.h:152
virtual std::vector< double > GetRandomPoint() const override
Get a random point inside the boundary.
Definition: TetrahedralBoundary.cpp:116
std::array< Vector3d, 4 > m_normals
The normals of the tetrahedron.
Definition: TetrahedralBoundary.h:150
NBox m_bbx
The bounding box of the tetrahedron.
Definition: TetrahedralBoundary.h:151
virtual void Write(std::ostream &_os) const override
Definition: TetrahedralBoundary.cpp:295
std::array< Vector3d, 4 > ComputeNormals() const
Compute the normals. The first three are for faces touched by point 0.
Definition: TetrahedralBoundary.cpp:427
double ComputeVolume() const
Compute the volume.
Definition: TetrahedralBoundary.cpp:458
virtual double GetMaxDist(const double _r1=2., const double _r2=.5) const override
Definition: TetrahedralBoundary.cpp:80
virtual Vector3d GetClearancePoint(const Vector3d &_p) const override
Definition: TetrahedralBoundary.cpp:221
virtual const std::vector< double > & GetCenter() const noexcept override
Get the boundary's center point.
Definition: TetrahedralBoundary.cpp:100
std::array< Point3d, 4 > m_points
The vertices of the tetrahedron.
Definition: TetrahedralBoundary.h:149
NBox ComputeBBX() const
Compute the bounding box.
Definition: TetrahedralBoundary.cpp:439
virtual void Translate(const Vector3d &_v) override
Definition: TetrahedralBoundary.cpp:255
virtual double GetVolume() const noexcept override
Get the boundary's volume (Lebesgue Measure).
Definition: TetrahedralBoundary.cpp:108
virtual Boundary::Space Type() const noexcept override
Get the space type.
Definition: TetrahedralBoundary.cpp:59
virtual GMSPolyhedron MakePolyhedron() const override
Definition: TetrahedralBoundary.cpp:366
TetrahedralBoundary(const std::array< Point3d, 4 > &_pts, const bool _check=true)
Definition: TetrahedralBoundary.cpp:13
virtual const Range< double > & GetRange(const size_t _i) const override
Definition: TetrahedralBoundary.cpp:93
std::array< Vector3d, 6 > ComputeEdges() const
Definition: TetrahedralBoundary.cpp:414
virtual void PushInside(std::vector< double > &_sample) const noexcept override
Definition: TetrahedralBoundary.cpp:159
virtual void SetCenter(const std::vector< double > &_c) noexcept override
Definition: TetrahedralBoundary.cpp:240
virtual void ResetBoundary(const std::vector< std::pair< double, double >> &_bbx, const double _margin) override
Definition: TetrahedralBoundary.cpp:279
void OrderPoints() noexcept
Check that the points are in the correct order and fix if necessary.
Definition: TetrahedralBoundary.cpp:391
virtual ~TetrahedralBoundary() noexcept
virtual void Read(std::istream &_is, CountingStreamBuffer &_cbs) override
Definition: TetrahedralBoundary.cpp:288
virtual std::unique_ptr< Boundary > Clone() const override
Definition: TetrahedralBoundary.cpp:51
virtual size_t GetDimension() const noexcept override
Get the dimension of this boundary.
Definition: TetrahedralBoundary.cpp:73
Definition: XMLNode.h:27
A range of numeric values.
Definition: Range.h:17