3#if !defined(_PIODATA_H)
6#include "vtkABINamespace.h"
19VTK_ABI_NAMESPACE_BEGIN
22 bool operator()(
const char* p,
const char* q)
const {
return strcmp(p, q) < 0; };
49typedef std::multimap<const char*, PIO_FIELD*, Cstring_less>
VAR_MAP;
50typedef VAR_MAP::iterator
VMI;
51typedef VAR_MAP::const_iterator
CVMI;
52typedef std::pair<VMI, VMI>
VMP;
53typedef std::pair<CVMI, CVMI>
CVMP;
58 PIO_DATA(
const char* piofile =
nullptr,
const std::list<std::string>* fields_to_read =
nullptr,
59 bool _defer_read_data =
true,
const std::set<const char*, Cstring_less>* rdata =
nullptr,
60 const std::set<const char*, Cstring_less>* cdata =
nullptr);
70 inline bool good_read() {
return (pio_field !=
nullptr) ? true :
false; }
87 void GetPIOData(
const char*,
const double*&,
const char*&);
93 const char* var,
int materialId);
96 if (RealData.find(_name) == RealData.end())
97 RealData.insert(strdup(_name));
101 if (CharData.find(_name) == CharData.end())
102 CharData.insert(strdup(_name));
108 std::set<const char*, Cstring_less> RealData;
109 std::set<const char*, Cstring_less> CharData;
111 std::istream* Infile;
115 int PIO_HEADER_LENGTH;
116 int PIO_INDEX_LENGTH;
117 const char* pio_dandt;
119 int64_t pio_position;
122 bool defer_read_data;
124 size_t timertype_len;
128 void ReadPioFieldData(
PIO_FIELD& pio_field);
129 bool read(
const char*,
const std::list<std::string>* fields_to_read =
nullptr);
130 bool read(
const std::list<std::string>* fields_to_read =
nullptr);
131 inline void byte_flip(
char* word, int64_t size)
133 if (size_buf < (
size_t)size)
137 buf =
new char[size_buf];
139 memcpy((
void*)buf, (
const void*)word, size);
140 for (int64_t i = 0; i < size; ++i)
141 word[i] = buf[size - 1 - i];
145 inline T read_pio_word(T& val)
148 this->Infile->read((
char*)&word,
sizeof(word));
150 byte_flip((
char*)&word,
sizeof(word));
155 inline bool read_pio_bool()
158 this->Infile->read((
char*)&word,
sizeof(word));
160 byte_flip((
char*)&word,
sizeof(word));
161 return (word != 0) ? true :
false;
164 inline void fstr2Cstr(
char* s,
size_t len)
const
175 inline char* read_pio_char_string(
size_t len)
181 buf =
new char[size_buf];
183 this->Infile->read(buf, len);
186 char* val =
new char[strlen(buf) + 1];
191 inline void insert_VAR_MAP_pairs()
193 for (
int i = 0; i < pio_num; ++i)
195 if (pio_field[i].read_field_data)
197#if !defined __SUNPRO_CC
198 VarMMap.insert(std::make_pair(pio_field[i].pio_name, pio_field + i));
200 VAR_MAP::value_type
type(pio_field[i].pio_name, pio_field + i);
207 inline bool read_field(
const char* pio_name,
const std::list<std::string>* fields_to_read)
209 std::string spio_name = std::string(pio_name);
210 if (fields_to_read ==
nullptr)
214 for (std::list<std::string>::const_iterator pos = fields_to_read->begin();
215 pos != fields_to_read->end(); ++pos)
217 if (spio_name == *pos)
bool IsPIOfile(const char *)
bool GetPIOfileTime(const char *, double &)
std::pair< VMI, VMI > VMP
std::pair< CVMI, CVMI > CVMP
std::multimap< const char *, PIO_FIELD *, Cstring_less > VAR_MAP
VAR_MAP::const_iterator CVMI
void print(std::ostream &)
void AddCharData(const char *_name)
int get_pio_signature() const
void GetPIOData(PIO_FIELD &, const double *&)
int get_PIO_INDEX_LENGTH() const
void GetPIOData(PIO_FIELD &, const double *&, const char *&)
void AddRealData(const char *_name)
void GetPIOData(const char *, const double *&)
PIO_FIELD * get_pio_field() const
bool GetPIOfileTime(const char *, double &)
void GetPIOData(const char *, const char *&)
double GetPIOData(const char *, int)
const double * GetPIOData(PIO_FIELD &)
PIO_DATA(const char *piofile=nullptr, const std::list< std::string > *fields_to_read=nullptr, bool _defer_read_data=true, const std::set< const char *, Cstring_less > *rdata=nullptr, const std::set< const char *, Cstring_less > *cdata=nullptr)
const char * get_name() const
void GetPIOData(PIO_FIELD &, const char *&)
void FreePIOData(PIO_FIELD &pio_field)
bool set_vector_field(std::valarray< std::valarray< double > > &, const char *)
bool set_scalar_field(std::valarray< double > &, const char *)
bool get_reverse_endian() const
int get_pio_num_with_size(int64_t n) const
int get_PIO_HEADER_LENGTH() const
int get_PIO_NAME_LENGTH() const
void GetPIOData(const char *, const double *&, const char *&)
bool set_scalar_field(std::valarray< uint64_t > &, const char *)
bool set_scalar_field(std::valarray< int64_t > &, const char *)
const double * GetPIOData(const char *)
bool reconstruct_chunk_field(int64_t numcell, std::valarray< double > &va, const char *prefix, const char *var, int materialId)
bool set_scalar_field(std::valarray< int > &, const char *)
const char * get_pio_dandt() const
int get_PIO_VERSION() const
bool operator()(const char *p, const char *q) const