00001 /* 00002 ** TP 4ETI CPE Lyon 00003 ** Copyright (C) 2012 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 #ifndef _GRID_HPP_ 00021 #define _GRID_HPP_ 00022 00023 #include <v3.hpp> 00024 #include <vector> 00025 00026 namespace cpe 00027 { 00028 00029 class patch4; 00030 00031 class grid 00032 { 00033 public: 00034 00035 // ********************************************* // 00036 // ********************************************* // 00037 // CONSTRUCTORS 00038 // ********************************************* // 00039 // ********************************************* // 00040 00042 grid(); 00044 grid(const unsigned int& Nu,const unsigned int& Nv); 00045 00046 // ********************************************* // 00047 // ********************************************* // 00048 // Size 00049 // ********************************************* // 00050 // ********************************************* // 00051 00053 void resize(const unsigned int& Nu,const unsigned int& Nv); 00054 00056 const unsigned int size_u() const; 00058 const unsigned int size_v() const; 00059 00060 00061 // ********************************************* // 00062 // ********************************************* // 00063 // Data 00064 // ********************************************* // 00065 // ********************************************* // 00066 00068 const v3& operator()(const unsigned int& ku,const unsigned int& kv) const; 00070 v3& operator()(const unsigned int& ku,const unsigned int& kv); 00071 00072 00073 // ********************************************* // 00074 // ********************************************* // 00075 // 4x4 patch 00076 // ********************************************* // 00077 // ********************************************* // 00078 00080 patch4 get_patch(const unsigned int& k_patch_u,const unsigned int& k_patch_v) const; 00081 00082 00083 // ********************************************* // 00084 // ********************************************* // 00085 // Special initialization 00086 // ********************************************* // 00087 // ********************************************* // 00088 00090 void build_meshgrid(); 00092 void build_sphere(); 00093 00094 00095 // ********************************************* // 00096 // ********************************************* // 00097 // Grid transformation 00098 // ********************************************* // 00099 // ********************************************* // 00100 00102 grid& operator*=(const double& s); 00104 friend grid operator*(const double& s,const grid& g); 00106 friend grid operator*(const grid& g,const double& s); 00107 00109 grid& operator+=(const v3& t); 00111 grid& operator-=(const v3& t); 00113 friend grid operator+(const grid& g,const v3& t); 00115 friend grid operator+(const v3& t,const grid& g); 00117 friend grid operator-(const grid& g,const v3& t); 00119 friend grid operator-(const v3& t,const grid& g); 00120 00122 grid operator-() const; 00123 00124 00125 // ********************************************* // 00126 // ********************************************* // 00127 // Topologie transform 00128 // ********************************************* // 00129 // ********************************************* // 00130 00132 void add_back_u(); 00134 void add_front_u(); 00135 00137 void add_back_v(); 00139 void add_front_v(); 00140 00142 void suppress_back_u(); 00144 void suppress_front_u(); 00145 00147 void suppress_back_v(); 00149 void suppress_front_v(); 00150 00152 void duplicate_boundary(); 00153 00154 00155 // ********************************************* // 00156 // ********************************************* // 00157 // INPUT OUTPUT 00158 // ********************************************* // 00159 // ********************************************* // 00160 00162 void write(const std::string& filename) const; 00164 static grid read(const std::string& filename); 00165 00166 private: 00167 00169 void assert_size(const unsigned int& ku,const unsigned int& kv) const; 00170 00172 unsigned int internal_size_u; 00174 unsigned int internal_size_v; 00175 00177 std::vector<v3> internal_data; 00178 }; 00179 } 00180 00181 #endif