Chaste Commit::29c3c4ab2bee00ddd311a035a1e522c03cbe928a
VtkMeshReader.hpp
1/*
2
3Copyright (C) Fujitsu Laboratories of Europe, 2009
4
5*/
6
7/*
8
9Copyright (c) 2005-2026, University of Oxford.
10All rights reserved.
11
12University of Oxford means the Chancellor, Masters and Scholars of the
13University of Oxford, having an administrative office at Wellington
14Square, Oxford OX1 2JD, UK.
15
16This file is part of Chaste.
17
18Redistribution and use in source and binary forms, with or without
19modification, are permitted provided that the following conditions are met:
20 * Redistributions of source code must retain the above copyright notice,
21 this list of conditions and the following disclaimer.
22 * Redistributions in binary form must reproduce the above copyright notice,
23 this list of conditions and the following disclaimer in the documentation
24 and/or other materials provided with the distribution.
25 * Neither the name of the University of Oxford nor the names of its
26 contributors may be used to endorse or promote products derived from this
27 software without specific prior written permission.
28
29THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
33LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
35GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
40*/
41
42
43#ifndef VTKMESHREADER_HPP_
44#define VTKMESHREADER_HPP_
45
46#include <vector>
47#include <string>
48#include <fstream>
49#include <sstream>
50#include <cassert>
51
52#define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
53#include <vtkDataArray.h>
54#include <vtkDoubleArray.h>
55#include <vtkCellData.h>
56#include <vtkPointData.h>
57#include <vtkTetra.h>
58#include <vtkUnstructuredGrid.h>
59#include <vtkUnstructuredGridReader.h>
60#include <vtkXMLUnstructuredGridReader.h>
61#include <vtkGeometryFilter.h>
62#include <vtkGenericGeometryFilter.h>
63#include <vtkDataCompressor.h>
64#include <vtkFeatureEdges.h>
65#include <vtkDataSetSurfaceFilter.h>
66#include <vtkSmartPointer.h>
67
68
70#include "AbstractMeshReader.hpp"
71
77template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
78class VtkMeshReader : public AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>
79{
80private:
81
83 vtkSmartPointer<vtkUnstructuredGrid> mpVtkUnstructuredGrid; //This is a smart pointer to keep Vtk from deleting the object in the 1D case
84
86 vtkGeometryFilter* mpVtkGeometryFilter;
87
89 vtkFeatureEdges* mpVtkFilterEdges;
90
93 std::ifstream mVtuFile;
95 unsigned mNumNodes;
96 unsigned mNumElements;
97 unsigned mNumFaces;
100 unsigned mNodesRead;
101 unsigned mElementsRead;
102 unsigned mFacesRead;
124 void CommonConstructor();
125
126public:
127
133 VtkMeshReader(std::string pathBaseName);
134
141 VtkMeshReader(vtkUnstructuredGrid* p_vtkUnstructuredGrid);
142
146 virtual ~VtkMeshReader();
147
151 unsigned GetNumElements() const;
152
156 unsigned GetNumCableElements() const;
157
161 unsigned GetNumNodes() const;
162
166 unsigned GetNumFaces() const;
167
171 unsigned GetNumEdges() const;
172
176 unsigned GetNumElementAttributes() const;
177
181 unsigned GetNumCableElementAttributes() const;
182
186 unsigned GetNumFaceAttributes() const;
187
192 void Reset();
193
197 std::vector<double> GetNextNode();
198
203
208
213
214
221 void GetCellData(std::string dataName, std::vector<double>& dataPayload);
222
230 void GetPointData(std::string dataName, std::vector<double>& dataPayload);
231
238 void GetCellData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
239
247 void GetPointData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
248
252 vtkUnstructuredGrid* OutputMeshAsVtkUnstructuredGrid();
253};
254
255#endif/*VTKMESHREADER_HPP_*/
ElementData GetNextCableElementData()
unsigned mNumNodeAttributes
unsigned mNodesPerElement
vtkFeatureEdges * mpVtkFilterEdges
unsigned mNumCableElementAttributes
unsigned GetNumCableElementAttributes() const
vtkSmartPointer< vtkUnstructuredGrid > mpVtkUnstructuredGrid
void GetPointData(std::string dataName, std::vector< double > &dataPayload)
unsigned GetNumElementAttributes() const
unsigned mElementsRead
unsigned GetNumCableElements() const
unsigned mOrderOfElements
void GetCellData(std::string dataName, std::vector< double > &dataPayload)
void CommonConstructor()
unsigned mCableElementsRead
unsigned GetNumFaceAttributes() const
std::ifstream mVtuFile
std::vector< double > GetNextNode()
unsigned mBoundaryFacesRead
vtkGeometryFilter * mpVtkGeometryFilter
unsigned mNumFaceAttributes
virtual ~VtkMeshReader()
vtkUnstructuredGrid * OutputMeshAsVtkUnstructuredGrid()
unsigned GetNumNodes() const
unsigned GetNumEdges() const
ElementData GetNextFaceData()
unsigned mNumCableElements
unsigned mMaxNodeBdyMarker
unsigned mBoundaryFacesSkipped
unsigned GetNumFaces() const
unsigned mNumElements
unsigned GetNumElements() const
ElementData GetNextElementData()
unsigned mNumElementAttributes