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
63658644
Commit
63658644
authored
Jun 29, 2018
by
Philip Trettner
Browse files
added primitive index
parent
eba11f32
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/polymesh/attributes.hh
View file @
63658644
...
...
@@ -23,6 +23,16 @@
namespace
polymesh
{
template
<
class
Primitive
,
class
AttrT
>
struct
primitive_attribute
{
};
// ===========================================
// OLD CODE:
template
<
class
AttrT
>
struct
vertex_attribute
:
vertex_attribute_base
{
...
...
@@ -413,37 +423,44 @@ halfedge_attribute<AttrT>& halfedge_attribute<AttrT>::operator=(halfedge_attribu
/// ======== CURSOR IMPLEMENTATION ========
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
&
fac
e_index
::
operator
[](
face_
attribute
<
AttrT
>&
attr
)
const
AttrT
&
primitiv
e_index
<
tag
>
::
operator
[](
primitive_index
::
attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
const
&
fac
e_index
::
operator
[](
face_
attribute
<
AttrT
>
const
&
attr
)
const
AttrT
const
&
primitiv
e_index
<
tag
>
::
operator
[](
primitive_index
::
attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
&
face_handle
::
operator
[](
face_
attribute
<
AttrT
>
&
attr
)
const
AttrT
&
primitive_index
<
tag
>::
operator
[](
primitive_index
::
attribute
<
AttrT
>
*
attr
)
const
{
return
attr
[
*
this
];
return
(
*
attr
)
[
*
this
];
}
template
<
class
tag
>
template
<
class
AttrT
>
AttrT
const
&
face_handle
::
operator
[](
face_
attribute
<
AttrT
>
const
&
attr
)
const
AttrT
const
&
primitive_index
<
tag
>::
operator
[](
primitive_index
::
attribute
<
AttrT
>
const
*
attr
)
const
{
return
attr
[
*
this
];
return
(
*
attr
)
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
vertex_index
::
operator
[](
vertex
_attribute
<
AttrT
>&
attr
)
const
AttrT
&
face_handle
::
operator
[](
face
_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
vertex_index
::
operator
[](
vertex
_attribute
<
AttrT
>
const
&
attr
)
const
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
{
...
...
@@ -455,16 +472,6 @@ AttrT const& vertex_handle::operator[](vertex_attribute<AttrT> const& attr) cons
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
edge_index
::
operator
[](
edge_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
edge_index
::
operator
[](
edge_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
edge_handle
::
operator
[](
edge_attribute
<
AttrT
>&
attr
)
const
{
...
...
@@ -476,16 +483,6 @@ AttrT const& edge_handle::operator[](edge_attribute<AttrT> const& attr) const
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_index
::
operator
[](
halfedge_attribute
<
AttrT
>&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
halfedge_index
::
operator
[](
halfedge_attribute
<
AttrT
>
const
&
attr
)
const
{
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>&
attr
)
const
{
...
...
@@ -497,16 +494,6 @@ AttrT const& halfedge_handle::operator[](halfedge_attribute<AttrT> const& attr)
return
attr
[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
face_index
::
operator
[](
face_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
face_index
::
operator
[](
face_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
face_handle
::
operator
[](
face_attribute
<
AttrT
>*
attr
)
const
{
...
...
@@ -518,16 +505,6 @@ AttrT const& face_handle::operator[](face_attribute<AttrT> const* attr) const
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
vertex_index
::
operator
[](
vertex_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
vertex_index
::
operator
[](
vertex_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
vertex_handle
::
operator
[](
vertex_attribute
<
AttrT
>*
attr
)
const
{
...
...
@@ -539,16 +516,6 @@ AttrT const& vertex_handle::operator[](vertex_attribute<AttrT> const* attr) cons
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
edge_index
::
operator
[](
edge_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
edge_index
::
operator
[](
edge_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
edge_handle
::
operator
[](
edge_attribute
<
AttrT
>*
attr
)
const
{
...
...
@@ -560,16 +527,6 @@ AttrT const& edge_handle::operator[](edge_attribute<AttrT> const* attr) const
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_index
::
operator
[](
halfedge_attribute
<
AttrT
>*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
const
&
halfedge_index
::
operator
[](
halfedge_attribute
<
AttrT
>
const
*
attr
)
const
{
return
(
*
attr
)[
*
this
];
}
template
<
class
AttrT
>
AttrT
&
halfedge_handle
::
operator
[](
halfedge_attribute
<
AttrT
>*
attr
)
const
{
...
...
src/polymesh/cursors.hh
View file @
63658644
...
...
@@ -2,132 +2,67 @@
#include <iostream>
#include "primitives.hh"
namespace
polymesh
{
class
Mesh
;
template
<
class
PropT
>
struct
vertex_attribute
;
template
<
class
PropT
>
struct
face_attribute
;
template
<
class
PropT
>
struct
edge_attribute
;
template
<
class
PropT
>
struct
halfedge_attribute
;
struct
vertex_handle
;
struct
face_handle
;
struct
edge_handle
;
struct
halfedge_handle
;
struct
face_vertex_ring
;
struct
face_edge_ring
;
struct
face_halfedge_ring
;
struct
face_face_ring
;
struct
vertex_halfedge_out_ring
;
struct
vertex_halfedge_in_ring
;
struct
vertex_face_ring
;
struct
vertex_edge_ring
;
struct
vertex_vertex_ring
;
// ======================== INDICES ========================
struct
face_index
template
<
typename
tag
>
struct
primitive_index
{
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
;
int
value
=
-
1
;
fac
e_index
()
=
default
;
explicit
fac
e_index
(
int
idx
)
:
value
(
idx
)
{}
primitiv
e_index
()
=
default
;
explicit
primitiv
e_index
(
int
idx
)
:
value
(
idx
)
{}
bool
is_valid
()
const
{
return
value
>=
0
;
}
bool
is_invalid
()
const
{
return
value
<
0
;
}
static
face_
index
invalid
()
{
return
{};
}
bool
operator
==
(
face_
index
const
&
rhs
)
const
{
return
value
==
rhs
.
value
;
}
bool
operator
!=
(
face_
index
const
&
rhs
)
const
{
return
value
!=
rhs
.
value
;
}
template
<
class
Prop
T
>
Prop
T
&
operator
[](
face_
attribute
<
Prop
T
>&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
face_
attribute
<
Prop
T
>
const
&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
&
operator
[](
face_
attribute
<
Prop
T
>*
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
face_
attribute
<
Prop
T
>
const
*
prop
)
const
;
static
index
_t
invalid
()
{
return
{};
}
bool
operator
==
(
index
_t
const
&
rhs
)
const
{
return
value
==
rhs
.
value
;
}
bool
operator
!=
(
index
_t
const
&
rhs
)
const
{
return
value
!=
rhs
.
value
;
}
template
<
class
Attr
T
>
Attr
T
&
operator
[](
attribute
<
Attr
T
>&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
attribute
<
Attr
T
>
const
&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
attribute
<
Attr
T
>*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
attribute
<
Attr
T
>
const
*
prop
)
const
;
};
struct
vertex_index
struct
face_index
:
primitive_index
<
face_tag
>
{
int
value
=
-
1
;
vertex_index
()
=
default
;
explicit
vertex_index
(
int
idx
)
:
value
(
idx
)
{}
bool
is_valid
()
const
{
return
value
>=
0
;
}
bool
is_invalid
()
const
{
return
value
<
0
;
}
static
vertex_index
invalid
()
{
return
{};
}
bool
operator
==
(
vertex_index
const
&
rhs
)
const
{
return
value
==
rhs
.
value
;
}
bool
operator
!=
(
vertex_index
const
&
rhs
)
const
{
return
value
!=
rhs
.
value
;
}
template
<
class
PropT
>
PropT
&
operator
[](
vertex_attribute
<
PropT
>&
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
vertex_attribute
<
PropT
>
const
&
prop
)
const
;
template
<
class
PropT
>
PropT
&
operator
[](
vertex_attribute
<
PropT
>*
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
vertex_attribute
<
PropT
>
const
*
prop
)
const
;
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
struct
edge_index
struct
edge_index
:
primitive_index
<
edge_tag
>
{
int
value
=
-
1
;
edge_index
()
=
default
;
explicit
edge_index
(
int
idx
)
:
value
(
idx
)
{}
bool
is_valid
()
const
{
return
value
>=
0
;
}
bool
is_invalid
()
const
{
return
value
<
0
;
}
static
edge_index
invalid
()
{
return
{};
}
bool
operator
==
(
edge_index
const
&
rhs
)
const
{
return
value
==
rhs
.
value
;
}
bool
operator
!=
(
edge_index
const
&
rhs
)
const
{
return
value
!=
rhs
.
value
;
}
template
<
class
PropT
>
PropT
&
operator
[](
edge_attribute
<
PropT
>&
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
edge_attribute
<
PropT
>
const
&
prop
)
const
;
template
<
class
PropT
>
PropT
&
operator
[](
edge_attribute
<
PropT
>*
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
edge_attribute
<
PropT
>
const
*
prop
)
const
;
using
primitive_index
::
primitive_index
;
using
primitive_index
::
operator
=
;
};
struct
halfedge_index
struct
halfedge_index
:
primitive_index
<
halfedge_tag
>
{
int
value
=
-
1
;
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
=
;
};
halfedge_index
()
=
default
;
explicit
halfedge_index
(
int
idx
)
:
value
(
idx
)
{}
bool
is_valid
()
const
{
return
value
>=
0
;
}
bool
is_invalid
()
const
{
return
value
<
0
;
}
static
halfedge_index
invalid
()
{
return
{};
}
bool
operator
==
(
halfedge_index
const
&
rhs
)
const
{
return
value
==
rhs
.
value
;
}
bool
operator
!=
(
halfedge_index
const
&
rhs
)
const
{
return
value
!=
rhs
.
value
;
}
template
<
class
PropT
>
PropT
&
operator
[](
halfedge_attribute
<
PropT
>&
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
halfedge_attribute
<
PropT
>
const
&
prop
)
const
;
template
<
class
PropT
>
PropT
&
operator
[](
halfedge_attribute
<
PropT
>*
prop
)
const
;
template
<
class
PropT
>
PropT
const
&
operator
[](
halfedge_attribute
<
PropT
>
const
*
prop
)
const
;
};
// ===========================================
// OLD CODE:
// ======================== HANDLES ========================
...
...
@@ -144,14 +79,14 @@ struct face_handle
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
Prop
T
>
Prop
T
&
operator
[](
face_attribute
<
Prop
T
>&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
face_attribute
<
Prop
T
>
const
&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
&
operator
[](
face_attribute
<
Prop
T
>*
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
face_attribute
<
Prop
T
>
const
*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
face_attribute
<
Attr
T
>&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
face_attribute
<
Attr
T
>
const
&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
face_attribute
<
Attr
T
>*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
face_attribute
<
Attr
T
>
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
...
...
@@ -181,14 +116,14 @@ struct vertex_handle
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
Prop
T
>
Prop
T
&
operator
[](
vertex_attribute
<
Prop
T
>&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
vertex_attribute
<
Prop
T
>
const
&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
&
operator
[](
vertex_attribute
<
Prop
T
>*
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
vertex_attribute
<
Prop
T
>
const
*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
vertex_attribute
<
Attr
T
>&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
vertex_attribute
<
Attr
T
>
const
&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
vertex_attribute
<
Attr
T
>*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
vertex_attribute
<
Attr
T
>
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
...
...
@@ -223,14 +158,14 @@ struct edge_handle
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
Prop
T
>
Prop
T
&
operator
[](
edge_attribute
<
Prop
T
>&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
edge_attribute
<
Prop
T
>
const
&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
&
operator
[](
edge_attribute
<
Prop
T
>*
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
edge_attribute
<
Prop
T
>
const
*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
edge_attribute
<
Attr
T
>&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
edge_attribute
<
Attr
T
>
const
&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
edge_attribute
<
Attr
T
>*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
edge_attribute
<
Attr
T
>
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
...
...
@@ -260,14 +195,14 @@ struct halfedge_handle
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
Prop
T
>
Prop
T
&
operator
[](
halfedge_attribute
<
Prop
T
>&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
halfedge_attribute
<
Prop
T
>
const
&
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
&
operator
[](
halfedge_attribute
<
Prop
T
>*
prop
)
const
;
template
<
class
Prop
T
>
Prop
T
const
&
operator
[](
halfedge_attribute
<
Prop
T
>
const
*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
halfedge_attribute
<
Attr
T
>&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
halfedge_attribute
<
Attr
T
>
const
&
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
&
operator
[](
halfedge_attribute
<
Attr
T
>*
prop
)
const
;
template
<
class
Attr
T
>
Attr
T
const
&
operator
[](
halfedge_attribute
<
Attr
T
>
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
...
...
src/polymesh/fwd.hh
0 → 100644
View file @
63658644
#pragma once
namespace
polymesh
{
class
Mesh
;
struct
vertex_tag
;
struct
face_tag
;
struct
edge_tag
;
struct
halfedge_tag
;
template
<
class
PropT
>
struct
vertex_attribute
;
template
<
class
PropT
>
struct
face_attribute
;
template
<
class
PropT
>
struct
edge_attribute
;
template
<
class
PropT
>
struct
halfedge_attribute
;
struct
vertex_index
;
struct
face_index
;
struct
edge_index
;
struct
halfedge_index
;
struct
vertex_handle
;
struct
face_handle
;
struct
edge_handle
;
struct
halfedge_handle
;
struct
face_vertex_ring
;
struct
face_edge_ring
;
struct
face_halfedge_ring
;
struct
face_face_ring
;
struct
vertex_halfedge_out_ring
;
struct
vertex_halfedge_in_ring
;
struct
vertex_face_ring
;
struct
vertex_edge_ring
;
struct
vertex_vertex_ring
;
}
src/polymesh/iterators.hh
View file @
63658644
...
...
@@ -9,6 +9,19 @@
namespace
polymesh
{
struct
valid_primitive_iterator
{
};
// ===========================================
// OLD CODE:
struct
valid_vertex_iterator
{
valid_vertex_iterator
()
=
default
;
...
...
src/polymesh/primitives.hh
0 → 100644
View file @
63658644
#pragma once
#include "fwd.hh"
namespace
polymesh
{
template
<
typename
tag
>
struct
primitive
;
template
<
>
struct
primitive
<
vertex_tag
>
{
using
index
=
vertex_index
;
using
handle
=
vertex_handle
;
template
<
class
AttrT
>
using
attribute
=
vertex_attribute
<
AttrT
>
;
};
template
<
>
struct
primitive
<
face_tag
>
{
using
index
=
face_index
;
using
handle
=
face_handle
;
template
<
class
AttrT
>
using
attribute
=
face_attribute
<
AttrT
>
;
};
template
<
>
struct
primitive
<
edge_tag
>
{
using
index
=
edge_index
;
using
handle
=
edge_handle
;
template
<
class
AttrT
>
using
attribute
=
edge_attribute
<
AttrT
>
;
};
template
<
>
struct
primitive
<
halfedge_tag
>
{
using
index
=
halfedge_index
;
using
handle
=
halfedge_handle
;
template
<
class
AttrT
>
using
attribute
=
halfedge_attribute
<
AttrT
>
;
};
}
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