BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
vtk_writer.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_vtk_writer_hpp
22 #define bempp_vtk_writer_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "../common/armadillo_fwd.hpp"
27 #include <memory>
28 #include <string>
29 
30 namespace Bempp
31 {
32 
42 class VtkWriter
43 {
44 public:
46  enum OutputType {
55  };
56 
58  enum DataType
59  {
60  CELL_DATA,
61  VERTEX_DATA
62  };
63 
65  virtual ~VtkWriter() {}
66 
73  void addCellData(const arma::Mat<double>& data, const std::string &name);
75  void addCellData(const arma::Mat<float>& data, const std::string &name);
76 
83  void addVertexData(const arma::Mat<double>& data, const std::string &name);
85  void addVertexData(const arma::Mat<float>& data, const std::string &name);
86 
88  virtual void clear() = 0;
89 
103  virtual std::string write (const std::string &name,
104  OutputType type = ASCII) = 0;
105 
134  virtual std::string pwrite(const std::string& name, const std::string& path,
135  const std::string& extendpath,
136  OutputType type = ASCII) = 0;
137 
138 private:
139  virtual void addCellDataDoubleImpl(
140  const arma::Mat<double>& data, const std::string &name) = 0;
141  virtual void addCellDataFloatImpl(
142  const arma::Mat<float>& data, const std::string &name) = 0;
143 
144  virtual void addVertexDataDoubleImpl(
145  const arma::Mat<double>& data, const std::string &name) = 0;
146  virtual void addVertexDataFloatImpl(
147  const arma::Mat<float>& data, const std::string &name) = 0;
148 };
149 
150 inline void VtkWriter::addCellData(const arma::Mat<double>& data,
151  const std::string& name)
152 {
153  addCellDataDoubleImpl(data, name);
154 }
155 
156 inline void VtkWriter::addCellData(const arma::Mat<float>& data,
157  const std::string& name)
158 {
159  addCellDataFloatImpl(data, name);
160 }
161 
162 inline void VtkWriter::addVertexData(const arma::Mat<double>& data,
163  const std::string& name)
164 {
165  addVertexDataDoubleImpl(data, name);
166 }
167 
168 inline void VtkWriter::addVertexData(const arma::Mat<float>& data,
169  const std::string& name)
170 {
171  addVertexDataFloatImpl(data, name);
172 }
173 
174 } // namespace Bempp
175 
176 #endif
void addVertexData(const arma::Mat< double > &data, const std::string &name)
Add a grid function (represented by a container) that lives on the vertices of the grid to the visual...
Definition: vtk_writer.hpp:162
virtual ~VtkWriter()
Destructor.
Definition: vtk_writer.hpp:65
Abstract exporter of data in the vtk format.
Definition: vtk_writer.hpp:42
OutputType
How data should be stored in a VTK file.
Definition: vtk_writer.hpp:46
Output to the file is in inline base64 binary.
Definition: vtk_writer.hpp:50
virtual std::string pwrite(const std::string &name, const std::string &path, const std::string &extendpath, OutputType type=ASCII)=0
Write output (interface might change later).
virtual std::string write(const std::string &name, OutputType type=ASCII)=0
Write output (interface might change later).
void addCellData(const arma::Mat< double > &data, const std::string &name)
Add a grid function (represented by a container) that lives on the cells of the grid to the visualiza...
Definition: vtk_writer.hpp:150
Output to the file is in appended raw binary.
Definition: vtk_writer.hpp:52
Output to the file is in ascii.
Definition: vtk_writer.hpp:48
Output to the file is in appended base64 binary.
Definition: vtk_writer.hpp:54
virtual void clear()=0
Clear the list of registered functions.
DataType
Dataset type.
Definition: vtk_writer.hpp:58