OGS
MeshGeoToolsLib::BoundaryElementsAlongPolyline Class Reference

Detailed Description

This class collects element edges located along a polyline. Note that internal edges are not collected in this class.

Definition at line 32 of file BoundaryElementsAlongPolyline.h.

#include <BoundaryElementsAlongPolyline.h>

Collaboration diagram for MeshGeoToolsLib::BoundaryElementsAlongPolyline:
[legend]

Public Member Functions

 BoundaryElementsAlongPolyline (MeshLib::Mesh const &mesh, MeshNodeSearcher const &mshNodeSearcher, GeoLib::Polyline const &ply)
 
virtual ~BoundaryElementsAlongPolyline ()
 destructor
 
GeoLib::Polyline const & getPolyline () const
 
std::vector< MeshLib::Element * > const & getBoundaryElements () const
 

Private Attributes

GeoLib::Polyline const & _ply
 
std::vector< MeshLib::Element * > _boundary_elements
 

Constructor & Destructor Documentation

◆ BoundaryElementsAlongPolyline()

MeshGeoToolsLib::BoundaryElementsAlongPolyline::BoundaryElementsAlongPolyline ( MeshLib::Mesh const & mesh,
MeshNodeSearcher const & mshNodeSearcher,
GeoLib::Polyline const & ply )

Constructor

Parameters
mesha mesh object
mshNodeSearchera MeshNodeSearcher object which is internally used to search mesh nodes
plya polyline object where edges are searched

Definition at line 102 of file BoundaryElementsAlongPolyline.cpp.

105 : _ply(ply)
106{
107 // search nodes and elements located along the polyline
108 auto node_ids_on_poly = mshNodeSearcher.getMeshNodeIDs(ply);
109 MeshLib::ElementSearch es(mesh);
110 es.searchByNodeIDs(node_ids_on_poly);
111 auto const& ele_ids_near_ply = es.getSearchedElementIDs();
112
113 // check all edges of the elements near the polyline
114 for (auto ele_id : ele_ids_near_ply)
115 {
116 auto* e = mesh.getElement(ele_id);
117 // skip line elements
118 if (e->getDimension() == 1)
119 {
120 continue;
121 }
122 // skip internal elements
123 if (!e->isBoundaryElement())
124 {
125 continue;
126 }
127 // find edges on the polyline
128 for (unsigned i = 0; i < e->getNumberOfEdges(); i++)
129 {
130 auto* edge = e->getEdge(i);
131 // check if all edge nodes are along the polyline (if yes, store a
132 // distance)
133 std::vector<std::size_t> edge_node_distances_along_ply;
134 if (includesAllEdgeNodeIDs(node_ids_on_poly, *edge,
135 edge_node_distances_along_ply))
136 {
137 auto* new_edge = modifyEdgeNodeOrdering(
138 *edge, ply, edge_node_distances_along_ply,
139 node_ids_on_poly);
140 if (edge != new_edge)
141 {
142 delete edge;
143 }
144 _boundary_elements.push_back(new_edge);
145 }
146 else
147 {
148 delete edge;
149 }
150 }
151 }
152
153 // The sort was necessary in OGS-5 for some reason. I'm not sure if it is
154 // needed anymore in OGS-6.
155 // sort picked edges according to a distance of their first node along the
156 // polyline
157 std::sort(begin(_boundary_elements), end(_boundary_elements),
159 {
160 std::size_t dist1 = std::distance(
161 node_ids_on_poly.begin(),
162 std::find(node_ids_on_poly.begin(),
163 node_ids_on_poly.end(), getNodeIndex(*e1, 0)));
164 std::size_t dist2 = std::distance(
165 node_ids_on_poly.begin(),
166 std::find(node_ids_on_poly.begin(),
167 node_ids_on_poly.end(), getNodeIndex(*e2, 0)));
168 return (dist1 < dist2);
169 });
170}
Element search class.
std::size_t getNodeIndex(Element const &element, unsigned const idx)
Definition Element.cpp:219
MeshLib::Element * modifyEdgeNodeOrdering(const MeshLib::Element &edge, const GeoLib::Polyline &ply, const std::vector< std::size_t > &edge_node_distances_along_ply, const std::vector< std::size_t > &node_ids_on_poly)
bool includesAllEdgeNodeIDs(std::vector< std::size_t > const &vec_node_ids, MeshLib::Element const &edge, std::vector< std::size_t > &edge_node_distances)

References _boundary_elements, MeshLib::Element::getEdge(), MeshLib::Mesh::getElement(), MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeIDs(), MeshLib::ElementSearch::getSearchedElementIDs(), and MeshLib::ElementSearch::searchByNodeIDs().

◆ ~BoundaryElementsAlongPolyline()

MeshGeoToolsLib::BoundaryElementsAlongPolyline::~BoundaryElementsAlongPolyline ( )
virtual

destructor

Definition at line 172 of file BoundaryElementsAlongPolyline.cpp.

173{
174 for (auto p : _boundary_elements)
175 {
176 delete p;
177 }
178}

References _boundary_elements.

Member Function Documentation

◆ getBoundaryElements()

std::vector< MeshLib::Element * > const & MeshGeoToolsLib::BoundaryElementsAlongPolyline::getBoundaryElements ( ) const
inline

Return the vector of boundary elements (i.e. edges). The elements are sorted according to their distance to the starting point of the given polyline.

Definition at line 61 of file BoundaryElementsAlongPolyline.h.

62 {
63 return _boundary_elements;
64 }

References _boundary_elements.

◆ getPolyline()

GeoLib::Polyline const & MeshGeoToolsLib::BoundaryElementsAlongPolyline::getPolyline ( ) const
inline

Deploying this method the user can get access to the underlying GeoLib::Polyline.

Returns
the underlying GeoLib::Polyline

Definition at line 54 of file BoundaryElementsAlongPolyline.h.

54{ return _ply; }

References _ply.

Referenced by MeshGeoToolsLib::BoundaryElementsSearcher::getBoundaryElements().

Member Data Documentation

◆ _boundary_elements

std::vector<MeshLib::Element*> MeshGeoToolsLib::BoundaryElementsAlongPolyline::_boundary_elements
private

◆ _ply

GeoLib::Polyline const& MeshGeoToolsLib::BoundaryElementsAlongPolyline::_ply
private

Definition at line 67 of file BoundaryElementsAlongPolyline.h.

Referenced by getPolyline().


The documentation for this class was generated from the following files: