OGS 6.2.1-97-g73d1aeda3
GeoMapper.cpp
Go to the documentation of this file.
1 
15 #include "GeoMapper.h"
16 
17 #include <algorithm>
18 #include <sstream>
19 #include <numeric>
20 
21 #include <logog/include/logog.hpp>
22 
23 #include "BaseLib/Algorithm.h"
24 
25 #include "GeoLib/AABB.h"
27 #include "GeoLib/GEOObjects.h"
28 #include "GeoLib/Raster.h"
29 #include "GeoLib/StationBorehole.h"
30 
31 #include "MeshLib/Mesh.h"
34 #include "MeshLib/Node.h"
38 
39 namespace MeshGeoToolsLib {
40 
41 GeoMapper::GeoMapper(GeoLib::GEOObjects &geo_objects, const std::string &geo_name)
42  : _geo_objects(geo_objects), _geo_name(const_cast<std::string&>(geo_name)),
43  _surface_mesh(nullptr), _grid(nullptr), _raster(nullptr)
44 {
45 }
46 
48 {
49  delete _surface_mesh;
50 }
51 
52 void GeoMapper::mapOnDEM(std::unique_ptr<GeoLib::Raster const> raster)
53 {
54  std::vector<GeoLib::Point*> const* pnts(_geo_objects.getPointVec(_geo_name));
55  if (! pnts) {
56  ERR("Geometry '%s' does not exist.", _geo_name.c_str());
57  return;
58  }
59  _raster = std::move(raster);
60 
61  if (GeoLib::isStation((*pnts)[0])) {
62  mapStationData(*pnts);
63  } else {
64  mapPointDataToDEM(*pnts);
65  }
66 }
67 
68 void GeoMapper::mapOnMesh(MeshLib::Mesh const*const mesh)
69 {
70  std::vector<GeoLib::Point*> const* pnts(_geo_objects.getPointVec(_geo_name));
71  if (! pnts) {
72  ERR("Geometry '%s' does not exist.", _geo_name.c_str());
73  return;
74  }
75 
76  // the variable _surface_mesh is reused below, so first the existing
77  // _surface_mesh has to be cleaned up
78 
79  delete _surface_mesh;
80 
81  if (mesh->getDimension() < 3)
82  {
83  _surface_mesh = new MeshLib::Mesh(*mesh);
84  }
85  else
86  {
87  const MathLib::Vector3 dir(0,0,-1);
89  }
90 
91  // init grid
92  MathLib::Point3d origin(std::array<double,3>{{0,0,0}});
93  MathLib::Vector3 normal(0,0,-1);
94  std::vector<MeshLib::Node> flat_nodes;
95  flat_nodes.reserve(_surface_mesh->getNumberOfNodes());
96  // copy nodes and project the copied nodes to the x-y-plane, i.e. set
97  // z-coordinate to zero
98  for (auto n_ptr : _surface_mesh->getNodes()) {
99  flat_nodes.emplace_back(*n_ptr);
100  flat_nodes.back()[2] = 0.0;
101  }
102  _grid = new GeoLib::Grid<MeshLib::Node>(flat_nodes.cbegin(), flat_nodes.cend());
103 
104  if (GeoLib::isStation((*pnts)[0])) {
105  mapStationData(*pnts);
106  } else {
108  }
109 
110  delete _grid;
111 }
112 
114 {
115  std::vector<GeoLib::Point*> const* points (this->_geo_objects.getPointVec(this->_geo_name));
116  if (points == nullptr)
117  {
118  ERR("Geometry '%s' not found.", this->_geo_name.c_str());
119  return;
120  }
121  std::for_each(points->begin(), points->end(), [value](GeoLib::Point* pnt){ (*pnt)[2] = value; });
122 }
123 
124 void GeoMapper::mapStationData(std::vector<GeoLib::Point*> const& points)
125 {
126  double min_val(0);
127  double max_val(0);
128  if (_surface_mesh)
129  {
130  GeoLib::AABB bounding_box(
131  _surface_mesh->getNodes().begin(), _surface_mesh->getNodes().end());
132  min_val = bounding_box.getMinPoint()[2];
133  max_val = bounding_box.getMaxPoint()[2];
134  }
135 
136  for (auto * pnt : points)
137  {
138  double offset =
139  (_grid)
140  ? (getMeshElevation((*pnt)[0], (*pnt)[1], min_val, max_val) -
141  (*pnt)[2])
142  : getDemElevation(*pnt);
143 
144  if (!GeoLib::isBorehole(pnt))
145  {
146  continue;
147  }
148  auto const& layers = static_cast<GeoLib::StationBorehole*>(pnt)->getProfile();
149  for (auto * layer_pnt : layers) {
150  (*layer_pnt)[2] = (*layer_pnt)[2] + offset;
151  }
152  }
153 }
154 
155 void GeoMapper::mapPointDataToDEM(std::vector<GeoLib::Point*> const& points)
156 {
157  for (auto * pnt : points)
158  {
159  GeoLib::Point &p(*pnt);
160  p[2] = getDemElevation(p);
161  }
162 }
163 
164 void GeoMapper::mapPointDataToMeshSurface(std::vector<GeoLib::Point*> const& pnts)
165 {
166  GeoLib::AABB const aabb(
167  _surface_mesh->getNodes().cbegin(), _surface_mesh->getNodes().cend());
168  double const min_val(aabb.getMinPoint()[2]);
169  double const max_val(aabb.getMaxPoint()[2]);
170 
171  for (auto * pnt : pnts) {
172  // check if pnt is inside of the bounding box of the _surface_mesh
173  // projected onto the y-x plane
174  GeoLib::Point &p(*pnt);
175  if (p[0] < aabb.getMinPoint()[0] || aabb.getMaxPoint()[0] < p[0])
176  {
177  continue;
178  }
179  if (p[1] < aabb.getMinPoint()[1] || aabb.getMaxPoint()[1] < p[1])
180  {
181  continue;
182  }
183 
184  p[2] = getMeshElevation(p[0], p[1], min_val, max_val);
185  }
186 }
187 
189 {
190  double const elevation (_raster->getValueAtPoint(pnt));
191  if (std::abs(elevation - _raster->getHeader().no_data) <
192  std::numeric_limits<double>::epsilon())
193  {
194  return 0.0;
195  }
196  return static_cast<float>(elevation);
197 }
198 
200  double x, double y, double min_val, double max_val) const
201 {
202  const MeshLib::Node* pnt =
203  _grid->getNearestPoint(MathLib::Point3d{{{x, y, 0}}});
204  const std::vector<MeshLib::Element*> elements(
205  _surface_mesh->getNode(pnt->getID())->getElements());
206  std::unique_ptr<GeoLib::Point> intersection;
207 
208  for (auto const & element : elements)
209  {
210  if (intersection == nullptr &&
211  element->getGeomType() != MeshLib::MeshElemType::LINE)
212  {
213  intersection = GeoLib::triangleLineIntersection(
214  *element->getNode(0), *element->getNode(1),
215  *element->getNode(2), GeoLib::Point(x, y, max_val),
216  GeoLib::Point(x, y, min_val));
217  }
218 
219  if (intersection == nullptr &&
220  element->getGeomType() == MeshLib::MeshElemType::QUAD)
221  {
222  intersection = GeoLib::triangleLineIntersection(
223  *element->getNode(0), *element->getNode(2),
224  *element->getNode(3), GeoLib::Point(x, y, max_val),
225  GeoLib::Point(x, y, min_val));
226  }
227  }
228  if (intersection)
229  {
230  return (*intersection)[2];
231  }
232  // if something goes wrong, simply take the elevation of the nearest mesh node
233  return (*(_surface_mesh->getNode(pnt->getID())))[2];
234 }
235 
242  std::vector<MeshLib::Element const*> const& elements,
243  MathLib::Point3d const& p)
244 {
245  for (auto const elem : elements) {
246  std::unique_ptr<MeshLib::Element> elem_2d(elem->clone());
247  // reset/copy the nodes
248  for (std::size_t k(0); k<elem_2d->getNumberOfNodes(); ++k) {
249  elem_2d->setNode(k, new MeshLib::Node(*elem_2d->getNode(k)));
250  }
251  // project to xy
252  for (std::size_t k(0); k<elem_2d->getNumberOfNodes(); ++k) {
253  (*const_cast<MeshLib::Node*>(elem_2d->getNode(k)))[2] = 0.0;
254  }
255  if (elem_2d->isPntInElement(MathLib::Point3d{ {{p[0], p[1], 0.0}} })) {
256  // clean up the copied nodes
257  for (std::size_t k(0); k<elem_2d->getNumberOfNodes(); ++k) {
258  delete elem_2d->getNode(k);
259  }
260  return elem;
261  }
262  // clean up the copied nodes
263  for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
264  {
265  delete elem_2d->getNode(k);
266  }
267  }
268  return nullptr;
269 }
270 
271 static std::vector<MathLib::Point3d> computeElementSegmentIntersections(
272  MeshLib::Element const& elem, GeoLib::LineSegment const& segment)
273 {
274  std::vector<MathLib::Point3d> element_intersections;
275  for (std::size_t k(0); k < elem.getNumberOfEdges(); ++k)
276  {
277  auto const edge =
278  std::unique_ptr<MeshLib::Element const>(elem.getEdge(k));
279  GeoLib::LineSegment elem_segment{
280  new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
281  const_cast<MeshLib::Node*>(edge->getNode(0))), 0),
282  new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
283  const_cast<MeshLib::Node*>(edge->getNode(1))), 0),
284  true};
285  std::vector<MathLib::Point3d> const intersections(
286  GeoLib::lineSegmentIntersect2d(segment, elem_segment));
287  element_intersections.insert(end(element_intersections),
288  begin(intersections), end(intersections));
289  }
290  return element_intersections;
291 }
292 
293 static std::vector<GeoLib::LineSegment> createSubSegmentsForElement(
294  std::vector<MathLib::Point3d> const& intersections,
295  MeshLib::Element const* const beg_elem,
296  MeshLib::Element const* const end_elem, MathLib::Point3d const& beg_pnt,
297  MathLib::Point3d const& end_pnt, MeshLib::Element const* const elem)
298 {
299  std::vector<GeoLib::LineSegment> sub_segments;
300  if (intersections.size() > 2) {
301  std::stringstream out;
302  out << "element with id " << elem->getID() << " and seg "
303  << " intersecting at more than two edges\n";
304  for (std::size_t k(0); k < intersections.size(); ++k)
305  {
306  out << k << " " << intersections[k] << "\n";
307  }
308  out << "Could not map segment on element. Aborting.\n";
309  OGS_FATAL("%s", out.str().c_str());
310  }
311 
312  if (intersections.size() == 1 && elem == beg_elem)
313  {
314  // The line segment intersects the element that contains the begin
315  // point of the line segment. Here the first sub line segment is
316  // added.
317  if (MathLib::sqrDist(beg_pnt, intersections[0]) >
318  std::numeric_limits<double>::epsilon())
319  {
320  sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0},
321  new GeoLib::Point{intersections[0], 0},
322  true);
323  }
324  }
325 
326  if (intersections.size() == 1 && elem == end_elem)
327  {
328  // The line segment intersects the element that contains the end
329  // point of the line segment. Here the last sub line segment is
330  // added.
331  if (MathLib::sqrDist(end_pnt, intersections[0]) >
332  std::numeric_limits<double>::epsilon())
333  {
334  sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
335  new GeoLib::Point{end_pnt, 0}, true);
336  }
337  }
338 
339  if (intersections.size() == 1 && (elem != beg_elem && elem != end_elem))
340  {
341  // Since the line segment enters and leaves the element in the same
342  // point there isn't any need to insert a new sub line segment.
343  return sub_segments;
344  }
345 
346  // create sub segment for the current element
347  if (intersections.size() == 2)
348  {
349  sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
350  new GeoLib::Point{intersections[1], 0}, true);
351  }
352  return sub_segments;
353 }
354 
355 static std::vector<GeoLib::LineSegment> mapLineSegment(
356  GeoLib::LineSegment const& segment,
357  std::vector<MeshLib::Element const*> const& surface_elements,
358  MeshLib::Element const* const beg_elem,
359  MeshLib::Element const* const end_elem)
360 {
361  std::vector<GeoLib::LineSegment> sub_segments;
362  MathLib::Point3d const& beg_pnt(segment.getBeginPoint());
363  MathLib::Point3d const& end_pnt(segment.getEndPoint());
364 
365  for (auto const elem : surface_elements) {
366  // compute element-segment-intersections (2d in x-y-plane)
367  std::vector<MathLib::Point3d> element_intersections(
368  computeElementSegmentIntersections(*elem, segment));
369  if (element_intersections.empty())
370  {
371  continue;
372  }
373 
374  BaseLib::makeVectorUnique(element_intersections);
375 
376  std::vector<GeoLib::LineSegment> sub_seg_elem(
377  createSubSegmentsForElement(element_intersections, beg_elem,
378  end_elem, beg_pnt, end_pnt, elem));
379  sub_segments.insert(sub_segments.end(), sub_seg_elem.begin(),
380  sub_seg_elem.end());
381  }
382 
383  // beg_elem == nullptr means there isn't any element corresponding to the
384  // beg_pnt and as a consequence the above algorithm doesn't insert a sub
385  // segment
386  if (beg_elem == nullptr)
387  {
388  auto min_dist_segment = std::min_element(
389  sub_segments.begin(), sub_segments.end(),
390  [&beg_pnt](GeoLib::LineSegment const& seg0,
391  GeoLib::LineSegment const& seg1)
392  {
393  // min dist for segment 0
394  const double d0(
395  std::min(MathLib::sqrDist(beg_pnt, seg0.getBeginPoint()),
396  MathLib::sqrDist(beg_pnt, seg0.getEndPoint())));
397  // min dist for segment 1
398  const double d1(
399  std::min(MathLib::sqrDist(beg_pnt, seg1.getBeginPoint()),
400  MathLib::sqrDist(beg_pnt, seg1.getEndPoint())));
401  return d0 < d1;
402  });
403  GeoLib::Point * pnt{
404  MathLib::sqrDist(beg_pnt, min_dist_segment->getBeginPoint()) <
405  MathLib::sqrDist(beg_pnt, min_dist_segment->getEndPoint())
406  ? new GeoLib::Point{min_dist_segment->getBeginPoint()}
407  : new GeoLib::Point{min_dist_segment->getEndPoint()}};
408  sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, pnt, true);
409  }
410  // sort all sub segments for the given segment (beg_pnt, end_pnt)
411  GeoLib::sortSegments(beg_pnt, sub_segments);
412 
413  sub_segments.erase(std::unique(sub_segments.begin(), sub_segments.end()),
414  sub_segments.end());
415 
416  return sub_segments;
417 }
418 
421 {
422  // create plane equation: n*p = d
423  MathLib::Vector3 const& p(*(elem.getNode(0)));
425  if (n[2] == 0.0) { // vertical plane, z coordinate is arbitrary
426  q[2] = p[2];
427  } else {
428  double const d(MathLib::scalarProduct(n, p));
429  q[2] = (d - n[0]*q[0] - n[1]*q[1])/n[2];
430  }
431 }
432 
433 static std::vector<MeshLib::Element const*>
435  MeshLib::MeshElementGrid const& mesh_element_grid,
436  GeoLib::LineSegment const& segment)
437 {
438  GeoLib::LineSegment seg_deep_copy(
439  new GeoLib::Point(segment.getBeginPoint()),
440  new GeoLib::Point(segment.getEndPoint()), true);
441  // modify z coordinates such that all surface elements around the line
442  // segment are found
443  seg_deep_copy.getBeginPoint()[2] = mesh_element_grid.getMinPoint()[2];
444  seg_deep_copy.getEndPoint()[2] = mesh_element_grid.getMaxPoint()[2];
445  std::array<MathLib::Point3d, 2> const pnts{
446  {seg_deep_copy.getBeginPoint(), seg_deep_copy.getEndPoint()}};
447  GeoLib::AABB aabb(pnts.cbegin(), pnts.cend());
448 
449  auto candidate_elements = mesh_element_grid.getElementsInVolume(
450  aabb.getMinPoint(), aabb.getMaxPoint());
451 
452  // make candidate elements unique
453  BaseLib::makeVectorUnique(candidate_elements);
454 
455  return candidate_elements;
456 }
457 
459  MeshLib::Element const& elem, double rel_eps)
460 {
461  // values will be initialized within computeSqrNodeDistanceRange
462  double sqr_min;
463  double sqr_max;
464  elem.computeSqrNodeDistanceRange(sqr_min, sqr_max);
465 
466  double const sqr_eps(rel_eps*rel_eps * sqr_min);
467  for (std::size_t k(0); k<elem.getNumberOfNodes(); ++k) {
468  auto const& node(*elem.getNode(k));
469  double const sqr_dist_2d(MathLib::sqrDist2d(p, node));
470  if (sqr_dist_2d < sqr_eps) {
471 #ifdef DEBUG_GEOMAPPER
472  std::stringstream out;
473  out.precision(std::numeric_limits<double>::digits10);
474  out << "Segment point snapped from " << p;
475 #endif
476  p = node;
477 #ifdef DEBUG_GEOMAPPER
478  out << "to " << p;
479  DBUG("%s", out.str().c_str());
480 #endif
481  return true;
482  }
483  }
484  return false;
485 }
486 
487 static void insertSubSegments(
488  GeoLib::Polyline& ply, GeoLib::PointVec& points,
490  std::vector<GeoLib::LineSegment> const& sub_segments)
491 {
492  std::size_t const j(segment_it.getSegmentNumber());
493  std::size_t new_pnts_cnt(0);
494  for (auto const& segment : sub_segments)
495  {
496  auto const begin_id(points.push_back(
497  new GeoLib::Point(segment.getBeginPoint(), points.size())));
498  if (ply.insertPoint(j + new_pnts_cnt + 1, begin_id))
499  {
500  new_pnts_cnt++;
501  }
502  auto const end_id(points.push_back(
503  new GeoLib::Point(segment.getEndPoint(), points.size())));
504  if (ply.insertPoint(j + new_pnts_cnt + 1, end_id))
505  {
506  new_pnts_cnt++;
507  }
508  }
509  segment_it += new_pnts_cnt;
510 }
511 
513  GeoLib::Polyline& ply,
514  GeoLib::PointVec& orig_points,
515  MeshLib::MeshElementGrid const& mesh_element_grid)
516 {
517  // for each segment ...
518  for (auto segment_it(ply.begin()); segment_it != ply.end(); ++segment_it)
519  {
520  auto candidate_elements(getCandidateElementsForLineSegmentIntersection(
521  mesh_element_grid, *segment_it));
522 
523  auto mapPoint = [&candidate_elements](MathLib::Point3d& p) {
524  auto const* elem(
525  findElementContainingPointXY(candidate_elements, p));
526  if (elem)
527  {
528  if (!snapPointToElementNode(p, *elem, 1e-3))
529  {
530  mapPointOnSurfaceElement(*elem, p);
531  }
532  }
533  return elem;
534  };
535 
536  // map segment begin and end point
537  auto const* beg_elem(mapPoint((*segment_it).getBeginPoint()));
538  auto const* end_elem(mapPoint((*segment_it).getEndPoint()));
539 
540  // Since the mapping of the segment begin and end points the coordinates
541  // changed. The internal data structures of PointVec are possibly
542  // invalid and hence it is necessary to re-create them.
543  orig_points.resetInternalDataStructures();
544 
545  if (beg_elem == end_elem) {
546  // TODO: handle cases: beg_elem == end_elem == nullptr
547  // There are further checks necessary to determine which case we are
548  // in:
549  // 1. beg_elem == end_elem and the segment intersects elements
550  // 2. beg_elem == end_elem and the segment does not intersect any
551  // element, i.e., the segment is located outside of the mesh area
552  //
553  // Case 1 needs additional work.
554  continue;
555  }
556 
557  // map the line segment (and if necessary for the mapping partition it)
558  std::vector<GeoLib::LineSegment> sub_segments(mapLineSegment(
559  *segment_it, candidate_elements, beg_elem, end_elem));
560 
561  if (sub_segments.empty())
562  {
563  continue;
564  }
565 
566  // The case sub_segment.size() == 1 is already handled above.
567 
568  if (sub_segments.size() > 1)
569  {
570  insertSubSegments(ply, orig_points, segment_it, sub_segments);
571  }
572  }
573 }
574 
576 {
577  // 1. extract surface
578 
579  delete _surface_mesh;
580 
581  if (mesh.getDimension()<3) {
582  _surface_mesh = new MeshLib::Mesh(mesh);
583  } else {
584  const MathLib::Vector3 dir(0,0,-1);
585  _surface_mesh =
587  }
588 
589  // 2. compute mesh grid for surface
590  MeshLib::MeshElementGrid const mesh_element_grid(*_surface_mesh);
591 
592  // 3. map each polyline
593  auto org_lines(_geo_objects.getPolylineVec(_geo_name));
594  auto org_points(_geo_objects.getPointVecObj(_geo_name));
595  for (auto org_line : *org_lines)
596  {
597  mapPolylineOnSurfaceMesh(*org_line, *org_points, mesh_element_grid);
598  }
599 }
600 
601 } // end namespace MeshGeoToolsLib
Implementation of heuristic search length strategy.
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition: Mesh.h:99
Container class for geometric objects.
Definition: GEOObjects.h:62
double sqrDist(const double *p0, const double *p1)
Definition: MathTools.h:83
const Node * getNode(std::size_t idx) const
Get the node with the given index.
Definition: Mesh.h:84
std::string & _geo_name
Definition: GeoMapper.h:86
double getMeshElevation(double x, double y, double min_val, double max_val) const
Definition: GeoMapper.cpp:199
std::vector< MathLib::Point3d > lineSegmentIntersect2d(GeoLib::LineSegment const &ab, GeoLib::LineSegment const &cd)
GeoLib::GEOObjects & _geo_objects
Definition: GeoMapper.h:85
void mapOnDEM(std::unique_ptr< GeoLib::Raster const > raster)
Maps geometry based on a raster file.
Definition: GeoMapper.cpp:52
static bool snapPointToElementNode(MathLib::Point3d &p, MeshLib::Element const &elem, double rel_eps)
Definition: GeoMapper.cpp:458
GeoLib::Point const & getBeginPoint() const
Definition: LineSegment.cpp:62
std::size_t size() const
Definition: TemplateVec.h:107
MeshLib::Mesh * _surface_mesh
only necessary for mapping on mesh
Definition: GeoMapper.h:89
Definition of the Node class.
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
Definition: GEOObjects.cpp:197
void makeVectorUnique(std::vector< T > &v)
Definition: Algorithm.h:195
A borehole as a geometric object.
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition: Point3d.h:58
Definition of the StationBorehole class.
Definition of the GeoMapper class.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:105
Definition of the GeoLib::Raster class.
Definition of the AABB class.
static void mapPolylineOnSurfaceMesh(GeoLib::Polyline &ply, GeoLib::PointVec &orig_points, MeshLib::MeshElementGrid const &mesh_element_grid)
Definition: GeoMapper.cpp:512
MathLib::Point3d const & getMinPoint() const
Definition: AABB.h:166
Definition of analytical geometry functions.
Definition of the Mesh class.
bool isBorehole(GeoLib::Point const *pnt)
GeoLib::Grid< MeshLib::Node > * _grid
Definition: GeoMapper.h:90
std::size_t getID() const
Definition: Point3dWithID.h:62
std::unique_ptr< GeoLib::Raster const > _raster
only necessary for mapping on DEM
Definition: GeoMapper.h:93
void setNode(unsigned idx, Node *node)
Definition: Element.cpp:172
void advancedMapOnMesh(MeshLib::Mesh const &mesh)
Definition: GeoMapper.cpp:575
std::unique_ptr< GeoLib::Point > triangleLineIntersection(MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, MathLib::Point3d const &p, MathLib::Point3d const &q)
static void mapPointOnSurfaceElement(MeshLib::Element const &elem, MathLib::Point3d &q)
Definition: GeoMapper.cpp:419
Definition of the MeshSurfaceExtraction class.
void sortSegments(MathLib::Point3d const &seg_beg_pnt, std::vector< GeoLib::LineSegment > &sub_segments)
static void insertSubSegments(GeoLib::Polyline &ply, GeoLib::PointVec &points, GeoLib::Polyline::SegmentIterator &segment_it, std::vector< GeoLib::LineSegment > const &sub_segments)
Definition: GeoMapper.cpp:487
static std::vector< MathLib::Point3d > computeElementSegmentIntersections(MeshLib::Element const &elem, GeoLib::LineSegment const &segment)
Definition: GeoMapper.cpp:271
void resetInternalDataStructures()
Definition: PointVec.cpp:257
void mapToConstantValue(double value)
Maps geometry to a constant elevation value.
Definition: GeoMapper.cpp:113
static const double q
static MeshLib::Element const * findElementContainingPointXY(std::vector< MeshLib::Element const *> const &elements, MathLib::Point3d const &p)
Definition: GeoMapper.cpp:241
void mapOnMesh(MeshLib::Mesh const *const mesh)
Definition: GeoMapper.cpp:68
static std::vector< MeshLib::Element const * > getCandidateElementsForLineSegmentIntersection(MeshLib::MeshElementGrid const &mesh_element_grid, GeoLib::LineSegment const &segment)
Definition: GeoMapper.cpp:434
T scalarProduct(T const *const v0, T const *const v1)
Definition: MathTools.h:28
static MathLib::Vector3 getSurfaceNormal(const Element *e)
Returns the surface normal of a 2D element.
Definition: FaceRule.cpp:35
GeoLib::Point const & getEndPoint() const
Definition: LineSegment.cpp:72
POINT * getNearestPoint(P const &pnt) const
Definition: Grid.h:422
MathLib::Point3d const & getMaxPoint() const
const PointVec * getPointVecObj(const std::string &name) const
Definition: GEOObjects.cpp:76
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition: AABB.h:50
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
Definition: Polyline.cpp:73
const std::vector< Point * > * getPointVec(const std::string &name) const
Definition: GEOObjects.cpp:63
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition: Polyline.h:50
virtual unsigned getNumberOfEdges() const =0
Get the number of edges for this element.
virtual void computeSqrNodeDistanceRange(double &min, double &max, bool check_allnodes=true) const
Compute the minimum and maximum node distances for this element.
Definition: Element.cpp:115
SegmentIterator begin() const
Definition: Polyline.h:191
virtual const Element * getEdge(unsigned i) const =0
Returns the i-th edge of the element.
TemplateElement< PointRule1 > Point
Definition: Point.h:19
void mapPointDataToMeshSurface(std::vector< GeoLib::Point *> const &pnts)
Mapping points on mesh.
Definition: GeoMapper.cpp:164
GeoMapper(GeoLib::GEOObjects &geo_objects, const std::string &geo_name)
Definition: GeoMapper.cpp:41
This class manages pointers to Points in a std::vector along with a name. It also handles the deletin...
Definition: PointVec.h:39
static MeshLib::Mesh * getMeshSurface(const MeshLib::Mesh &subsfc_mesh, const MathLib::Vector3 &dir, double angle, std::string const &subsfc_node_id_prop_name="", std::string const &subsfc_element_id_prop_name="", std::string const &face_id_prop_name="")
static std::vector< GeoLib::LineSegment > createSubSegmentsForElement(std::vector< MathLib::Point3d > const &intersections, MeshLib::Element const *const beg_elem, MeshLib::Element const *const end_elem, MathLib::Point3d const &beg_pnt, MathLib::Point3d const &end_pnt, MeshLib::Element const *const elem)
Definition: GeoMapper.cpp:293
float getDemElevation(GeoLib::Point const &pnt) const
Returns the elevation at Point (x,y) based on a raster.
Definition: GeoMapper.cpp:188
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
virtual std::size_t getID() const final
Returns the ID of the element.
Definition: Element.h:90
Definition of the projectMeshOntoPlane.
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
virtual unsigned getNumberOfNodes() const =0
Returns the number of all nodes including both linear and nonlinear nodes.
std::size_t push_back(Point *pnt)
Definition: PointVec.cpp:131
Definition of the Element class.
MathLib::Point3d const & getMinPoint() const
static std::vector< GeoLib::LineSegment > mapLineSegment(GeoLib::LineSegment const &segment, std::vector< MeshLib::Element const *> const &surface_elements, MeshLib::Element const *const beg_elem, MeshLib::Element const *const end_elem)
Definition: GeoMapper.cpp:355
void mapPointDataToDEM(std::vector< GeoLib::Point *> const &points)
Mapping points on a raster.
Definition: GeoMapper.cpp:155
std::size_t getSegmentNumber() const
Definition: Polyline.cpp:501
void mapStationData(std::vector< GeoLib::Point *> const &points)
Mapping stations, boreholes on a raster or mesh.
Definition: GeoMapper.cpp:124
bool isStation(GeoLib::Point const *pnt)
Definition: Station.cpp:83
std::vector< MeshLib::Element const * > getElementsInVolume(POINT const &min, POINT const &max) const
const Node * getNode(unsigned i) const
Definition: Element.cpp:158
SegmentIterator end() const
Definition: Polyline.h:196