Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scotty3D
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Courses
Scotty3D
Commits
c015a687
Commit
c015a687
authored
3 years ago
by
TheNumbat
Browse files
Options
Downloads
Patches
Plain Diff
add vert/edge/face accessibility check
parent
0258a1ed
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/geometry/halfedge.cpp
+41
-18
41 additions, 18 deletions
src/geometry/halfedge.cpp
with
41 additions
and
18 deletions
src/geometry/halfedge.cpp
+
41
−
18
View file @
c015a687
...
@@ -375,6 +375,9 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
...
@@ -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."
}};
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
;
std
::
set
<
HalfedgeRef
>
permutation
;
// Check valid halfedge permutation
// Check valid halfedge permutation
...
@@ -406,24 +409,6 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
...
@@ -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
// Check whether each halfedge incident on a vertex points to that vertex
for
(
VertexRef
v
=
vertices_begin
();
v
!=
vertices_end
();
v
++
)
{
for
(
VertexRef
v
=
vertices_begin
();
v
!=
vertices_end
();
v
++
)
{
...
@@ -434,12 +419,15 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
...
@@ -434,12 +419,15 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
v
,
"A vertex's halfedge is erased!"
}};
return
{{
v
,
"A vertex's halfedge is erased!"
}};
}
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
do
{
accessible
.
insert
(
h
);
if
(
h
->
vertex
()
!=
v
)
{
if
(
h
->
vertex
()
!=
v
)
{
return
{{
h
,
"A vertex's halfedge does not point to that vertex!"
}};
return
{{
h
,
"A vertex's halfedge does not point to that vertex!"
}};
}
}
h
=
h
->
twin
()
->
next
();
h
=
h
->
twin
()
->
next
();
}
while
(
h
!=
v
->
halfedge
());
}
while
(
h
!=
v
->
halfedge
());
v_accessible
[
v
]
=
std
::
move
(
accessible
);
}
}
// Check whether each halfedge incident on an edge points to that edge
// 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::
...
@@ -452,12 +440,15 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
e
,
"An edge's halfedge is erased!"
}};
return
{{
e
,
"An edge's halfedge is erased!"
}};
}
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
do
{
accessible
.
insert
(
h
);
if
(
h
->
edge
()
!=
e
)
{
if
(
h
->
edge
()
!=
e
)
{
return
{{
h
,
"An edge's halfedge does not point to that edge!"
}};
return
{{
h
,
"An edge's halfedge does not point to that edge!"
}};
}
}
h
=
h
->
twin
();
h
=
h
->
twin
();
}
while
(
h
!=
e
->
halfedge
());
}
while
(
h
!=
e
->
halfedge
());
e_accessible
[
e
]
=
std
::
move
(
accessible
);
}
}
// Check whether each halfedge incident on a face points to that face
// 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::
...
@@ -470,12 +461,44 @@ std::optional<std::pair<Halfedge_Mesh::ElementRef, std::string>> Halfedge_Mesh::
return
{{
f
,
"A face's halfedge is erased!"
}};
return
{{
f
,
"A face's halfedge is erased!"
}};
}
}
std
::
set
<
HalfedgeRef
>
accessible
;
do
{
do
{
accessible
.
insert
(
h
);
if
(
h
->
face
()
!=
f
)
{
if
(
h
->
face
()
!=
f
)
{
return
{{
h
,
"A face's halfedge does not point to that face!"
}};
return
{{
h
,
"A face's halfedge does not point to that face!"
}};
}
}
h
=
h
->
next
();
h
=
h
->
next
();
}
while
(
h
!=
f
->
halfedge
());
}
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
();
do_erase
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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