- updated the OpenMesh tutorials to be OM 3 compliant
- added all the tutorials except "Using IO::Options" as unittests git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@968 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -46,20 +46,20 @@ int main(int argc, char **argv)
|
||||
{
|
||||
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
|
||||
{
|
||||
mesh.property(cogs,v_it).vectorize(0.0f);
|
||||
valence = 0;
|
||||
mesh.property(cogs,*v_it).vectorize(0.0f);
|
||||
valence = 0.0;
|
||||
|
||||
for (vv_it=mesh.vv_iter( v_it ); vv_it; ++vv_it)
|
||||
for (vv_it=mesh.vv_iter( *v_it ); vv_it; ++vv_it)
|
||||
{
|
||||
mesh.property(cogs,v_it) += mesh.point( vv_it );
|
||||
mesh.property(cogs,*v_it) += mesh.point( *vv_it );
|
||||
++valence;
|
||||
}
|
||||
mesh.property(cogs,v_it) /= valence;
|
||||
mesh.property(cogs,*v_it) /= valence;
|
||||
}
|
||||
|
||||
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
|
||||
if ( !mesh.is_boundary( v_it ) )
|
||||
mesh.set_point( v_it, mesh.property(cogs,v_it) );
|
||||
if ( !mesh.is_boundary( *v_it ) )
|
||||
mesh.set_point( *v_it, mesh.property(cogs,*v_it) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,21 +52,20 @@ private:
|
||||
: mesh_(_mesh), cog_(_cog)
|
||||
{}
|
||||
|
||||
void operator()(typename Mesh::Vertex& _v)
|
||||
void operator()(const typename Mesh::VertexHandle& _vh)
|
||||
{
|
||||
typename Mesh::VertexHandle vh( mesh_.handle(_v) );
|
||||
typename Mesh::VertexVertexIter vv_it;
|
||||
typename Mesh::Scalar valence(0.0);
|
||||
|
||||
mesh_.property(cog_, vh) = typename Mesh::Point(0.0, 0.0, 0.0);
|
||||
mesh_.property(cog_, _vh) = typename Mesh::Point(0.0, 0.0, 0.0);
|
||||
|
||||
for (vv_it=mesh_.vv_iter(vh); vv_it; ++vv_it)
|
||||
for (vv_it=mesh_.vv_iter(_vh); vv_it.is_valid(); ++vv_it)
|
||||
{
|
||||
mesh_.property(cog_, vh) += mesh_.point( vv_it );
|
||||
mesh_.property(cog_, _vh) += mesh_.point( *vv_it );
|
||||
++valence;
|
||||
}
|
||||
|
||||
mesh_.property(cog_, mesh_.handle(_v) ) /= valence;
|
||||
mesh_.property(cog_, _vh ) /= valence;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -82,12 +81,11 @@ private:
|
||||
: mesh_(_mesh), cog_(_cog)
|
||||
{}
|
||||
|
||||
void operator()(typename Mesh::Vertex& _v)
|
||||
void operator()(const typename Mesh::VertexHandle& _vh)
|
||||
{
|
||||
typename Mesh::VertexHandle vh(mesh_.handle(_v));
|
||||
|
||||
if (!mesh_.is_boundary(vh))
|
||||
mesh_.set_point( vh, mesh_.property(cog_, vh) );
|
||||
if (!mesh_.is_boundary(_vh))
|
||||
mesh_.set_point( _vh, mesh_.property(cog_, _vh) );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -52,9 +52,9 @@ int main(int argc, char **argv)
|
||||
for (MyMesh::VertexIter v_it = mesh.vertices_begin();
|
||||
v_it != mesh.vertices_end(); ++v_it)
|
||||
{
|
||||
std::cout << "Vertex #" << v_it << ": " << mesh.point( v_it );
|
||||
mesh.set_point( v_it, mesh.point(v_it)+mesh.normal(v_it) );
|
||||
std::cout << " moved to " << mesh.point( v_it ) << std::endl;
|
||||
std::cout << "Vertex #" << *v_it << ": " << mesh.point( *v_it );
|
||||
mesh.set_point( *v_it, mesh.point(*v_it)+mesh.normal(*v_it) );
|
||||
std::cout << " moved to " << mesh.point( *v_it ) << std::endl;
|
||||
}
|
||||
|
||||
// don't need the normals anymore? Remove them!
|
||||
|
||||
@@ -85,9 +85,9 @@ int main(int argc, char **argv)
|
||||
for (MyMesh::VertexIter v_it = mesh.vertices_begin();
|
||||
v_it != mesh.vertices_end(); ++v_it)
|
||||
{
|
||||
std::cout << "Vertex #" << v_it << ": " << mesh.point( v_it );
|
||||
mesh.set_point( v_it, mesh.point(v_it)+mesh.normal(v_it) );
|
||||
std::cout << " moved to " << mesh.point( v_it ) << std::endl;
|
||||
std::cout << "Vertex #" << *v_it << ": " << mesh.point( *v_it );
|
||||
mesh.set_point( *v_it, mesh.point(*v_it)+mesh.normal(*v_it) );
|
||||
std::cout << " moved to " << mesh.point( *v_it ) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -100,13 +100,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
cog[0] = cog[1] = cog[2] = valence = 0.0;
|
||||
|
||||
for (vv_it=mesh.vv_iter(*v_it); vv_it; ++vv_it)
|
||||
for (vv_it=mesh.vv_iter(*v_it); vv_it.is_valid(); ++vv_it)
|
||||
{
|
||||
cog += mesh.point( *vv_it );
|
||||
++valence;
|
||||
}
|
||||
|
||||
mesh.data(v_it).set_cog(cog / valence);
|
||||
mesh.data(*v_it).set_cog(cog / valence);
|
||||
}
|
||||
|
||||
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
|
||||
|
||||
@@ -15,10 +15,10 @@ fill_props( Mesh& _m, OpenMesh::VPropHandleT<float> _ph, bool _check=false)
|
||||
it != _m.vertices_end(); ++it)
|
||||
{
|
||||
const float v = a[it->idx()%9];
|
||||
if ( _check && !(_m.property( _ph, it ) == v) )
|
||||
if ( _check && !(_m.property( _ph, *it ) == v) )
|
||||
return false;
|
||||
else
|
||||
_m.property( _ph, it ) = v;
|
||||
_m.property( _ph, *it ) = v;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -35,15 +35,15 @@ fill_props( Mesh& _m, OpenMesh::EPropHandleT<bool> _ph, bool _check=false )
|
||||
const size_t n = it->idx();
|
||||
const bool v = ((n&(n-1))==0); // true for 0,1,2,4,8,..
|
||||
|
||||
if (_check && _m.property( _ph, it ) != v)
|
||||
if (_check && _m.property( _ph, *it ) != v)
|
||||
{
|
||||
std::cout << " eprop_bool: " << n << " -> "
|
||||
<< _m.property(_ph, it ) << " != " << v << std::endl;
|
||||
<< _m.property(_ph, *it ) << " != " << v << std::endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_m.property( _ph, it ) = v;
|
||||
_m.property( _ph, *it ) = v;
|
||||
std::cout << " eprop_bool: " << n << " -> " << v << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ fill_props(Mesh& _m, OpenMesh::FPropHandleT<std::string> _ph, bool _check=false)
|
||||
for( typename Mesh::FaceIter it=_m.faces_begin();
|
||||
it != _m.faces_end(); ++it)
|
||||
{
|
||||
const int n = ++(it->idx());
|
||||
_m.property( _ph, it ) = int2roman(n);
|
||||
const int n = (it->idx()) + 1;
|
||||
_m.property( _ph, *it ) = int2roman(n);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -92,10 +92,10 @@ fill_props( Mesh& _m, OpenMesh::HPropHandleT<T> _ph, bool _check=false)
|
||||
v.vec4fval[2] = c[n%9];
|
||||
v.vec4fval[3] = d[n%9];
|
||||
|
||||
if ( _check && _m.property( _ph, it ) != v )
|
||||
if ( _check && _m.property( _ph, *it ) != v )
|
||||
return false;
|
||||
else
|
||||
_m.property( _ph, it ) = v;
|
||||
_m.property( _ph, *it ) = v;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user