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