Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polymesh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Philip Trettner
polymesh
Commits
acadd249
Commit
acadd249
authored
6 years ago
by
Philip Trettner
Browse files
Options
Downloads
Patches
Plain Diff
working on smart ranges
parent
bed5c608
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/polymesh/algorithms/properties.hh
+5
-2
5 additions, 2 deletions
src/polymesh/algorithms/properties.hh
src/polymesh/impl/impl_ranges.hh
+23
-13
23 additions, 13 deletions
src/polymesh/impl/impl_ranges.hh
src/polymesh/ranges.hh
+22
-20
22 additions, 20 deletions
src/polymesh/ranges.hh
with
50 additions
and
35 deletions
src/polymesh/algorithms/properties.hh
+
5
−
2
View file @
acadd249
...
...
@@ -16,6 +16,9 @@
// - vertex normal
// - curvature
// - topological properties
//
// Note: unary properties should be usable as free functions OR as index into handles
// e.g. valence(v) is the same as v[valence]
namespace
polymesh
{
/// returns true if the vertex lies at a boundary
...
...
@@ -33,7 +36,7 @@ bool is_isolated(vertex_handle v);
bool
is_isolated
(
edge_handle
v
);
/// returns the vertex valence (number of adjacent vertices)
int
valence
_of
(
vertex_handle
v
);
int
valence
(
vertex_handle
v
);
/// returns the area of the (flat) polygonal face
template
<
class
Vec3
>
...
...
@@ -65,7 +68,7 @@ inline bool is_isolated(vertex_handle v) { return v.is_isolated(); }
inline
bool
is_isolated
(
edge_handle
v
)
{
return
v
.
is_isolated
();
}
inline
int
valence
_of
(
vertex_handle
v
)
{
return
v
.
adjacent_vertices
().
size
();
}
inline
int
valence
(
vertex_handle
v
)
{
return
v
.
adjacent_vertices
().
size
();
}
template
<
class
Vec3
>
typename
field_3d
<
Vec3
>::
Scalar
triangle_area
(
face_handle
f
,
vertex_attribute
<
Vec3
>
const
&
position
)
...
...
This diff is collapsed.
Click to expand it.
src/polymesh/impl/impl_ranges.hh
+
23
−
13
View file @
acadd249
...
...
@@ -4,33 +4,33 @@
namespace
polymesh
{
template
<
class
this_t
,
class
tag
>
typename
smart_range
<
this_t
,
tag
>::
handle
smart_range
<
this_t
,
tag
>::
first
()
const
template
<
class
this_t
,
class
ElementT
>
ElementT
smart_range
<
this_t
,
ElementT
>::
first
()
const
{
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
return
h
;
return
handle
::
invalid
()
;
return
{}
;
}
template
<
class
this_t
,
class
tag
>
typename
smart_range
<
this_t
,
tag
>::
handle
smart_range
<
this_t
,
tag
>::
last
()
const
template
<
class
this_t
,
class
ElementT
>
ElementT
smart_range
<
this_t
,
ElementT
>::
last
()
const
{
handle
result
;
ElementT
result
;
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
result
=
h
;
return
result
;
}
template
<
class
this_t
,
class
tag
>
bool
smart_range
<
this_t
,
tag
>::
any
()
const
template
<
class
this_t
,
class
ElementT
>
bool
smart_range
<
this_t
,
ElementT
>::
any
()
const
{
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
return
true
;
return
false
;
}
template
<
class
this_t
,
class
tag
>
template
<
typename
PredT
>
bool
smart_range
<
this_t
,
tag
>::
any
(
PredT
&&
p
)
const
template
<
class
this_t
,
class
ElementT
>
template
<
class
PredT
>
bool
smart_range
<
this_t
,
ElementT
>::
any
(
PredT
&&
p
)
const
{
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
if
(
p
(
h
))
...
...
@@ -38,8 +38,18 @@ bool smart_range<this_t, tag>::any(PredT&& p) const
return
false
;
}
template
<
class
this_t
,
class
tag
>
int
smart_range
<
this_t
,
tag
>::
count
()
const
template
<
class
this_t
,
class
ElementT
>
template
<
class
PredT
>
bool
smart_range
<
this_t
,
ElementT
>::
all
(
PredT
&&
p
)
const
{
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
if
(
!
p
(
h
))
return
false
;
return
true
;
}
template
<
class
this_t
,
class
ElementT
>
int
smart_range
<
this_t
,
ElementT
>::
count
()
const
{
auto
cnt
=
0
;
for
(
auto
h
:
static_cast
<
this_t
const
*>
(
this
))
...
...
This diff is collapsed.
Click to expand it.
src/polymesh/ranges.hh
+
22
−
20
View file @
acadd249
...
...
@@ -7,40 +7,43 @@
namespace
polymesh
{
template
<
class
T
>
struct
aabb
{
T
min
;
T
max
;
};
template
<
class
this_t
,
class
tag
>
template
<
class
this_t
,
class
ElementT
>
struct
smart_range
{
template
<
class
AttrT
>
using
attribute
=
typename
primitive
<
tag
>::
template
attribute
<
AttrT
>;
using
handle
=
typename
primitive
<
tag
>::
handle
;
/// returns the first element in this range
/// returns invalid on empty ranges
handle
first
()
const
;
/// returns invalid on empty ranges
(or default ctor'd one)
ElementT
first
()
const
;
/// returns the last element in this range
/// returns invalid on empty ranges
/// returns invalid on empty ranges
(or default ctor'd one)
/// TODO: how to make this O(1)
handle
last
()
const
;
ElementT
last
()
const
;
/// returns true if the range is non-empty
bool
any
()
const
;
/// returns true if any handle fulfils p(h)
template
<
typename
PredT
>
/// also works for boolean attributes
template
<
class
PredT
>
bool
any
(
PredT
&&
p
)
const
;
/// returns true if any attribute is true for this range
// bool any(attribute<bool> const& a) const;
/// returns true if all handles fulfil p(h)
template
<
typename
PredT
>
/// also works for boolean attributes
template
<
class
PredT
>
bool
all
(
PredT
&&
p
)
const
;
/// returns true if all attributes are true for this range
// bool all(attribute<bool> const& a) const;
/// returns the number of elements in this range
/// NOTE: this is an O(n) operation, prefer size() if available
/// TODO: maybe SFINAE to implement this via size() if available?
int
count
()
const
;
// template<class T>
// T min() const;
// TODO:
// - average
// - sum
...
...
@@ -51,15 +54,14 @@ struct smart_range
// - map
// - skip
// - only_valid
// - count
};
// ================= COLLECTION =================
template
<
class
mesh_ptr
,
class
tag
,
class
iterator
>
struct
smart_collection
:
smart_range
<
smart_collection
<
mesh_ptr
,
tag
,
iterator
>
,
t
ag
>
struct
smart_collection
:
smart_range
<
smart_collection
<
mesh_ptr
,
tag
,
iterator
>
,
t
ypename
primitive
<
tag
>::
handle
>
{
template
<
typename
AttrT
>
template
<
class
AttrT
>
using
attribute
=
typename
primitive
<
tag
>::
template
attribute
<
AttrT
>;
/// Number of primitives, INCLUDING those marked for deletion
...
...
@@ -232,7 +234,7 @@ struct valid_halfedge_const_collection : smart_collection<Mesh const*, halfedge_
// ================= RINGS =================
template
<
class
this_t
,
class
tag
>
struct
primitive_ring
:
smart_range
<
this_t
,
t
ag
>
struct
primitive_ring
:
smart_range
<
this_t
,
t
ypename
primitive
<
tag
>::
handle
>
{
using
handle
=
typename
primitive
<
tag
>::
handle
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment