00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CMGUIWRITER_HPP_
00030 #define CMGUIWRITER_HPP_
00031
00032 #include "AbstractMeshWriter.hpp"
00033
00034
00035 static const char CmguiNodeFileHeader[] = " #Fields=1\n\
00036 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\
00037 x. Value index= 1, #Derivatives= 0\n\
00038 y. Value index= 2, #Derivatives= 0\n\
00039 z. Value index= 3, #Derivatives= 0\n";
00040
00041 static const char CmguiElementFileHeader[] = "Shape. Dimension=3, simplex(2;3)*simplex*simplex\n\
00042 #Scale factor sets= 0\n\
00043 #Nodes= 4\n\
00044 #Fields=1\n\
00045 1) coordinates, coordinate, rectangular cartesian, #Components=3\n\
00046 x. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00047 #Nodes= 4\n\
00048 1. #Values=1\n\
00049 Value indices: 1\n\
00050 Scale factor indices: 1\n\
00051 2. #Values=1\n\
00052 Value indices: 1\n\
00053 Scale factor indices: 2\n\
00054 3. #Values=1\n\
00055 Value indices: 1\n\
00056 Scale factor indices: 3\n\
00057 4. #Values=1\n\
00058 Value indices: 1\n\
00059 Scale factor indices: 4\n\
00060 y. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00061 #Nodes= 4\n\
00062 1. #Values=1\n\
00063 Value indices: 1\n\
00064 Scale factor indices: 1\n\
00065 2. #Values=1\n\
00066 Value indices: 1\n\
00067 Scale factor indices: 2\n\
00068 3. #Values=1\n\
00069 Value indices: 1\n\
00070 Scale factor indices: 3\n\
00071 4. #Values=1\n\
00072 Value indices: 1\n\
00073 Scale factor indices: 4\n\
00074 z. l.simplex(2;3)*l.simplex*l.simplex, no modify, standard node based.\n\
00075 #Nodes= 4\n\
00076 1. #Values=1\n\
00077 Value indices: 1\n\
00078 Scale factor indices: 1\n\
00079 2. #Values=1\n\
00080 Value indices: 1\n\
00081 Scale factor indices: 2\n\
00082 3. #Values=1\n\
00083 Value indices: 1\n\
00084 Scale factor indices: 3\n\
00085 4. #Values=1\n\
00086 Value indices: 1\n\
00087 Scale factor indices: 4\n";
00088
00089
00101 class CmguiWriter : public AbstractMeshWriter<3,3>
00102 {
00103 public:
00104 CmguiWriter(const std::string &rDirectory,
00105 const std::string &rBaseName,
00106 const bool &rCleanDirectory=true);
00107 void WriteFiles();
00108 virtual ~CmguiWriter()
00109 {}
00110 };
00111
00112
00113 CmguiWriter::CmguiWriter(const std::string &rDirectory,
00114 const std::string &rBaseName,
00115 const bool &rCleanDirectory)
00116 : AbstractMeshWriter<3,3>(rDirectory, rBaseName, rCleanDirectory)
00117 {
00118 this->mIndexFromZero=false;
00119 }
00120
00121 void CmguiWriter::WriteFiles()
00122 {
00124
00126 std::string node_file_name = this->mBaseName+".exnode";
00127 out_stream p_node_file = this->mpOutputFileHandler->OpenOutputFile(node_file_name);
00128
00129
00130 *p_node_file << "Group name: " << this->mBaseName << "\n";
00131 *p_node_file << CmguiNodeFileHeader;
00132
00133
00134 for (unsigned item_num=0; item_num<this->GetNumNodes(); item_num++)
00135 {
00136 std::vector<double> current_item = this->mNodeData[item_num];
00137
00138 *p_node_file << "Node:\t" << item_num+1 << "\t";
00139 for (unsigned i=0;i<3;i++)
00140 {
00141 *p_node_file << current_item[i] << "\t";
00142 }
00143
00144 *p_node_file << "\n";
00145 }
00146 p_node_file->close();
00147
00149
00151 std::string elem_file_name = this->mBaseName+".exelem";
00152 out_stream p_elem_file = this->mpOutputFileHandler->OpenOutputFile(elem_file_name);
00153
00154
00155 *p_elem_file << "Group name: " << this->mBaseName << "\n";
00156 *p_elem_file << CmguiElementFileHeader;
00157
00158
00159 for (unsigned item_num=0; item_num<this->GetNumElements(); item_num++)
00160 {
00161 std::vector<unsigned> current_element = this->mElementData[item_num];
00162
00163 *p_elem_file << "Element:\t" << item_num+1 << " 0 0 Nodes:\t";
00164 for (unsigned i=0; i<4; i++)
00165 {
00166 *p_elem_file << current_element[i]+1 << "\t";
00167 }
00168
00169 *p_elem_file << "\n";
00170 }
00171 p_elem_file->close();
00172
00173 }
00174
00175 #endif