geometry.h

Go to the documentation of this file.
00001 /*
00002     mesh3d
00003     Copyright (C) 2010  Timo Suoranta
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library 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 GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 */
00019 
00027 #ifndef MESH3D__GEOMETRY__H
00028 #define MESH3D__GEOMETRY__H
00029 
00030 #include <vector>
00031 #include "mesh3d/point.h"
00032 #include "mesh3d/polygon.h"
00033 #include "mesh3d/attribute_map.h"
00034 #include "mesh3d/attribute_map_collection.h"
00035 
00036 namespace mesh3d {
00037 
00038 /*  "point_locations"  */ 
00039 /*  "polygon_normals"  */ 
00040 /*  "corner normals"   */ 
00042 class geometry 
00043 {
00044 public:
00045     typedef attribute_map_collection<point*>   point_attribute_map_collection;
00046     typedef attribute_map_collection<corner*>  corner_attribute_map_collection;
00047     typedef attribute_map_collection<polygon*> polygon_attribute_map_collection;
00048 
00049     typedef std::vector<mesh3d::point*>   point_collection;
00050     typedef std::vector<mesh3d::polygon*> polygon_collection;
00051 
00052 public:
00053     geometry();
00054     ~geometry();
00055 
00056 public:
00057     point_attribute_map_collection    &point_attributes  (){ return m_point_attribute_map_collection; }
00058     corner_attribute_map_collection   &corner_attributes (){ return m_corner_attribute_map_collection; }
00059     polygon_attribute_map_collection  &polygon_attributes(){ return m_polygon_attribute_map_collection; }
00060 
00061     point_attribute_map_collection   const &point_attributes  () const { return m_point_attribute_map_collection; }
00062     corner_attribute_map_collection  const &corner_attributes () const { return m_corner_attribute_map_collection; }
00063     polygon_attribute_map_collection const &polygon_attributes() const { return m_polygon_attribute_map_collection; }
00064 
00065     void    reserve_points  (size_t point_count);
00066     void    reserve_polygons(size_t polygon_count);
00067     point   *make_point     ();
00068     polygon *make_polygon   ();
00069 
00070     point   *make_point  (float x, float y, float z);
00071     point   *make_point  (double x, double y, double z);
00072     point   *make_point  (double x, double y, double z, double nx, double ny, double nz, double s, double t);
00073     polygon *make_polygon(point *p0);
00074     polygon *make_polygon(point *p0, point *p1);
00075     polygon *make_polygon(point *p0, point *p1, point *p2);
00076     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3);
00077     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4);
00078     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4, point *p5);
00079     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4, point *p5, point *p6);
00080     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4, point *p5, point *p6, point *p7);
00081     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4, point *p5, point *p6, point *p7, point *p8);
00082     polygon *make_polygon(point *p0, point *p1, point *p2, point *p3, point *p4, point *p5, point *p6, point *p7, point *p8, point *p9);
00083     polygon *make_polygon(size_t p0);
00084     polygon *make_polygon(size_t p0, size_t p1);
00085     polygon *make_polygon(size_t p0, size_t p1, size_t p2);
00086     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3);
00087     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4);
00088     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4, size_t p5);
00089     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4, size_t p5, size_t p6);
00090     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4, size_t p5, size_t p6, size_t p7);
00091     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4, size_t p5, size_t p6, size_t p7, size_t p8);
00092     polygon *make_polygon(size_t p0, size_t p1, size_t p2, size_t p3, size_t p4, size_t p5, size_t p6, size_t p7, size_t p8, size_t p9);
00093 
00094     point_collection          &points            ();
00095     point_collection   const  &points            () const;
00096     polygon_collection        &polygons          ();
00097     polygon_collection const  &polygons          () const;
00098 
00099     void compute_polygon_normals    ();
00100     void compute_polygon_centroids  ();
00101     void compute_corner_normals     (float max_smoothing_angle);
00102 
00103 private:
00104     point_attribute_map_collection      m_point_attribute_map_collection;
00105     corner_attribute_map_collection     m_corner_attribute_map_collection;
00106     polygon_attribute_map_collection    m_polygon_attribute_map_collection;
00107 
00108     point_collection                    m_points;
00109     polygon_collection                  m_polygons;
00110 };
00111 
00112 }
00113 
00114 #endif 
00115 
Generated on Sun Apr 11 12:23:08 2010 for RenderStack by  doxygen 1.6.3