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"
30#include "MeshLib/Mesh.h"
32#include "MeshLib/Node.h"
34
35namespace 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
51
52void 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
73void 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
137void 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 auto const [min, max] = aabb.getMinMaxPoints();
187
188 for (auto* pnt : pnts)
189 {
190 // check if pnt is inside of the bounding box of the _surface_mesh
191 // projected onto the y-x plane
192 GeoLib::Point& p(*pnt);
193 if (p[0] < min[0] || max[0] < p[0])
194 {
195 continue;
196 }
197 if (p[1] < min[1] || max[1] < p[1])
198 {
199 continue;
200 }
201
202 p[2] = getMeshElevation(p[0], p[1], min[2], max[2]);
203 }
204}
205
207{
208 double const elevation(_raster->getValueAtPoint(pnt));
209 if (std::abs(elevation - _raster->getHeader().no_data) <
210 std::numeric_limits<double>::epsilon())
211 {
212 return 0.0;
213 }
214 return static_cast<float>(elevation);
215}
216
217double GeoMapper::getMeshElevation(double x, double y, double min_val,
218 double max_val) const
219{
220 const MeshLib::Node* pnt =
222 auto const elements(
224 std::unique_ptr<GeoLib::Point> intersection;
225
226 for (auto const& element : elements)
227 {
228 if (intersection == nullptr &&
229 element->getGeomType() != MeshLib::MeshElemType::LINE)
230 {
232 *element->getNode(0), *element->getNode(1),
233 *element->getNode(2), GeoLib::Point(x, y, max_val),
234 GeoLib::Point(x, y, min_val));
235 }
236
237 if (intersection == nullptr &&
238 element->getGeomType() == MeshLib::MeshElemType::QUAD)
239 {
241 *element->getNode(0), *element->getNode(2),
242 *element->getNode(3), GeoLib::Point(x, y, max_val),
243 GeoLib::Point(x, y, min_val));
244 }
245 }
246 if (intersection)
247 {
248 return (*intersection)[2];
249 }
250 // if something goes wrong, simply take the elevation of the nearest mesh
251 // node
252 return (*(_surface_mesh->getNode(pnt->getID())))[2];
253}
254
262 std::vector<MeshLib::Element const*> const& elements,
263 MathLib::Point3d const& p)
264{
265 for (auto const elem : elements)
266 {
267 std::unique_ptr<MeshLib::Element> elem_2d(elem->clone());
268 // reset/copy the nodes
269 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
270 {
271 elem_2d->setNode(k, new MeshLib::Node(*elem_2d->getNode(k)));
272 }
273 // project to xy
274 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
275 {
276 (*const_cast<MeshLib::Node*>(elem_2d->getNode(k)))[2] = 0.0;
277 }
278 if (elem_2d->isPntInElement(MathLib::Point3d{{{p[0], p[1], 0.0}}}))
279 {
280 // clean up the copied nodes
281 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
282 {
283 delete elem_2d->getNode(k);
284 }
285 return elem;
286 }
287 // clean up the copied nodes
288 for (std::size_t k(0); k < elem_2d->getNumberOfNodes(); ++k)
289 {
290 delete elem_2d->getNode(k);
291 }
292 }
293 return nullptr;
294}
295
296static std::vector<MathLib::Point3d> computeElementSegmentIntersections(
297 MeshLib::Element const& elem, GeoLib::LineSegment const& segment)
298{
299 std::vector<MathLib::Point3d> element_intersections;
300 for (std::size_t k(0); k < elem.getNumberOfEdges(); ++k)
301 {
302 auto const edge =
303 std::unique_ptr<MeshLib::Element const>(elem.getEdge(k));
304 GeoLib::LineSegment elem_segment{
305 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
306 const_cast<MeshLib::Node*>(edge->getNode(0))),
307 0),
308 new GeoLib::Point(*dynamic_cast<MathLib::Point3d*>(
309 const_cast<MeshLib::Node*>(edge->getNode(1))),
310 0),
311 true};
312 std::vector<MathLib::Point3d> const intersections(
313 GeoLib::lineSegmentIntersect2d(segment, elem_segment));
314 element_intersections.insert(end(element_intersections),
315 begin(intersections), end(intersections));
316 }
317 return element_intersections;
318}
319
320static std::vector<GeoLib::LineSegment> createSubSegmentsForElement(
321 std::vector<MathLib::Point3d> const& intersections,
322 MeshLib::Element const* const beg_elem,
323 MeshLib::Element const* const end_elem, MathLib::Point3d const& beg_pnt,
324 MathLib::Point3d const& end_pnt, MeshLib::Element const* const elem)
325{
326 std::vector<GeoLib::LineSegment> sub_segments;
327 if (intersections.size() > 2)
328 {
329 std::stringstream out;
330 out << "element with id " << elem->getID() << " and seg "
331 << " intersecting at more than two edges\n";
332 for (std::size_t k(0); k < intersections.size(); ++k)
333 {
334 out << k << " " << intersections[k] << "\n";
335 }
336 out << "Could not map segment on element. Aborting.\n";
337 OGS_FATAL("{:s}", out.str());
338 }
339
340 if (intersections.size() == 1 && elem == beg_elem)
341 {
342 // The line segment intersects the element that contains the begin
343 // point of the line segment. Here the first sub line segment is
344 // added.
345 if (MathLib::sqrDist(beg_pnt, intersections[0]) >
346 std::numeric_limits<double>::epsilon())
347 {
348 sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0},
349 new GeoLib::Point{intersections[0], 0},
350 true);
351 }
352 }
353
354 if (intersections.size() == 1 && elem == end_elem)
355 {
356 // The line segment intersects the element that contains the end
357 // point of the line segment. Here the last sub line segment is
358 // added.
359 if (MathLib::sqrDist(end_pnt, intersections[0]) >
360 std::numeric_limits<double>::epsilon())
361 {
362 sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
363 new GeoLib::Point{end_pnt, 0}, true);
364 }
365 }
366
367 if (intersections.size() == 1 && (elem != beg_elem && elem != end_elem))
368 {
369 // Since the line segment enters and leaves the element in the same
370 // point there isn't any need to insert a new sub line segment.
371 return sub_segments;
372 }
373
374 // create sub segment for the current element
375 if (intersections.size() == 2)
376 {
377 sub_segments.emplace_back(new GeoLib::Point{intersections[0], 0},
378 new GeoLib::Point{intersections[1], 0}, true);
379 }
380 return sub_segments;
381}
382
383static std::vector<GeoLib::LineSegment> mapLineSegment(
384 GeoLib::LineSegment const& segment,
385 std::vector<MeshLib::Element const*> const& surface_elements,
386 MeshLib::Element const* const beg_elem,
387 MeshLib::Element const* const end_elem)
388{
389 std::vector<GeoLib::LineSegment> sub_segments;
390 MathLib::Point3d const& beg_pnt(segment.getBeginPoint());
391 MathLib::Point3d const& end_pnt(segment.getEndPoint());
392
393 for (auto const elem : surface_elements)
394 {
395 // compute element-segment-intersections (2d in x-y-plane)
396 std::vector<MathLib::Point3d> element_intersections(
397 computeElementSegmentIntersections(*elem, segment));
398 if (element_intersections.empty())
399 {
400 continue;
401 }
402
403 BaseLib::makeVectorUnique(element_intersections);
404
405 std::vector<GeoLib::LineSegment> sub_seg_elem(
406 createSubSegmentsForElement(element_intersections, beg_elem,
407 end_elem, beg_pnt, end_pnt, elem));
408 sub_segments.insert(sub_segments.end(), sub_seg_elem.begin(),
409 sub_seg_elem.end());
410 }
411
412 // beg_elem == nullptr means there isn't any element corresponding to the
413 // beg_pnt and as a consequence the above algorithm doesn't insert a sub
414 // segment
415 if (beg_elem == nullptr)
416 {
417 auto min_dist_segment = std::min_element(
418 sub_segments.begin(), sub_segments.end(),
419 [&beg_pnt](GeoLib::LineSegment const& seg0,
420 GeoLib::LineSegment const& seg1)
421 {
422 // min dist for segment 0
423 const double d0(
424 std::min(MathLib::sqrDist(beg_pnt, seg0.getBeginPoint()),
425 MathLib::sqrDist(beg_pnt, seg0.getEndPoint())));
426 // min dist for segment 1
427 const double d1(
428 std::min(MathLib::sqrDist(beg_pnt, seg1.getBeginPoint()),
429 MathLib::sqrDist(beg_pnt, seg1.getEndPoint())));
430 return d0 < d1;
431 });
432 GeoLib::Point* pnt{
433 MathLib::sqrDist(beg_pnt, min_dist_segment->getBeginPoint()) <
434 MathLib::sqrDist(beg_pnt, min_dist_segment->getEndPoint())
435 ? new GeoLib::Point{min_dist_segment->getBeginPoint()}
436 : new GeoLib::Point{min_dist_segment->getEndPoint()}};
437 sub_segments.emplace_back(new GeoLib::Point{beg_pnt, 0}, pnt, true);
438 }
439 // sort all sub segments for the given segment (beg_pnt, end_pnt)
440 GeoLib::sortSegments(beg_pnt, sub_segments);
441
442 sub_segments.erase(std::unique(sub_segments.begin(), sub_segments.end()),
443 sub_segments.end());
444
445 return sub_segments;
446}
447
450{
451 // create plane equation: n*p = d
452 auto const& p = elem.getNode(0)->asEigenVector3d();
453 Eigen::Vector3d const n(MeshLib::FaceRule::getSurfaceNormal(elem));
454 if (n[2] == 0.0)
455 { // vertical plane, z coordinate is arbitrary
456 q[2] = p[2];
457 }
458 else
459 {
460 double const d(n.dot(p));
461 q[2] = (d - n[0] * q[0] - n[1] * q[1]) / n[2];
462 }
463}
464
465static std::vector<MeshLib::Element const*>
467 MeshLib::MeshElementGrid const& mesh_element_grid,
468 GeoLib::LineSegment const& segment)
469{
470 GeoLib::LineSegment seg_deep_copy(
471 new GeoLib::Point(segment.getBeginPoint()),
472 new GeoLib::Point(segment.getEndPoint()), true);
473 // modify z coordinates such that all surface elements around the line
474 // segment are found
475 seg_deep_copy.getBeginPoint()[2] = mesh_element_grid.getMinPoint()[2];
476 seg_deep_copy.getEndPoint()[2] = mesh_element_grid.getMaxPoint()[2];
477 std::array<MathLib::Point3d, 2> const pnts{
478 {seg_deep_copy.getBeginPoint(), seg_deep_copy.getEndPoint()}};
479 GeoLib::AABB aabb(pnts.cbegin(), pnts.cend());
480
481 // TODO TF: remove after getElementsInVolume interface change
482 auto convert_to_Point3d = [](Eigen::Vector3d const& v) {
483 return MathLib::Point3d{std::array{v[0], v[1], v[2]}};
484 };
485
486 auto const min = convert_to_Point3d(aabb.getMinPoint());
487 auto const max = convert_to_Point3d(aabb.getMaxPoint());
488 auto candidate_elements = mesh_element_grid.getElementsInVolume(min, max);
489
490 // make candidate elements unique
491 BaseLib::makeVectorUnique(candidate_elements);
492
493 return candidate_elements;
494}
495
497 MeshLib::Element const& elem, double rel_eps)
498{
499 // values will be initialized within computeSqrNodeDistanceRange
500 auto const [sqr_min, sqr_max] = MeshLib::computeSqrNodeDistanceRange(elem);
501
502 double const sqr_eps(rel_eps * rel_eps * sqr_min);
503 for (std::size_t k(0); k < elem.getNumberOfNodes(); ++k)
504 {
505 auto const& node(*elem.getNode(k));
506 double const sqr_dist_2d(MathLib::sqrDist2d(p, node));
507 if (sqr_dist_2d < sqr_eps)
508 {
509#ifdef DEBUG_GEOMAPPER
510 std::stringstream out;
511 out.precision(std::numeric_limits<double>::max_digits10);
512 out << "Segment point snapped from " << p;
513#endif
514 p = node;
515#ifdef DEBUG_GEOMAPPER
516 out << "to " << p;
517 DBUG("{:s}", out.str());
518#endif
519 return true;
520 }
521 }
522 return false;
523}
524
528 std::vector<GeoLib::LineSegment> const& sub_segments)
529{
530 std::size_t const j(segment_it.getSegmentNumber());
531 std::size_t new_pnts_cnt(0);
532 for (auto const& segment : sub_segments)
533 {
534 auto const begin_id(points.push_back(
535 new GeoLib::Point(segment.getBeginPoint(), points.size())));
536 if (ply.insertPoint(j + new_pnts_cnt + 1, begin_id))
537 {
538 new_pnts_cnt++;
539 }
540 auto const end_id(points.push_back(
541 new GeoLib::Point(segment.getEndPoint(), points.size())));
542 if (ply.insertPoint(j + new_pnts_cnt + 1, end_id))
543 {
544 new_pnts_cnt++;
545 }
546 }
547 segment_it += new_pnts_cnt;
548}
549
551 GeoLib::Polyline& ply,
552 GeoLib::PointVec& orig_points,
553 MeshLib::MeshElementGrid const& mesh_element_grid)
554{
555 // for each segment ...
556 for (auto segment_it(ply.begin()); segment_it != ply.end(); ++segment_it)
557 {
559 mesh_element_grid, *segment_it));
560
561 auto mapPoint = [&candidate_elements](MathLib::Point3d& p)
562 {
563 auto const* elem(
564 findElementContainingPointXY(candidate_elements, p));
565 if (elem)
566 {
567 if (!snapPointToElementNode(p, *elem, 1e-3))
568 {
569 mapPointOnSurfaceElement(*elem, p);
570 }
571 }
572 return elem;
573 };
574
575 // map segment begin and end point
576 auto const* beg_elem(mapPoint((*segment_it).getBeginPoint()));
577 auto const* end_elem(mapPoint((*segment_it).getEndPoint()));
578
579 // Since the mapping of the segment begin and end points the coordinates
580 // changed. The internal data structures of PointVec are possibly
581 // invalid and hence it is necessary to re-create them.
582 orig_points.resetInternalDataStructures();
583
584 if (beg_elem == end_elem)
585 {
586 // TODO: handle cases: beg_elem == end_elem == nullptr
587 // There are further checks necessary to determine which case we are
588 // in:
589 // 1. beg_elem == end_elem and the segment intersects elements
590 // 2. beg_elem == end_elem and the segment does not intersect any
591 // element, i.e., the segment is located outside of the mesh area
592 //
593 // Case 1 needs additional work.
594 continue;
595 }
596
597 // map the line segment (and if necessary for the mapping partition it)
598 std::vector<GeoLib::LineSegment> sub_segments(mapLineSegment(
599 *segment_it, candidate_elements, beg_elem, end_elem));
600
601 if (sub_segments.empty())
602 {
603 continue;
604 }
605
606 // The case sub_segment.size() == 1 is already handled above.
607
608 if (sub_segments.size() > 1)
609 {
610 insertSubSegments(ply, orig_points, segment_it, sub_segments);
611 }
612 }
613}
614
615void GeoMapper::advancedMapOnMesh(MeshLib::Mesh const& mesh)
616{
617 // 1. extract surface
618 delete _surface_mesh;
619
620 if (mesh.getDimension() < 3)
621 {
622 _surface_mesh = new MeshLib::Mesh(mesh);
623 }
624 else
625 {
626 Eigen::Vector3d const dir({0, 0, -1});
628 mesh, dir, 90 + 1e-6);
629 }
630
631 // 2. compute mesh grid for surface
632 MeshLib::MeshElementGrid const mesh_element_grid(*_surface_mesh);
633
634 // 3. map each polyline
635 auto org_lines(_geo_objects.getPolylineVec(_geo_name));
636 auto org_points(_geo_objects.getPointVecObj(_geo_name));
637 for (auto org_line : *org_lines)
638 {
639 mapPolylineOnSurfaceMesh(*org_line, *org_points, mesh_element_grid);
640 }
641}
642
643} // 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 DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
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:56
Eigen::Vector3d const & getMaxPoint() const
Definition AABB.h:187
Eigen::Vector3d const & getMinPoint() const
Definition AABB.h:180
MinMaxPoints getMinMaxPoints() const
Definition AABB.h:174
Container class for geometric objects.
Definition GEOObjects.h:57
const std::vector< Point * > * getPointVec(const std::string &name) const
POINT * getNearestPoint(P const &pnt) const
Definition Grid.h:469
GeoLib::Point const & getBeginPoint() const
GeoLib::Point const & getEndPoint() const
This class manages pointers to Points in a std::vector along with a name. It also handles the deletio...
Definition PointVec.h:36
std::size_t push_back(Point *pnt)
Definition PointVec.cpp:133
void resetInternalDataStructures()
Definition PointVec.cpp:259
std::size_t getSegmentNumber() const
Definition Polyline.cpp:387
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:40
virtual bool insertPoint(std::size_t pos, std::size_t pnt_id)
Definition Polyline.cpp:55
SegmentIterator begin() const
Definition Polyline.h:188
SegmentIterator end() const
Definition Polyline.h:190
A borehole as a geometric object.
std::size_t size() const
Definition TemplateVec.h:99
std::size_t getID() const
Eigen::Vector3d const & asEigenVector3d() const
Definition Point3d.h:64
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.
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.
std::string & _geo_name
Definition GeoMapper.h:85
void mapStationData(std::vector< GeoLib::Point * > const &points)
Mapping stations, boreholes on a raster or mesh.
double getMeshElevation(double x, double y, double min_val, double max_val) const
GeoLib::GEOObjects & _geo_objects
Definition GeoMapper.h:84
float getDemElevation(GeoLib::Point const &pnt) const
Returns the elevation at Point (x,y) based on a raster.
std::unique_ptr< GeoLib::Raster const > _raster
only necessary for mapping on DEM
Definition GeoMapper.h:92
MeshLib::Mesh * _surface_mesh
only necessary for mapping on mesh
Definition GeoMapper.h:88
void mapOnMesh(MeshLib::Mesh const *const mesh)
Definition GeoMapper.cpp:73
GeoLib::Grid< MeshLib::Node > * _grid
Definition GeoMapper.h:89
void mapPointDataToMeshSurface(std::vector< GeoLib::Point * > const &pnts)
Mapping points on mesh.
virtual const Element * getEdge(unsigned i) const =0
Returns the i-th edge of the element.
virtual unsigned getNumberOfNodes() const =0
virtual const Node * getNode(unsigned idx) const =0
virtual unsigned getNumberOfEdges() const =0
Get the number of edges for this element.
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:89
static Eigen::Vector3d getSurfaceNormal(Element const &e)
Returns the surface normal of a 2D element.
Definition FaceRule.cpp:40
Eigen::Vector3d const & getMinPoint() const
std::vector< MeshLib::Element const * > getElementsInVolume(POINT const &min, POINT const &max) const
Eigen::Vector3d const & getMaxPoint() const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
const Node * getNode(std::size_t idx) const
Get the node with the given index.
Definition Mesh.h:91
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:100
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
Definition Mesh.cpp:256
static MeshLib::Mesh * getMeshSurface(const MeshLib::Mesh &subsfc_mesh, Eigen::Vector3d const &dir, double angle, std::string_view subsfc_node_id_prop_name="", std::string_view subsfc_element_id_prop_name="", std::string_view face_id_prop_name="")
void makeVectorUnique(std::vector< T > &v)
Definition Algorithm.h:180
bool isStation(GeoLib::Point const *pnt)
Definition Station.cpp:77
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)
double sqrDist2d(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.h:123
double sqrDist(MathLib::Point3d const &p0, MathLib::Point3d const &p1)
Definition Point3d.cpp:26
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)
static bool snapPointToElementNode(MathLib::Point3d &p, MeshLib::Element const &elem, double rel_eps)
static std::vector< MathLib::Point3d > computeElementSegmentIntersections(MeshLib::Element const &elem, GeoLib::LineSegment const &segment)
static void insertSubSegments(GeoLib::Polyline &ply, GeoLib::PointVec &points, GeoLib::Polyline::SegmentIterator &segment_it, std::vector< GeoLib::LineSegment > const &sub_segments)
static void mapPointOnSurfaceElement(MeshLib::Element const &elem, MathLib::Point3d &q)
static std::vector< MeshLib::Element const * > getCandidateElementsForLineSegmentIntersection(MeshLib::MeshElementGrid const &mesh_element_grid, GeoLib::LineSegment const &segment)
static void mapPolylineOnSurfaceMesh(GeoLib::Polyline &ply, GeoLib::PointVec &orig_points, MeshLib::MeshElementGrid const &mesh_element_grid)
static MeshLib::Element const * findElementContainingPointXY(std::vector< MeshLib::Element const * > const &elements, MathLib::Point3d const &p)
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)
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:136