polygon.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__POLYGON__H
00028 #define MESH3D__POLYGON__H
00029 
00030 #include "mesh3d/attribute_map.h"
00031 #include "mesh3d/vec3.h"
00032 #include <vector>
00033 #include <memory>
00034 #include <algorithm>
00035 
00036 namespace mesh3d {
00037 
00038 class geometry;
00039 class corner;
00040 class point;
00041 
00043 class polygon 
00044 {
00045 
00046 public:
00047     typedef std::vector<mesh3d::corner*> corner_collection;
00048 
00049     polygon(){}
00050     ~polygon();
00051 
00052 public:
00053     void copy_polygon_normal_to_corners(
00054         std::tr1::shared_ptr<attribute_map<mesh3d::corner*,  mesh3d::vec3> >  corner_normals,
00055         std::tr1::shared_ptr<attribute_map<mesh3d::polygon*, mesh3d::vec3> >  polygon_normals
00056     );
00057     void compute_normal(
00058         std::tr1::shared_ptr<attribute_map<mesh3d::polygon*, mesh3d::vec3> >  polygon_normals,
00059         std::tr1::shared_ptr<attribute_map<mesh3d::point*,   mesh3d::vec3> >  point_locations
00060     );
00061     void compute_centroid(
00062         std::tr1::shared_ptr<attribute_map<mesh3d::polygon*, mesh3d::vec3> >  polygon_centroids,
00063         std::tr1::shared_ptr<attribute_map<mesh3d::point*,   mesh3d::vec3> >  point_locations
00064     );
00065     void compute_corner_normals(
00066         std::tr1::shared_ptr<attribute_map<mesh3d::corner*,  mesh3d::vec3> >  corner_normals,
00067         std::tr1::shared_ptr<attribute_map<mesh3d::polygon*, mesh3d::vec3> >  polygon_normals,
00068         std::tr1::shared_ptr<attribute_map<mesh3d::point*,   mesh3d::vec3> >  point_locations,
00069         float                                                                 cos_max_smoothing_angle
00070     );
00071     mesh3d::corner *corner      (mesh3d::point *pnt);
00072     mesh3d::corner *make_corner (mesh3d::point *pnt);
00073 
00074     corner_collection       &corners()       { return m_corners; }
00075     corner_collection const &corners() const { return m_corners; }
00076 
00077     void                    reverse()   { std::reverse(m_corners.begin(), m_corners.end()); }
00078 
00079 private:
00080     corner_collection   m_corners;
00081 };
00082 
00083 }
00084 
00085 #endif 
00086 
Generated on Sun Apr 11 12:23:08 2010 for RenderStack by  doxygen 1.6.3