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 
42 namespace CGNSRead
43 {
44 
45 //------------------------------------------------------------------------------
46 template <typename T>
47 inline int readNodeData(int cgioNum, double nodeId, std::vector<T>& data)
48 {
49  int n;
50  cgsize_t size = 1;
51  cgsize_t dimVals[12];
52  int ndim;
53 
54  if (cgio_get_dimensions(cgioNum, nodeId, &ndim, dimVals) != CG_OK)
55  {
56  cgio_error_exit("cgio_get_dimensions");
57  return 1;
58  }
59 
60  // allocate data
61  for (n = 0; n < ndim; n++)
62  {
63  size *= dimVals[n];
64  }
65  if (size <= 0)
66  {
67  return 1;
68  }
69  data.resize(size);
70 
71  // read data
72  if (cgio_read_all_data(cgioNum, nodeId, &data[0]) != CG_OK)
73  {
74  return 1;
75  }
76 
77  return 0;
78 }
79 
80 //------------------------------------------------------------------------------
81 // Specialize char array
82 template <>
83 int readNodeData<char>(int cgioNum, double nodeId, std::vector<char>& data);
84 
85 //------------------------------------------------------------------------------
86 int readNodeStringData(int cgioNum, double nodeId, std::string& data);
87 
88 //------------------------------------------------------------------------------
89 int getNodeChildrenId(int cgioNum, double fatherId, std::vector<double>& childrenIds);
90 
91 //------------------------------------------------------------------------------
92 int readBaseIds(int cgioNum, double rootId, std::vector<double>& baseIds);
93 
94 //------------------------------------------------------------------------------
95 int readBaseCoreInfo(int cgioNum, double baseId, CGNSRead::BaseInformation &baseInfo);
96 
97 //------------------------------------------------------------------------------
98 int readBaseIteration(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
99 
100 //------------------------------------------------------------------------------
101 int readZoneIterInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
102 
103 //------------------------------------------------------------------------------
104 int readSolInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
105 
106 //------------------------------------------------------------------------------
107 int readBaseFamily(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
108 
109 //------------------------------------------------------------------------------
110 int readBaseReferenceState(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
111 
112 //------------------------------------------------------------------------------
113 int readZoneInfo(int cgioNum, double nodeId, CGNSRead::BaseInformation& baseInfo);
114 
115 }
116 #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:47
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)