/home/ann2.ext/paccaulf/projsem2/ContourActif/mesh.h

Aller à la documentation de ce fichier.
00001 
00010 #ifndef MESH_H 
00011 #define MESH_H 
00012  
00013 #include <list>
00014 
00015 // CGAL 
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         // iterator on the vertices
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         // iterator on the halfedges    
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         // iterator on the border halfedges
00058         Halfedge_iterator border_halfedges_begin() const { return _mesh->border_halfedges_begin(); }
00059 
00060         // iterator on the facets
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         //iterator on halfedges around a vertex
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         //iterator on halfedges around a facet
00070         typedef Enriched_polyhedron<Enriched_kernel,Enriched_items>::Halfedge_around_facet_circulator Halfedge_around_facet_circulator;
00071 
00072         //chemin sur le mesh
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         // attributes 
00083         Polyhedron *_mesh;
00084         Point dir ; // direction de l'affichage
00085         
00086         // Mesh construction/destruction
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         //F#op# Dessin des points du Snake, cliques par l'utilisateur
00098         void drawUserSnake();
00099         //F#op# Dessin du plus court chemin approximatif entre source et target.
00100         // drawPathEnds est facultatif
00101         void drawSnakePath(Mesh::Vertex_handle source, Mesh::Vertex_handle target, int drawPathEnds) ;
00102 
00103         //V#op# Dessin de la region locale par dessus le maillage
00104         void drawLocalRegion();
00105         // Dessin de la region locale 2d (sans le maillage)
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         // Snake construction
00119 
00120         // _snake_total : snake en cours de construction
00121         std::vector < Vertex_chemin > _snake_total ;
00122         
00123         // _snake_vertex : l'ensemble des points cliques par l utilisateur
00124         std::vector < Vertex_handle > _snake_vertex ;
00125         
00126         // returns the nearest Vertex of the facet F to the selectedVertex, 
00127         // which is supposedly on a facet named F.
00128         Vertex_handle nearestVertexOnFacet(Point selectedPoint) ;
00129         
00130         // computes the shortest path between dsource and ddestination
00131         //std::list<Halfedge> dijkstraShortestPath(Vertex dsource, Vertex ddestination);
00132         void approx_shortest_path(Vertex_chemin &chemin, Vertex_handle source, Vertex_handle target) const ;
00133 
00134 
00135         // Local Region construction
00136         // precond : le snake est fini de construire
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 //      void Trace_Local_region( Polyhedron P ) ;// OpenGL 
00147 };
00148 
00149 #endif

Généré le Thu Jun 15 18:48:52 2006 pour Projet Image 2006 - Vincent Vidal, Florent Paccault - par  doxygen 1.4.7