CmguiWriter.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 #include "CmguiWriter.hpp"
00030 
00032 // Implementation
00034 
00035 CmguiWriter::CmguiWriter(const std::string &rDirectory,
00036                          const std::string &rBaseName,
00037                          const bool &rCleanDirectory)
00038         : AbstractTetrahedralMeshWriter<3,3>(rDirectory, rBaseName, rCleanDirectory)
00039 {
00040     this->mIndexFromZero = false;
00041 }
00042 
00043 void CmguiWriter::WriteFiles()
00044 {
00046     // Write the exnode file
00048     std::string node_file_name = this->mBaseName + ".exnode";
00049     out_stream p_node_file = this->mpOutputFileHandler->OpenOutputFile(node_file_name);
00050 
00051     // Write the node header
00052     *p_node_file << "Group name: " << this->mBaseName << "\n";
00053     *p_node_file << CmguiNodeFileHeader;
00054 
00055     // Write each node's data
00056     for (unsigned item_num=0; item_num<this->GetNumNodes(); item_num++)
00057     {
00058         std::vector<double> current_item = this->mNodeData[item_num];
00059 
00060         *p_node_file << "Node:\t" << item_num+1 << "\t";
00061         for (unsigned i=0; i<3; i++)
00062         {
00063             *p_node_file << current_item[i] << "\t";
00064         }
00065 
00066         *p_node_file << "\n";
00067     }
00068     p_node_file->close();
00069 
00071     // Write the exlem file
00073     std::string elem_file_name = this->mBaseName + ".exelem";
00074     out_stream p_elem_file = this->mpOutputFileHandler->OpenOutputFile(elem_file_name);
00075 
00076     // Write the elem header
00077     *p_elem_file << "Group name: " << this->mBaseName << "\n";
00078     *p_elem_file << CmguiElementFileHeader;
00079 
00080     // Write each elements's data
00081     for (unsigned item_num=0; item_num<this->GetNumElements(); item_num++)
00082     {
00083         std::vector<unsigned> current_element = this->mElementData[item_num];
00084 
00085         *p_elem_file << "Element:\t" << item_num+1 << " 0 0 Nodes:\t";
00086         for (unsigned i=0; i<4; i++)
00087         {
00088             *p_elem_file << current_element[i]+1 << "\t";
00089         }
00090 
00091         *p_elem_file << "\n";
00092     }
00093     p_elem_file->close();
00094 }

Generated on Tue Aug 4 16:10:24 2009 for Chaste by  doxygen 1.5.5