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
05e7f641
Commit
05e7f641
authored
Jul 10, 2018
by
Philip Trettner
Browse files
added attach and fill functions
parent
7182aec1
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/polymesh/Mesh.hh
View file @
05e7f641
...
...
@@ -170,6 +170,12 @@ private:
/// splits a half-edge
vertex_index
halfedge_split
(
halfedge_index
h
);
/// fills a face
face_index
face_fill
(
halfedge_index
h
);
/// attaches a given vertex to the to-vertex of a given half-edge
void
halfedge_attach
(
halfedge_index
h
,
vertex_index
v
);
/// collapse a vertex
void
vertex_collapse
(
vertex_index
v
);
/// collapse a half-edge
...
...
@@ -197,6 +203,8 @@ private:
void
fix_boundary_state_of
(
vertex_index
v_idx
);
/// choses a new half-edge for a given face, prefers boundary ones
void
fix_boundary_state_of
(
face_index
f_idx
);
/// choses a new half-edge for all vertices of a face, prefers boundary ones
void
fix_boundary_state_of_vertices
(
face_index
f_idx
);
// attributes
bool
is_boundary
(
vertex_index
idx
)
const
;
...
...
@@ -409,5 +417,5 @@ private:
#include
"impl/impl_cursors.hh"
#include
"impl/impl_iterators.hh"
#include
"impl/impl_mesh.hh"
#include
"impl/impl_ranges.hh"
#include
"impl/impl_primitive.hh"
#include
"impl/impl_ranges.hh"
src/polymesh/impl/impl_mesh.hh
View file @
05e7f641
...
...
@@ -406,6 +406,24 @@ inline void Mesh::fix_boundary_state_of(face_index f_idx)
}
while
(
he
!=
he_begin
);
}
inline
void
Mesh
::
fix_boundary_state_of_vertices
(
face_index
f_idx
)
{
auto
&
f
=
face
(
f_idx
);
auto
he_begin
=
f
.
halfedge
;
auto
he
=
he_begin
;
do
{
auto
&
h_ref
=
halfedge
(
he
);
// fix vertex
fix_boundary_state_of
(
h_ref
.
to_vertex
);
// advance
he
=
h_ref
.
next_halfedge
;
}
while
(
he
!=
he_begin
);
}
inline
halfedge_index
Mesh
::
find_free_incident
(
halfedge_index
in_begin
,
halfedge_index
in_end
)
const
{
assert
(
halfedge
(
in_begin
).
to_vertex
==
halfedge
(
in_end
).
to_vertex
);
...
...
@@ -703,6 +721,65 @@ inline vertex_index Mesh::halfedge_split(halfedge_index h)
return
v
;
}
inline
face_index
Mesh
::
face_fill
(
halfedge_index
h
)
{
assert
(
is_boundary
(
h
));
auto
f
=
alloc_face
();
auto
&
f_ref
=
face
(
f
);
f_ref
.
halfedge
=
h
;
auto
h_begin
=
h
;
do
{
auto
&
h_ref
=
halfedge
(
h
);
// set face
h_ref
.
face
=
f
;
// set boundary
if
(
is_boundary
(
opposite
(
h
)))
f_ref
.
halfedge
=
h
;
// advance
h
=
h_ref
.
next_halfedge
;
}
while
(
h
!=
h_begin
);
// fix vertex boundaries
fix_boundary_state_of_vertices
(
f
);
return
f
;
}
inline
void
Mesh
::
halfedge_attach
(
halfedge_index
h
,
vertex_index
v
)
{
assert
(
vertex
(
v
).
is_isolated
());
auto
&
h_ref
=
halfedge
(
h
);
auto
h_next
=
h_ref
.
next_halfedge
;
auto
v_to
=
h_ref
.
to_vertex
;
auto
f
=
h_ref
.
face
;
auto
e
=
alloc_edge
();
auto
h0
=
halfedge_of
(
e
,
0
);
auto
h1
=
halfedge_of
(
e
,
1
);
auto
&
h0_ref
=
halfedge
(
h0
);
auto
&
h1_ref
=
halfedge
(
h1
);
h0_ref
.
face
=
f
;
h0_ref
.
to_vertex
=
v
;
h1_ref
.
face
=
f
;
h1_ref
.
to_vertex
=
v_to
;
connect_prev_next
(
h
,
h0
);
connect_prev_next
(
h0
,
h1
);
connect_prev_next
(
h1
,
h_next
);
}
inline
void
Mesh
::
vertex_collapse
(
vertex_index
v
)
{
auto
&
v_ref
=
vertex
(
v
);
...
...
src/polymesh/impl/impl_ranges.hh
View file @
05e7f641
...
...
@@ -650,6 +650,12 @@ vertex_handle face_collection<iterator>::split(face_handle f) const
return
this
->
mesh
->
handle_of
(
this
->
mesh
->
face_split
(
f
.
idx
));
}
template
<
class
iterator
>
face_handle
face_collection
<
iterator
>::
fill
(
halfedge_handle
h
)
const
{
return
this
->
mesh
->
handle_of
(
this
->
mesh
->
face_fill
(
h
.
idx
));
}
template
<
class
iterator
>
vertex_handle
edge_collection
<
iterator
>::
split
(
edge_handle
e
)
const
{
...
...
@@ -686,6 +692,12 @@ vertex_handle halfedge_collection<iterator>::split(halfedge_handle h) const
return
this
->
mesh
->
handle_of
(
this
->
mesh
->
halfedge_split
(
h
.
idx
));
}
template
<
class
iterator
>
void
halfedge_collection
<
iterator
>::
attach
(
halfedge_handle
h
,
vertex_handle
v
)
const
{
this
->
mesh
->
halfedge_attach
(
h
.
idx
,
v
.
idx
);
}
template
<
class
iterator
>
void
halfedge_collection
<
iterator
>::
rotate_next
(
halfedge_handle
h
)
const
{
...
...
src/polymesh/ranges.hh
View file @
05e7f641
...
...
@@ -212,6 +212,10 @@ struct face_collection : smart_collection<Mesh*, face_tag, iterator>
/// The face itself is deleted and multiple new ones are created
vertex_handle
split
(
face_handle
f
)
const
;
/// Fills the half-edge ring of a given boundary half-edge
/// Returns the new face
face_handle
fill
(
halfedge_handle
h
)
const
;
/// Removes a face (adjacent edges and vertices are NOT removed)
/// (marks it as removed, compactify mesh to actually remove it)
void
remove
(
face_handle
f
)
const
;
...
...
@@ -274,6 +278,9 @@ struct halfedge_collection : smart_collection<Mesh*, halfedge_tag, iterator>
/// (thus h->next() is the newly inserted edge and h->vertex_to() is the returned vertex)
vertex_handle
split
(
halfedge_handle
h
)
const
;
/// Given an isolated vertex v, inserts a self-adjacent edge at the to-vertex to v
void
attach
(
halfedge_handle
h
,
vertex_handle
v
)
const
;
/// Moves the to-vertex of this half-edge to the same as the next half-edge
/// Preserves all attributes
/// NOTE: does not work on boundaries!
...
...
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