svMultiPhysics
Loading...
Searching...
No Matches
VtkData.h
1/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2 *
3 * All Rights Reserved.
4 *
5 * See Copyright-SimVascular.txt for additional details.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject
13 * to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef VTK_DATA_H
32#define VTK_DATA_H
33
34#include "Array.h"
35#include "Vector.h"
36
37#include <string>
38
39class VtkData {
40 public:
41 VtkData();
42 virtual ~VtkData();
43
44 virtual Array<int> get_connectivity() = 0;
45 virtual Array<double> get_points() = 0;
46 virtual int num_elems() = 0;
47 virtual int elem_type() = 0;
48 virtual int np_elem() = 0;
49 virtual int num_points() = 0;
50 virtual void read_file(const std::string& file_name) = 0;
51
52 virtual void set_element_data(const std::string& data_name, const Array<double>& data) = 0;
53 virtual void set_element_data(const std::string& data_name, const Array<int>& data) = 0;
54
55 virtual void set_point_data(const std::string& data_name, const Array<double>& data) = 0;
56 virtual void set_point_data(const std::string& data_name, const Array<int>& data) = 0;
57 virtual void set_point_data(const std::string& data_name, const Vector<int>& data) = 0;
58
59 virtual void set_points(const Array<double>& points) = 0;
60 virtual void set_connectivity(const int nsd, const Array<int>& conn, const int pid = 0) = 0;
61
62 virtual bool has_point_data(const std::string& data_name) = 0;
63
64 virtual void copy_points(Array<double>& points) = 0;
65 virtual void copy_point_data(const std::string& data_name, Array<double>& mesh_data) = 0;
66 virtual void copy_point_data(const std::string& data_name, Vector<double>& mesh_data) = 0;
67 virtual void write() = 0;
68
69 static VtkData* create_reader(const std::string& file_name);
70 static VtkData* create_writer(const std::string& file_name);
71
72 std::string file_name;
73};
74
75class VtkVtpData : public VtkData {
76 public:
77 VtkVtpData();
78 VtkVtpData(const std::string& file_name, bool reader=true);
80
81 virtual Array<int> get_connectivity();
82 virtual Array<double> get_points();
83 virtual int elem_type();
84 virtual int num_elems();
85 virtual int np_elem();
86 virtual int num_points();
87 virtual void read_file(const std::string& file_name);
88
89 void copy_points(Array<double>& points);
90 void copy_point_data(const std::string& data_name, Array<double>& mesh_data);
91 void copy_point_data(const std::string& data_name, Vector<double>& mesh_data);
92 void copy_point_data(const std::string& data_name, Vector<int>& mesh_data);
93 Array<double> get_point_data(const std::string& data_name);
94 std::vector<std::string> get_point_data_names();
95 bool has_point_data(const std::string& data_name);
96 virtual void set_connectivity(const int nsd, const Array<int>& conn, const int pid = 0);
97
98 virtual void set_element_data(const std::string& data_name, const Array<double>& data);
99 virtual void set_element_data(const std::string& data_name, const Array<int>& data);
100
101 virtual void set_point_data(const std::string& data_name, const Array<double>& data);
102 virtual void set_point_data(const std::string& data_name, const Array<int>& data);
103 virtual void set_point_data(const std::string& data_name, const Vector<int>& data);
104
105 virtual void set_points(const Array<double>& points);
106 virtual void write();
107
108 private:
109 class VtkVtpDataImpl;
110 VtkVtpDataImpl* impl;
111};
112
113class VtkVtuData : public VtkData {
114 public:
115 VtkVtuData();
116 VtkVtuData(const std::string& file_name, bool reader=true);
117 ~VtkVtuData();
118
119 virtual Array<int> get_connectivity();
120 virtual int elem_type();
121 virtual int num_elems();
122 virtual int np_elem();
123 virtual int num_points();
124 virtual void read_file(const std::string& file_name);
125
126 void copy_points(Array<double>& points);
127 void copy_point_data(const std::string& data_name, Array<double>& mesh_data);
128 void copy_point_data(const std::string& data_name, Vector<double>& mesh_data);
129 void copy_point_data(const std::string& data_name, Vector<int>& mesh_data);
130
131 Array<double> get_point_data(const std::string& data_name);
132 std::vector<std::string> get_point_data_names();
133 virtual Array<double> get_points();
134 bool has_point_data(const std::string& data_name);
135 virtual void set_connectivity(const int nsd, const Array<int>& conn, const int pid = 0);
136
137 virtual void set_element_data(const std::string& data_name, const Array<double>& data);
138 virtual void set_element_data(const std::string& data_name, const Array<int>& data);
139
140 virtual void set_point_data(const std::string& data_name, const Array<double>& data);
141 virtual void set_point_data(const std::string& data_name, const Array<int>& data);
142 virtual void set_point_data(const std::string& data_name, const Vector<int>& data);
143
144 virtual void set_points(const Array<double>& points);
145 virtual void write();
146
147 private:
148 class VtkVtuDataImpl;
149 VtkVtuDataImpl* impl;
150};
151
152#endif
The Vector template class is used for storing int and double data.
Definition Vector.h:50
Definition VtkData.h:39
Definition VtkData.cpp:59
Definition VtkData.h:75
std::vector< std::string > get_point_data_names()
Get a list of point data names.
Definition VtkData.cpp:707
virtual Array< double > get_points()
Get an array of point data from an unstructured grid.
Definition VtkData.cpp:722
void copy_point_data(const std::string &data_name, Array< double > &mesh_data)
Copy an array of point data from an polydata mesh into the given Array.
Definition VtkData.cpp:596
Array< double > get_point_data(const std::string &data_name)
Get an array of point data from an unstructured grid.
Definition VtkData.cpp:680
void copy_points(Array< double > &points)
Copy points into the given array.
Definition VtkData.cpp:661
Definition VtkData.cpp:243
Definition VtkData.h:113
void copy_point_data(const std::string &data_name, Array< double > &mesh_data)
Copy an array of point data from an unstructured grid into the given Array.
Definition VtkData.cpp:878
void copy_points(Array< double > &points)
Copy points into the given array.
Definition VtkData.cpp:944
Array< double > get_point_data(const std::string &data_name)
Get an array of point data from an unstructured grid.
Definition VtkData.cpp:976
std::vector< std::string > get_point_data_names()
Get a list of point data names.
Definition VtkData.cpp:863