00001
00010 #ifndef MESH_H
00011 #define MESH_H
00012
00013 #include <list>
00014
00015
00016 #include <CGAL/basic.h>
00017 #include <CGAL/Simple_cartesian.h>
00018 #include <CGAL/Triangulation_2.h>
00019
00020 #include "lib/enriched_kernel.h"
00021 #include "lib/enriched_items.h"
00022 #include "lib/enriched_polyhedron.h"
00023
00024 #include "snake.h"
00025
00034 class Mesh
00035 {
00036 public:
00037
00038 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items> Polyhedron ;
00039 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Vertex Vertex;
00040 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Vector Vector;
00041 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Point Point;
00042 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge Halfedge;
00043 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Facet_handle Facet_handle;
00044 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Vertex_handle Vertex_handle;
00045 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_handle Halfedge_handle;
00046
00047
00048
00049 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Vertex_iterator Vertex_iterator;
00050 Vertex_iterator vertices_begin() const { return _mesh->vertices_begin(); }
00051 Vertex_iterator vertices_end() const { return _mesh->vertices_end(); }
00052
00053
00054 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_iterator Halfedge_iterator;
00055 Halfedge_iterator halfedges_begin() const { return _mesh->halfedges_begin(); }
00056 Halfedge_iterator halfedges_end() const { return _mesh->halfedges_end(); }
00057
00058 Halfedge_iterator border_halfedges_begin() const { return _mesh->border_halfedges_begin(); }
00059
00060
00061 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Facet_iterator Facet_iterator;
00062 Facet_iterator facets_begin() const { return _mesh->facets_begin(); }
00063 Facet_iterator facets_end() const { return _mesh->facets_end(); }
00064
00065
00066 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator;
00067 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_around_vertex_const_circulator Halfedge_around_vertex_const_circulator;
00068
00069
00070 typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_around_facet_circulator Halfedge_around_facet_circulator;
00071
00072
00073 typedef std::vector< Vertex_handle > Vertex_chemin ;
00074
00075 private:
00076 bool _isValid;
00077 char* _message;
00078
00079 void gl_draw_facet(Facet_handle, bool, bool, bool) const;
00080 bool loadFromFile(const char*);
00081 public:
00082
00083 Polyhedron *_mesh;
00084 Point dir ;
00085
00086
00087 Mesh(const char*);
00088 ~Mesh();
00089
00090 void compute_normals();
00091
00092 void saveToFile(const char*) const;
00093
00094 void draw(bool, bool, bool) const;
00095 void draw_edges() const;
00096 void draw_vertices() const;
00097
00098 void drawUserSnake();
00099
00100
00101 void drawSnakePath(Mesh::Vertex_handle source, Mesh::Vertex_handle target, int drawPathEnds) ;
00102
00103
00104 void drawLocalRegion();
00105
00106 void draw2dRegion() ;
00107
00108 void BoundingBox(double * centre, double * diameter);
00109
00110 bool isValid() const;
00111 char* message() const;
00112
00113 std::size_t size_of_vertices() const;
00114 std::size_t size_of_facets() const;
00115
00116
00117
00118
00119
00120
00121 std::vector < Vertex_chemin > _snake_total ;
00122
00123
00124 std::vector < Vertex_handle > _snake_vertex ;
00125
00126
00127
00128 Vertex_handle nearestVertexOnFacet(Point selectedPoint) ;
00129
00130
00131
00132 void approx_shortest_path(Vertex_chemin &chemin, Vertex_handle source, Vertex_handle target) const ;
00133
00134
00135
00136
00137 Snake _snake_fini ;
00138
00139 Polyhedron Local_region( std::vector< Vertex_chemin >& Snake ) ;
00140
00141 void computeLocalRegion() {
00142 _snake_fini=Snake(_snake_total, Local_region(_snake_total)) ;
00143 }
00144
00145
00146
00147 };
00148
00149 #endif