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
885fafb6
Commit
885fafb6
authored
Jul 16, 2018
by
Philip Trettner
Browse files
restructure algorithms folder, fixed some hole-related problems, added sqrt3-subdiv
parent
56153d0f
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/polymesh/Mesh.hh
View file @
885fafb6
...
...
@@ -114,10 +114,10 @@ private:
void
reserve_edges
(
int
capacity
);
void
reserve_halfedges
(
int
capacity
);
int
size_faces
()
const
{
return
(
int
)
mFaces
.
size
();
}
int
size_vertices
()
const
{
return
(
int
)
mVertices
.
size
();
}
int
size_edges
()
const
{
return
(
int
)
mHalfedges
.
size
()
>>
1
;
}
int
size_halfedges
()
const
{
return
(
int
)
mHalfedges
.
size
();
}
int
size_
all_
faces
()
const
{
return
(
int
)
mFaces
.
size
();
}
int
size_
all_
vertices
()
const
{
return
(
int
)
mVertices
.
size
();
}
int
size_
all_
edges
()
const
{
return
(
int
)
mHalfedges
.
size
()
>>
1
;
}
int
size_
all_
halfedges
()
const
{
return
(
int
)
mHalfedges
.
size
();
}
int
size_valid_faces
()
const
{
return
(
int
)
mFaces
.
size
()
-
mRemovedFaces
;
}
int
size_valid_vertices
()
const
{
return
(
int
)
mVertices
.
size
()
-
mRemovedVertices
;
}
...
...
@@ -302,42 +302,42 @@ private:
struct
face_info
&
face
(
face_index
i
)
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_faces
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
faces
());
return
mFaces
[
i
.
value
];
}
struct
face_info
const
&
face
(
face_index
i
)
const
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_faces
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
faces
());
return
mFaces
[
i
.
value
];
}
struct
vertex_info
&
vertex
(
vertex_index
i
)
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_vertices
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
vertices
());
return
mVertices
[
i
.
value
];
}
struct
vertex_info
const
&
vertex
(
vertex_index
i
)
const
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_vertices
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
vertices
());
return
mVertices
[
i
.
value
];
}
struct
halfedge_info
&
halfedge
(
halfedge_index
i
)
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_halfedges
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
halfedges
());
return
mHalfedges
[
i
.
value
];
}
struct
halfedge_info
const
&
halfedge
(
halfedge_index
i
)
const
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_halfedges
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
halfedges
());
return
mHalfedges
[
i
.
value
];
}
struct
halfedge_info
&
halfedge
(
edge_index
i
,
int
h
)
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_edges
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
edges
());
return
mHalfedges
[(
i
.
value
<<
1
)
+
h
];
}
struct
halfedge_info
const
&
halfedge
(
edge_index
i
,
int
h
)
const
{
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_edges
());
assert
(
i
.
is_valid
()
&&
i
.
value
<
size_
all_
edges
());
return
mHalfedges
[(
i
.
value
<<
1
)
+
h
];
}
...
...
src/polymesh/algorithms/geodesic
_fast_marching
.hh
→
src/polymesh/algorithms/geodesic
s/fmm_linear
.hh
View file @
885fafb6
...
...
@@ -8,7 +8,7 @@ namespace polymesh
{
vertex_attribute
<
float
>
geodesic_fast_marching_linear
(
Mesh
const
&
m
,
vertex_attribute
<
glm
::
vec3
>
const
&
position
)
{
auto
dis
=
m
.
vertices
().
make_attribute
<
float
>
(
-
1
);
auto
dis
=
m
.
vertices
().
make_attribute
_with_default
<
float
>
(
std
::
numeric_limits
<
float
>::
max
()
);
// TODO
...
...
src/polymesh/algorithms/geodesics/fmm_radial.hh
0 → 100644
View file @
885fafb6
src/polymesh/algorithms/geodesic
_nn
f.hh
→
src/polymesh/algorithms/geodesic
s/gs
f.hh
View file @
885fafb6
#pragma once
#include
"..
/Mesh.hh
"
#include
"..
/fields.hh
"
#include
<polymesh
/Mesh.hh
>
#include
<polymesh
/fields.hh
>
namespace
polymesh
{
...
...
@@ -28,4 +28,4 @@ GeodesicNNF<Vec3, Scalar> make_geodesic_nnf(Mesh const& m, vertex_attribute<Vec3
}
// Implementation
#include
"g
eodesic_nn
f.impl.hh"
#include
"g
s
f.impl.hh"
src/polymesh/algorithms/geodesic
_nn
f.impl.hh
→
src/polymesh/algorithms/geodesic
s/gs
f.impl.hh
View file @
885fafb6
#pragma once
#include
"g
eodesic_nn
f.hh"
#include
"g
s
f.hh"
namespace
polymesh
{
...
...
src/polymesh/algorithms/geodesics/heat.hh
0 → 100644
View file @
885fafb6
src/polymesh/algorithms/subdivision/loop.hh
0 → 100644
View file @
885fafb6
#pragma once
#include
<polymesh/Mesh.hh>
namespace
polymesh
{
/// Performs a loop subdivision step (topology only)
void
subdivide_loop
(
Mesh
&
m
);
}
src/polymesh/algorithms/subdivision/sqrt3.hh
0 → 100644
View file @
885fafb6
#pragma once
#include
<polymesh/Mesh.hh>
namespace
polymesh
{
/// Performs a uniform sqrt-3 subdivision step (topology only)
/// A provided function is called for each new vertex with handles (v_new, v0, v1, v2)
template
<
class
VertexF
>
void
subdivide_sqrt3
(
Mesh
&
m
,
VertexF
&&
vf
);
/// ======== IMPLEMENTATION ========
template
<
class
VertexF
>
void
subdivide_sqrt3
(
Mesh
&
m
,
VertexF
&&
vf
)
{
auto
e_end
=
m
.
edges
().
end
();
for
(
auto
f
:
m
.
faces
())
{
auto
h
=
f
.
any_halfedge
();
auto
v0
=
h
.
vertex_from
();
auto
v1
=
h
.
vertex_to
();
auto
v2
=
h
.
next
().
vertex_to
();
// split face
auto
v
=
m
.
faces
().
split
(
f
);
// call vf
vf
(
v
,
v0
,
v1
,
v2
);
}
// rotate old edges
for
(
auto
it
=
m
.
edges
().
begin
();
it
!=
e_end
;
++
it
)
{
auto
e
=
*
it
;
if
(
e
.
is_boundary
())
continue
;
m
.
edges
().
rotate_next
(
e
);
}
}
}
src/polymesh/impl/impl_attributes.hh
View file @
885fafb6
...
...
@@ -97,7 +97,7 @@ inline void Mesh::register_attr(primitive_attribute_base<vertex_tag> *attr) cons
nextAttrs
->
mPrevAttribute
=
attr
;
// resize attr
attr
->
resize
(
vertices
().
size
(),
false
);
attr
->
resize
(
all_
vertices
().
size
(),
false
);
}
inline
void
Mesh
::
deregister_attr
(
primitive_attribute_base
<
vertex_tag
>
*
attr
)
const
...
...
@@ -125,7 +125,7 @@ inline void Mesh::register_attr(primitive_attribute_base<face_tag> *attr) const
nextAttrs
->
mPrevAttribute
=
attr
;
// resize attr
attr
->
resize
(
faces
().
size
(),
false
);
attr
->
resize
(
all_
faces
().
size
(),
false
);
}
inline
void
Mesh
::
deregister_attr
(
primitive_attribute_base
<
face_tag
>
*
attr
)
const
...
...
@@ -153,7 +153,7 @@ inline void Mesh::register_attr(primitive_attribute_base<edge_tag> *attr) const
nextAttrs
->
mPrevAttribute
=
attr
;
// resize attr
attr
->
resize
(
edges
().
size
(),
false
);
attr
->
resize
(
all_
edges
().
size
(),
false
);
}
inline
void
Mesh
::
deregister_attr
(
primitive_attribute_base
<
edge_tag
>
*
attr
)
const
...
...
@@ -181,7 +181,7 @@ inline void Mesh::register_attr(primitive_attribute_base<halfedge_tag> *attr) co
nextAttrs
->
mPrevAttribute
=
attr
;
// resize attr
attr
->
resize
(
halfedges
().
size
(),
false
);
attr
->
resize
(
all_
halfedges
().
size
(),
false
);
}
inline
void
Mesh
::
deregister_attr
(
primitive_attribute_base
<
halfedge_tag
>
*
attr
)
const
...
...
src/polymesh/impl/impl_mesh.hh
View file @
885fafb6
...
...
@@ -491,7 +491,7 @@ inline vertex_index Mesh::next_valid_idx_from(vertex_index idx) const
for
(
auto
i
=
idx
.
value
;
i
<
(
int
)
mVertices
.
size
();
++
i
)
if
(
mVertices
[
i
].
is_valid
())
return
vertex_index
(
i
);
return
vertex_index
(
size_vertices
());
// end index
return
vertex_index
(
size_
all_
vertices
());
// end index
}
inline
vertex_index
Mesh
::
prev_valid_idx_from
(
vertex_index
idx
)
const
...
...
@@ -507,7 +507,7 @@ inline edge_index Mesh::next_valid_idx_from(edge_index idx) const
for
(
auto
i
=
idx
.
value
<<
1
;
i
<
(
int
)
mHalfedges
.
size
();
i
+=
2
)
if
(
mHalfedges
[
i
].
is_valid
())
return
edge_index
(
i
>>
1
);
return
edge_index
(
size_edges
());
// end index
return
edge_index
(
size_
all_
edges
());
// end index
}
inline
edge_index
Mesh
::
prev_valid_idx_from
(
edge_index
idx
)
const
...
...
@@ -523,7 +523,7 @@ inline face_index Mesh::next_valid_idx_from(face_index idx) const
for
(
auto
i
=
idx
.
value
;
i
<
(
int
)
mFaces
.
size
();
++
i
)
if
(
mFaces
[
i
].
is_valid
())
return
face_index
(
i
);
return
face_index
(
size_faces
());
// end index
return
face_index
(
size_
all_
faces
());
// end index
}
inline
face_index
Mesh
::
prev_valid_idx_from
(
face_index
idx
)
const
...
...
@@ -539,7 +539,7 @@ inline halfedge_index Mesh::next_valid_idx_from(halfedge_index idx) const
for
(
auto
i
=
idx
.
value
;
i
<
(
int
)
mHalfedges
.
size
();
++
i
)
if
(
mHalfedges
[
i
].
is_valid
())
return
halfedge_index
(
i
);
return
halfedge_index
(
size_halfedges
());
// end index
return
halfedge_index
(
size_
all_
halfedges
());
// end index
}
inline
halfedge_index
Mesh
::
prev_valid_idx_from
(
halfedge_index
idx
)
const
...
...
@@ -581,7 +581,8 @@ inline vertex_index Mesh::face_split(face_index f)
add_face
(
vs
,
3
);
h
=
halfedge
(
h
).
next_halfedge
;
// NOTE: add_face inserted a new halfedge
h
=
halfedge
(
opposite
(
halfedge
(
h
).
next_halfedge
)).
next_halfedge
;
}
while
(
h
!=
h_begin
);
return
vs
[
0
];
...
...
@@ -1121,10 +1122,10 @@ inline void Mesh::compactify()
return
;
// calculate remappings
int
v_cnt
=
size_vertices
();
int
f_cnt
=
size_faces
();
int
e_cnt
=
size_edges
();
int
h_cnt
=
size_halfedges
();
int
v_cnt
=
size_
all_
vertices
();
int
f_cnt
=
size_
all_
faces
();
int
e_cnt
=
size_
all_
edges
();
int
h_cnt
=
size_
all_
halfedges
();
std
::
vector
<
int
>
v_new_to_old
;
std
::
vector
<
int
>
f_new_to_old
;
std
::
vector
<
int
>
e_new_to_old
;
...
...
@@ -1214,13 +1215,13 @@ inline void Mesh::compactify()
mHalfedges
.
shrink_to_fit
();
for
(
auto
a
=
mVertexAttrs
;
a
;
a
=
a
->
mNextAttribute
)
a
->
resize
(
size_vertices
(),
true
);
a
->
resize
(
size_
all_
vertices
(),
true
);
for
(
auto
a
=
mFaceAttrs
;
a
;
a
=
a
->
mNextAttribute
)
a
->
resize
(
size_faces
(),
true
);
a
->
resize
(
size_
all_
faces
(),
true
);
for
(
auto
a
=
mEdgeAttrs
;
a
;
a
=
a
->
mNextAttribute
)
a
->
resize
(
size_edges
(),
true
);
a
->
resize
(
size_
all_
edges
(),
true
);
for
(
auto
a
=
mHalfedgeAttrs
;
a
;
a
=
a
->
mNextAttribute
)
a
->
resize
(
size_halfedges
(),
true
);
a
->
resize
(
size_
all_
halfedges
(),
true
);
mRemovedFaces
=
0
;
mRemovedHalfedges
=
0
;
...
...
src/polymesh/impl/impl_primitive.hh
View file @
885fafb6
...
...
@@ -5,10 +5,10 @@
namespace
polymesh
{
// primitive::all_size
inline
int
primitive
<
vertex_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_vertices
();
}
inline
int
primitive
<
face_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_faces
();
}
inline
int
primitive
<
edge_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_edges
();
}
inline
int
primitive
<
halfedge_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_halfedges
();
}
inline
int
primitive
<
vertex_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_
all_
vertices
();
}
inline
int
primitive
<
face_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_
all_
faces
();
}
inline
int
primitive
<
edge_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_
all_
edges
();
}
inline
int
primitive
<
halfedge_tag
>::
all_size
(
Mesh
const
&
m
)
{
return
m
.
size_
all_
halfedges
();
}
// primitive::valid_size
inline
int
primitive
<
vertex_tag
>::
valid_size
(
Mesh
const
&
m
)
{
return
m
.
size_valid_vertices
();
}
...
...
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