00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MESH_H__
00024 #define __MESH_H__
00025
00026 #include <boost/shared_ptr.hpp>
00027
00028 #include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
00029 #include <OpenMesh/Core/IO/importer/ImporterT.hh>
00030
00031 #include "../math/math.h"
00032 #include "./object.h"
00033
00041 namespace MeshNS {
00042
00047 enum RenderMode {
00048 smooth= 0,
00049 wire
00050 };
00051
00052
00053 typedef OpenMesh::PolyMesh_ArrayKernelT<> Polyhedron;
00054 typedef Polyhedron::Point Point;
00055 typedef Polyhedron::HalfedgeIter HalfEdgeIter;
00056 typedef Polyhedron::Halfedge Halfedge;
00057 typedef Polyhedron::Vertex Vertex;
00058 typedef Polyhedron::VertexIter VertexIter;
00059 typedef Polyhedron::ConstVertexIter ConstVertexIter;
00060 typedef Polyhedron::Face Face;
00061 typedef Polyhedron::FaceIter FaceIter;
00062 typedef Polyhedron::ConstFaceIter ConstFaceIter;
00063 typedef Polyhedron::EdgeIter EdgeIter;
00064 typedef Polyhedron::FaceVertexIter FaceVertexIter;
00065 typedef Polyhedron::ConstFaceVertexIter ConstFaceVertexIter;
00066 typedef Polyhedron::FaceHalfedgeIter FaceHalfEdgeIter;
00067 typedef Polyhedron::ConstFaceHalfedgeIter ConstFaceHalfEdgeIter;
00068 typedef Polyhedron::Normal Normal;
00069 typedef boost::shared_ptr<Polyhedron> PolyhedronPtr;
00070
00072 void loadMesh(PolyhedronPtr p, std::vector<SimpleVertex> verts, std::vector<SimpleFace> faces );
00073
00074
00081 void drawMesh(const Polyhedron& polyhedron, const RenderMode& mode,
00082 const std::vector<float>& color);
00083
00090 void drawMesh(const Polyhedron& polyhedron, const RenderMode& mode,
00091 bool setColor= true);
00092
00099 void
00100 drawMeshWithVertexColor(const Polyhedron& polyhedron, const RenderMode& mode);
00101
00110 inline Point v1(const Polyhedron& p, const Polyhedron::Face& f) {
00111 ConstFaceVertexIter fCirc= p.cfv_iter(p.handle(f));
00112 return p.point(fCirc.handle());
00113 }
00114
00123 inline Point v2(const Polyhedron& p, const Polyhedron::Face& f) {
00124 ConstFaceVertexIter fCirc= p.cfv_iter(p.handle(f));
00125 ++fCirc;
00126 return p.point(fCirc.handle());
00127 }
00128
00137 inline Point v3(const Polyhedron&p, const Polyhedron::Face& f) {
00138 ConstFaceVertexIter fCirc= p.cfv_iter(p.handle(f));
00139 ++fCirc;
00140 ++fCirc;
00141 return p.point(fCirc.handle());
00142 }
00143
00154 inline Point vX(const Polyhedron&p, const Polyhedron::Face& f, int x) {
00155 ConstFaceVertexIter fCirc= p.cfv_iter(p.handle(f));
00156 int i= 0;
00157 while (i < x) {
00158 if (!fCirc)
00159 throw int();
00160 ++fCirc;
00161 }
00162 return p.point(fCirc.handle());
00163 }
00164
00165 }
00166
00167 #endif