ParaView
cgio_helpers.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: cgio_helpers.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14  =========================================================================*/
15 // Copyright 2013-2014 Mickael Philit.
16 
17 // .NAME cgio_helpers -- function used by vtkCGNSReader
18 // and vtkCGNSReaderInternal
19 // .SECTION Description
20 // provide function to simplify "CGNS" reading through cgio
21 //
22 // .SECTION Caveats
23 //
24 //
25 // .SECTION Thanks
26 // Thanks to .
27 
28 #ifndef cgio_helpers_h
29 #define cgio_helpers_h
30 
31 #include <map>
32 #include <string.h> // for inline strcmp
33 #include <string>
34 #include <vector>
35 
36 #include <cgns_io.h> // Low level IO for fast parsing
37 #include <cgnslib.h> // DataType, and other definition
38 
39 #include "vtkCGNSReaderInternal.h"
40 
41 namespace CGNSRead
42 {
43 
44 //------------------------------------------------------------------------------
45 template <typename T>
46 inline int readNodeData(int cgioNum, double nodeId, std::vector<T>& data)
47 {
48  int n;
49  cgsize_t size = 1;
50  cgsize_t dimVals[12];
51  int ndim;
52 
53  if (cgio_get_dimensions(cgioNum, nodeId, &ndim, dimVals) != CG_OK)
54  {
55  cgio_error_exit("cgio_get_dimensions");
56  return 1;
57  }
58 
59  // allocate data
60  for (n = 0; n < ndim; n++)
61  {
62  size *= dimVals[n];
63  }
64  if (size <= 0)
65  {
66  return 1;
67  }
68  data.resize(size);
69 
70  // read data
71  if (cgio_read_all_data(cgioNum, nodeId, &data[0]) != CG_OK)
72  {
73  return 1;
74  }
75 
76  return 0;
77 }
78 
79 //------------------------------------------------------------------------------
80 // Specialize char array
81 template <>
82 int readNodeData<char>(int cgioNum, double nodeId, std::vector<char>& data);
83 
84 //------------------------------------------------------------------------------
85 int readNodeStringData(int cgioNum, double nodeId, std::string& data);
86 
87 //------------------------------------------------------------------------------
88 int getNodeChildrenId(int cgioNum, double fatherId, std::vector<double>& childrenIds);
89 
90 //------------------------------------------------------------------------------
91 int readBaseIds(int cgioNum, double rootId, std::vector<double>& baseIds);
92 
93 //------------------------------------------------------------------------------
94 int readBaseCoreInfo(int cgioNum, double baseId, CGNSRead::BaseInformation& baseInfo);
95 
96 //------------------------------------------------------------------------------
97 int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
98 
99 //------------------------------------------------------------------------------
100 int readZoneIterInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
101 
102 //------------------------------------------------------------------------------
103 int readSolInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
104 
105 //------------------------------------------------------------------------------
106 int readBaseFamily(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
107 
108 //------------------------------------------------------------------------------
109 int readBaseReferenceState(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
110 
111 //------------------------------------------------------------------------------
112 int readZoneInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
113 }
114 #endif // cgio_helpers_h
int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int readBaseFamily(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int getNodeChildrenId(int cgioNum, double fatherId, std::vector< double > &childrenIds)
int readBaseCoreInfo(int cgioNum, double baseId, CGNSRead::BaseInformation &baseInfo)
int readBaseReferenceState(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int readNodeData< char >(int cgioNum, double nodeId, std::vector< char > &data)
int readBaseIds(int cgioNum, double rootId, std::vector< double > &baseIds)
int readZoneIterInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int readNodeData(int cgioNum, double nodeId, std::vector< T > &data)
Definition: cgio_helpers.h:46
int readZoneInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int readSolInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation &baseInfo)
int readNodeStringData(int cgioNum, double nodeId, std::string &data)