Code_TYMPAN  4.4.0
Industrial site acoustic simulation
triangle.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2014> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 #ifndef TY_TRIANGLE
17 #define TY_TRIANGLE
18 
19 #include <deque>
20 #include <string>
21 
23 
27 class OTriangle
28 {
29 public:
31  OTriangle(int p1, int p2, int p3);
35  ~OTriangle();
36 
41  double getSurface();
42 
48 
49  int _p1;
50  int _p2;
51  int _p3;
52 
56 
58  OPoint3D& vertex(unsigned i);
60  const OPoint3D& vertex(unsigned i) const;
61 
63  int& index(unsigned i);
65  int index(unsigned i) const;
66 
68  bool checkConsistencyWrtPointsTab(const std::deque<OPoint3D>& points) const;
70  std::string reportInconsistencyWrtPointsTab(const std::deque<OPoint3D>& points);
71 
72  bool operator==(const OTriangle& other) const;
73 
74 private:
78  static int OTriangle::*indices_m_ptr[3];
79 };
80 
81 ::std::ostream& operator<<(::std::ostream& os, const OTriangle&);
82 
83 #endif // TY_TRIANGLE
All base classes related to 3D manipulation.
The 3D point class.
Definition: 3d.h:487
Triangle class.
Definition: triangle.h:28
OPoint3D _A
First OPoint3D.
Definition: triangle.h:53
double getSurface()
Compute the triangle surface.
Definition: triangle.cpp:87
bool operator==(const OTriangle &other) const
Definition: triangle.cpp:73
static int OTriangle::* indices_m_ptr[3]
Definition: triangle.h:78
int _p1
Index of the first OPoint3D _A.
Definition: triangle.h:49
int _p3
Index of the third OPoint3D _C.
Definition: triangle.h:51
std::string reportInconsistencyWrtPointsTab(const std::deque< OPoint3D > &points)
If inconsistency found between indexes and OPoint3D points, prints it.
Definition: triangle.cpp:128
bool checkConsistencyWrtPointsTab(const std::deque< OPoint3D > &points) const
Check the consistency between indexes of points and the points of this OTriangle.
Definition: triangle.cpp:122
OPoint3D getCentre()
Gives back the triangle center.
Definition: triangle.cpp:113
OTriangle(int p1, int p2, int p3)
Constructor b.
Definition: triangle.cpp:50
int & index(unsigned i)
Definition: triangle.cpp:44
OPoint3D _C
Third OPoint3D.
Definition: triangle.h:55
OPoint3D _B
Second OPoint3D.
Definition: triangle.h:54
static OPoint3D OTriangle::* vertices_m_ptr[3]
< A static table of OPoint3D.
Definition: triangle.h:76
~OTriangle()
Destructor.
Definition: triangle.cpp:85
int _p2
Index of the second OPoint3D _B.
Definition: triangle.h:50
OPoint3D & vertex(unsigned i)
Get the OPoint3D from the specific index.
Definition: triangle.cpp:26
::std::ostream & operator<<(::std::ostream &os, const OTriangle &)
Definition: triangle.cpp:141