Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
polymesh
Commits
34a08585
Commit
34a08585
authored
Jul 23, 2018
by
Philip Trettner
Browse files
refactoring to SOA complete
parent
e8221643
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/polymesh/Mesh.cc
View file @
34a08585
...
...
@@ -18,7 +18,7 @@ using namespace polymesh;
void
Mesh
::
assert_consistency
()
const
{
// check sizes
assert
(
mHalfedge
s
.
size
()
%
2
==
0
);
///< even number of halfedges
assert
(
mHalfedge
ToNextHalfedge
.
size
()
%
2
==
0
);
///< even number of halfedges
// check correct counts
{
...
...
src/polymesh/Mesh.hh
View file @
34a08585
...
...
@@ -121,15 +121,15 @@ private:
void
reserve_edges
(
int
capacity
);
void
reserve_halfedges
(
int
capacity
);
int
size_all_faces
()
const
{
return
(
int
)
mFace
s
.
size
();
}
int
size_all_vertices
()
const
{
return
(
int
)
mVert
ices
.
size
();
}
int
size_all_edges
()
const
{
return
(
int
)
mHalfedge
s
.
size
()
>>
1
;
}
int
size_all_halfedges
()
const
{
return
(
int
)
mHalfedge
s
.
size
();
}
int
size_all_faces
()
const
{
return
(
int
)
mFace
ToHalfedge
.
size
();
}
int
size_all_vertices
()
const
{
return
(
int
)
mVert
exToOutgoingHalfedge
.
size
();
}
int
size_all_edges
()
const
{
return
(
int
)
mHalfedge
ToNextHalfedge
.
size
()
>>
1
;
}
int
size_all_halfedges
()
const
{
return
(
int
)
mHalfedge
ToNextHalfedge
.
size
();
}
int
size_valid_faces
()
const
{
return
(
int
)
mFace
s
.
size
()
-
mRemovedFaces
;
}
int
size_valid_vertices
()
const
{
return
(
int
)
mVert
ices
.
size
()
-
mRemovedVertices
;
}
int
size_valid_edges
()
const
{
return
((
int
)
mHalfedge
s
.
size
()
-
mRemovedHalfedges
)
>>
1
;
}
int
size_valid_halfedges
()
const
{
return
(
int
)
mHalfedge
s
.
size
()
-
mRemovedHalfedges
;
}
int
size_valid_faces
()
const
{
return
(
int
)
mFace
ToHalfedge
.
size
()
-
mRemovedFaces
;
}
int
size_valid_vertices
()
const
{
return
(
int
)
mVert
exToOutgoingHalfedge
.
size
()
-
mRemovedVertices
;
}
int
size_valid_edges
()
const
{
return
((
int
)
mHalfedge
ToNextHalfedge
.
size
()
-
mRemovedHalfedges
)
>>
1
;
}
int
size_valid_halfedges
()
const
{
return
(
int
)
mHalfedge
ToNextHalfedge
.
size
()
-
mRemovedHalfedges
;
}
// returns the next valid idx (returns the given one if valid)
// NOTE: the result can be invalid if no valid one was found
...
...
@@ -235,6 +235,8 @@ private:
bool
is_boundary
(
vertex_index
idx
)
const
;
bool
is_boundary
(
halfedge_index
idx
)
const
;
bool
is_boundary
(
edge_index
idx
)
const
;
bool
is_boundary
(
face_index
idx
)
const
;
bool
is_removed
(
vertex_index
idx
)
const
;
bool
is_removed
(
face_index
idx
)
const
;
...
...
@@ -242,6 +244,7 @@ private:
bool
is_removed
(
halfedge_index
idx
)
const
;
bool
is_isolated
(
vertex_index
idx
)
const
;
bool
is_isolated
(
edge_index
idx
)
const
;
vertex_index
&
to_vertex_of
(
halfedge_index
idx
);
face_index
&
face_of
(
halfedge_index
idx
);
...
...
@@ -263,6 +266,7 @@ private:
/// Returns the opposite of a given valid half-edge
halfedge_index
opposite
(
halfedge_index
he
)
const
;
face_index
opposite_face_of
(
halfedge_index
he
)
const
;
/// Makes two half-edges adjacent
/// Ensures:
...
...
@@ -289,6 +293,8 @@ private:
edge_index
edge_of
(
halfedge_index
idx
)
const
{
return
edge_index
(
idx
.
value
>>
1
);
}
/// returns a half-edge belonging to an edge
halfedge_index
halfedge_of
(
edge_index
idx
,
int
i
)
const
{
return
halfedge_index
((
idx
.
value
<<
1
)
+
i
);
}
vertex_index
to_vertex_of
(
edge_index
idx
,
int
i
)
const
{
return
to_vertex_of
(
halfedge_of
(
idx
,
i
));
}
face_index
face_of
(
edge_index
idx
,
int
i
)
const
{
return
face_of
(
halfedge_of
(
idx
,
i
));
}
vertex_index
&
from_vertex_of
(
halfedge_index
idx
);
vertex_index
from_vertex_of
(
halfedge_index
idx
)
const
;
...
...
src/polymesh/impl/impl_cursors.hh
View file @
34a08585
...
...
@@ -18,61 +18,39 @@ auto primitive_handle<tag>::operator[](FuncT&& f) const -> tmp::result_type_of<F
return
f
(
*
static_cast
<
typename
primitive
<
tag
>::
handle
const
*>
(
this
));
}
inline
bool
vertex_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
!
mesh
->
vertex
(
idx
).
is_valid
();
}
inline
bool
face_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
!
mesh
->
face
(
idx
).
is_valid
();
}
inline
bool
edge_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
!
mesh
->
halfedge
(
idx
,
0
).
is_valid
();
}
inline
bool
halfedge_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
!
mesh
->
halfedge
(
idx
).
is_valid
();
}
inline
bool
vertex_handle
::
is_isolated
()
const
{
return
mesh
->
vertex
(
idx
).
is_isolated
();
}
inline
bool
vertex_handle
::
is_boundary
()
const
{
auto
const
&
v
=
mesh
->
vertex
(
idx
);
if
(
v
.
is_isolated
())
return
true
;
return
mesh
->
halfedge
(
v
.
outgoing_halfedge
).
is_free
();
}
inline
bool
face_handle
::
is_boundary
()
const
{
return
mesh
->
halfedge
(
mesh
->
opposite
(
mesh
->
face
(
idx
).
halfedge
)).
is_free
();
}
inline
bool
edge_handle
::
is_isolated
()
const
{
return
mesh
->
halfedge
(
idx
,
0
).
is_free
()
&&
mesh
->
halfedge
(
idx
,
1
).
is_free
();
}
inline
bool
edge_handle
::
is_boundary
()
const
{
return
mesh
->
halfedge
(
idx
,
0
).
is_free
()
||
mesh
->
halfedge
(
idx
,
1
).
is_free
();
}
inline
bool
halfedge_handle
::
is_boundary
()
const
{
return
mesh
->
halfedge
(
idx
).
is_free
();
}
inline
vertex_handle
halfedge_handle
::
vertex_to
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
idx
).
to_vertex
);
}
inline
vertex_handle
halfedge_handle
::
vertex_from
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
opposite
(
idx
)).
to_vertex
);
}
inline
edge_handle
halfedge_handle
::
edge
()
const
{
return
mesh
->
handle_of
(
mesh
->
edge_of
(
idx
));
}
inline
face_handle
halfedge_handle
::
face
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
idx
).
face
);
}
inline
halfedge_handle
halfedge_handle
::
next
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
idx
).
next_halfedge
);
}
inline
halfedge_handle
halfedge_handle
::
prev
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
idx
).
prev_halfedge
);
}
inline
bool
vertex_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
mesh
->
is_removed
(
idx
);
}
inline
bool
face_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
mesh
->
is_removed
(
idx
);
}
inline
bool
edge_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
mesh
->
is_removed
(
idx
);
}
inline
bool
halfedge_handle
::
is_removed
()
const
{
return
idx
.
is_valid
()
&&
mesh
->
is_removed
(
idx
);
}
inline
bool
vertex_handle
::
is_isolated
()
const
{
return
mesh
->
is_isolated
(
idx
);
}
inline
bool
edge_handle
::
is_isolated
()
const
{
return
mesh
->
is_isolated
(
idx
);
}
inline
bool
vertex_handle
::
is_boundary
()
const
{
return
mesh
->
is_boundary
(
idx
);
}
inline
bool
face_handle
::
is_boundary
()
const
{
return
mesh
->
is_boundary
(
idx
);
}
inline
bool
edge_handle
::
is_boundary
()
const
{
return
mesh
->
is_boundary
(
idx
);
}
inline
bool
halfedge_handle
::
is_boundary
()
const
{
return
mesh
->
is_boundary
(
idx
);
}
inline
vertex_handle
halfedge_handle
::
vertex_to
()
const
{
return
mesh
->
handle_of
(
mesh
->
to_vertex_of
(
idx
));
}
inline
vertex_handle
halfedge_handle
::
vertex_from
()
const
{
return
mesh
->
handle_of
(
mesh
->
from_vertex_of
(
idx
));
}
inline
halfedge_handle
halfedge_handle
::
next
()
const
{
return
mesh
->
handle_of
(
mesh
->
next_halfedge_of
(
idx
));
}
inline
halfedge_handle
halfedge_handle
::
prev
()
const
{
return
mesh
->
handle_of
(
mesh
->
prev_halfedge_of
(
idx
));
}
inline
halfedge_handle
halfedge_handle
::
opposite
()
const
{
return
mesh
->
handle_of
(
mesh
->
opposite
(
idx
));
}
inline
face_handle
halfedge_handle
::
opposite_face
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
opposite
(
idx
)).
face
);
}
inline
edge_handle
halfedge_handle
::
edge
()
const
{
return
mesh
->
handle_of
(
mesh
->
edge_of
(
idx
));
}
inline
face_handle
halfedge_handle
::
face
()
const
{
return
mesh
->
handle_of
(
mesh
->
face_of
(
idx
));
}
inline
face_handle
halfedge_handle
::
opposite_face
()
const
{
return
mesh
->
handle_of
(
mesh
->
opposite_face_of
(
idx
));
}
inline
halfedge_handle
edge_handle
::
halfedgeA
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge_of
(
idx
,
0
));
}
inline
halfedge_handle
edge_handle
::
halfedgeB
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge_of
(
idx
,
1
));
}
inline
vertex_handle
edge_handle
::
vertexA
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
halfedge_of
(
idx
,
0
)).
to_vertex
);
}
inline
vertex_handle
edge_handle
::
vertexB
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
halfedge_of
(
idx
,
1
)).
to_vertex
);
}
inline
face_handle
edge_handle
::
faceA
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
halfedge_of
(
idx
,
0
)).
face
);
}
inline
face_handle
edge_handle
::
faceB
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
halfedge_of
(
idx
,
1
)).
face
);
}
inline
vertex_handle
edge_handle
::
vertexA
()
const
{
return
mesh
->
handle_of
(
mesh
->
to_vertex_of
(
idx
,
0
));
}
inline
vertex_handle
edge_handle
::
vertexB
()
const
{
return
mesh
->
handle_of
(
mesh
->
to_vertex_of
(
idx
,
1
));
}
inline
face_handle
edge_handle
::
faceA
()
const
{
return
mesh
->
handle_of
(
mesh
->
face_of
(
idx
,
0
));
}
inline
face_handle
edge_handle
::
faceB
()
const
{
return
mesh
->
handle_of
(
mesh
->
face_of
(
idx
,
1
));
}
inline
face_handle
vertex_handle
::
any_face
()
const
{
auto
h
=
mesh
->
vertex
(
idx
).
outgoing_halfedge
;
return
mesh
->
handle_of
(
h
.
is_valid
()
?
mesh
->
halfedge
(
h
).
face
:
face_index
::
invalid
());
auto
h
=
mesh
->
outgoing_halfedge
_of
(
idx
)
;
return
mesh
->
handle_of
(
h
.
is_valid
()
?
mesh
->
face_of
(
h
)
:
face_index
::
invalid
());
}
inline
face_handle
vertex_handle
::
any_valid_face
()
const
...
...
@@ -83,23 +61,23 @@ inline face_handle vertex_handle::any_valid_face() const
return
mesh
->
handle_of
(
face_index
::
invalid
());
}
inline
halfedge_handle
vertex_handle
::
any_outgoing_halfedge
()
const
{
return
mesh
->
handle_of
(
mesh
->
vertex
(
idx
).
outgoing_halfedge
);
}
inline
halfedge_handle
vertex_handle
::
any_outgoing_halfedge
()
const
{
return
mesh
->
handle_of
(
mesh
->
outgoing_halfedge
_of
(
idx
)
);
}
inline
halfedge_handle
vertex_handle
::
any_incoming_halfedge
()
const
{
auto
h
=
mesh
->
vertex
(
idx
).
outgoing_halfedge
;
auto
h
=
mesh
->
outgoing_halfedge
_of
(
idx
)
;
return
mesh
->
handle_of
(
h
.
is_valid
()
?
mesh
->
opposite
(
h
)
:
halfedge_index
::
invalid
());
}
inline
edge_handle
vertex_handle
::
any_edge
()
const
{
auto
h
=
mesh
->
vertex
(
idx
).
outgoing_halfedge
;
auto
h
=
mesh
->
outgoing_halfedge
_of
(
idx
)
;
return
mesh
->
handle_of
(
h
.
is_valid
()
?
mesh
->
edge_of
(
h
)
:
edge_index
::
invalid
());
}
inline
vertex_handle
face_handle
::
any_vertex
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
(
mesh
->
face
(
idx
).
halfedge
).
to_vertex
);
}
inline
vertex_handle
face_handle
::
any_vertex
()
const
{
return
mesh
->
handle_of
(
mesh
->
to_vertex_of
(
mesh
->
halfedge_of
(
idx
))
);
}
inline
halfedge_handle
face_handle
::
any_halfedge
()
const
{
return
mesh
->
handle_of
(
mesh
->
face
(
idx
).
halfedge
);
}
inline
halfedge_handle
face_handle
::
any_halfedge
()
const
{
return
mesh
->
handle_of
(
mesh
->
halfedge
_of
(
idx
)
);
}
inline
face_vertex_ring
face_handle
::
vertices
()
const
{
return
{
*
this
};
}
...
...
src/polymesh/impl/impl_mesh.hh
View file @
34a08585
...
...
@@ -137,7 +137,7 @@ inline face_index Mesh::add_face(const halfedge_index *half_loop, int vcnt)
{
auto
h
=
half_loop
[
i
];
auto
v
=
to_vertex_of
(
h
);
auto
f
=
face_of
(
opposite
(
h
)
)
;
auto
f
=
opposite
_face_of
(
h
);
// fix vertex
fix_boundary_state_of
(
v
);
...
...
@@ -501,15 +501,18 @@ inline halfedge_index Mesh::find_halfedge(vertex_index from, vertex_index to) co
inline
bool
Mesh
::
is_boundary
(
vertex_index
idx
)
const
{
auto
oh
=
outgoing_halfedge_of
(
idx
);
return
oh
.
is_valid
()
&&
is_boundary
(
oh
);
return
!
oh
.
is_valid
()
||
is_boundary
(
oh
);
}
inline
bool
Mesh
::
is_free
(
halfedge_index
idx
)
const
{
return
face_of
(
idx
).
is_invalid
();
}
inline
bool
Mesh
::
is_boundary
(
halfedge_index
idx
)
const
{
return
is_free
(
idx
);
}
inline
bool
Mesh
::
is_boundary
(
face_index
idx
)
const
{
return
is_free
(
opposite
(
halfedge_of
(
idx
)));
}
inline
bool
Mesh
::
is_boundary
(
edge_index
idx
)
const
{
return
is_free
(
halfedge_of
(
idx
,
0
))
||
is_free
(
halfedge_of
(
idx
,
1
));
}
inline
bool
Mesh
::
is_isolated
(
vertex_index
idx
)
const
{
return
outgoing_halfedge_of
(
idx
).
is_invalid
();
}
inline
bool
Mesh
::
is_isolated
(
edge_index
idx
)
const
{
return
is_free
(
halfedge_of
(
idx
,
0
))
&&
is_free
(
halfedge_of
(
idx
,
1
));
}
inline
bool
Mesh
::
is_removed
(
vertex_index
idx
)
const
{
return
outgoing_halfedge_of
(
idx
).
value
>
=
-
1
;
}
inline
bool
Mesh
::
is_removed
(
vertex_index
idx
)
const
{
return
outgoing_halfedge_of
(
idx
).
value
=
=
-
2
;
}
inline
bool
Mesh
::
is_removed
(
face_index
idx
)
const
{
return
halfedge_of
(
idx
).
is_invalid
();
}
inline
bool
Mesh
::
is_removed
(
edge_index
idx
)
const
{
return
to_vertex_of
(
halfedge_of
(
idx
,
0
)).
is_invalid
();
}
inline
bool
Mesh
::
is_removed
(
halfedge_index
idx
)
const
{
return
to_vertex_of
(
idx
).
is_invalid
();
}
...
...
@@ -537,6 +540,7 @@ inline halfedge_index Mesh::halfedge_of(face_index idx) const { return mFaceToHa
inline
halfedge_index
Mesh
::
outgoing_halfedge_of
(
vertex_index
idx
)
const
{
return
mVertexToOutgoingHalfedge
[(
int
)
idx
];
}
inline
halfedge_index
Mesh
::
opposite
(
halfedge_index
he
)
const
{
return
halfedge_index
(
he
.
value
^
1
);
}
inline
face_index
Mesh
::
opposite_face_of
(
halfedge_index
he
)
const
{
return
face_of
(
opposite
(
he
));
}
inline
vertex_index
&
Mesh
::
from_vertex_of
(
halfedge_index
idx
)
{
return
to_vertex_of
(
opposite
(
idx
));
}
inline
vertex_index
Mesh
::
from_vertex_of
(
halfedge_index
idx
)
const
{
return
to_vertex_of
(
opposite
(
idx
));
}
...
...
@@ -786,7 +790,7 @@ inline face_index Mesh::face_fill(halfedge_index h)
halfedge_of
(
f
)
=
h
;
// fix adj face boundary
auto
adj_face
=
face_of
(
opposite
(
h
)
)
;
auto
adj_face
=
opposite
_face_of
(
h
);
if
(
adj_face
.
is_valid
())
fix_boundary_state_of
(
adj_face
);
...
...
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment