Finished except unittests

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@910 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2013-08-07 12:24:09 +00:00
parent e30da7ea10
commit 959d80bb07
16 changed files with 117 additions and 113 deletions

View File

@@ -104,16 +104,16 @@ compute_new_positions_C0()
for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{
if (this->is_active(v_it))
if (this->is_active(*v_it))
{
// compute umbrella
u = zero;
for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it.is_valid(); ++vv_it)
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it)
{
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(*vv_it)) * w;
}
u *= this->weight(v_it);
u *= this->weight(*v_it);
u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it));
// damping
@@ -146,43 +146,43 @@ compute_new_positions_C1()
for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{
u = zero;
for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it.is_valid(); ++vv_it)
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it)
{
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
u -= vector_cast<typename Mesh::Normal>(Base::mesh_.point(*vv_it))*w;
}
u *= this->weight(v_it);
u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
u *= this->weight(*v_it);
u += vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it));
Base::mesh_.property(umbrellas_, v_it) = u;
Base::mesh_.property(umbrellas_, *v_it) = u;
}
// 2nd pass: compute updates
for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{
if (this->is_active(v_it))
if (this->is_active(*v_it))
{
uu = zero;
diag = 0.0;
for (vv_it=Base::mesh_.cvv_iter(v_it); vv_it.is_valid(); ++vv_it)
for (vv_it=Base::mesh_.cvv_iter(*v_it); vv_it.is_valid(); ++vv_it)
{
w = this->weight(Base::mesh_.edge_handle(vv_it.current_halfedge_handle()));
uu -= Base::mesh_.property(umbrellas_, *vv_it);
diag += (w * this->weight(*vv_it) + 1.0) * w;
}
uu *= this->weight(v_it);
diag *= this->weight(v_it);
uu += Base::mesh_.property(umbrellas_, v_it);
uu *= this->weight(*v_it);
diag *= this->weight(*v_it);
uu += Base::mesh_.property(umbrellas_, *v_it);
if (diag) uu *= 1.0/diag;
// damping
uu *= 0.25;
// store new position
p = vector_cast<typename Mesh::Normal>(Base::mesh_.point(v_it));
p = vector_cast<typename Mesh::Normal>(Base::mesh_.point(*v_it));
p -= uu;
this->set_new_position(v_it, p);
this->set_new_position(*v_it, p);
}
}
}

View File

@@ -140,7 +140,7 @@ compute_weights(LaplaceWeighting _weighting)
// init vertex weights
for (v_it=Base::mesh_.vertices_begin(); v_it!=v_end; ++v_it)
Base::mesh_.property(vertex_weights_, v_it) = 0.0;
Base::mesh_.property(vertex_weights_, *v_it) = 0.0;
@@ -156,9 +156,9 @@ compute_weights(LaplaceWeighting _weighting)
v0 = Base::mesh_.to_vertex_handle(heh0);
v1 = Base::mesh_.to_vertex_handle(heh1);
Base::mesh_.property(edge_weights_, e_it) = 1.0;
Base::mesh_.property(vertex_weights_, v0) += 1.0;
Base::mesh_.property(vertex_weights_, v1) += 1.0;
Base::mesh_.property(edge_weights_, *e_it) = 1.0;
Base::mesh_.property(vertex_weights_, v0) += 1.0;
Base::mesh_.property(vertex_weights_, v1) += 1.0;
}
break;

View File

@@ -135,8 +135,8 @@ initialize(Component _comp, Continuity _cont)
// store original points & normals
for (v_it=mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{
mesh_.property(original_positions_, v_it) = mesh_.point(v_it);
mesh_.property(original_normals_, v_it) = mesh_.normal(v_it);
mesh_.property(original_positions_, *v_it) = mesh_.point(*v_it);
mesh_.property(original_normals_, *v_it) = mesh_.normal(*v_it);
}
}
@@ -155,7 +155,7 @@ set_active_vertices()
// is something selected?
bool nothing_selected(true);
for (v_it=mesh_.vertices_begin(); v_it!=v_end; ++v_it)
if (mesh_.status(v_it).selected())
if (mesh_.status(*v_it).selected())
{ nothing_selected = false; break; }
@@ -163,15 +163,15 @@ set_active_vertices()
bool active;
for (v_it=mesh_.vertices_begin(); v_it!=v_end; ++v_it)
{
active = ((nothing_selected || mesh_.status(v_it).selected())
&& !mesh_.is_boundary(v_it)
&& !mesh_.status(v_it).locked());
active = ((nothing_selected || mesh_.status(*v_it).selected())
&& !mesh_.is_boundary(*v_it)
&& !mesh_.status(*v_it).locked());
if ( skip_features_ ) {
active = active && !mesh_.status(v_it).feature();
active = active && !mesh_.status(*v_it).feature();
typename Mesh::VertexOHalfedgeIter voh_it(mesh_,v_it);
typename Mesh::VertexOHalfedgeIter voh_it(mesh_,*v_it);
for ( ; voh_it.is_valid() ; ++voh_it ) {
// If the edge is a feature edge, skip the current vertex while smoothing
@@ -190,7 +190,7 @@ set_active_vertices()
}
}
mesh_.property(is_active_, v_it) = active;
mesh_.property(is_active_, *v_it) = active;
}
@@ -200,7 +200,7 @@ set_active_vertices()
typename Mesh::VVIter vv_it;
for (v_it=mesh_.vertices_begin(); v_it!=v_end; ++v_it)
if (mesh_.is_boundary(v_it))
if (mesh_.is_boundary(*v_it))
for (vv_it=mesh_.vv_iter(*v_it); vv_it.is_valid(); ++vv_it)
mesh_.property(is_active_, *vv_it) = false;
}
@@ -360,14 +360,14 @@ project_to_tangent_plane()
for (; v_it != v_end; ++v_it)
{
if (is_active(v_it))
if (is_active(*v_it))
{
translation = new_position(v_it)-orig_position(v_it);
normal = orig_normal(v_it);
translation = new_position(*v_it)-orig_position(*v_it);
normal = orig_normal(*v_it);
normal *= dot(translation, normal);
translation -= normal;
translation += vector_cast<typename Mesh::Normal>(orig_position(v_it));
set_new_position(v_it, translation);
translation += vector_cast<typename Mesh::Normal>(orig_position(*v_it));
set_new_position(*v_it, translation);
}
}
}
@@ -390,17 +390,17 @@ local_error_check()
for (; v_it != v_end; ++v_it)
{
if (is_active(v_it))
if (is_active(*v_it))
{
translation = new_position(v_it) - orig_position(v_it);
translation = new_position(*v_it) - orig_position(*v_it);
s = fabs(dot(translation, orig_normal(v_it)));
s = fabs(dot(translation, orig_normal(*v_it)));
if (s > tolerance_)
{
translation *= (tolerance_ / s);
translation += vector_cast<NormalType>(orig_position(v_it));
set_new_position(v_it, translation);
translation *= (tolerance_ / s);
translation += vector_cast<NormalType>(orig_position(*v_it));
set_new_position(*v_it, translation);
}
}
}
@@ -419,8 +419,8 @@ move_points()
v_end(mesh_.vertices_end());
for (; v_it != v_end; ++v_it)
if (is_active(v_it))
mesh_.set_point(v_it, mesh_.property(new_positions_, v_it));
if (is_active(*v_it))
mesh_.set_point(*v_it, mesh_.property(new_positions_, *v_it));
}