VtkMeshReader.hpp

00001 /*
00002 
00003 Copyright (C) Fujitsu Laboratories of Europe, 2009
00004 
00005 */
00006 
00007 /*
00008 
00009 Copyright (C) University of Oxford, 2005-2011
00010 
00011 University of Oxford means the Chancellor, Masters and Scholars of the
00012 University of Oxford, having an administrative office at Wellington
00013 Square, Oxford OX1 2JD, UK.
00014 
00015 This file is part of Chaste.
00016 
00017 Chaste is free software: you can redistribute it and/or modify it
00018 under the terms of the GNU Lesser General Public License as published
00019 by the Free Software Foundation, either version 2.1 of the License, or
00020 (at your option) any later version.
00021 
00022 Chaste is distributed in the hope that it will be useful, but WITHOUT
00023 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00024 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00025 License for more details. The offer of Chaste under the terms of the
00026 License is subject to the License being interpreted in accordance with
00027 English Law and subject to any action against the University of Oxford
00028 being under the jurisdiction of the English Courts.
00029 
00030 You should have received a copy of the GNU Lesser General Public License
00031 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00032 
00033 */
00034 
00035 
00036 #ifndef VTKMESHREADER_HPP_
00037 #define VTKMESHREADER_HPP_
00038 
00039 #include <vector>
00040 #include <string>
00041 #include <fstream>
00042 #include <sstream>
00043 #include <cassert>
00044 
00045 #ifdef CHASTE_VTK
00046 //Requires  "sudo aptitude install libvtk5-dev" or similar
00047 #define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
00048 #include <vtkDataArray.h>
00049 #include <vtkDoubleArray.h>
00050 #include <vtkCellData.h>
00051 #include <vtkPointData.h>
00052 #include <vtkTetra.h>
00053 #include <vtkUnstructuredGrid.h>
00054 #include <vtkUnstructuredGridReader.h>
00055 #include <vtkXMLUnstructuredGridReader.h>
00056 #include <vtkGeometryFilter.h>
00057 #include <vtkGenericGeometryFilter.h>
00058 #include <vtkDataCompressor.h>
00059 
00060 #include "UblasVectorInclude.hpp"
00061 #include "AbstractMeshReader.hpp"
00062 
00069 template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
00070 class VtkMeshReader : public AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>
00071 {
00072 private:
00073 
00075     vtkUnstructuredGrid* mpVtkUnstructuredGrid;
00076 
00078     vtkGeometryFilter* mpVtkGeometryFilter;
00079 
00080     bool mIndexFromZero;             
00082     std::ifstream mVtuFile;            
00084     unsigned mNumNodes;                
00085     unsigned mNumElements;            
00086     unsigned mNumFaces;                
00088     unsigned mNodesRead;            
00089     unsigned mElementsRead;            
00090     unsigned mFacesRead;            
00091     unsigned mBoundaryFacesRead;    
00093     unsigned mNumNodeAttributes;     
00094     unsigned mMaxNodeBdyMarker;     
00095     unsigned mNumElementAttributes; 
00096     unsigned mNumFaceAttributes;     
00098     unsigned mOrderOfElements;        
00099     unsigned mNodesPerElement;        
00101 public:
00102 
00108     VtkMeshReader(std::string pathBaseName);
00109 
00116     VtkMeshReader(vtkUnstructuredGrid* p_vtkUnstructuredGrid);
00117 
00121     virtual ~VtkMeshReader();
00122 
00126     unsigned GetNumElements() const;
00127 
00131     unsigned GetNumNodes() const;
00132 
00136     unsigned GetNumFaces() const;
00137 
00141     unsigned GetNumEdges() const;
00142 
00146     unsigned GetNumElementAttributes() const;
00147 
00151     unsigned GetNumFaceAttributes() const;
00152 
00157     void Reset();
00158 
00164     void Initialize();
00165 
00169     std::vector<double> GetNextNode();
00170 
00174     ElementData GetNextElementData();
00175 
00179     ElementData GetNextFaceData();
00180 
00181 
00188      void GetCellData(std::string dataName, std::vector<double>& dataPayload);
00189 
00197     void GetPointData(std::string dataName, std::vector<double>& dataPayload);
00198 
00205      void GetCellData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
00206 
00214     void GetPointData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
00215 
00219     vtkUnstructuredGrid* OutputMeshAsVtkUnstructuredGrid();
00220 
00221 };
00222 
00223 #endif/*CHASTE_VTK*/
00224 
00225 #endif/*VTKMESHREADER_HPP_*/
Generated on Thu Dec 22 13:00:16 2011 for Chaste by  doxygen 1.6.3