Skip to content
GitLab
Menu
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
fec75cbb
Commit
fec75cbb
authored
Jun 30, 2018
by
Philip Trettner
Browse files
templated rings
parent
a9a33e0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Readme.md
View file @
fec75cbb
...
...
@@ -19,4 +19,3 @@ Best used with glm and glow.
*
smart ranges: average, min, max, any, all, first, last ...
*
mid-level topo API: edge-rotate-next/prev, edge-split, edge-collapse, halfedge-split, halfedge-collapse, vertex-collapse
*
annotate property preservation for mid-level topo API
*
move "remove" API to handles
src/polymesh/ranges.hh
View file @
fec75cbb
...
...
@@ -184,200 +184,102 @@ struct valid_halfedge_const_collection : smart_collection<Mesh const*, halfedge_
// ================= RINGS =================
// rings
/// all vertices belonging to a face
struct
face_vertex_ring
template
<
class
this_t
,
class
element_handle
>
struct
primitive_ring
{
face_handle
face
;
/// Number of
vertice
s
/// Number of
element
s
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
vertex_handle
v
)
const
;
// Iteration:
face_vertex_circulator
begin
()
const
{
return
{
face
.
any_halfedge
(),
false
};
}
face_vertex_circulator
end
()
const
{
return
{
face
.
any_halfedge
(),
true
};
}
bool
contains
(
element_handle
v
)
const
;
};
/// all halfedge
s
b
el
onging to a face
struct
face_
halfedge_ring
template
<
clas
s
el
ement_handle
,
class
circulator
>
struct
face_
primitive_ring
:
primitive_ring
<
face_primitive_ring
<
element_handle
,
circulator
>
,
element_handle
>
{
face_handle
face
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
halfedge_handle
h
)
const
;
face_primitive_ring
(
face_handle
f
)
{
face
=
f
;
}
// Iteration:
face_halfedge_
circulator
begin
()
const
{
return
{
face
.
any_halfedge
(),
false
};
}
face_halfedge_
circulator
end
()
const
{
return
{
face
.
any_halfedge
(),
true
};
}
circulator
begin
()
const
{
return
{
face
.
any_halfedge
(),
false
};
}
circulator
end
()
const
{
return
{
face
.
any_halfedge
(),
true
};
}
};
/// all edge
s
b
el
onging to a face
struct
face_edge_ring
template
<
clas
s
el
ement_handle
,
class
circulator
>
struct
vertex_primitive_ring
:
primitive_ring
<
vertex_primitive_ring
<
element_handle
,
circulator
>
,
element_handle
>
{
face_handle
face
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
edge_handle
e
)
const
;
vertex_handle
vertex
;
vertex_primitive_ring
(
vertex_handle
v
)
{
vertex
=
v
;
}
// Iteration:
face_edge_
circulator
begin
()
const
{
return
{
face
.
any_halfedge
(),
false
};
}
face_edge_
circulator
end
()
const
{
return
{
face
.
any
_halfedge
(),
true
};
}
circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()
};
}
circulator
end
()
const
{
return
{
vertex
.
any_outgoing
_halfedge
(),
true
};
}
};
/// all
adjacent fa
ces belonging to a face
struct
face_
face_ring
/// all
verti
ces belonging to a face
struct
face_
vertex_ring
:
face_primitive_ring
<
vertex_handle
,
face_vertex_circulator
>
{
face_handle
face
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
face_handle
f
)
const
;
using
face_primitive_ring
<
vertex_handle
,
face_vertex_circulator
>::
face_primitive_ring
;
};
// Iteration:
face_face_circulator
begin
()
const
{
return
{
face
.
any_halfedge
(),
false
};
}
face_face_circulator
end
()
const
{
return
{
face
.
any_halfedge
(),
true
};
}
/// all halfedges belonging to a face
struct
face_halfedge_ring
:
face_primitive_ring
<
halfedge_handle
,
face_halfedge_circulator
>
{
using
face_primitive_ring
<
halfedge_handle
,
face_halfedge_circulator
>::
face_primitive_ring
;
};
/// all
outgoing half-edges from a vertex
struct
vertex_halfedge_out_ring
/// all
edges belonging to a face
struct
face_edge_ring
:
face_primitive_ring
<
edge_handle
,
face_edge_circulator
>
{
vertex_handle
vertex
;
using
face_primitive_ring
<
edge_handle
,
face_edge_circulator
>::
face_primitive_ring
;
};
/// Number of verti
ce
s
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this
ring
bool
contains
(
halfedge_handle
h
)
const
;
/// all adjacent faces belonging to a fa
ce
struct
face_face_ring
:
face_primitive_ring
<
face_handle
,
face_face_circulator
>
{
using
face_primitive_ring
<
face_handle
,
face_face_circulator
>::
face_primitive_
ring
;
}
;
// Iteration:
vertex_halfedge_out_circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()};
}
vertex_halfedge_out_circulator
end
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
true
};
}
/// all outgoing half-edges from a vertex
struct
vertex_halfedge_out_ring
:
vertex_primitive_ring
<
halfedge_handle
,
vertex_halfedge_out_circulator
>
{
using
vertex_primitive_ring
<
halfedge_handle
,
vertex_halfedge_out_circulator
>::
vertex_primitive_ring
;
};
/// all incoming half-edges from a vertex
struct
vertex_halfedge_in_ring
struct
vertex_halfedge_in_ring
:
vertex_primitive_ring
<
halfedge_handle
,
vertex_halfedge_in_circulator
>
{
vertex_handle
vertex
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
halfedge_handle
h
)
const
;
// Iteration:
vertex_halfedge_in_circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()};
}
vertex_halfedge_in_circulator
end
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
true
};
}
using
vertex_primitive_ring
<
halfedge_handle
,
vertex_halfedge_in_circulator
>::
vertex_primitive_ring
;
};
/// all adjacent vertices of a vertex
struct
vertex_vertex_ring
struct
vertex_vertex_ring
:
vertex_primitive_ring
<
vertex_handle
,
vertex_vertex_circulator
>
{
vertex_handle
vertex
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
vertex_handle
v
)
const
;
// Iteration:
vertex_vertex_circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()};
}
vertex_vertex_circulator
end
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
true
};
}
using
vertex_primitive_ring
<
vertex_handle
,
vertex_vertex_circulator
>::
vertex_primitive_ring
;
};
/// all adjacent edges of a vertex
struct
vertex_edge_ring
struct
vertex_edge_ring
:
vertex_primitive_ring
<
edge_handle
,
vertex_edge_circulator
>
{
vertex_handle
vertex
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
edge_handle
e
)
const
;
// Iteration:
vertex_edge_circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()};
}
vertex_edge_circulator
end
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
true
};
}
using
vertex_primitive_ring
<
edge_handle
,
vertex_edge_circulator
>::
vertex_primitive_ring
;
};
/// all adjacent faces of a vertex (INCLUDES invalid ones for boundaries)
struct
vertex_face_ring
struct
vertex_face_ring
:
vertex_primitive_ring
<
face_handle
,
vertex_face_circulator
>
{
vertex_handle
vertex
;
/// Number of vertices
/// O(result) computation
int
size
()
const
;
/// Returns true if handle is contained in this ring
bool
contains
(
face_handle
f
)
const
;
// Iteration:
vertex_face_circulator
begin
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
vertex
.
is_isolated
()};
}
vertex_face_circulator
end
()
const
{
return
{
vertex
.
any_outgoing_halfedge
(),
true
};
}
using
vertex_primitive_ring
<
face_handle
,
vertex_face_circulator
>::
vertex_primitive_ring
;
};
/// ======== IMPLEMENTATION ========
inline
int
face_vertex_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
face_edge_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
face_halfedge_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
face_face_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
vertex_halfedge_out_ring
::
size
()
const
template
<
class
this_t
,
class
element_handle
>
int
primitive_ring
<
this_t
,
element_handle
>::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
for
(
auto
v
:
*
static_cast
<
this_t
const
*>
(
this
)
)
{
(
void
)
v
;
// unused
cnt
++
;
...
...
@@ -385,119 +287,12 @@ inline int vertex_halfedge_out_ring::size() const
return
cnt
;
}
inline
int
vertex_halfedge_in_ring
::
size
()
const
template
<
class
this_t
,
class
element_handle
>
bool
primitive_ring
<
this_t
,
element_handle
>::
contains
(
element_handle
v
)
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
vertex_vertex_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
vertex_edge_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
int
vertex_face_ring
::
size
()
const
{
auto
cnt
=
0
;
for
(
auto
v
:
*
this
)
{
(
void
)
v
;
// unused
cnt
++
;
}
return
cnt
;
}
inline
bool
face_vertex_ring
::
contains
(
vertex_handle
v
)
const
{
for
(
auto
v2
:
*
this
)
if
(
v
==
v2
)
return
true
;
return
false
;
}
inline
bool
face_edge_ring
::
contains
(
edge_handle
e
)
const
{
for
(
auto
e2
:
*
this
)
if
(
e
==
e2
)
return
true
;
return
false
;
}
inline
bool
face_halfedge_ring
::
contains
(
halfedge_handle
h
)
const
{
for
(
auto
h2
:
*
this
)
if
(
h
==
h2
)
return
true
;
return
false
;
}
inline
bool
face_face_ring
::
contains
(
face_handle
f
)
const
{
for
(
auto
f2
:
*
this
)
if
(
f
==
f2
)
return
true
;
return
false
;
}
inline
bool
vertex_halfedge_out_ring
::
contains
(
halfedge_handle
h
)
const
{
for
(
auto
h2
:
*
this
)
if
(
h
==
h2
)
return
true
;
return
false
;
}
inline
bool
vertex_halfedge_in_ring
::
contains
(
halfedge_handle
h
)
const
{
for
(
auto
h2
:
*
this
)
if
(
h
==
h2
)
return
true
;
return
false
;
}
inline
bool
vertex_vertex_ring
::
contains
(
vertex_handle
v
)
const
{
for
(
auto
v2
:
*
this
)
for
(
auto
v2
:
*
static_cast
<
this_t
const
*>
(
this
))
if
(
v
==
v2
)
return
true
;
return
false
;
}
inline
bool
vertex_edge_ring
::
contains
(
edge_handle
e
)
const
{
for
(
auto
e2
:
*
this
)
if
(
e
==
e2
)
return
true
;
return
false
;
}
inline
bool
vertex_face_ring
::
contains
(
face_handle
f
)
const
{
for
(
auto
f2
:
*
this
)
if
(
f
==
f2
)
return
true
;
return
false
;
}
}
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