Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenMesh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenMesh
OpenMesh
Commits
50e3887a
Commit
50e3887a
authored
Jan 11, 2017
by
Janis Born
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Midpoint uniform subdivision scheme
parent
3179316c
Pipeline
#4115
failed with stage
in 40 minutes and 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
src/OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh
src/OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh
+82
-0
No files found.
src/OpenMesh/Tools/Subdivider/Uniform/MidpointT.hh
0 → 100644
View file @
50e3887a
#pragma once
#include <OpenMesh/Core/Mesh/BaseKernel.hh>
#include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
#include <OpenMesh/Core/Utils/PropertyManager.hh>
#include <algorithm>
namespace
OpenMesh
{
namespace
Subdivider
{
namespace
Uniform
{
template
<
typename
MeshType
,
typename
RealType
=
double
>
class
MidpointT
:
public
SubdividerT
<
MeshType
,
RealType
>
{
public:
using
real_t
=
RealType
;
using
mesh_t
=
MeshType
;
using
parent_t
=
SubdividerT
<
MeshType
,
RealType
>
;
using
parent_t
::
parent_t
;
const
char
*
name
()
const
{
return
"midpoint"
;
}
protected:
// SubdividerT interface
bool
prepare
(
mesh_t
&
_m
)
override
{
return
true
;
}
bool
subdivide
(
mesh_t
&
_m
,
size_t
_n
,
const
bool
_update_points
=
true
)
override
{
auto
edge_midpoint
=
makePropertyManagerFromNew
<
EPropHandleT
<
typename
mesh_t
::
VertexHandle
>>
(
_m
,
"edge_midpoint"
);
auto
is_original_vertex
=
makePropertyManagerFromNew
<
VPropHandleT
<
bool
>>
(
_m
,
"is_original_vertex"
);
for
(
size_t
iteration
=
0
;
iteration
<
_n
;
++
iteration
)
{
is_original_vertex
.
set_range
(
_m
.
vertices_begin
(),
_m
.
vertices_end
(),
true
);
// Create vertices on edge midpoints
for
(
const
auto
&
eh
:
_m
.
edges
())
{
auto
new_vh
=
_m
.
new_vertex
(
_m
.
calc_edge_midpoint
(
eh
));
edge_midpoint
[
eh
]
=
new_vh
;
is_original_vertex
[
new_vh
]
=
false
;
}
// Create new faces from original faces
for
(
const
auto
&
fh
:
_m
.
faces
())
{
std
::
vector
<
typename
mesh_t
::
VertexHandle
>
new_corners
;
for
(
const
auto
&
eh
:
_m
.
fe_range
(
fh
))
{
new_corners
.
push_back
(
edge_midpoint
[
eh
]);
}
_m
.
add_face
(
new_corners
);
}
// Create new faces from original vertices
for
(
const
auto
&
vh
:
_m
.
vertices
())
{
if
(
is_original_vertex
[
vh
])
{
if
(
!
_m
.
is_boundary
(
vh
))
{
std
::
vector
<
typename
mesh_t
::
VertexHandle
>
new_corners
;
for
(
const
auto
&
eh
:
_m
.
ve_range
(
vh
))
{
new_corners
.
push_back
(
edge_midpoint
[
eh
]);
}
std
::
reverse
(
begin
(
new_corners
),
end
(
new_corners
));
_m
.
add_face
(
new_corners
);
}
}
}
for
(
const
auto
&
vh
:
_m
.
vertices
())
{
if
(
is_original_vertex
[
vh
])
{
_m
.
delete_vertex
(
vh
);
}
}
}
return
true
;
}
bool
cleanup
(
mesh_t
&
_m
)
override
{
return
true
;
}
};
}
// namespace Uniform
}
// namespace Subdivider
}
// namespace OpenMesh
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