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:
Jan Möbius
2009-02-06 13:37:46 +00:00
parent c3321ebdd9
commit 97f515985d
417 changed files with 76182 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
class BaseExporter
{
public:
virtual void update() = 0;
virtual PVertexIter const_vertices_begin() = 0;
virtual PVertexIter const_vertices_end() = 0;
virtual PTexCoordIter const_texcoords_begin() = 0;
virtual PTexCoordIter const_texcoords_end() = 0;
virtual PIdxFaceIter const_idx_faces_begin() = 0;
virtual PIdxFaceIter const_idx_faces_end() = 0;
virtual PFaceIter const_set_faces_begin() = 0;
virtual PFaceIter const_set_faces_end() = 0;
virtual unsigned int n_faces() = 0;
virtual unsigned int n_vertices() = 0;
virtual unsigned int n_texcoords() = 0;
};

View File

@@ -0,0 +1,9 @@
class BaseImporter
{
public:
virtual void add_vertex (const OpenMesh::Vec3f&) {};
virtual void add_normal (const OpenMesh::Vec3f&) {};
virtual void add_texture (const OpenMesh::Vec2f&) {};
virtual void add_face (const FaceType&) {};
};

View File

@@ -0,0 +1,13 @@
class BaseReader
{
public:
virtual std::string get_description() const = 0;
virtual std::string get_extensions() const = 0;
virtual std::string get_magic() const { return std::string(""); }
virtual bool read(std::istream& _is, BaseImporter& _bi) const = 0;
virtual bool read(const std::string& _filename, BaseImporter& _bi) const = 0;
...
};

50
Doc/Examples/adasub.cc Normal file
View File

@@ -0,0 +1,50 @@
#include <iostream>
#include <algorithm>
#include <iterator>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <OpenMesh/Tools/Subdivider/Adaptive/CompositeT.hh>
// ----------------------------------------
using OpenMesh::Subdivider::Adaptive;
// ---------------------------------------- necessary types
OpenMesh::TriMesh_ArrayKernelT< CompositeTraits > MyMesh;
CompositeT< MyMesh > Subdivider;
// ---------------------------------------- setup a subdivider
int main(int argc, char **argv)
{
MyMesh mesh; // create mesh and fill it
if (!OpenMesh::IO::read_mesh(mesh, argv[1]))
return 1; // error reading mesh
Subdivider subdivider(mesh); // bind subdivider to mesh
// -------------------- add some rules
// anonymous registration
subdivider.add< Tvv3<MyMesh>::Handle >();
subdivider.add< VF<MyMesh>::Handle >();
subdivider.add< FF<MyMesh>::Handle >();
// 'named' registration
FVc<MyMesh>::Handle hFVc;
subdivider.add( hFVc );
// print pre-computed coefficients to std::cout...
std::copy(subdivider.rule( hFVc ).coeffs().begin(),
subdivider.rule( hFVc ).coeffs().end(),
std::ostream_iterator<double>(std::cout, ", "));
// prepare subdivider and the traits
if (!subdivider.initialize())
return 1; // error initializing subdivider
MyMesh::FaceHandle fh; // select a face
subdivider.refine(fh);
}

View File

@@ -0,0 +1,8 @@
template <class Traits>
struct TriMesh_ArrayKernel_GeneratorT
{
typedef FinalMeshItemsT<ArrayItems, Traits, true> MeshItems;
typedef AttribKernelT<MeshItems> AttribKernel;
typedef ArrayKernelT<AttribKernel, MeshItems> MeshKernel;
typedef TriMeshT<MeshKernel> Mesh;
};

View File

@@ -0,0 +1,11 @@
MyMesh mesh;
// (linearly) iterate over all vertices
for (MyMesh::VertexIter v_it=mesh.vertices_begin(); v_it!=mesh.vertices_end(); ++v_it)
{
// circulate around the current vertex
for (MyMesh::VertexVertexIter vv_it=mesh.vv_iter(v_it.handle()); vv_it; ++vv_it)
{
// do something with e.g. mesh.point(*vv_it)
}
}

30
Doc/Examples/decimater.cc Normal file
View File

@@ -0,0 +1,30 @@
//
using namespace OpenMesh
// ---------------------------------------- necessary types
// Mesh type
typedef TriMesh_ArrayKernelT<> Mesh;
// Decimater type
typedef Decimater::DecimaterT< Mesh > Decimater;
// Decimation Module Handle type
typedef Decimater::ModQuadricT< decimater >::Handle HModQuadric;
// ---------------------------------------- decimater setup
Mesh mesh; // a mesh object
Decimater decimater(mesh); // a decimater object, connected to a mesh
HModQuadric hModQuadric; // use a quadric module
decimater.add( hModQuadric ); // register module at the decimater
std::cout << decimater.module( hModQuadric ).name() << std::endl;
// the way to access the module
decimater.initialize(); // let the decimater initialize the mesh and the
// modules
decimater.decimate(); // do decimation

View File

@@ -0,0 +1,14 @@
#include <OpenMesh/Core/Utils/GenProg.hh>
// draw a face normal if we have one
void drawFaceNormal(const MyMesh::Face& _f) {
drawFaceNormal(_f, GenProg::Bool2Type<OM_Check_Attrib(MyMesh::Face, Normal)>());
}
// normal exists -> use it
void drawFaceNormal(const MyMesh::Face& _f, GenProg::Bool2Type<true>) {
glNormal3fv(_f.normal());
}
// empty dummy (no normals)
void drawFaceNormal(const MyMesh::Face& _f, GenProg::Bool2Type<false>){}

18
Doc/Examples/iterators.cc Normal file
View File

@@ -0,0 +1,18 @@
MyMesh mesh;
// iterate over all vertices
for (MyMesh::VertexIter v_it=mesh.vertices_begin(); v_it!=mesh.vertices_end(); ++v_it)
...; // do something with *v_it, v_it->, or v_it.handle()
// iterate over all halfedges
for (MyMesh::HalfedgeIter h_it=mesh.halfedges_begin(); v_it!=mesh.halfedges_end(); ++v_it)
...; // do something with *h_it, h_it->, or h_it.handle()
// iterate over all edges
for (MyMesh::EdgeIter e_it=mesh.edges_begin(); v_it!=mesh.edges_end(); ++v_it)
...; // do something with *e_it, e_it->, or e_it.handle()
// iterator over all faces
for (MyMesh::FaceIter f_it=mesh.faces_begin(); v_it!=mesh.faces_end(); ++v_it)
...; // do something with *f_it, f_it->, or f_it.handle()

17
Doc/Examples/mesh_io.cc Normal file
View File

@@ -0,0 +1,17 @@
#include <OpenMesh/Core/IO/MeshIO.hh>
MyMesh mesh;
if (!OpenMesh::IO::read_mesh(mesh, "some input file"))
{
std::cerr << "read error\n";
exit(1);
}
// do something with your mesh ...
if (!OpenMesh::IO::write_mesh(mesh, "some output file"))
{
std::cerr << "write error\n";
exit(1);
}

51
Doc/Examples/mymesh.cc Normal file
View File

@@ -0,0 +1,51 @@
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
// define traits
struct MyTraits : public OpenMesh::DefaultTraits
{
// use double valued coordinates
typedef OpenMesh::Vec3d Point;
// use vertex normals and vertex colors
VertexAttributes( OpenMesh::DefaultAttributer::Normal |
OpenMesh::DefaultAttributer::Color );
// store the previous halfedge
HalfedgeAttributes( OpenMesh::DefaultAttributer::PrevHalfedge );
// use face normals
FaceAttributes( OpenMesh::DefaultAttributer::Normal );
// store a face handle for each vertex
VertexTraits
{
typename Base::Refs::FaceHandle my_face_handle;
};
};
// Select mesh type (TriMesh) and kernel (ArrayKernel)
// and define my personal mesh type (MyMesh)
typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh;
int main(int argc, char **argv)
{
MyMesh mesh;
// -------------------- Add dynamic data
// for each vertex an extra double value
OpenMesh::VPropHandleT< double > vprop_double;
mesh.add_property( vprop_double );
// for the mesh an extra string
OpenMesh::MPropHandleT< string > mprop_string;
mesh.add_property( mprop_string );
// -------------------- do something
...;
}

17
Doc/Examples/traits0.cc Normal file
View File

@@ -0,0 +1,17 @@
struct DefaultTraits
{
typedef Vec3f Point;
typedef Vec3f Normal;
typedef Vec2f TexCoord;
typedef Vec3uc Color;
VertexTraits {};
HalfedgeTraits {};
EdgeTraits {};
FaceTraits {};
VertexAttributes(0);
HalfedgeAttributes(Attributes::PrevHalfedge);
EdgeAttributes(0);
FaceAttributes(0);
};

4
Doc/Examples/traits1.cc Normal file
View File

@@ -0,0 +1,4 @@
struct MyTraits : public OpenMesh::DefaultTraits
{
typedef OpenMesh::Vec3d Point; // use double-values points
};

7
Doc/Examples/traits2.cc Normal file
View File

@@ -0,0 +1,7 @@
struct MyTraits : public OpenMesh::DefaultTraits
{
VertexTraits
{
int some_additional_index;
};
};

7
Doc/Examples/traits3.cc Normal file
View File

@@ -0,0 +1,7 @@
struct MyTraits : public OpenMesh::DefaultTraits
{
template <class Base, class Refs> struct VertexT : public Base
{
int some_additional_index;
};
};

8
Doc/Examples/traits4.cc Normal file
View File

@@ -0,0 +1,8 @@
struct MyTraits : public OpenMesh::DefaultTraits
{
VertexTraits
{
int some_additional_index;
typename Base::Refs::FaceHandle my_face_handle;
};
};

7
Doc/Examples/traits5.cc Normal file
View File

@@ -0,0 +1,7 @@
struct MyTraits : public OpenMesh::DefaultTraits
{
VertexAttributes( OpenMesh::Attributes::Normal |
OpenMesh::Attributes::Color );
FaceAttributes( OpenMesh::Attributes::Normal );
};