Skip to content
Snippets Groups Projects
Commit 2f8dc47d authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[App/U] M2R; Use local lambda for is_right_of().

parent 126c245a
No related branches found
No related tags found
No related merge requests found
...@@ -31,33 +31,47 @@ std::size_t getProjectedElementIndex( ...@@ -31,33 +31,47 @@ std::size_t getProjectedElementIndex(
std::vector<const MeshLib::Element*> const& elems, std::vector<const MeshLib::Element*> const& elems,
MeshLib::Node const& node) MeshLib::Node const& node)
{ {
auto is_right_of = [&node](MeshLib::Node const& a, MeshLib::Node const& b) {
return GeoLib::getOrientationFast(node, a, b) ==
GeoLib::Orientation::CW;
};
std::size_t const n_elems = elems.size(); std::size_t const n_elems = elems.size();
for (std::size_t i = 0; i < n_elems; ++i) for (std::size_t i = 0; i < n_elems; ++i)
{ {
if (elems[i]->getGeomType() == MeshLib::MeshElemType::LINE) if (elems[i]->getGeomType() == MeshLib::MeshElemType::LINE)
{
continue; continue;
MeshLib::Node const* const a = elems[i]->getNode(0); }
MeshLib::Node const* const b = elems[i]->getNode(1); auto const& a = *elems[i]->getNode(0);
if (GeoLib::getOrientationFast(node, *a, *b) == GeoLib::Orientation::CW) auto const& b = *elems[i]->getNode(1);
if (is_right_of(a, b))
{
continue; continue;
MeshLib::Node const* const c = elems[i]->getNode(2); }
if (GeoLib::getOrientationFast(node, *b, *c) == GeoLib::Orientation::CW) auto const& c = *elems[i]->getNode(2);
if (is_right_of(b, c))
{
continue; continue;
}
if (elems[i]->getGeomType() == MeshLib::MeshElemType::TRIANGLE) if (elems[i]->getGeomType() == MeshLib::MeshElemType::TRIANGLE)
{ {
if (GeoLib::getOrientationFast(node, *c, *a) == if (is_right_of(c, a))
GeoLib::Orientation::CW) {
continue; continue;
}
} }
if (elems[i]->getGeomType() == MeshLib::MeshElemType::QUAD) if (elems[i]->getGeomType() == MeshLib::MeshElemType::QUAD)
{ {
MeshLib::Node const* const d = elems[i]->getNode(3); auto const& d = *elems[i]->getNode(3);
if (GeoLib::getOrientationFast(node, *c, *d) == if (is_right_of(c, d))
GeoLib::Orientation::CW) {
continue; continue;
if (GeoLib::getOrientationFast(node, *d, *a) == }
GeoLib::Orientation::CW) if (is_right_of(d, a))
{
continue; continue;
}
} }
return elems[i]->getID(); return elems[i]->getID();
} }
......
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