00001 /* 00002 00003 Copyright (C) University of Oxford, 2005-2011 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 "FibreWriter.hpp" 00030 #include "Version.hpp" 00031 00032 template<unsigned DIM> 00033 FibreWriter<DIM>::FibreWriter(const std::string& rDirectory, 00034 const std::string& rBaseName, 00035 const bool clearOutputDir) 00036 : mBaseName(rBaseName), 00037 mFileIsBinary(false) 00038 { 00039 mpOutputFileHandler= new OutputFileHandler(rDirectory, clearOutputDir); 00040 } 00041 00042 template<unsigned DIM> 00043 FibreWriter<DIM>::~FibreWriter() 00044 { 00045 delete mpOutputFileHandler; 00046 } 00047 00048 template<unsigned DIM> 00049 void FibreWriter<DIM>::WriteAllAxi(const std::vector< c_vector<double, DIM> >& direction) 00050 { 00051 // Write axi file 00052 std::string axi_file_name = this->mBaseName + ".axi"; 00053 out_stream p_axi_file = this->mpOutputFileHandler->OpenOutputFile(axi_file_name); 00054 00055 // \todo #1768 - Make binary writing work 00056 // if (this->mFileIsBinary) 00057 // { 00058 // *p_axi_file << "\tBIN\n"; 00059 // } 00060 // else 00061 // { 00062 // *p_axi_file << "\n"; 00063 // } 00064 00065 *p_axi_file << direction.size() << std::endl; 00066 for (unsigned i=0; i<direction.size();i++ ) 00067 { 00068 for(unsigned j=0; j<DIM; j++) 00069 { 00070 *p_axi_file << direction[i](j) << "\t"; 00071 } 00072 *p_axi_file <<"\n"; 00073 } 00074 *p_axi_file << "#\n# " << ChasteBuildInfo::GetProvenanceString(); 00075 p_axi_file->close(); 00076 } 00077 00078 00079 template<unsigned DIM> 00080 void FibreWriter<DIM>::SetWriteFileAsBinary() 00081 { 00082 mFileIsBinary = true; 00083 } 00084 00085 template class FibreWriter<1>; 00086 template class FibreWriter<2>; 00087 template class FibreWriter<3>; 00088 00089 00090 00091 00092