Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feliks Kiszkurno
ogs-feliks
Commits
52afdc7a
Commit
52afdc7a
authored
1 year ago
by
Dmitri Naumov
Committed by
Tom Fischer
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[GL] EarClipping; auto for iterators. Reduce scope
parent
1f5542f0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/EarClippingTriangulation.cpp
+13
-21
13 additions, 21 deletions
GeoLib/EarClippingTriangulation.cpp
with
13 additions
and
21 deletions
GeoLib/EarClippingTriangulation.cpp
+
13
−
21
View file @
52afdc7a
...
@@ -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
>::
iter
ato
r
it
(
_vertex_list
.
begin
()
),
a
u
to
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
>::
iter
ato
r
it
=
_vertex_list
.
begin
();
a
u
to
it
=
_vertex_list
.
begin
();
std
::
list
<
std
::
size_t
>::
iter
ato
r
prev
=
_vertex_list
.
end
();
a
u
to
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
>::
iter
ato
r
next
=
it
;
a
u
to
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
prev
prev
=
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
>::
iter
ato
r
next
=
_vertex_list
.
begin
();
a
u
to
next
=
_vertex_list
.
begin
();
std
::
list
<
std
::
size_t
>::
iter
ato
r
prev
=
next
;
a
u
to
prev
=
next
;
++
next
;
++
next
;
if
(
next
==
_vertex_list
.
end
())
if
(
next
==
_vertex_list
.
end
())
{
{
return
;
return
;
}
}
std
::
list
<
std
::
size_t
>::
iter
ato
r
it
=
next
;
a
u
to
it
=
next
;
++
next
;
++
next
;
if
(
next
==
_vertex_list
.
end
())
if
(
next
==
_vertex_list
.
end
())
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment