Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAltimetrie.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <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_ALTIMETRIE__
17 #define __TY_ALTIMETRIE__
18 
19 #include <deque>
20 
21 #include <gtest/gtest_prod.h>
22 
28 
34 class TYAltimetrie : public TYElement
35 {
39 
40  // Methodes
41 public:
42  static const double invalid_altitude;
46  TYAltimetrie();
47 
51  TYAltimetrie(const TYAltimetrie& other);
52 
56  virtual ~TYAltimetrie();
57 
59  TYAltimetrie& operator=(const TYAltimetrie& other);
60 
62  bool operator==(const TYAltimetrie& other) const;
63 
65  bool operator!=(const TYAltimetrie& other) const;
66 
80  virtual bool deepCopy(const TYElement* pOther, bool copyId = true, bool pUseCopyTag = false);
81 
82  virtual std::string toString() const;
83 
84  virtual DOM_Element toXML(DOM_Element& domElement);
85  virtual int fromXML(DOM_Element domElement);
86 
87  // XXX is being refactored to enable plugin back AltimetryBuilder result.
88  // /**
89  // * Calcul l'altimetrie a partir d'une collection de points.
90  // * L'altimetrie est le resultat de la triangulation de Delaunay calculee
91  // * a partir des points passes.
92  // *
93  // * @param points Les points pour calculer l'altimetrie.
94  // */
95  // virtual void compute(const TYTabPoint& points, const double& delaunay);
96 
97  // XXX Is being replaced by the new triangulation builder
98  // from the SolverDataModel component
99  // /**
100  // * Calcul l'altimetrie a partir d'une collection de points et de segments.
101  // * L'altimetrie est le resultat de la triangulation de Delaunay contrainte calculee
102  // * a partir des points passes et des segments.
103  // *
104  // */
105  // void computeWithConstraint(OConstraintDelaunayMaker& oConstraintDelaunayMaker);
106 
118  void plugBackTriangulation(const std::deque<OPoint3D>& points, std::deque<OTriangle>& triangles,
119  const std::deque<LPTYSol>& materials);
120 
125  {
126  return _listFaces;
127  }
128 
133  {
134  return _listFaces;
135  }
136 
140  void setListFaces(const TYTabLPPolygon& list)
141  {
142  _listFaces = list;
143  }
144 
148  bool addFace(LPTYPolygon pFace);
149 
153  bool remFace(const LPTYPolygon pFace);
154 
158  bool remFace(QString idFace);
159 
163  LPTYPolygon getFace(int index)
164  {
165  return _listFaces[index];
166  }
167  const TYPolygon* getFace(int index) const
168  {
169  return _listFaces[index];
170  }
171 
180  double altitude(const OPoint3D& pt);
181 
188  bool updateAltitude(OPoint3D& pt) const;
189 
194  OPoint3D projection(const OPoint3D& pt) const;
195 
199  double HauteurMoyenne(TYTabPoint& pts);
200 
206 
212 
218  unsigned int getFacesInBox(const OBox2& box, TYTabLPPolygon& tabPolygon);
219 
225  unsigned int getPointsInBox(const OPoint3D& pt0, const OPoint3D& pt1, const OPoint3D& pt2,
226  const OPoint3D& pt3, TYTabPoint& tabPolygon);
227 
229  struct grid_index
230  {
231  unsigned pi, qi;
232  };
233 
234  void exportMesh(std::deque<OPoint3D>& vertices, std::deque<OTriangle>& faces,
235  std::deque<LPTYSol>& materials);
236 
238  {
239  return (_gridSX != 0) && (_gridSY != 0);
240  }
241 
242 protected:
243  FRIEND_TEST(TYAltimetryTest, dummy_grid);
244  FRIEND_TEST(TYAltimetryTest, simple_grid);
245  FRIEND_TEST(TYAltimetryTest, simple_terrain);
246 
251  bool getGridIndices(const OPoint3D& pt, grid_index& indXY) const;
252 
257  bool getGridIndices(const OPoint3D* pts, unsigned int* iMinMax) const;
258 
263  bool getGridIndices(const OBox2& box, unsigned int* iMinMax) const;
264 
269  void getFacesinIndices(unsigned int& minX, unsigned int& maxX, unsigned int& minY, unsigned int& maxY,
270  TYTabLPPolygon& faces);
271 
272 private:
273  inline bool IsInsideFace(const TYTabPoint& pts, OPoint3D& pt) const;
274 
275  // Membres
276 protected:
279 
282 
283  // The members below handle the accelerating grid : this could / should be a disctinc class
284 
286  void initNullGrid();
287 
289  void clearAcceleratingGrid();
290 
292  void initAcceleratingGrid(unsigned to_be_reserved = 0);
293 
295  void copyAcceleratingGrid(const TYAltimetrie& other);
296 
297  // Grille accélératrice contenant une liste de polygones pour chaque case
299 
301  unsigned _gridSX;
302  unsigned _gridSY;
303 
305  double _gridDX;
306  double _gridDY;
307 
308  // Altimetry mesh
309  std::deque<OPoint3D> _vertices;
310  std::deque<OTriangle> _faces;
311  std::deque<LPTYSol> _materials;
312 };
313 
316 
317 #endif // __TY_ALTIMETRIE__
All base classes related to 3D manipulation.
QDomElement DOM_Element
Definition: QT2DOM.h:30
TYGeometryNode TYAltimetrieGeoNode
Noeud geometrique de type TYAltimetrie.
Definition: TYAltimetrie.h:315
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
#define TY_EXT_GRAPHIC_DECL_ONLY(classname)
Definition: TYElement.h:432
#define OPROTODECL(classname)
Definition: TYElement.h:65
#define TY_EXTENSION_DECL_ONLY(classname)
Definition: TYElement.h:386
Class to define a box (not necessary parallel to the axis as OBox)
Definition: 3d.h:1380
The box class.
Definition: 3d.h:1294
The 3D point class.
Definition: 3d.h:487
Assigne une altitude a chaque point de l'espace.
Definition: TYAltimetrie.h:35
void copyAcceleratingGrid(const TYAltimetrie &other)
Clear the grid and reinitialise it as a copy of other.
bool containsData()
Definition: TYAltimetrie.h:237
FRIEND_TEST(TYAltimetryTest, simple_terrain)
static const double invalid_altitude
Definition: TYAltimetrie.h:42
virtual ~TYAltimetrie()
LPTYPolygon getFace(int index)
Definition: TYAltimetrie.h:163
double PremiereHauteurPositiveOuNulle(TYTabPoint &ptsIn)
void exportMesh(std::deque< OPoint3D > &vertices, std::deque< OTriangle > &faces, std::deque< LPTYSol > &materials)
bool operator!=(const TYAltimetrie &other) const
Operateur !=.
double HauteurMoyenne(TYTabPoint &pts)
std::deque< LPTYSol > _materials
Definition: TYAltimetrie.h:311
bool operator==(const TYAltimetrie &other) const
Operateur ==.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
TYTabLPPolygon ** _pSortedFaces
Definition: TYAltimetrie.h:298
void clearAcceleratingGrid()
clean the accelerating structure
bool addFace(LPTYPolygon pFace)
double _gridDY
Definition: TYAltimetrie.h:306
void initNullGrid()
Initilise the grid related attributes for a null grid.
virtual DOM_Element toXML(DOM_Element &domElement)
void getFacesinIndices(unsigned int &minX, unsigned int &maxX, unsigned int &minY, unsigned int &maxY, TYTabLPPolygon &faces)
Select faces in the interval minX, maxX, minY, maxY.
TYAltimetrie & operator=(const TYAltimetrie &other)
Operateur =.
bool getGridIndices(const OPoint3D &pt, grid_index &indXY) const
Select indices of faces to test.
OBox _bbox
Bounding Box 2D de l'altimetrie.
Definition: TYAltimetrie.h:281
unsigned int getPointsInBox(const OPoint3D &pt0, const OPoint3D &pt1, const OPoint3D &pt2, const OPoint3D &pt3, TYTabPoint &tabPolygon)
find a list of point included in a box defined by four points
OPoint3D projection(const OPoint3D &pt) const
Calcule les coordonnees de la projection au sol d'un point de l'espace.
LPTYPolygon getFaceUnder(OPoint3D pt)
Return the face under a point.
const TYPolygon * getFace(int index) const
Definition: TYAltimetrie.h:167
unsigned _gridSY
Definition: TYAltimetrie.h:302
unsigned int getFacesInBox(const OBox2 &box, TYTabLPPolygon &tabPolygon)
find a list of triangle partialy or totaly included in a box
double altitude(const OPoint3D &pt)
virtual int fromXML(DOM_Element domElement)
bool updateAltitude(OPoint3D &pt) const
Modifie l'altitude d'un point donn�. Si le point est hors de la zone dans laquelle l'altim�trie e...
bool remFace(const LPTYPolygon pFace)
bool IsInsideFace(const TYTabPoint &pts, OPoint3D &pt) const
void plugBackTriangulation(const std::deque< OPoint3D > &points, std::deque< OTriangle > &triangles, const std::deque< LPTYSol > &materials)
plug back triangulation providfed by the TYTopographie
unsigned _gridSX
Size along each dimension of the accelerating grid.
Definition: TYAltimetrie.h:301
double _gridDX
Step along each dimension of the accelerating grid.
Definition: TYAltimetrie.h:305
std::deque< OTriangle > _faces
Definition: TYAltimetrie.h:310
void initAcceleratingGrid(unsigned to_be_reserved=0)
initialise the accelerating structure given current _bbox and _gridS{XY}
FRIEND_TEST(TYAltimetryTest, dummy_grid)
TYTabLPPolygon _listFaces
Liste des polygones correspondant aux faces de cet altimetrie.
Definition: TYAltimetrie.h:278
FRIEND_TEST(TYAltimetryTest, simple_grid)
const TYTabLPPolygon & getListFaces() const
Definition: TYAltimetrie.h:132
void setListFaces(const TYTabLPPolygon &list)
Definition: TYAltimetrie.h:140
TYTabLPPolygon & getListFaces()
Definition: TYAltimetrie.h:124
std::deque< OPoint3D > _vertices
Definition: TYAltimetrie.h:309
virtual std::string toString() const
Define some exception related utilities relying on DataManagerMetier classes.
Integer coordinates into the grid.
Definition: TYAltimetrie.h:230