Polygon.h

Go to the documentation of this file.
00001 /*
00002 **    Mesh Converter
00003 **    Copyright (C) 2008 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 /*
00021 ** Polygon.h
00022 ** 
00023 ** Made by damien
00024 ** Login   <damien@ortie>
00025 ** 
00026 ** Started on  Wed Jul  2 11:38:01 2008 damien
00027 ** Last update Wed Jul  2 11:38:01 2008 damien
00028 */
00029 
00030 
00031 
00032 #ifndef         POLYGON_H_
00033 # define        POLYGON_H_
00034 
00035 #include <V_3D.h>
00036 #include <Segment.h>
00037 #include <Triangle.h>
00038 #include <vector>
00039 
00040 
00042 
00046 class Polygon
00047 {
00048 public:
00049   
00050   //*********************************************//
00051   // CONSTRUCTORS
00052   //*********************************************//
00053   
00055   Polygon();
00057   Polygon(const V_3D& x0,const V_3D& x1,const V_3D& x2);
00059   Polygon(const V_3D& x0,const V_3D& x1,const V_3D& x2,const V_3D& x3);
00061   Polygon(const std::vector <V_3D>& v);
00063   Polygon(const Polygon& poly);
00065   ~Polygon();
00066 
00067 
00068 
00069   //*********************************************//
00070   // Access
00071   //*********************************************//
00072 
00074   int size() const;
00075 
00077   Segment get_segment(int index) const;
00078   
00079   //*********************************************//
00080   // Manipulation
00081   //*********************************************//
00082 
00084   int destroy();
00085   
00087   int set_polygon(const std::vector <V_3D>& v);
00089   int set_polygon(const V_3D& x0,const V_3D& x1,const V_3D& x2);
00090   
00092   int add_vertex(const V_3D& v);
00094   int add_vertex(double x0,double x1,double x2);
00096   int add_vertex(const std::vector <V_3D>& v);
00097   
00099 
00100   std::vector <Polygon> triangulate() const;
00102 
00103   std::vector <Triangle> get_triangulation() const;
00104 
00106   V_3D normal() const;
00107 
00109   Triangle to_triangle() const;
00110 
00111   //*********************************************//
00112   // Informations
00113   //*********************************************//
00114 
00115 
00117   double shortest_distance_to_point(const V_3D& x) const;
00118   
00120 
00127   V_3D closest_point(const V_3D& x,int *type) const;
00129   V_3D closest_point(const V_3D& x) const;
00130 
00131 
00133 
00136   V_3D closest_segment_point(const Segment& s) const;
00137 
00138 
00140 
00147   std::vector <V_3D> plane_intersection(const V_3D& n,const V_3D& x0,int *type) const;
00149 
00150   std::vector <V_3D> plane_intersection(const V_3D& n,const V_3D& x0,int *type,std::vector <int> *type_edge) const;
00151 
00152 
00154 
00158   Polygon half_space_intersection(const V_3D& n,const V_3D& x0,int *type);
00159 
00160 
00161   //*********************************************//
00162   // Subdivision
00163   //*********************************************//
00164   
00166 
00171   std::vector <Polygon> subdivide_mid_edge() const;
00173 
00177   std::vector <Polygon> subdivide_barycenter_mid_edge() const;
00178 
00179   //*********************************************//
00180   // Operators
00181   //*********************************************//
00182 
00184   V_3D operator()(int index) const;
00186   V_3D& operator()(int index);
00188   V_3D operator[](int index) const;
00190   V_3D& operator[](int index);
00191 
00193   Polygon& operator=(const Polygon&);
00194 
00196   friend ostream& operator << (ostream& flux, const Polygon& _v);
00197 
00198 
00199 private:
00200   std::vector <V_3D> x;
00201 
00202 };
00203 
00204 
00205 #endif      /* !POLYGON_H_ */

Generated on Mon Mar 30 16:55:54 2009 by  doxygen 1.5.6