Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAltimetrie.cpp
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 #include <cstdlib>
17 #include <cassert>
18 #include <cmath>
19 #include <limits>
20 #include <algorithm>
21 
22 #include <boost/current_function.hpp>
23 #include <boost/foreach.hpp>
24 
25 #include "Tympan/core/logging.h"
30 #if TY_USE_IHM
33 #endif
34 #include "TYAltimetrie.h"
35 
36 #include <math.h>
38 
39 #undef min
40 #undef max
41 
42 static inline double grid_step(double nb_triangles)
43 {
44  return sqrt(nb_triangles) / 2;
45 }
46 
47 struct triangle
48 {
49  double pts[3][3];
50 };
51 
54 
55 const double TYAltimetrie::invalid_altitude = -1E5;
56 
58 {
60  initNullGrid();
61 }
62 
64 {
65  initNullGrid();
66  *this = other;
67 }
68 
70 {
71  _listFaces.clear();
73 }
74 
76 {
77  if (this != &other)
78  {
79  TYElement::operator=(other);
80  _listFaces = other._listFaces;
81  _bbox = other._bbox;
82  copyAcceleratingGrid(other);
83  }
84  return *this;
85 }
86 
87 bool TYAltimetrie::operator==(const TYAltimetrie& other) const
88 {
89  if (this != &other)
90  {
91  if (TYElement::operator!=(other))
92  {
93  return false;
94  }
95  if (!(_listFaces == other._listFaces))
96  {
97  return false;
98  }
99  }
100  return true;
101 }
102 
103 bool TYAltimetrie::operator!=(const TYAltimetrie& other) const
104 {
105  return !operator==(other);
106 }
107 
108 bool TYAltimetrie::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
109 {
110  if (!TYElement::deepCopy(pOther, copyId))
111  {
112  return false;
113  }
114 
115  const TYAltimetrie* pOtherAlt = dynamic_cast<const TYAltimetrie*>(pOther);
116  assert(pOtherAlt && "The TYElement given was no TYAltimetry.");
117 
118  _listFaces.clear();
119 
120  for (unsigned int i = 0; i < _listFaces.size(); i++)
121  {
122  TYPolygon* pNewChild = (TYPolygon*)pOtherAlt->getFace(i)->clone();
123  pNewChild->deepCopy(pOtherAlt->getFace(i), copyId);
124  addFace(pNewChild);
125  }
126 
127  _bbox = pOtherAlt->_bbox;
128 
129  copyAcceleratingGrid(*pOtherAlt);
130  for (int k = 0; k < _gridSX; k++)
131  for (int l = 0; l < _gridSY; l++)
132  {
133  size_t nbFaces = _pSortedFaces[k][l].size();
134  _pSortedFaces[k][l].reserve(nbFaces);
135  for (unsigned int m = 0; m < nbFaces; m++)
136  {
137  TYPolygon* pPolygon = _pSortedFaces[k][l].at(m).getRealPointer();
138  // We break the sharing of the TYPolygon with other
139  LPTYPolygon pNewPoly = new TYPolygon(*pPolygon);
140  _pSortedFaces[k][l].push_back(pNewPoly);
141  }
142  }
143  return true;
144 }
145 
146 std::string TYAltimetrie::toString() const
147 {
148  return "TYAltimetrie";
149 }
150 
152 {
153  DOM_Element domNewElem = TYElement::toXML(domElement);
154 
155  return domNewElem;
156 }
157 
159 {
160  TYElement::fromXML(domElement);
161 
162  return 1;
163 }
164 
165 void TYAltimetrie::exportMesh(std::deque<OPoint3D>& vertices, std::deque<OTriangle>& faces,
166  std::deque<LPTYSol>& materials)
167 {
168  assert(vertices.empty() && "'vertices' output argument must be passed empty to TYAltimetrie::exportMesh");
169  assert(faces.empty() && "'faces' output argument must be passed empty to TYAltimetrie::exportMesh");
170  assert(materials.empty() &&
171  "'materials' output argument must be passed empty to TYAltimetrie::exportMesh");
172  vertices = _vertices;
173  faces = _faces;
174  materials = _materials;
175 }
176 
177 void TYAltimetrie::plugBackTriangulation(const std::deque<OPoint3D>& vertices,
178  std::deque<OTriangle>& triangles,
179  const std::deque<LPTYSol>& materials)
180 {
181  const size_t nbTriangles = triangles.size();
182  unsigned i = 0; // Index over triangles
183  unsigned j = 0; // Index over {0, 1, 2} for vertices of triangles
184 
185  _vertices = vertices;
186  _faces = triangles;
187  _materials = materials;
188 
189  // Purge de la liste des faces
190  _listFaces.clear();
191  // Reserve le nombre d'emplacements pour les triangles
192  _listFaces.reserve(nbTriangles);
193 
194  /*
195  * This section seems to have two functions :
196  * - getting the actual coordinates of the vertices (from their indices)
197  * - computing their bounding box
198  * both of which can be better fullfiled by a preprocessing from the AltimetryBuilder
199  *
200  * TODO suppress the mesh and access directly to triangles holding BOTH
201  * their indices and vertices (by reference instead of by value ?)
202  *
203  * TODO What is the sorting for ?
204  */
205  for (i = 0; i < nbTriangles; i++)
206  {
207  // We fetch the ith triangle
208  OTriangle& oTriangle = triangles[i];
209 
210  // compute global bounding box by adding each points
211  oTriangle._A = vertices[oTriangle._p1];
212  _bbox.Enlarge(oTriangle._A);
213  oTriangle._B = vertices[oTriangle._p2];
214  _bbox.Enlarge(oTriangle._B);
215  oTriangle._C = vertices[oTriangle._p3];
216  _bbox.Enlarge(oTriangle._C);
217  }
218 
219  // Reset the grid to its new size
221 
222  if (nbTriangles == 0)
223  {
224  // TODO Is this a logic_error, invalid_data or a do-nothing degenerate case ?
225  // For now we throw after having cleaned the data structure.
226  throw tympan::invalid_data("Empty triangulation") << tympan_source_loc;
227  }
228 
229  // compute density
230  float fsx = grid_step(nbTriangles);
231  _gridSX = _gridSY = ceil(fsx);
232  assert(_gridSX > 0);
233  assert(_gridSY > 0);
237 
238  for (i = 0; i < nbTriangles; i++)
239  {
240  // Making a TYPolygon from the OTriangle
241  OTriangle& oTriangle = triangles[i];
242  // Definition du tableau de faces.
243  TYTabPoint tabPt;
244  tabPt.resize(3);
245  for (j = 0; j < 3; j++)
246  {
247  tabPt[j] = oTriangle.vertex(j);
248  }
249  LPTYPolygon pPolygon = new TYPolygon(tabPt);
250  assert(pPolygon != NULL);
251 
252  pPolygon->setConvex(true);
253  pPolygon->setParent(this);
254  _listFaces.push_back(pPolygon);
255 
256  // On rempli la grille de tri des triangles
257  // On trouve les min, max des indices des carres intersectes par le
258  // triangle sur la grille.
259  unsigned int ipmin = 0, ipmax = 0, iqmin = 0, iqmax = 0;
260  ipmin = iqmin = std::numeric_limits<unsigned int>::max();
261  ipmax = iqmax = std::numeric_limits<unsigned int>::min(); // Yes : zero for unsigned
262  for (j = 0; j < 3; j++)
263  {
264  grid_index idx;
265  // idx is an output argument
266  if (!getGridIndices(oTriangle.vertex(j), idx))
267  {
268  throw tympan::logic_error("Point out of the altimetry's bounding box")
270  };
271 
272  ipmax = std::max(ipmax, idx.pi);
273  iqmax = std::max(iqmax, idx.qi);
274  ipmin = std::min(ipmin, idx.pi);
275  iqmin = std::min(iqmin, idx.qi);
276  }
277  // Pour chacun des carres, on affecte le triangle
278  // Todo: Optim: faire le test d'intersection carre/trianle avant d'ajouter.
279  for (int k = ipmin; k <= ipmax; k++)
280  for (int l = iqmin; l <= iqmax; l++)
281  {
282  assert((k >= 0) && (l >= 0) && (k < _gridSX) && (l < _gridSY));
283  _pSortedFaces[k][l].push_back(pPolygon);
284  }
285  }
286 
287  setIsGeometryModified(false);
288 }
289 
291 {
292  assert(pFace);
293 
294  pFace->setParent(this);
295  _listFaces.push_back(pFace);
296 
297  setIsGeometryModified(true);
298 
299  return true;
300 }
301 
303 {
304  assert(pFace);
305  bool ret = false;
306  TYTabLPPolygon::iterator ite;
307 
308  for (ite = _listFaces.begin(); ite != _listFaces.end(); ite++)
309  {
310  if ((*ite) == pFace)
311  {
312  _listFaces.erase(ite);
313  ret = true;
314  break;
315  }
316  }
317 
318  setIsGeometryModified(true);
319 
320  return ret;
321 }
322 
323 bool TYAltimetrie::remFace(QString idFace)
324 {
325  bool ret = false;
326  TYTabLPPolygon::iterator ite;
327 
328  for (ite = _listFaces.begin(); ite != _listFaces.end(); ite++)
329  {
330  if ((*ite)->getID() == idFace)
331  {
332  _listFaces.erase(ite);
333  ret = true;
334  break;
335  }
336  }
337 
338  setIsGeometryModified(true);
339 
340  return ret;
341 }
342 
343 inline bool TYAltimetrie::IsInsideFace(const TYTabPoint& pts, OPoint3D& pt) const
344 {
345  if (pts.size() < 3)
346  {
347  return false;
348  } // le triangle n'est pas complet!!!!
349 
350  double x = NAN, y = NAN; // coord 2D du point
351  double xa = NAN, ya = NAN, xb = NAN, yb = NAN, xc = NAN, yc = NAN; // coord 2D des sommets du triangle
352  double bx = NAN, by = NAN, cx = NAN, cy = NAN;
353  double hx = NAN, hy = NAN;
354  double a2 = NAN, a3 = NAN;
355 
356  x = pt._x;
357  y = pt._y;
358  xa = pts[0]._x;
359  ya = pts[0]._y;
360  xb = pts[1]._x;
361  yb = pts[1]._y;
362  xc = pts[2]._x;
363  yc = pts[2]._y;
364 
365  bx = xc - xa;
366  by = yc - ya;
367  cx = xb - xa;
368  cy = yb - ya;
369  hx = x - xa;
370  hy = y - ya;
371  a2 = (bx * hy - by * hx) / (bx * cy - by * cx);
372  a3 = (hx * cy - hy * cx) / (bx * cy - by * cx);
373 
374  if (a2 < 0)
375  {
376  return false;
377  }
378  if (a3 < 0)
379  {
380  return false;
381  }
382  if (a2 + a3 > 1)
383  {
384  return false;
385  }
386 
387  return true;
388 }
389 
391 {
392  // Recherche des indices de la grilles qui incluent les sommets de la boite
393  grid_index idx;
394  bool test = getGridIndices(pt, idx);
395  if (!test)
396  {
397  return 0;
398  }
399  unsigned int pi = idx.pi, qi = idx.qi;
400 
401  TYTabLPPolygon* pDivRef = &(_pSortedFaces[pi][qi]);
402  TYPolygon* pFace = NULL;
403 
404  if (pDivRef != NULL) // sanity check
405  {
406  for (size_t i = 0; i < pDivRef->size(); i++)
407  {
408  pFace = pDivRef->at(i);
409 
410  if (pFace != NULL)
411  {
412  if (IsInsideFace(pFace->getPoints(), pt))
413  {
414  return pFace;
415  }
416  }
417  }
418  }
419 
420  return pFace;
421 }
422 
423 unsigned int TYAltimetrie::getFacesInBox(const OBox2& box, TYTabLPPolygon& tabPolygon)
424 {
425  // Recherche des indices de la grilles qui incluent les sommets de la boite
426  unsigned int iMinMax[4];
427  bool test = getGridIndices(box, iMinMax);
428  if (!test)
429  {
430  return 0;
431  }
432 
433  // Rcupration des faces correspondantes
434  TYTabLPPolygon faces;
435  getFacesinIndices(iMinMax[0], iMinMax[1], iMinMax[2], iMinMax[3], faces);
436 
437  // Test des points des faces par rapport la box
438  // Si au moins un point de la face est dans la box, la face est mise dans la liste
439  unsigned int faceCount = 0; // Compteur de faces
440  for (size_t i = 0; i < faces.size(); i++)
441  {
442  TYTabPoint& pts = faces[i]->getPoints();
443  for (size_t y = 0; y < pts.size(); y++)
444  {
445  if (box.isInside(pts[y]))
446  {
447  tabPolygon.push_back(faces[i]);
448  faceCount++;
449  continue;
450  }
451  }
452  }
453 
454  if (faceCount == 0) // Aucune face trouve
455  {
456  for (size_t i = 0; i < faces.size(); i++)
457  {
458  tabPolygon.push_back(faces[i]);
459  }
460  }
461 
462  return faceCount;
463 }
464 
465 unsigned int TYAltimetrie::getPointsInBox(const OPoint3D& pt0, const OPoint3D& pt1, const OPoint3D& pt2,
466  const OPoint3D& pt3, TYTabPoint& tabPoints)
467 {
468  unsigned int pointCount = 0;
469  OPoint3D pts[4];
470  pts[0] = pt0;
471  pts[1] = pt1;
472  pts[2] = pt2;
473  pts[3] = pt3;
474 
475  unsigned int iMinMax[4];
476 
477  bool test = getGridIndices(pts, iMinMax);
478  if (!test)
479  {
480  return 0;
481  }
482 
483  // Rcupration des faces correspondantes
484  TYTabLPPolygon faces;
485  getFacesinIndices(iMinMax[0], iMinMax[1], iMinMax[2], iMinMax[3], faces);
486 
487  // Test des points des faces par rapport la box
488  // Si le point est dans le primtre, il est ajout la liste
489  for (size_t i = 0; i < faces.size(); i++)
490  {
491  TYTabPoint& ptsFaces = faces[i]->getPoints();
492  for (size_t y = 0; y < ptsFaces.size(); y++)
493  {
494  if (OGeometrie::pointInPolygonRayCasting(ptsFaces[y], pts, 4))
495  {
496  tabPoints.push_back(ptsFaces[y]);
497  pointCount++;
498  }
499  }
500  }
501 
502  return pointCount;
503 }
504 
505 bool TYAltimetrie::getGridIndices(const OPoint3D& pt, grid_index& indXY) const
506 {
507 
508  if ((_gridDX == 0) || (_gridDY == 0))
509  {
510  // This is supposed to be an error case isn't it ? Then we should NOT return SILENTLY.
511  // but raising this exception seem to causes regression in some cases...
512  throw tympan::logic_error("No face in accelerating structure of the altimetry") << tympan_source_loc;
513  }
514  // A sanity check has to be represented by an assert, not an if silencing a failure.
515  assert(_pSortedFaces != NULL && "Sanity Check...");
516 
517  if (!_bbox.isInside2D(pt)) // si le point n'est pas dans la bounding box de l'altimetrie
518  {
519  return false;
520  // The return above preserves legacy behaviour but the exception below should be prefered
521  /*
522  throw tympan::logic_error("Point out of the altimetry's bounding box")
523  << tympan_source_loc << tympan::position_errinfo(pt);
524  */
525  }
526 
527  double p = NAN, q = NAN;
528  unsigned pi = 0, qi = 0;
529  assert(_gridDX != 0);
530  assert(_gridDY != 0);
531  p = (pt._x - _bbox._min._x) / _gridDX;
532  q = (pt._y - _bbox._min._y) / _gridDY;
533  pi = floor(p);
534  qi = floor(q);
535 
536  // In case pt lies on the top-most (resp. right-most) border of the bounding box
537  // p could be exactly _gridSX (resp. q exactly _gridSY) and this needs clipping.
538  pi = std::min(pi, _gridSX - 1);
539  qi = std::min(qi, _gridSY - 1);
540 
541  assert((pi >= 0) && (qi >= 0) && (pi < _gridSX) && (qi < _gridSY));
542 
543  indXY.pi = pi;
544  indXY.qi = qi;
545 
546  return true;
547 }
548 
549 bool TYAltimetrie::getGridIndices(const OPoint3D* pts, unsigned int* iMinMax) const
550 {
551  unsigned minX = std::numeric_limits<unsigned>::max();
552  unsigned maxX = std::numeric_limits<unsigned>::min();
553  unsigned minY = std::numeric_limits<unsigned>::max();
554  unsigned maxY = std::numeric_limits<unsigned>::min();
555 
556  // Test des quatre points et rcupration des indices
557  grid_index iXY;
558 
559  bool res = true;
560 
561  for (size_t i = 0; i < 4; i++)
562  {
563  res &= getGridIndices(pts[i], iXY);
564  minX = std::min(minX, iXY.pi);
565  minY = std::min(minY, iXY.qi);
566  maxX = std::max(maxX, iXY.pi);
567  maxY = std::max(maxY, iXY.qi);
568  }
569 
570  iMinMax[0] = minX;
571  iMinMax[1] = maxX;
572  iMinMax[2] = minY;
573  iMinMax[3] = maxY;
574 
575  return res;
576 }
577 
578 bool TYAltimetrie::getGridIndices(const OBox2& box, unsigned int* iMinMax) const
579 {
580  OPoint3D pts[4];
581 
582  for (int i = 1, j = 0; i < 5; i++, j++)
583  {
584  pts[j] = box.BoxCoord(i);
585  }
586 
587  return getGridIndices(pts, iMinMax);
588 }
589 
590 void TYAltimetrie::getFacesinIndices(unsigned int& minX, unsigned int& maxX, unsigned int& minY,
591  unsigned int& maxY, TYTabLPPolygon& faces)
592 {
593  std::map<LPTYPolygon, int> mapFaces;
594  TYTabLPPolygon* pDivRef = NULL;
595 
596  // Utilisation d'un map pour filtrer les faces
597  for (unsigned int i = minX; i <= maxX; i++)
598  {
599  for (unsigned int j = minY; j <= maxY; j++)
600  {
601  pDivRef = &(_pSortedFaces[i][j]);
602  for (size_t k = 0; k < pDivRef->size(); k++)
603  {
604  mapFaces[pDivRef->at(k)] = i * j * static_cast<int>(k);
605  }
606  }
607  }
608 
609  // Remplissage du tableau
610  std::map<LPTYPolygon, int>::iterator it;
611  for (it = mapFaces.begin(); it != mapFaces.end(); it++)
612  {
613  faces.push_back(it->first);
614  }
615 }
616 
618 {
619  OPoint3D ptTest(pt);
620  ptTest._z = invalid_altitude;
621 
622  const double M_DOUBLE_INFINITE = 1e6; // CAUTION ! Numerical instability:
623  // One could prefer using `std::numeric_limits<double>::infinity()` or
624  // `std::numeric_limits<double>::max()` but both cause the call to
625  // pFace->intersects(...) below to fail silently
626  // Using this big but no too big ad hoc 1E6 seems OK...
627 
628  grid_index idx;
629  if (!getGridIndices(pt, idx))
630  {
631  // Early termination with invalid altitude generaly due to
632  // pt being out the geometrical scope of the altimetry.
633  return ptTest;
634  }
635 
636  OSegment3D segTest;
637  TYTabLPPolygon& divRef = _pSortedFaces[idx.pi][idx.qi];
638 
639  BOOST_FOREACH (const LPTYPolygon& pFace, divRef)
640  {
641  if (IsInsideFace(pFace->getPoints(), ptTest))
642  {
643  segTest._ptA = ptTest;
644  segTest._ptB = ptTest;
645  segTest._ptA._z = +M_DOUBLE_INFINITE;
646  segTest._ptB._z = -M_DOUBLE_INFINITE;
647 
648  if (pFace->intersects(segTest, ptTest, false) == INTERS_OUI)
649  {
650  assert(ptTest._z != invalid_altitude && "Successful intersection expected");
651  return ptTest;
652  }
653  }
654  }
655  assert(ptTest._z == invalid_altitude && "invalid_altitude expected to denote failure");
656  return ptTest;
657 }
658 
660 {
661  pt = projection(pt);
662  if (pt._z == invalid_altitude)
663  {
664  /* OMessageManager::get()->warning(
665  "%s Could not compute valid altitude for point at (%f, %f)",
666  BOOST_CURRENT_FUNCTION, pt._x, pt._y);*/
667  return false;
668  }
669  return true;
670 }
671 
673 {
674  return projection(pt)._z;
675 }
676 
678 {
679  double dHauteurMoyenne = 0;
680  OPoint3D pt;
681  bool bOK = false;
682  int nNbHauteurs = 0;
683  for (unsigned int i = 0; i < pts.size(); i++)
684  {
685  pt = pts[i];
686  bOK = updateAltitude(pt);
687  if (bOK)
688  {
689  dHauteurMoyenne += pts.at(i)._z - pt._z;
690  nNbHauteurs++;
691  }
692  }
693  if (nNbHauteurs == 0 || dHauteurMoyenne < 0) // si l'altitude de la polyligne (info z de TYTabPoint) n'est
694  // pas passee, on renvoie une hauteur nulle
695  {
696  return 0;
697  }
698  dHauteurMoyenne /= nNbHauteurs;
699  return dHauteurMoyenne;
700 }
701 
703 {
704  // On calcule la moyenne de hauteur de tous les points de la polyligne
705  double dHauteur = 0;
706  int i = 0;
707  do
708  {
709  OPoint3D courant(0.0, 0.0, 0.0);
710  courant._x = ptsIn.at(i)._x;
711  courant._y = ptsIn.at(i)._y;
712  bool bOK = updateAltitude(courant);
713  if (!bOK)
714  {
715  return 0;
716  }
717  dHauteur = ptsIn.at(i)._z - courant._z;
718  i++;
719  } while (dHauteur < 0 && i < (int)ptsIn.size());
720  if (dHauteur < 0)
721  {
722  return 0;
723  }
724  return dHauteur;
725 }
726 
728 {
729  // Initialisation of members
730  _pSortedFaces = NULL;
731  _gridSX = 0;
732  _gridSY = 0;
733  _gridDX = 0.0f;
734  _gridDY = 0.0f;
735 }
736 
738 {
739  // clear existing grid
740  if (_pSortedFaces)
741  {
742  for (int k = 0; k < _gridSX; k++)
743  {
744  for (int l = 0; l < _gridSY; l++)
745  {
746  _pSortedFaces[k][l].clear();
747  }
748  delete[] _pSortedFaces[k];
749  }
750  delete[] _pSortedFaces;
751  }
752  initNullGrid();
753 }
754 
755 void TYAltimetrie::initAcceleratingGrid(unsigned to_be_reserved)
756 {
757  assert(_pSortedFaces == NULL && "The accelerating grid must have been cleared.");
758  assert(_gridSX && _gridSY && "The size of the grid must be positive.");
759 
761  for (int k = 0; k < _gridSX; k++)
762  {
764  for (int l = 0; l < _gridSY; l++)
765  {
766  _pSortedFaces[k][l].reserve(to_be_reserved);
767  }
768  }
769 }
770 
772 {
774 
775  _gridSX = other._gridSX;
776  _gridSY = other._gridSY;
777  _gridDX = other._gridDX;
778  _gridDY = other._gridDY;
780 
781  for (int k = 0; k < _gridSX; k++)
782  for (int l = 0; l < _gridSY; l++)
783  {
784  // This is a copy of a STL vector/deque of SmartPtr
785  _pSortedFaces[k][l] = other._pSortedFaces[k][l];
786  }
787 }
All base classes related to 3D manipulation.
#define INTERS_OUI
The intersection exists.
Definition: 3d.h:33
QDomElement DOM_Element
Definition: QT2DOM.h:30
Representation graphique de l'altimetrie (fichier header)
outil IHM pour une altimetrie (fichier header)
TY_EXTENSION_INST(TYAltimetrie)
TY_EXT_GRAPHIC_INST(TYAltimetrie)
#define min(a, b)
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
Definition: TYDefines.h:340
std::vector< LPTYPolygon > TYTabLPPolygon
Collection de pointeurs de TYPolygon.
Definition: TYDefines.h:349
Class to define a box (not necessary parallel to the axis as OBox)
Definition: 3d.h:1380
virtual bool isInside(const OPoint3D &pt) const
Test whether the point is inside the box or not.
Definition: 3d.cpp:1887
OPoint3D BoxCoord(int N) const
Returns the coordinates of one of the box corner. \ We consider that the first corner is the one on t...
Definition: 3d.cpp:1859
virtual bool isInside2D(const OPoint3D &pt) const
Test whether the point is inside the box or not (from upper point of view).
Definition: 3d.cpp:1564
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
Definition: 3d.cpp:1614
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1371
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1372
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
static bool pointInPolygonRayCasting(const OPoint3D &ptP, const OPoint3D *pts, int nbPts)
Tests if a point is inside a polygon using ray casting algorithm.
Definition: 3d.cpp:1046
The 3D point class.
Definition: 3d.h:487
virtual OPrototype * clone() const =0
virtual const char * getClassName() const
Definition: TYElement.h:249
Class to define a segment.
Definition: 3d.h:1089
OPoint3D _ptA
Point A of the segment.
Definition: 3d.h:1201
OPoint3D _ptB
Point B of the segment.
Definition: 3d.h:1203
Triangle class.
Definition: triangle.h:28
OPoint3D _A
First OPoint3D.
Definition: triangle.h:53
int _p1
Index of the first OPoint3D _A.
Definition: triangle.h:49
int _p3
Index of the third OPoint3D _C.
Definition: triangle.h:51
OPoint3D _C
Third OPoint3D.
Definition: triangle.h:55
OPoint3D _B
Second OPoint3D.
Definition: triangle.h:54
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
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.
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.
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}
TYTabLPPolygon _listFaces
Liste des polygones correspondant aux faces de cet altimetrie.
Definition: TYAltimetrie.h:278
std::deque< OPoint3D > _vertices
Definition: TYAltimetrie.h:309
virtual std::string toString() const
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
virtual void setIsGeometryModified(bool isModified)
Definition: TYElement.cpp:253
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
const TYTabPoint & getPoints() const
Definition: TYPolygon.h:123
void setConvex(bool bConvex)
Definition: TYPolygon.h:145
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYPolygon.cpp:112
virtual int intersects(const TYSurfaceInterface *pSurf, OSegment3D &seg) const
Definition: TYPolygon.cpp:271
#define tympan_source_loc
This macro build a source_loc object to be attached to a tympan::Exception.
Definition: exceptions.h:76
boost::error_info< struct tag_position, OPoint3D > position_errinfo
Definition: exceptions.h:16
Integer coordinates into the grid.
Definition: TYAltimetrie.h:230
double pts[3][3]
The base exception class for errors due to invalid data.
Definition: exceptions.h:60
The base exception class for internal logic / algorithmic errors.
Definition: exceptions.h:53