AFEPack
|
00001 00011 #ifndef __SimplestSimplexMesh_h__ 00012 #define __SimplestSimplexMesh_h__ 00013 00014 #include "Geometry.h" 00015 00016 template <int DIM, int DOW=DIM> 00017 class SimplestSimplexMesh : public SimplestMesh<DIM,DOW> 00018 { 00019 public: 00020 SimplestSimplexMesh() {} 00021 virtual ~SimplestSimplexMesh() {} 00022 00023 public: 00024 void readData(const std::string& file) {} 00025 }; 00026 00027 template <int DOW> 00028 class SimplestSimplexMesh<2,DOW> : public SimplestMesh<2,DOW> 00029 { 00030 public: 00031 SimplestSimplexMesh<2,DOW>() 00032 { 00033 this->setTemplateGeometry(*(new std::vector<TemplateGeometry<2> >(1))); 00034 this->templateGeometry(0).readData("triangle.tmp_geo"); 00035 } 00036 virtual ~SimplestSimplexMesh() 00037 { 00038 delete &(this->templateGeometry()); 00039 } 00040 00041 public: 00042 void readData(const std::string& file) 00043 { 00044 std::cerr << "Reading in simplest triangle mesh data ..." << std::endl; 00045 00046 u_int n_point, n_element; 00047 std::ifstream is(file.c_str()); 00048 is >> n_point; 00049 this->point().resize(n_point); 00050 for (u_int i = 0;i < n_point;++ i) { 00051 is >> this->point(i); 00052 } 00053 00054 is >> n_element; 00055 this->element().resize(n_element); 00056 for (u_int i = 0;i < n_element;++ i) { 00057 for (u_int k = 0;k < 3;++ k) { 00058 is >> this->element(i).vertex[k]; 00059 } 00060 this->element(i).template_element = 0; 00061 } 00062 00063 is.close(); 00064 } 00065 }; 00066 00067 template <int DOW> 00068 class SimplestSimplexMesh<3,DOW> : public SimplestMesh<3,DOW> 00069 { 00070 public: 00071 SimplestSimplexMesh<3,DOW>() 00072 { 00073 this->setTemplateGeometry(*(new std::vector<TemplateGeometry<3> >(1))); 00074 this->templateGeometry(0).readData("tetrahedron.tmp_geo"); 00075 } 00076 virtual ~SimplestSimplexMesh() 00077 { 00078 delete &(this->templateGeometry()); 00079 } 00080 00081 public: 00082 void readData(const std::string& file) 00083 { 00084 std::cerr << "Reading in simplest tetrahedron mesh data ..." << std::endl; 00085 00086 u_int n_point, n_element; 00087 std::ifstream is(file.c_str()); 00088 is >> n_point; 00089 this->point().resize(n_point); 00090 for (u_int i = 0;i < n_point;++ i) { 00091 is >> this->point(i); 00092 } 00093 00094 is >> n_element; 00095 this->element().resize(n_element); 00096 for (u_int i = 0;i < n_element;++ i) { 00097 this->element(i).vertex.resize(4); 00098 for (u_int k = 0;k < 4;++ k) { 00099 is >> this->element(i).vertex[k]; 00100 } 00101 this->element(i).template_element = 0; 00102 } 00103 00104 is.close(); 00105 } 00106 }; 00107 00108 #endif // __SimplestSimplexMesh_h__ 00109