First checkin for OpenMesh 2.0
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@2 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
24
Doc/Tutorial/03-properties/ACGMakefile
Normal file
24
Doc/Tutorial/03-properties/ACGMakefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#== SYSTEM PART -- DON'T TOUCH ==============================================
|
||||
include $(ACGMAKE)/Config
|
||||
#==============================================================================
|
||||
|
||||
|
||||
# subdirs to process
|
||||
SUBDIRS = $(call find-subdirs)
|
||||
|
||||
# programms (files containing main(), w/o suffix)
|
||||
EXECS = $(call cxx-find-execs)
|
||||
|
||||
# packages (qt, opengl, ...)
|
||||
PACKAGES :=
|
||||
|
||||
# project DSOs
|
||||
PROJ_LIBS := OpenMesh/Core
|
||||
|
||||
# modules to use (cxx, c, moc, uic, yacc) ! order-dependent !
|
||||
MODULES := cxx
|
||||
|
||||
|
||||
#== SYSTEM PART -- DON'T TOUCH ==============================================
|
||||
include $(ACGMAKE)/Rules
|
||||
#==============================================================================
|
||||
74
Doc/Tutorial/03-properties/smooth.cc
Normal file
74
Doc/Tutorial/03-properties/smooth.cc
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
// --------------------
|
||||
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||
|
||||
typedef OpenMesh::TriMesh_ArrayKernelT<> MyMesh;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MyMesh mesh;
|
||||
|
||||
|
||||
// check command line options
|
||||
if (argc != 4)
|
||||
{
|
||||
std::cerr << "Usage: " << argv[0] << " #iterations infile outfile\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// read mesh from stdin
|
||||
if ( ! OpenMesh::IO::read_mesh(mesh, argv[2]) )
|
||||
{
|
||||
std::cerr << "Error: Cannot read mesh from " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this vertex property stores the computed centers of gravity
|
||||
OpenMesh::VPropHandleT<MyMesh::Point> cogs;
|
||||
mesh.add_property(cogs);
|
||||
|
||||
// smoothing mesh argv[1] times
|
||||
MyMesh::VertexIter v_it, v_end(mesh.vertices_end());
|
||||
MyMesh::VertexVertexIter vv_it;
|
||||
MyMesh::Point cog;
|
||||
MyMesh::Scalar valence;
|
||||
unsigned int i, N(atoi(argv[1]));
|
||||
|
||||
|
||||
for (i=0; i < N; ++i)
|
||||
{
|
||||
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
|
||||
{
|
||||
mesh.property(cogs,v_it).vectorize(0.0f);
|
||||
valence = 0;
|
||||
|
||||
for (vv_it=mesh.vv_iter( v_it ); vv_it; ++vv_it)
|
||||
{
|
||||
mesh.property(cogs,v_it) += mesh.point( vv_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) );
|
||||
}
|
||||
|
||||
|
||||
// write mesh to stdout
|
||||
if ( ! OpenMesh::IO::write_mesh(mesh, argv[3]) )
|
||||
{
|
||||
std::cerr << "Error: cannot write mesh to " << argv[3] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user