Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Courses
Scotty3D
Commits
c015a687
Commit
c015a687
authored
Oct 17, 2021
by
TheNumbat
Browse files
add vert/edge/face accessibility check
parent
0258a1ed
Changes
1
Show whitespace changes
Inline
Side-by-side
src/geometry/halfedge.cpp
View file @
c015a687
...
...
@@ -375,6 +375,9 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
if
(
!
finite
)
return
{{
v
,
"A vertex position was set to a non-finite value."
}};
}
std
::
unordered_map
<
VertexRef
,
std
::
set
<
HalfedgeRef
>>
v_accessible
;
std
::
unordered_map
<
EdgeRef
,
std
::
set
<
HalfedgeRef
>>
e_accessible
;
std
::
unordered_map
<
FaceRef
,
std
::
set
<
HalfedgeRef
>>
f_accessible
;
std
::
set
<
HalfedgeRef
>
permutation
;
// Check valid halfedge permutation
...
...
@@ -406,24 +409,6 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
}
}
for
(
HalfedgeRef
h
=
halfedges_begin
();
h
!=
halfedges_end
();
h
++
)
{
if
(
herased
.
find
(
h
)
!=
herased
.
end
())
continue
;
// Check whether each halfedge was pointed to by a halfedge
if
(
permutation
.
find
(
h
)
==
permutation
.
end
())
{
return
{{
h
,
"A halfedge is the next of zero halfedges!"
}};
}
// Check twin relationships
if
(
h
->
twin
()
==
h
)
{
return
{{
h
,
"A halfedge's twin is itself!"
}};
}
if
(
h
->
twin
()
->
twin
()
!=
h
)
{
return
{{
h
,
"A halfedge's twin's twin is not itself!"
}};
}
}
// Check whether each halfedge incident on a vertex points to that vertex
for
(
VertexRef
v
=
vertices_begin
();
v
!=
vertices_end
();
v
++
)
{
...
...
@@ -434,12 +419,15 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
v
,
"A vertex's halfedge is erased!"
}};
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
accessible
.
insert
(
h
);
if
(
h
->
vertex
()
!=
v
)
{
return
{{
h
,
"A vertex's halfedge does not point to that vertex!"
}};
}
h
=
h
->
twin
()
->
next
();
}
while
(
h
!=
v
->
halfedge
());
v_accessible
[
v
]
=
std
::
move
(
accessible
);
}
// Check whether each halfedge incident on an edge points to that edge
...
...
@@ -452,12 +440,15 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
e
,
"An edge's halfedge is erased!"
}};
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
accessible
.
insert
(
h
);
if
(
h
->
edge
()
!=
e
)
{
return
{{
h
,
"An edge's halfedge does not point to that edge!"
}};
}
h
=
h
->
twin
();
}
while
(
h
!=
e
->
halfedge
());
e_accessible
[
e
]
=
std
::
move
(
accessible
);
}
// Check whether each halfedge incident on a face points to that face
...
...
@@ -470,12 +461,44 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
f
,
"A face's halfedge is erased!"
}};
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
accessible
.
insert
(
h
);
if
(
h
->
face
()
!=
f
)
{
return
{{
h
,
"A face's halfedge does not point to that face!"
}};
}
h
=
h
->
next
();
}
while
(
h
!=
f
->
halfedge
());
f_accessible
[
f
]
=
std
::
move
(
accessible
);
}
for
(
HalfedgeRef
h
=
halfedges_begin
();
h
!=
halfedges_end
();
h
++
)
{
if
(
herased
.
find
(
h
)
!=
herased
.
end
())
continue
;
// Check whether each halfedge was pointed to by a halfedge
if
(
permutation
.
find
(
h
)
==
permutation
.
end
())
{
return
{{
h
,
"A halfedge is the next of zero halfedges!"
}};
}
// Check twin relationships
if
(
h
->
twin
()
==
h
)
{
return
{{
h
,
"A halfedge's twin is itself!"
}};
}
if
(
h
->
twin
()
->
twin
()
!=
h
)
{
return
{{
h
,
"A halfedge's twin's twin is not itself!"
}};
}
// Check that the halfedge can be found via its vertex, edge, and face
if
(
v_accessible
[
h
->
vertex
()].
count
(
h
)
==
0
)
{
return
{{
h
,
"A halfedge is not accessible from its vertex!"
}};
}
if
(
e_accessible
[
h
->
edge
()].
count
(
h
)
==
0
)
{
return
{{
h
,
"A halfedge is not accessible from its edge!"
}};
}
if
(
f_accessible
[
h
->
face
()].
count
(
h
)
==
0
)
{
return
{{
h
,
"A halfedge is not accessible from its face!"
}};
}
}
do_erase
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment