Loading...
Searching...
No Matches
VTKField.cpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#include "VTK.hpp"
26
27namespace bitpit{
28
41
42 switch (fieldType) {
43
44 case VTKFieldType::SCALAR:
45 return 1;
46
47 case VTKFieldType::VECTOR:
48 return 3;
49
50 case VTKFieldType::TENSOR:
51 return 9;
52
53 default:
54 throw std::runtime_error("Unable to identify the number of components of field type " + std::to_string(static_cast<int>(fieldType)));
55
56 }
57}
58
59
64
65 m_name = "undefined" ;
66 m_dataType = VTKDataType::UNDEFINED ;
67 m_location = VTKLocation::UNDEFINED ;
68 m_codification = VTKFormat::UNDEFINED ;
69 m_offset = 0 ;
70 m_fieldType = VTKFieldType::UNDEFINED ;
71 m_position = 0 ;
72 m_streamer = nullptr ;
73 m_enabled = true ;
74
75}
76
81VTKField::VTKField( const std::string &name ): VTKField() {
82 setName(name) ;
83}
84
89void VTKField::setName( const std::string &name){
90 m_name= name;
91}
92
98 m_dataType= type;
99}
100
106 m_location= loc;
107}
108
116
122 m_fieldType= type;
123}
124
129void VTKField::setPosition( std::fstream::pos_type pos ){
130 m_position =pos ;
131}
132
137void VTKField::setOffset( uint64_t off){
138 m_offset= off;
139}
140
146 m_streamer= &streamer;
147}
148
153 m_enabled=true;
154}
155
160 m_enabled=false;
161}
162
167const std::string & VTKField::getName() const{
168 return m_name;
169}
170
178
184
186}
187
195
203
211
216uint64_t VTKField::getOffset() const{
217 return m_offset;
218}
219
225std::fstream::pos_type VTKField::getPosition() const{
226 return m_position;
227}
228
234 return *m_streamer;
235}
236
242 return m_enabled;
243}
244
250
251 bool allData(true);
252
253 allData &= m_name != "undefined" ;
254 allData &= m_dataType != VTKDataType::UNDEFINED ;
255 allData &= m_location != VTKLocation::UNDEFINED ;
256 allData &= m_codification != VTKFormat::UNDEFINED ;
257 allData &= m_fieldType != VTKFieldType::UNDEFINED ;
258 allData &= m_streamer != nullptr ;
259
260 return allData;
261
262}
263
268void VTKField::write( std::fstream &str) const{
269 if(m_streamer){
271 }
272}
273
280void VTKField::read( std::fstream &str, uint64_t entries, uint8_t components ) const{
281 if(m_streamer){
282 m_streamer->absorbData( str, m_name, m_codification, entries, components, m_dataType) ;
283 }
284}
285
286}
The base class to be used to derive VTK streamers form.
Definition VTK.hpp:209
virtual void flushData(std::fstream &, const std::string &, VTKFormat)
virtual void absorbData(std::fstream &, const std::string &, VTKFormat, uint64_t, uint8_t, VTKDataType)
VTKField handles geometry and data field information for the VTK format.
Definition VTK.hpp:247
VTKFieldType m_fieldType
Definition VTK.hpp:252
const std::string & getName() const
Definition VTKField.cpp:167
VTKFormat getCodification() const
Definition VTKField.cpp:208
VTKDataType m_dataType
Definition VTK.hpp:253
bool isEnabled() const
Definition VTKField.cpp:241
std::fstream::pos_type getPosition() const
Definition VTKField.cpp:225
const VTKBaseStreamer & getStreamer() const
Definition VTKField.cpp:233
uint64_t getOffset() const
Definition VTKField.cpp:216
void setDataType(VTKDataType)
Definition VTKField.cpp:97
VTKBaseStreamer * m_streamer
Definition VTK.hpp:258
VTKFieldType getFieldType() const
Definition VTKField.cpp:175
VTKLocation getLocation() const
Definition VTKField.cpp:200
VTKFormat m_codification
Definition VTK.hpp:255
unsigned getComponentCount() const
Definition VTKField.cpp:183
void setStreamer(VTKBaseStreamer &)
Definition VTKField.cpp:145
uint64_t m_offset
Definition VTK.hpp:256
void setCodification(VTKFormat)
Definition VTKField.cpp:113
void write(std::fstream &) const
Definition VTKField.cpp:268
std::string m_name
Definition VTK.hpp:251
void setFieldType(VTKFieldType)
Definition VTKField.cpp:121
bool hasAllMetaData() const
Definition VTKField.cpp:249
void read(std::fstream &, uint64_t, uint8_t) const
Definition VTKField.cpp:280
VTKDataType getDataType() const
Definition VTKField.cpp:192
VTKLocation m_location
Definition VTK.hpp:254
std::fstream::pos_type m_position
Definition VTK.hpp:257
void setOffset(uint64_t)
Definition VTKField.cpp:137
void setName(const std::string &)
Definition VTKField.cpp:89
void setPosition(std::fstream::pos_type)
Definition VTKField.cpp:129
void setLocation(VTKLocation)
Definition VTKField.cpp:105
VTKFieldType
Definition VTK.hpp:63
VTKFormat
Definition VTK.hpp:92
VTKDataType
Definition VTK.hpp:74
VTKLocation
Definition VTK.hpp:102
--- layout: doxygen_footer ---