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