VertexMeshWriter.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 #ifndef VERTEXMESHWRITER_HPP_
00029 #define VERTEXMESHWRITER_HPP_
00030 
00031 // Forward declaration prevents circular include chain
00032 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00033 class VertexMesh;
00034 
00035 #ifdef CHASTE_VTK
00036 //Requires  "sudo aptitude install libvtk5-dev" or similar
00037 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
00038 #include <vtkDoubleArray.h>
00039 #include <vtkCellData.h>
00040 #include <vtkPointData.h>
00041 #include <vtkConvexPointSet.h>
00042 #include <vtkPolygon.h>
00043 #include <vtkUnstructuredGrid.h>
00044 #include <vtkUnstructuredGridWriter.h>
00045 #include <vtkXMLUnstructuredGridWriter.h>
00046 #include <vtkDataCompressor.h>
00047 #endif //CHASTE_VTK
00048 
00049 #include "VertexMesh.hpp"
00050 #include "AbstractMeshWriter.hpp"
00051 #include "NodeMap.hpp"
00052 
00053 // Forward declaration prevents circular include chain
00054 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00055 class VertexMesh;
00056 
00057 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00058 struct MeshWriterIterators;
00059 
00063 template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00064 class VertexMeshWriter : public AbstractMeshWriter<ELEMENT_DIM, SPACE_DIM>
00065 {
00066 private:
00071     VertexMesh<ELEMENT_DIM,SPACE_DIM>* mpMesh;
00072 
00074     MeshWriterIterators<ELEMENT_DIM,SPACE_DIM>* mpIters;
00075 
00077     NodeMap* mpNodeMap;
00079     unsigned mNodeMapCurrentIndex;
00080 
00081 #ifdef CHASTE_VTK
00082 //Requires  "sudo aptitude install libvtk5-dev" or similar
00084     vtkUnstructuredGrid* mpVtkUnstructedMesh;
00085 #endif //CHASTE_VTK
00086 
00087 public:
00088 
00096     VertexMeshWriter(const std::string& rDirectory,
00097                      const std::string& rBaseName,
00098                      const bool clearOutputDir=true);
00099 
00103     ~VertexMeshWriter();
00104 
00106 
00111     void WriteFilesUsingMesh(VertexMesh<ELEMENT_DIM, SPACE_DIM>& rMesh);
00112 
00119     void WriteVtkUsingMesh(VertexMesh<ELEMENT_DIM, SPACE_DIM>& rMesh, std::string stamp="");
00120 
00127     void AddCellData(std::string dataName, std::vector<double> dataPayload);
00128 
00135     void AddPointData(std::string dataName, std::vector<double> dataPayload);
00136 
00137     std::vector<double> GetNextNode();
00138 
00139     ElementData GetNextElement();
00140 
00145     void WriteFiles();
00146 
00147 };
00148 
00149 #endif /*VERTEXMESHWRITER_HPP_*/

Generated by  doxygen 1.6.2