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
2cadd067
Commit
2cadd067
authored
Jun 29, 2018
by
Philip Trettner
Browse files
added primitive_handle
parent
63658644
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/polymesh/attributes.hh
View file @
2cadd067
...
...
@@ -448,93 +448,29 @@ AttrT const& primitive_index<tag>::operator[](primitive_index::attribute<AttrT>
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
face_handle
::
operator
[](
face_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
face_handle
::
operator
[](
face_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
vertex_handle
::
operator
[](
vertex_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
vertex_handle
::
operator
[](
vertex_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
edge_handle
::
operator
[](
edge_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
edge_handle
::
operator
[](
edge_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
face_handle
::
operator
[](
face_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
face_handle
::
operator
[](
face_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
&
vertex
_handle
::
operator
[](
vertex_
attribute
<
AttrT
>
*
attr
)
const
AttrT
&
primitive
_handle
<
tag
>
::
operator
[](
primitive_handle
::
attribute
<
AttrT
>
&
attr
)
const
{
return
(
*
attr
)[
*
this
];
return
attr
[
idx
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
const
&
vertex
_handle
::
operator
[](
vertex_
attribute
<
AttrT
>
const
*
attr
)
const
AttrT
const
&
primitive
_handle
<
tag
>
::
operator
[](
primitive_handle
::
attribute
<
AttrT
>
const
&
attr
)
const
{
return
(
*
attr
)[
*
this
];
return
attr
[
idx
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
&
edg
e_handle
::
operator
[](
edge_
attribute
<
AttrT
>*
attr
)
const
AttrT
&
primitiv
e_handle
<
tag
>
::
operator
[](
primitive_handle
::
attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
return
(
*
attr
)[
idx
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
const
&
edg
e_handle
::
operator
[](
edge_
attribute
<
AttrT
>
const
*
attr
)
const
AttrT
const
&
primitiv
e_handle
<
tag
>
::
operator
[](
primitive_handle
::
attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
return
(
*
attr
)[
idx
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
}
src/polymesh/cursors.hh
View file @
2cadd067
...
...
@@ -6,9 +6,9 @@
namespace
polymesh
{
// ========================
INDICES
========================
// ========================
BASE
========================
template
<
typename
tag
>
template
<
class
tag
>
struct
primitive_index
{
template
<
class
AttrT
>
...
...
@@ -38,60 +38,64 @@ struct primitive_index
AttrT
const
&
operator
[](
attribute
<
AttrT
>
const
*
prop
)
const
;
};
template
<
class
tag
>
struct
primitive_handle
{
template
<
class
AttrT
>
using
attribute
=
typename
primitive
<
tag
>::
template
attribute
<
AttrT
>;
using
index_t
=
typename
primitive
<
tag
>::
index
;
using
handle_t
=
typename
primitive
<
tag
>::
handle
;
Mesh
const
*
mesh
=
nullptr
;
index_t
idx
;
primitive_handle
()
=
default
;
primitive_handle
(
Mesh
const
*
mesh
,
index_t
idx
)
:
mesh
(
mesh
),
idx
(
idx
)
{}
bool
operator
==
(
index_t
const
&
rhs
)
const
{
return
idx
==
rhs
;
}
bool
operator
!=
(
index_t
const
&
rhs
)
const
{
return
idx
!=
rhs
;
}
bool
operator
==
(
handle_t
const
&
rhs
)
const
{
return
mesh
==
rhs
.
mesh
&&
idx
==
rhs
.
idx
;
}
bool
operator
!=
(
handle_t
const
&
rhs
)
const
{
return
mesh
!=
rhs
.
mesh
||
idx
!=
rhs
.
idx
;
}
template
<
class
AttrT
>
AttrT
&
operator
[](
attribute
<
AttrT
>&
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
attribute
<
AttrT
>
const
&
prop
)
const
;
template
<
class
AttrT
>
AttrT
&
operator
[](
attribute
<
AttrT
>*
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
attribute
<
AttrT
>
const
*
prop
)
const
;
bool
is_valid
()
const
{
return
idx
.
is_valid
();
}
///< valid idx (but could be deleted in some iterators)
bool
is_invalid
()
const
{
return
!
idx
.
is_valid
();
}
///< invalid idx
};
// ======================== INDICES ========================
struct
face_index
:
primitive_index
<
face_tag
>
{
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
struct
edge_index
:
primitive_index
<
edge_tag
>
{
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
struct
halfedge_index
:
primitive_index
<
halfedge_tag
>
{
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
struct
vertex_index
:
primitive_index
<
vertex_tag
>
{
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
// ===========================================
// OLD CODE:
// ======================== HANDLES ========================
struct
face_handle
struct
face_handle
:
primitive_handle
<
face_tag
>
{
Mesh
const
*
mesh
=
nullptr
;
face_index
idx
;
face_handle
()
=
default
;
face_handle
(
Mesh
const
*
mesh
,
face_index
idx
)
:
mesh
(
mesh
),
idx
(
idx
)
{}
bool
operator
==
(
face_index
const
&
rhs
)
const
{
return
idx
==
rhs
;
}
bool
operator
!=
(
face_index
const
&
rhs
)
const
{
return
idx
!=
rhs
;
}
bool
operator
==
(
face_handle
const
&
rhs
)
const
{
return
mesh
==
rhs
.
mesh
&&
idx
==
rhs
.
idx
;
}
bool
operator
!=
(
face_handle
const
&
rhs
)
const
{
return
mesh
!=
rhs
.
mesh
||
idx
!=
rhs
.
idx
;
}
template
<
class
AttrT
>
AttrT
&
operator
[](
face_attribute
<
AttrT
>&
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
face_attribute
<
AttrT
>
const
&
prop
)
const
;
template
<
class
AttrT
>
AttrT
&
operator
[](
face_attribute
<
AttrT
>*
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
face_attribute
<
AttrT
>
const
*
prop
)
const
;
bool
is_valid
()
const
{
return
idx
.
is_valid
();
}
///< valid idx (but could be deleted in some iterators)
bool
is_invalid
()
const
{
return
!
idx
.
is_valid
();
}
///< invalid idx
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
using
primitive_handle
::
primitive_handle
;
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
bool
is_boundary
()
const
;
///< true if this face lies at a boundary
vertex_handle
any_vertex
()
const
;
...
...
@@ -103,32 +107,11 @@ struct face_handle
face_face_ring
adjacent_faces
()
const
;
///< includes invalid ones for boundaries!
};
struct
vertex_handle
struct
vertex_handle
:
primitive_handle
<
vertex_tag
>
{
Mesh
const
*
mesh
=
nullptr
;
vertex_index
idx
;
vertex_handle
()
=
default
;
vertex_handle
(
Mesh
const
*
mesh
,
vertex_index
idx
)
:
mesh
(
mesh
),
idx
(
idx
)
{}
bool
operator
==
(
vertex_index
const
&
rhs
)
const
{
return
idx
==
rhs
;
}
bool
operator
!=
(
vertex_index
const
&
rhs
)
const
{
return
idx
!=
rhs
;
}
bool
operator
==
(
vertex_handle
const
&
rhs
)
const
{
return
mesh
==
rhs
.
mesh
&&
idx
==
rhs
.
idx
;
}
bool
operator
!=
(
vertex_handle
const
&
rhs
)
const
{
return
mesh
!=
rhs
.
mesh
||
idx
!=
rhs
.
idx
;
}
template
<
class
AttrT
>
AttrT
&
operator
[](
vertex_attribute
<
AttrT
>&
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
vertex_attribute
<
AttrT
>
const
&
prop
)
const
;
template
<
class
AttrT
>
AttrT
&
operator
[](
vertex_attribute
<
AttrT
>*
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
vertex_attribute
<
AttrT
>
const
*
prop
)
const
;
bool
is_valid
()
const
{
return
idx
.
is_valid
();
}
///< valid idx (but could be deleted in some iterators)
bool
is_invalid
()
const
{
return
!
idx
.
is_valid
();
}
///< invalid idx
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
using
primitive_handle
::
primitive_handle
;
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
bool
is_isolated
()
const
;
///< true if this vertex is not connected at all
bool
is_boundary
()
const
;
///< true if this vertex lies at a boundary
...
...
@@ -145,32 +128,11 @@ struct vertex_handle
vertex_vertex_ring
adjacent_vertices
()
const
;
};
struct
edge_handle
struct
edge_handle
:
primitive_handle
<
edge_tag
>
{
Mesh
const
*
mesh
=
nullptr
;
edge_index
idx
;
edge_handle
()
=
default
;
edge_handle
(
Mesh
const
*
mesh
,
edge_index
idx
)
:
mesh
(
mesh
),
idx
(
idx
)
{}
bool
operator
==
(
edge_index
const
&
rhs
)
const
{
return
idx
==
rhs
;
}
bool
operator
!=
(
edge_index
const
&
rhs
)
const
{
return
idx
!=
rhs
;
}
bool
operator
==
(
edge_handle
const
&
rhs
)
const
{
return
mesh
==
rhs
.
mesh
&&
idx
==
rhs
.
idx
;
}
bool
operator
!=
(
edge_handle
const
&
rhs
)
const
{
return
mesh
!=
rhs
.
mesh
||
idx
!=
rhs
.
idx
;
}
template
<
class
AttrT
>
AttrT
&
operator
[](
edge_attribute
<
AttrT
>&
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
edge_attribute
<
AttrT
>
const
&
prop
)
const
;
template
<
class
AttrT
>
AttrT
&
operator
[](
edge_attribute
<
AttrT
>*
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
edge_attribute
<
AttrT
>
const
*
prop
)
const
;
bool
is_valid
()
const
{
return
idx
.
is_valid
();
}
///< valid idx (but could be deleted in some iterators)
bool
is_invalid
()
const
{
return
!
idx
.
is_valid
();
}
///< invalid idx
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
using
primitive_handle
::
primitive_handle
;
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
bool
is_isolated
()
const
;
///< true if this edge has no faces
bool
is_boundary
()
const
;
///< true if this edge is a boundary
...
...
@@ -182,32 +144,11 @@ struct edge_handle
face_handle
faceB
()
const
;
///< can be invalid if boundary
};
struct
halfedge_handle
struct
halfedge_handle
:
primitive_handle
<
halfedge_tag
>
{
Mesh
const
*
mesh
=
nullptr
;
halfedge_index
idx
;
halfedge_handle
()
=
default
;
halfedge_handle
(
Mesh
const
*
mesh
,
halfedge_index
idx
)
:
mesh
(
mesh
),
idx
(
idx
)
{}
bool
operator
==
(
halfedge_index
const
&
rhs
)
const
{
return
idx
==
rhs
;
}
bool
operator
!=
(
halfedge_index
const
&
rhs
)
const
{
return
idx
!=
rhs
;
}
bool
operator
==
(
halfedge_handle
const
&
rhs
)
const
{
return
mesh
==
rhs
.
mesh
&&
idx
==
rhs
.
idx
;
}
bool
operator
!=
(
halfedge_handle
const
&
rhs
)
const
{
return
mesh
!=
rhs
.
mesh
||
idx
!=
rhs
.
idx
;
}
template
<
class
AttrT
>
AttrT
&
operator
[](
halfedge_attribute
<
AttrT
>&
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
halfedge_attribute
<
AttrT
>
const
&
prop
)
const
;
template
<
class
AttrT
>
AttrT
&
operator
[](
halfedge_attribute
<
AttrT
>*
prop
)
const
;
template
<
class
AttrT
>
AttrT
const
&
operator
[](
halfedge_attribute
<
AttrT
>
const
*
prop
)
const
;
bool
is_valid
()
const
{
return
idx
.
is_valid
();
}
///< valid idx (but could be deleted in some iterators)
bool
is_invalid
()
const
{
return
!
idx
.
is_valid
();
}
///< invalid idx
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
using
primitive_handle
::
primitive_handle
;
bool
is_removed
()
const
;
///< marked for deletion (but valid idx)
bool
is_boundary
()
const
;
///< true if this half-edge is a boundary (CAUTION: its opposite might not be)
vertex_handle
vertex_to
()
const
;
...
...
@@ -222,53 +163,19 @@ struct halfedge_handle
/// ======== IMPLEMENTATION ========
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
vertex_index
v
)
template
<
class
tag
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
primitive_index
<
tag
>
const
&
v
)
{
out
<<
"vertex
"
<<
v
.
value
;
out
<<
primitive
<
tag
>::
name
<<
"
"
<<
v
.
value
;
if
(
v
.
is_invalid
())
out
<<
" (invalid)"
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
face_index
f
)
{
out
<<
"face "
<<
f
.
value
;
if
(
f
.
is_invalid
())
out
<<
" (invalid)"
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
edge_index
e
)
{
out
<<
"edge "
<<
e
.
value
;
if
(
e
.
is_invalid
())
out
<<
" (invalid)"
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
halfedge_index
h
)
{
out
<<
"half-edge "
<<
h
.
value
;
if
(
h
.
is_invalid
())
out
<<
" (invalid)"
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
vertex_handle
v
)
template
<
class
tag
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
primitive_handle
<
tag
>
const
&
v
)
{
out
<<
v
.
idx
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
face_handle
f
)
{
out
<<
f
.
idx
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
edge_handle
e
)
{
out
<<
e
.
idx
;
return
out
;
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
halfedge_handle
h
)
{
out
<<
h
.
idx
;
return
out
;
}
}
src/polymesh/primitives.hh
View file @
2cadd067
...
...
@@ -10,6 +10,8 @@ struct primitive;
template
<
>
struct
primitive
<
vertex_tag
>
{
static
constexpr
auto
name
=
"vertex"
;
using
index
=
vertex_index
;
using
handle
=
vertex_handle
;
...
...
@@ -20,6 +22,8 @@ struct primitive<vertex_tag>
template
<
>
struct
primitive
<
face_tag
>
{
static
constexpr
auto
name
=
"face"
;
using
index
=
face_index
;
using
handle
=
face_handle
;
...
...
@@ -30,6 +34,8 @@ struct primitive<face_tag>
template
<
>
struct
primitive
<
edge_tag
>
{
static
constexpr
auto
name
=
"edge"
;
using
index
=
edge_index
;
using
handle
=
edge_handle
;
...
...
@@ -40,6 +46,8 @@ struct primitive<edge_tag>
template
<
>
struct
primitive
<
halfedge_tag
>
{
static
constexpr
auto
name
=
"half-edge"
;
using
index
=
halfedge_index
;
using
handle
=
halfedge_handle
;
...
...
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