Skip to content
Snippets Groups Projects
Commit cc58e8d5 authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

add a general searching function for any geometric types in MeshNodeSearcher

parent 2e84c1dc
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,28 @@ MeshNodeSearcher::~MeshNodeSearcher() ...@@ -75,6 +75,28 @@ MeshNodeSearcher::~MeshNodeSearcher()
} }
} }
std::vector<std::size_t> MeshNodeSearcher::getMeshNodeIDs(GeoLib::GeoObject const& geoObj)
{
std::vector<std::size_t> vec_nodes;
switch (geoObj.getGeoType()) {
case GeoLib::GEOTYPE::POINT:
{
auto node_id = this->getMeshNodeIDForPoint(*dynamic_cast<const GeoLib::PointWithID*>(&geoObj));
if (node_id) vec_nodes.push_back(*node_id);
break;
}
case GeoLib::GEOTYPE::POLYLINE:
vec_nodes = this->getMeshNodeIDsAlongPolyline(*dynamic_cast<const GeoLib::Polyline*>(&geoObj));
break;
case GeoLib::GEOTYPE::SURFACE:
vec_nodes = this->getMeshNodeIDsAlongSurface(*dynamic_cast<const GeoLib::Surface*>(&geoObj));
break;
default:
break;
}
return vec_nodes;
}
boost::optional<std::size_t> MeshNodeSearcher::getMeshNodeIDForPoint(GeoLib::Point const& pnt) const boost::optional<std::size_t> MeshNodeSearcher::getMeshNodeIDForPoint(GeoLib::Point const& pnt) const
{ {
auto* found = _mesh_grid.getNearestPoint(pnt.getCoords()); auto* found = _mesh_grid.getNearestPoint(pnt.getCoords());
......
...@@ -51,6 +51,13 @@ public: ...@@ -51,6 +51,13 @@ public:
explicit MeshNodeSearcher(MeshLib::Mesh const& mesh); explicit MeshNodeSearcher(MeshLib::Mesh const& mesh);
virtual ~MeshNodeSearcher(); virtual ~MeshNodeSearcher();
/**
* Searches for the nearest mesh nodes on the given geometric object (point, polyline, surface).
* @param geoObj a GeoLib::GeoObject where the nearest mesh node is searched for
* @return a vector of mesh node ids
*/
std::vector<std::size_t> getMeshNodeIDs(GeoLib::GeoObject const& geoObj);
/** /**
* Searches for the node nearest by the given point. If there are two nodes * Searches for the node nearest by the given point. If there are two nodes
* with the same distance the id of the one that was first found will be * with the same distance the id of the one that was first found will be
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment