Skip to content
Snippets Groups Projects
Commit 52afdc7a authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Tom Fischer
Browse files

[GL] EarClipping; auto for iterators. Reduce scope

parent 1f5542f0
No related branches found
No related tags found
No related merge requests found
...@@ -162,10 +162,10 @@ void EarClippingTriangulation::initLists() ...@@ -162,10 +162,10 @@ void EarClippingTriangulation::initLists()
{ {
// go through points checking ccw, cw or collinear order and identifying // go through points checking ccw, cw or collinear order and identifying
// ears // ears
std::list<std::size_t>::iterator it(_vertex_list.begin()), auto it = _vertex_list.begin();
prev(_vertex_list.end()), next; auto prev = _vertex_list.end();
--prev; --prev;
next = it; auto next = it;
++next; ++next;
GeoLib::Orientation orientation; GeoLib::Orientation orientation;
bool first_run( bool first_run(
...@@ -218,8 +218,8 @@ void EarClippingTriangulation::clipEars() ...@@ -218,8 +218,8 @@ void EarClippingTriangulation::clipEars()
// remove ear from vertex_list, apply changes to _ear_list, // remove ear from vertex_list, apply changes to _ear_list,
// _convex_vertex_list // _convex_vertex_list
bool nfound(true); bool nfound(true);
std::list<std::size_t>::iterator it = _vertex_list.begin(); auto it = _vertex_list.begin();
std::list<std::size_t>::iterator prev = _vertex_list.end(); auto prev = _vertex_list.end();
--prev; --prev;
while (nfound && it != _vertex_list.end()) while (nfound && it != _vertex_list.end())
{ {
...@@ -227,7 +227,7 @@ void EarClippingTriangulation::clipEars() ...@@ -227,7 +227,7 @@ void EarClippingTriangulation::clipEars()
{ {
nfound = false; nfound = false;
it = _vertex_list.erase(it); // remove ear tip it = _vertex_list.erase(it); // remove ear tip
std::list<std::size_t>::iterator next = it; auto next = it;
if (next == _vertex_list.end()) if (next == _vertex_list.end())
{ {
next = _vertex_list.begin(); next = _vertex_list.begin();
...@@ -238,15 +238,11 @@ void EarClippingTriangulation::clipEars() ...@@ -238,15 +238,11 @@ void EarClippingTriangulation::clipEars()
_triangles.emplace_back(_pnts, *prev, *next, ear); _triangles.emplace_back(_pnts, *prev, *next, ear);
// check the orientation of prevprev, prev, next // check the orientation of prevprev, prev, next
std::list<std::size_t>::iterator prevprev; auto prevprev = prev;
if (prev == _vertex_list.begin()) if (prev == _vertex_list.begin())
{ {
prevprev = _vertex_list.end(); prevprev = _vertex_list.end();
} }
else
{
prevprev = prev;
}
--prevprev; --prevprev;
// apply changes to _convex_vertex_list and _ear_list looking // apply changes to _convex_vertex_list and _ear_list looking
...@@ -289,18 +285,14 @@ void EarClippingTriangulation::clipEars() ...@@ -289,18 +285,14 @@ void EarClippingTriangulation::clipEars()
} }
// check the orientation of prev, next, nextnext // check the orientation of prev, next, nextnext
std::list<std::size_t>::iterator nextnext, auto nextnext = next;
help_it(_vertex_list.end()); ++nextnext;
auto help_it = _vertex_list.end();
--help_it; --help_it;
if (next == help_it) if (next == help_it)
{ {
nextnext = _vertex_list.begin(); nextnext = _vertex_list.begin();
} }
else
{
nextnext = next;
++nextnext;
}
// apply changes to _convex_vertex_list and _ear_list looking // apply changes to _convex_vertex_list and _ear_list looking
// "forward" // "forward"
...@@ -344,14 +336,14 @@ void EarClippingTriangulation::clipEars() ...@@ -344,14 +336,14 @@ void EarClippingTriangulation::clipEars()
// add last triangle // add last triangle
{ {
std::list<std::size_t>::iterator next = _vertex_list.begin(); auto next = _vertex_list.begin();
std::list<std::size_t>::iterator prev = next; auto prev = next;
++next; ++next;
if (next == _vertex_list.end()) if (next == _vertex_list.end())
{ {
return; return;
} }
std::list<std::size_t>::iterator it = next; auto it = next;
++next; ++next;
if (next == _vertex_list.end()) if (next == _vertex_list.end())
{ {
......
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