Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
VtkMeshReader.hpp
1/*
2
3Copyright (C) Fujitsu Laboratories of Europe, 2009
4
5*/
6
7/*
8
9Copyright (c) 2005-2024, 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#ifdef CHASTE_VTK
53//Requires "sudo aptitude install libvtk5-dev" or similar
54#define _BACKWARD_BACKWARD_WARNING_H 1 //Cut out the strstream deprecated warning for now (gcc4.3)
55#include <vtkDataArray.h>
56#include <vtkDoubleArray.h>
57#include <vtkCellData.h>
58#include <vtkPointData.h>
59#include <vtkTetra.h>
60#include <vtkUnstructuredGrid.h>
61#include <vtkUnstructuredGridReader.h>
62#include <vtkXMLUnstructuredGridReader.h>
63#include <vtkGeometryFilter.h>
64#include <vtkGenericGeometryFilter.h>
65#include <vtkDataCompressor.h>
66#include <vtkFeatureEdges.h>
67#include <vtkDataSetSurfaceFilter.h>
68#include <vtkSmartPointer.h>
69
70
72#include "AbstractMeshReader.hpp"
73
79template <unsigned ELEMENT_DIM, unsigned SPACE_DIM>
80class VtkMeshReader : public AbstractMeshReader<ELEMENT_DIM, SPACE_DIM>
81{
82private:
83
85 vtkSmartPointer<vtkUnstructuredGrid> mpVtkUnstructuredGrid; //This is a smart pointer to keep Vtk from deleting the object in the 1D case
86
88 vtkGeometryFilter* mpVtkGeometryFilter;
89
91 vtkFeatureEdges* mpVtkFilterEdges;
92
95 std::ifstream mVtuFile;
97 unsigned mNumNodes;
98 unsigned mNumElements;
99 unsigned mNumFaces;
102 unsigned mNodesRead;
103 unsigned mElementsRead;
104 unsigned mFacesRead;
126 void CommonConstructor();
127
128public:
129
135 VtkMeshReader(std::string pathBaseName);
136
143 VtkMeshReader(vtkUnstructuredGrid* p_vtkUnstructuredGrid);
144
148 virtual ~VtkMeshReader();
149
153 unsigned GetNumElements() const;
154
158 unsigned GetNumCableElements() const;
159
163 unsigned GetNumNodes() const;
164
168 unsigned GetNumFaces() const;
169
173 unsigned GetNumEdges() const;
174
178 unsigned GetNumElementAttributes() const;
179
183 unsigned GetNumCableElementAttributes() const;
184
188 unsigned GetNumFaceAttributes() const;
189
194 void Reset();
195
199 std::vector<double> GetNextNode();
200
205
210
215
216
223 void GetCellData(std::string dataName, std::vector<double>& dataPayload);
224
232 void GetPointData(std::string dataName, std::vector<double>& dataPayload);
233
240 void GetCellData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
241
249 void GetPointData(std::string dataName, std::vector<c_vector<double,SPACE_DIM> >& dataPayload);
250
254 vtkUnstructuredGrid* OutputMeshAsVtkUnstructuredGrid();
255};
256
257#endif/*CHASTE_VTK*/
258
259#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