openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
IGBheader.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <https://www.gnu.org/licenses/>.
18 // ----------------------------------------------------------------------------
19 
20 
21 /* src/IGBheader.h. Generated automatically by configure. */
22 #ifndef IGBheader_h
23 #define IGBheader_h
24 
25 #include <cstdio>
26 #include <cstdlib>
27 #include <fstream>
28 #include <zlib.h>
29 #include <cstring>
30 #include <cctype>
31 #include <cassert>
32 #include <cmath>
33 #include <limits>
34 #include <algorithm>
35 #include <type_traits>
36 #include "short_float.h"
37 
38 template<class T>
39 typename std::enable_if<!std::numeric_limits<T>::is_integer, bool>::type
40  almost_equal(T x, T y, int ulp = 2)
41 {
42  // the machine epsilon has to be scaled to the magnitude of the values used
43  // and multiplied by the desired precision in ULPs (units in the last place)
44  return std::abs(x-y) <= std::numeric_limits<T>::epsilon() * std::abs(x+y) * ulp
45  // unless the result is subnormal
46  || std::abs(x-y) < std::numeric_limits<T>::min();
47 }
48 
49 #define NALLOC 100
50 
51 #define NUL 0
52 #define INCONNU 0
53 
54 #define IGB_BIG_ENDIAN 666666666
55 #define IGB_LITTLE_ENDIAN 777777777
56 #define N_SYSTEMES 2
57 
58 
59 /* ------------------------ TYPES definition ------------------------------ */
60 #define IGB_BYTE 1 /* -- byte ----------------------------------- */
61 #define IGB_CHAR 2 /* -- Char ----------------------------------- */
62 #define IGB_SHORT 3 /* -- short ---------------------------------- */
63 #define IGB_LONG 4 /* -- long ----------------------------------- */
64 #define IGB_FLOAT 5 /* -- float ---------------------------------- */
65 #define IGB_DOUBLE 6 /* -- Double --------------------------------- */
66 #define IGB_COMPLEX 7 /* -- 2 x float (real part, imaginary part) -- */
67 #define IGB_D_COMPLEX 8 /* -- 2 x Double (real part, imaginary part) - */
68 #define IGB_RGBA 9 /* -- 4 x byte (red, green, blue, alpha) ----- */
69 #define IGB_STRUCTURE 10 /* -- Structure ------------------------------ */
70 #define IGB_POINTER 11 /* -- void * --------------------------------- */
71 #define IGB_LIST 12 /* -- List --------------------------------- */
72 #define IGB_INT 13 /* -- integer -------------------------------- */
73 #define IGB_UINT 14 /* -- unsigned integer------------------------ */
74 #define IGB_USHORT 15 /* -- unsigned short integer------------------ */
75 #define IGB_VEC3_f 16 /* -- 3 X float ------------------------------ */
76 #define IGB_VEC3_d 17 /* -- 3 X double ----------------------------- */
77 #define IGB_VEC4_f 18 /* -- 4 X float ------------------------------ */
78 #define IGB_VEC4_d 19 /* -- 4 X double ----------------------------- */
79 #define IGB_HFLOAT 20 /* -- half float ----------------------------- */
80 #define IGB_VEC9_f 21 /* -- 9 X foat ------------------------------- */
81 #define IGB_VEC9_d 22 /* -- 9 X double ----------------------------- */
82 #define IGB_MIN_TYPE 1
83 #define IGB_MAX_TYPE 22
84 
85 #define Byte hByte
86 
87 /* Types de trames */
88 #define MIN_TRAME 0
89 #define C8 0
90 #define C4 1
91 #define HEX 2
92 #define HEXEDGES 3
93 #define HEXBRIDGES 4
94 #define HEXLINES 5
95 #define HEX2 6
96 #define MAX_TRAME 6
97 #define NTRAMES 7
98 
99 
100 /* define for endedness */
101 #define IGB_ENDIAN_VAL -1.24e5
102 #define IGB_LITTLE_END_REP 0,48,242,199
103 
104 // error codes
105 #define ERR_EOF_IN_HEADER 1
106 #define ERR_LINE_TOO_LONG 2
107 #define ERR_UNPRINTABLE_CHAR 3
108 #define ERR_IGB_SYNTAX 4
109 #define ERR_UNDEFINED_X_Y_TYPE 5
110 #define ERR_SIZE_REDEFINED 6
111 #define ERR_SIZE_NOT_DEFINED 7
112 #define WARN_DIM_INCONSISTENT 256
113 
114 #ifndef PrMTYPES
115 #define PrMTYPES
116 /*
117  Definition des types List, bytes, Char, Double, complex d_complex
118  et rgba
119 */
120 typedef struct List
121 {
122  long nitems;
123  char *items;
124 }
125 List;
126 typedef unsigned char byte;
127 #ifndef __GL_GL_H__
128 typedef unsigned char Byte;
129 typedef char *String;
130 #endif
131 typedef signed char Char;
132 typedef struct S_Complex S_Complex;
133 typedef double Double;
134 typedef struct D_Complex D_Complex;
135 typedef float Float;
136 typedef int Int;
137 typedef long Long;
138 typedef unsigned int UInt;
139 typedef short Short;
140 typedef int BooleaN;
141 typedef int Flag;
142 typedef char *RDir;
143 typedef char *RFile;
144 typedef char *RWDir;
145 typedef char *RWFile;
146 typedef char *WDir;
147 typedef char *WFile;
148 typedef char **Text;
149 typedef void Any;
150 struct S_Complex
151 {
152  Float real, imag;
153 };
154 struct D_Complex
155 {
156  Double real, imag;
157 };
158 #endif
159 
160 /* Indice de chaque composante dans le vecteur b[] de l'union rgba */
161 typedef union rgba {
162  unsigned long l;
163  byte b[4];
164 } rgba ;
165 #define RGBA_ROUGE 3
166 #define RGBA_VERT 2
167 #define RGBA_BLEU 1
168 #define RGBA_ALPHA 0
169 
170 #define HFLT_MIN -65504
171 #define HFLT_MAX 65504
172 
173 /* -------------- Definition du type des variables globales de header.c - */
174 
175 #ifndef HEADER_GLOBALS
176 extern bool Header_Quiet;
177 extern const char *Header_Type[IGB_MAX_TYPE+1];
178 extern const size_t Data_Size[IGB_MAX_TYPE+1];
179 extern const unsigned short Num_Components[IGB_MAX_TYPE+1];
180 extern const char *Header_Systeme[N_SYSTEMES];
181 extern const unsigned long Header_Systeme_No[N_SYSTEMES];
182 extern char Header_Message[256];
183 #endif
184 
185 class IGBheader;
186 
187 template<class T>
188 int read_IGB_data( T* dp, int numt, IGBheader* h, char *buf=NULL );
189 
190 template<class T>
191 T IGB_convert_buffer_datum( IGBheader*, void *buf, int a );
192 
194 {
195  private:
196  void* file=NULL;
197  bool gzipping=false; // are we gzipping data?
198  size_t v_x=0, v_y=0, v_z=1, v_t=1;
199  int v_type=0;
200  int v_taille ;
201  unsigned long v_systeme=endian() ;
202  int v_num=0;
203  int v_bin=0;
204  int v_trame=C8;
205  unsigned int v_lut=0 ;
206  unsigned int v_comp=0 ;
207  float v_epais=0;
208  float v_org_x=1., v_org_y=1., v_org_z=1., v_org_t=0.;
209  float v_inc_x=1., v_inc_y=1., v_inc_z=1., v_inc_t=1.;
210  float v_dim_x, v_dim_y, v_dim_z, v_dim_t ;
211  float *v_vect_z=NULL;
212  char v_unites_x[41]={}, v_unites_y[41]={}, v_unites_z[41]={}, v_unites_t[41]={};
214  char v_unites[41]={};
215  float v_facteur=1., v_zero=0.;
216  char v_struct_desc[41]={};
217  char v_aut_name[41]={};
218  char** v_comment=(char**)calloc(NALLOC,sizeof(char*));
219  void* v_transparent=NULL;
220  int puts_fcn(char *);
221  int seek(size_t, int );
222  int get_character();
223  int read_vz( float *vz, int sz );
224  size_t bytes_read=0;
225 
226  // boolean flags to indicate if a default value has been overridden
227  bool bool_x=false, bool_y=false, bool_z=false, bool_t=false;
228  bool bool_type=false;
229  bool bool_taille=false;
230  bool bool_num=false;
231  bool bool_bin=false;
232  bool bool_trame=false;
233  bool bool_lut=false;
234  bool bool_comp=false;
235  bool bool_epais=false;
236  bool bool_org_x=false, bool_org_y=false, bool_org_z=false, bool_org_t=false;
237  bool bool_inc_x=false, bool_inc_y=false, bool_inc_z=false, bool_inc_t=false;
238  bool bool_dim_x, bool_dim_y=false, bool_dim_z=false, bool_dim_t=false;
239  bool bool_vect_z=false;
240  bool bool_unites_x=false, bool_unites_y=false, bool_unites_z=false, bool_unites_t=false;
241  bool bool_unites=false;
242  bool bool_facteur=false, bool_zero=false;
243  bool bool_struct_desc=false;
244  bool bool_aut_name=false;
245  bool bool_comment=false;
246  bool bool_transparent=false;
247  char transstr[257];
248 
249  public:
250  IGBheader( gzFile a = NULL, bool read=false, bool quiet=false );
251  IGBheader( FILE *f, bool read=false, bool quiet=false );
252  IGBheader( IGBheader *h ) { *this=*h; }
253  ~IGBheader();
254  int write();
255  int read( bool quiet=false );
256  void fileptr( gzFile f );
257  void fileptr( FILE* f );
258  void* fileptr(void){ return file; }
259  void close(void){if(gzipping)gzclose((gzFile)file);else fclose((FILE*)file);}
260  void swab( void *, int nd=-1 );
261  double from_raw( double a ){ return a*v_facteur+v_zero; }
262  double to_raw( double a ){ return (a-v_zero)/v_facteur; }
263  size_t slice_sz(){ return v_x*v_y*v_z; }
264  int go2slice(size_t s );
265  void comment( const char* );
266  inline char **comment(void){return v_comment;}
267  inline size_t data_size(void){return Data_Size[v_type];}
268  inline size_t x(void){ return v_x; }
269  inline size_t x( bool &set ){ set=bool_x; return v_x; }
270  inline void x( size_t a ){ v_x = a; bool_x = true;}
271  inline size_t y(void){ return v_y; }
272  inline size_t y( bool &set ){ set=bool_y; return v_y; }
273  inline void y( size_t a ){ v_y = a; bool_y = true;}
274  inline size_t z(void){ return v_z; }
275  inline size_t z( bool &set ){ set=bool_z; return v_z; }
276  inline void z( size_t a ){ v_z = a; bool_z = true;}
277  inline size_t t(void){ return v_t; }
278  inline size_t t( bool &set ){ set=bool_t; return v_t; }
279  inline void t( size_t a ){ v_t = a; bool_t = true;}
280  inline int type(void){ return v_type; }
281  inline int type( bool &set ){ set=bool_type; return v_type; }
282  inline void type( int a ){ v_type = a; bool_type = true; }
283  void type( char* );
284  inline int taille(void){ return v_taille; }
285  inline int taille( bool &set ){ set=bool_taille; return v_taille; }
286  inline void taille( int a ){ v_taille = a; bool_taille = true;}
287  inline int num(void){ return v_num; }
288  inline int num( bool &set ){ set=bool_num; return v_num; }
289  inline void num( int a ){ v_num = a; bool_num = true;}
290  inline int bin(void){ return v_bin; }
291  inline int bin( bool &set ){ set=bool_bin; return v_bin; }
292  inline void bin( int a ){ v_bin = a; bool_bin = true;}
293  inline int trame(void){ return v_trame; }
294  inline int trame( bool &set ){ set=bool_trame; return v_trame; }
295  inline void trame( int a ){ v_trame = a; bool_trame = true;}
296  const char* systemestr(void);
297  inline int systeme( void ){ return v_systeme; }
298  void systeme( const char* s );
299  inline unsigned int lut(void){ return v_lut; }
300  inline unsigned int lut( bool &set ){ set=bool_lut; return v_lut; }
301  inline void lut( unsigned int a ){ v_lut = a; bool_lut = true; }
302  inline unsigned int comp(void){ return v_comp; }
303  inline unsigned int comp( bool &set ){ set=bool_lut; return v_lut; }
304  inline void comp( unsigned int a ){ v_comp = a; bool_comp = true;}
305  inline float epais(void){ return v_epais; }
306  inline float epais( bool &set ){ set=bool_epais; return v_epais; }
307  inline void epais( float a ){ v_epais = a; bool_epais = true;}
308  inline float org_x(void){ return v_org_x; }
309  inline float org_x( bool &set ){ set=bool_org_x; return v_org_x; }
310  inline void org_x( float a ){ v_org_x = a; bool_org_x = true; }
311  inline float org_y(void){ return v_org_y; }
312  inline float org_y( bool &set ){ set=bool_org_y; return v_org_y; }
313  inline void org_y( float a ){ v_org_y = a; bool_org_y = true; }
314  inline float org_z(void){ return v_org_z; }
315  inline float org_z( bool &set ){ set=bool_org_z; return v_org_z; }
316  inline void org_z( float a ){ v_org_z = a; bool_org_z = true;}
317  inline float org_t(void){ return v_org_t; }
318  inline float org_t( bool &set ){ set=bool_org_t; return v_org_t; }
319  inline void org_t( float a ){ v_org_t = a; bool_org_t = true;}
320  inline void inc_x( float a ){ v_inc_x = a; bool_inc_x = true;}
321  inline float inc_x( bool &set ){ set=bool_inc_x; return v_inc_x; }
322  inline float inc_x(void){ return v_inc_x; }
323  inline void inc_y( float a ){ v_inc_y = a; bool_inc_y = true;}
324  inline float inc_y( bool &set ){ set=bool_inc_y; return v_inc_y; }
325  inline float inc_y(void){ return v_inc_y; }
326  inline void inc_z( float a ){ v_inc_z = a; bool_inc_z = true;}
327  inline float inc_z( bool &set ){ set=bool_inc_z; return v_inc_z; }
328  inline float inc_z(void){ return v_inc_z; }
329  inline void inc_t( float a ){ v_inc_t = a; bool_inc_t = true;}
330  inline float inc_t( bool &set ){ set=bool_inc_t; return v_inc_t; }
331  inline float inc_t(void){ return v_inc_t; }
332  inline void dim_x( float a ){ v_dim_x = a; bool_dim_x = true;}
333  inline float dim_x( bool &set ){ set=bool_dim_x; return v_dim_x; }
334  inline float dim_x(void){ return v_dim_x; }
335  inline void dim_y( float a ){ v_dim_y = a; bool_dim_y = true;}
336  inline float dim_y( bool &set ){ set=bool_dim_y; return v_dim_y; }
337  inline float dim_y(void){ return v_dim_y; }
338  inline void dim_z( float a ){ v_dim_z = a; bool_dim_y = true;}
339  inline float dim_z( bool &set ){ set=bool_dim_z; return v_dim_z; }
340  inline float dim_z(void){ return v_dim_z; }
341  inline void dim_t( float a ){ v_dim_t = a; bool_dim_t = true;}
342  inline float dim_t( bool &set ){ set=bool_dim_t; return v_dim_t; }
343  inline float dim_t(void){ return v_dim_t; }
344  inline void facteur( float a ){ v_facteur = a; bool_facteur = true; }
345  inline float facteur( bool &set ){ set=bool_facteur; return v_facteur; }
346  inline float facteur(void){ return v_facteur; }
347  inline void zero( float a ){ v_zero = a; bool_zero = true; }
348  inline float zero( bool &set ){ set=bool_zero; return v_zero; }
349  inline float zero(void){ return v_zero; }
350  inline void vect_z( float* a ){ v_vect_z = a; bool_vect_z = true; }
351  inline float* vect_z( bool &set ){ set=bool_vect_z; return v_vect_z; }
352  inline float* vect_z(void){ return v_vect_z; }
353  inline void unites_x( const char* a ){ strcpy(v_unites_x, a); bool_unites_x = true; }
354  inline char* unites_x( bool &set ){ set=bool_unites_x; return v_unites_x; }
355  inline char* unites_x(void){ return v_unites_x; }
356  inline void unites_y( const char* a ){ strcpy(v_unites_y, a); bool_unites_y = true;}
357  inline char* unites_y( bool &set ){ set=bool_unites_y; return v_unites_y; }
358  inline char* unites_y(void){ return v_unites_y; }
359  inline void unites_z( const char* a ){ strcpy(v_unites_z,a); bool_unites_z = true; }
360  inline char* unites_z( bool &set ){ set=bool_unites_z; return v_unites_z; }
361  inline char* unites_z(void){ return v_unites_z; }
362  inline void unites_t( const char* a ){ strcpy(v_unites_t, a); bool_unites_t = true; }
363  inline char* unites_t( bool &set ){ set=bool_unites_t; return v_unites_t; }
364  inline char* unites_t(void){ return v_unites_t; }
365  inline void unites( const char* a ){ strcpy(v_unites, a); bool_unites = true; }
366  inline char* unites( bool &set ){ set=bool_unites; return v_unites; }
367  inline char* unites(void){ return v_unites; }
368  inline void struct_desc( const char* a ){ strcpy(v_struct_desc, a); bool_struct_desc = true; }
369  inline char* struct_desc( bool &set ){ set=bool_struct_desc; return v_struct_desc; }
370  inline char* struct_desc(void){ return v_struct_desc; }
371  inline void aut_name( const char* a ){ strcpy(v_aut_name, a); bool_aut_name = true; }
372  inline char* aut_name( bool &set ){ set=bool_aut_name; return v_aut_name; }
373  inline char* aut_name(void){ return v_aut_name; }
374  inline void transparent( void* a ){ v_transparent=a; bool_transparent = true; }
375  inline void* transparent( bool &set ){ set=bool_transparent; return v_transparent; }
376  inline void* transparent(void){ return v_transparent; }
377  inline char* transparentstr(void){ return transstr; }
378  unsigned short num_components(){ return Num_Components[v_type]; }
379  int endian();
380  long tell();
381  template<class T> int read_data( T* dp, size_t numt=1, char *buf=NULL );
382  template<class T> void write_data( T* dp, size_t numt=1, char *buf=NULL );
383  template<class T> void to_bin( void *buf, T d );
384  template<class T> void to_bin( void *buf, T *d );
385  template<class T> T convert_buffer_datum( void *buf, int a );
386 };
387 
388 
395 template<class T>
396 void
397 IGBheader::write_data( T* dp, size_t numt, char *buf )
398 {
399  const size_t slicesize = data_size()*slice_sz()*numt;
400  bool alloc_buf = false;
401  if ( buf==NULL ) {
402  buf = new char[slicesize]();
403  alloc_buf = true;
404  }
405 
406  const size_t numprimitive = slice_sz()*num_components();
407  for ( size_t a=0; a<numprimitive; a++ )
408  to_bin<T>( buf+a*data_size(), dp[a] );
409 
410  if( gzipping )
411  gzwrite( (gzFile)file, buf, slicesize );
412  else
413  fwrite( buf, 1, slicesize, (FILE*)file );
414 
415  if ( alloc_buf ) delete[] buf;
416 }
417 
418 
429 template<class T>
430 int
431 IGBheader::read_data( T* dp, size_t numt, char *buf )
432 {
433  const size_t slicesize = data_size()*slice_sz()*numt;
434  bool alloc_buf = false;
435  if ( buf==NULL ) {
436  buf = new char[slicesize]();
437  alloc_buf = true;
438  }
439 
440  int numread;
441  if( gzipping )
442  numread = gzread( (gzFile)(file), buf, slicesize )/data_size();
443  else
444  numread = fread( buf, 1, slicesize, (FILE *)(file) )/data_size();
445 
446  if ( systeme() != endian() ) swab(buf, numread);
447 
448  size_t numprimitive = numread*num_components(); // adjust vector types
449 
450  #pragma omp parallel for schedule(guided)
451  for ( size_t a=0; a<numprimitive; a++ )
452  dp[a] = convert_buffer_datum<T>( buf, a );
453 
454  if ( alloc_buf ) delete[] buf;
455  return numread;
456 }
457 
458 
465 template<class T>
466 T IGBheader::convert_buffer_datum( void *buf, int a )
467 {
468  T datum;
469 
470  switch ( type() ) {
471  case IGB_BYTE:
472  datum = ((unsigned char *)buf)[a];
473  break;
474  case IGB_CHAR:
475  datum = ((signed char *)buf)[a];
476  break;
477  case IGB_SHORT:
478  datum = ((short *)buf)[a];
479  break;
480  case IGB_LONG:
481  datum = ((long *)buf)[a];
482  break;
483  case IGB_FLOAT:
484  case IGB_VEC3_f:
485  case IGB_VEC4_f:
486  case IGB_VEC9_f:
487  datum = ((float *)buf)[a];
488  break;
489  case IGB_DOUBLE:
490  case IGB_VEC3_d:
491  case IGB_VEC4_d:
492  case IGB_VEC9_d:
493  datum = ((double *)buf)[a];
494  break;
495  case IGB_INT:
496  datum = ((int *)buf)[a];
497  break;
498  case IGB_UINT:
499  datum = ((unsigned int *)buf)[a];
500  break;
501  case IGB_USHORT:
502  datum = ((unsigned short *)buf)[a];
503  break;
504  case IGB_HFLOAT:
505  datum = floatFromShort(((short_float *)buf)[a]);
506  break;
507  default:
508  memset(&datum,0,sizeof(datum));
509  }
510  return datum=from_raw(datum);
511 }
512 
519 #define CONVERT_TYPE(D,m,M,B) { if(datum > M) datum = M; else if(datum < m) datum = m; \
520  const D a0 = static_cast<D>(datum); (*reinterpret_cast<D*>(B))=a0;}
521 
527 template<class T>
528 void
529 IGBheader::to_bin( void *buf, T d )
530 {
531  double datum=to_raw(d);
532  switch ( type() ) {
533  case IGB_BYTE:
534  CONVERT_TYPE( unsigned char, 0, std::numeric_limits<unsigned char>::max(), buf )
535  break;
536  case IGB_CHAR:
538  break;
539  case IGB_SHORT:
541  break;
542  case IGB_LONG:
544  break;
545  case IGB_FLOAT:
546  CONVERT_TYPE( float, std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max(), buf )
547  break;
548  case IGB_VEC3_f:
549  case IGB_VEC4_f:
550  case IGB_VEC9_f:
551  assert(0);
552  break;
553  case IGB_DOUBLE:
554  CONVERT_TYPE( double, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), buf )
555  break;
556  case IGB_VEC3_d:
557  case IGB_VEC4_d:
558  case IGB_VEC9_d:
559  assert(0);
560  break;
561  case IGB_INT:
563  break;
564  case IGB_UINT:
565  CONVERT_TYPE( unsigned int, 0, std::numeric_limits<unsigned int>::max(), buf )
566  break;
567  case IGB_USHORT:
568  CONVERT_TYPE( unsigned short, 0, std::numeric_limits<unsigned short>::max(), buf )
569  break;
570  case IGB_HFLOAT:
571  float fdatum;
572  CONVERT_TYPE( float, HFLT_MIN, HFLT_MAX, &fdatum )
573  (*reinterpret_cast<short_float*>(buf)) = shortFromFloat(datum);
574  break;
575  default:
576  assert(0);
577  }
578 }
579 
585 template<class T>
586 void
587 IGBheader::to_bin( void *buf, T *d )
588 {
589  switch ( type() ) {
590  case IGB_VEC3_d:
591  case IGB_VEC4_d:
592  case IGB_VEC9_d:
593  for( size_t i=0; i<num_components(); i++ ){
594  double datum=to_raw(d[i]);
595  char *dp = (char *)buf + i*sizeof(double);
596  CONVERT_TYPE( double, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max(), dp )
597  }
598  break;
599  case IGB_VEC3_f:
600  case IGB_VEC4_f:
601  case IGB_VEC9_f:
602  for( size_t i=0; i<num_components(); i++ ){
603  double datum=to_raw(d[i]);
604  char *dp = (char *)buf + i*sizeof(float);
605  CONVERT_TYPE( float, std::numeric_limits<float>::lowest(), std::numeric_limits<float>::max(), dp )
606  }
607  break;
608  default:
609  to_bin<T>( buf, *d );
610  }
611 }
612 #endif //IGBheader_h
constexpr T min(T a, T b)
Definition: ion_type.h:33
unsigned int lut(bool &set)
Definition: IGBheader.h:300
int type(void)
Definition: IGBheader.h:280
void inc_x(float a)
Definition: IGBheader.h:320
size_t t(bool &set)
Definition: IGBheader.h:278
float inc_t(void)
Definition: IGBheader.h:331
double from_raw(double a)
Definition: IGBheader.h:261
int read_data(T *dp, size_t numt=1, char *buf=NULL)
Definition: IGBheader.h:431
#define N_SYSTEMES
Definition: IGBheader.h:56
#define IGB_SHORT
Definition: IGBheader.h:62
void epais(float a)
Definition: IGBheader.h:307
void dim_t(float a)
Definition: IGBheader.h:341
int BooleaN
Definition: IGBheader.h:140
float * vect_z(bool &set)
Definition: IGBheader.h:351
unsigned char byte
Definition: IGBheader.h:126
union rgba rgba
float org_x(bool &set)
Definition: IGBheader.h:309
#define C8
Definition: IGBheader.h:89
short Short
Definition: IGBheader.h:139
#define Byte
Definition: IGBheader.h:85
int trame(bool &set)
Definition: IGBheader.h:294
constexpr T max(T a, T b)
Definition: ion_type.h:31
#define IGB_UINT
Definition: IGBheader.h:73
char * String
Definition: IGBheader.h:129
size_t z(void)
Definition: IGBheader.h:274
char * unites_x(bool &set)
Definition: IGBheader.h:354
float inc_x(bool &set)
Definition: IGBheader.h:321
#define IGB_VEC4_f
Definition: IGBheader.h:77
void trame(int a)
Definition: IGBheader.h:295
char * RDir
Definition: IGBheader.h:142
const char * Header_Type[IGB_MAX_TYPE+1]
Definition: IGBheader.cc:249
size_t x(bool &set)
Definition: IGBheader.h:269
size_t slice_sz()
Definition: IGBheader.h:263
void to_bin(void *buf, T d)
Definition: IGBheader.h:529
uint16_t short_float
Definition: short_float.h:49
float facteur(bool &set)
Definition: IGBheader.h:345
const char * Header_Systeme[N_SYSTEMES]
Definition: IGBheader.cc:289
float * vect_z(void)
Definition: IGBheader.h:352
void t(size_t a)
Definition: IGBheader.h:279
void * transparent(void)
Definition: IGBheader.h:376
int Flag
Definition: IGBheader.h:141
char ** Text
Definition: IGBheader.h:148
size_t t(void)
Definition: IGBheader.h:277
void unites_x(const char *a)
Definition: IGBheader.h:353
char Header_Message[256]
Definition: IGBheader.cc:247
int read_IGB_data(T *dp, int numt, IGBheader *h, char *buf=NULL)
unsigned int lut(void)
Definition: IGBheader.h:299
#define IGB_INT
Definition: IGBheader.h:72
void dim_x(float a)
Definition: IGBheader.h:332
size_t data_size(void)
Definition: IGBheader.h:267
float org_y(bool &set)
Definition: IGBheader.h:312
size_t z(bool &set)
Definition: IGBheader.h:275
float zero(bool &set)
Definition: IGBheader.h:348
char * RFile
Definition: IGBheader.h:143
int Int
Definition: IGBheader.h:136
char * struct_desc(void)
Definition: IGBheader.h:370
char * aut_name(void)
Definition: IGBheader.h:373
float org_t(bool &set)
Definition: IGBheader.h:318
char * unites(bool &set)
Definition: IGBheader.h:366
void dim_y(float a)
Definition: IGBheader.h:335
double to_raw(double a)
Definition: IGBheader.h:262
void org_z(float a)
Definition: IGBheader.h:316
#define IGB_BYTE
Definition: IGBheader.h:60
void unites(const char *a)
Definition: IGBheader.h:365
void * fileptr(void)
Definition: IGBheader.h:258
IGBheader(IGBheader *h)
Definition: IGBheader.h:252
int bin(bool &set)
Definition: IGBheader.h:291
const unsigned long Header_Systeme_No[N_SYSTEMES]
Definition: IGBheader.cc:282
#define NALLOC
Definition: IGBheader.h:49
#define IGB_MAX_TYPE
Definition: IGBheader.h:83
int bin(void)
Definition: IGBheader.h:290
void type(int a)
Definition: IGBheader.h:282
float inc_x(void)
Definition: IGBheader.h:322
unsigned long l
Definition: IGBheader.h:162
void inc_y(float a)
Definition: IGBheader.h:323
char * unites_z(bool &set)
Definition: IGBheader.h:360
int taille(bool &set)
Definition: IGBheader.h:285
#define IGB_VEC9_f
Definition: IGBheader.h:80
int num(void)
Definition: IGBheader.h:287
const unsigned short Num_Components[IGB_MAX_TYPE+1]
Definition: IGBheader.cc:275
float inc_z(void)
Definition: IGBheader.h:328
float inc_t(bool &set)
Definition: IGBheader.h:330
float epais(void)
Definition: IGBheader.h:305
#define IGB_VEC4_d
Definition: IGBheader.h:78
char * RWDir
Definition: IGBheader.h:144
#define HFLT_MAX
Definition: IGBheader.h:171
#define HFLT_MIN
Definition: IGBheader.h:170
float dim_z(bool &set)
Definition: IGBheader.h:339
float inc_y(void)
Definition: IGBheader.h:325
unsigned int UInt
Definition: IGBheader.h:138
#define IGB_CHAR
Definition: IGBheader.h:61
void org_x(float a)
Definition: IGBheader.h:310
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp=2)
Definition: IGBheader.h:40
const size_t Data_Size[IGB_MAX_TYPE+1]
Definition: IGBheader.cc:264
unsigned short num_components()
Definition: IGBheader.h:378
float inc_y(bool &set)
Definition: IGBheader.h:324
float dim_z(void)
Definition: IGBheader.h:340
signed char Char
Definition: IGBheader.h:131
void * transparent(bool &set)
Definition: IGBheader.h:375
float org_t(void)
Definition: IGBheader.h:317
void unites_t(const char *a)
Definition: IGBheader.h:362
void close(void)
Definition: IGBheader.h:259
void x(size_t a)
Definition: IGBheader.h:270
void struct_desc(const char *a)
Definition: IGBheader.h:368
int type(bool &set)
Definition: IGBheader.h:281
void lut(unsigned int a)
Definition: IGBheader.h:301
float org_z(bool &set)
Definition: IGBheader.h:315
void comp(unsigned int a)
Definition: IGBheader.h:304
char * items
Definition: IGBheader.h:123
struct List List
int systeme(void)
Definition: IGBheader.h:297
char * unites_x(void)
Definition: IGBheader.h:355
void num(int a)
Definition: IGBheader.h:289
void Any
Definition: IGBheader.h:149
char * aut_name(bool &set)
Definition: IGBheader.h:372
size_t y(bool &set)
Definition: IGBheader.h:272
char * unites(void)
Definition: IGBheader.h:367
float inc_z(bool &set)
Definition: IGBheader.h:327
#define CONVERT_TYPE(D, m, M, B)
Definition: IGBheader.h:519
int taille(void)
Definition: IGBheader.h:284
void vect_z(float *a)
Definition: IGBheader.h:350
char * unites_t(bool &set)
Definition: IGBheader.h:363
char * RWFile
Definition: IGBheader.h:145
float dim_t(bool &set)
Definition: IGBheader.h:342
void org_t(float a)
Definition: IGBheader.h:319
char * unites_t(void)
Definition: IGBheader.h:364
void unites_y(const char *a)
Definition: IGBheader.h:356
char * WFile
Definition: IGBheader.h:147
T convert_buffer_datum(void *buf, int a)
Definition: IGBheader.h:466
#define IGB_DOUBLE
Definition: IGBheader.h:65
void taille(int a)
Definition: IGBheader.h:286
char * WDir
Definition: IGBheader.h:146
void unites_z(const char *a)
Definition: IGBheader.h:359
unsigned int comp(bool &set)
Definition: IGBheader.h:303
void aut_name(const char *a)
Definition: IGBheader.h:371
char * unites_y(bool &set)
Definition: IGBheader.h:357
int trame(void)
Definition: IGBheader.h:293
void y(size_t a)
Definition: IGBheader.h:273
float epais(bool &set)
Definition: IGBheader.h:306
void zero(float a)
Definition: IGBheader.h:347
float Float
Definition: IGBheader.h:135
void z(size_t a)
Definition: IGBheader.h:276
float dim_x(void)
Definition: IGBheader.h:334
float facteur(void)
Definition: IGBheader.h:346
void org_y(float a)
Definition: IGBheader.h:313
Double real
Definition: IGBheader.h:156
float dim_y(bool &set)
Definition: IGBheader.h:336
#define IGB_USHORT
Definition: IGBheader.h:74
unsigned int comp(void)
Definition: IGBheader.h:302
void facteur(float a)
Definition: IGBheader.h:344
void inc_t(float a)
Definition: IGBheader.h:329
void transparent(void *a)
Definition: IGBheader.h:374
size_t x(void)
Definition: IGBheader.h:268
char ** comment(void)
Definition: IGBheader.h:266
void inc_z(float a)
Definition: IGBheader.h:326
long nitems
Definition: IGBheader.h:122
double Double
Definition: IGBheader.h:133
void bin(int a)
Definition: IGBheader.h:292
void write_data(T *dp, size_t numt=1, char *buf=NULL)
Definition: IGBheader.h:397
#define IGB_VEC9_d
Definition: IGBheader.h:81
float dim_y(void)
Definition: IGBheader.h:337
#define IGB_FLOAT
Definition: IGBheader.h:64
#define IGB_LONG
Definition: IGBheader.h:63
bool Header_Quiet
Definition: IGBheader.cc:246
long Long
Definition: IGBheader.h:137
float org_z(void)
Definition: IGBheader.h:314
char * unites_z(void)
Definition: IGBheader.h:361
Float real
Definition: IGBheader.h:152
size_t y(void)
Definition: IGBheader.h:271
T IGB_convert_buffer_datum(IGBheader *, void *buf, int a)
#define IGB_VEC3_d
Definition: IGBheader.h:76
float dim_t(void)
Definition: IGBheader.h:343
#define IGB_HFLOAT
Definition: IGBheader.h:79
float zero(void)
Definition: IGBheader.h:349
float dim_x(bool &set)
Definition: IGBheader.h:333
float org_y(void)
Definition: IGBheader.h:311
char * transparentstr(void)
Definition: IGBheader.h:377
char * unites_y(void)
Definition: IGBheader.h:358
char * struct_desc(bool &set)
Definition: IGBheader.h:369
int num(bool &set)
Definition: IGBheader.h:288
float org_x(void)
Definition: IGBheader.h:308
#define IGB_VEC3_f
Definition: IGBheader.h:75
void dim_z(float a)
Definition: IGBheader.h:338