00001 /* 00002 ** Mesh Converter 00003 ** Copyright (C) 2009 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 #ifndef MC_TRIANGLE_HPP_ 00020 #define MC_TRIANGLE_HPP_ 00021 00022 #include <MC_v3d.hpp> 00023 #include <MC_v3d_vector.hpp> 00024 #include <MC_polygon.hpp> 00025 #include <MC_matrix.hpp> 00026 00027 #include <stdlib.h> 00028 #include <iostream> 00029 00030 00031 00032 namespace mesh_conv 00033 { 00034 00035 class MC_segment; 00036 00038 00039 class MC_triangle : public MC_v3d_vector 00040 { 00041 public: 00042 00043 //************************************************// 00044 //************************************************// 00045 //Constructor 00046 //************************************************// 00047 //************************************************// 00048 00050 MC_triangle(); 00052 MC_triangle(const MC_v3d& v0,const MC_v3d& v1,const MC_v3d& v2); 00054 MC_triangle(const MC_v3d_vector& vec); 00056 MC_triangle(const std::vector <MC_v3d>& vec); 00058 MC_triangle(const MC_triangle& p); 00059 00061 MC_triangle(const MC_polygon& p); 00062 00064 static std::vector<MC_triangle> triangulate(const MC_polygon& p); 00065 00066 //************************************************// 00067 //************************************************// 00068 //Informations 00069 //************************************************// 00070 //************************************************// 00071 00075 MC_v3d normal() const; 00076 00078 MC_v3d barycenter() const; 00079 00080 //************************************************// 00081 //************************************************// 00082 // Informations 00083 //************************************************// 00084 //************************************************// 00085 00099 MC_v3d closest_point(const MC_v3d& x,int *type=0) const; 00100 00101 00104 bool is_inside(const MC_v3d& _x) const; 00105 00109 std::pair<MC_double_vector,bool> barycentric_coordinates(const MC_v3d& x) const; 00110 00112 double area() const; 00113 00119 MC_matrix inertia() const; 00120 00121 00122 //************************************************// 00123 //************************************************// 00124 //Geometry transform (intersection, ...) 00125 //************************************************// 00126 //************************************************// 00127 00140 MC_v3d segment_intersection(const MC_segment& s,int *type=0) const; 00141 00142 00147 static MC_v3d pn_triangle(const MC_v3d_vector& X,const MC_v3d_vector& N,const MC_double_vector& bar_coord) ; 00148 00149 //************************************************// 00150 //************************************************// 00151 // Get 00152 //************************************************// 00153 //************************************************// 00154 00156 MC_segment segment(const int& edge_number) const; 00157 00158 00159 private: 00160 00161 }; 00162 00163 } 00164 00165 #endif
1.6.1