MCPcopy Create free account
hub / github.com/Kitware/VTK / GetCoords

Function GetCoords

IO/NetCDF/vtkNetCDFCFWriter.cxx:138–178  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

136
137//------------------------------------------------------------------------------
138void GetCoords(vtkImageData* id, int attributeType, std::array<std::vector<double>, 3>* coord,
139 std::array<std::vector<std::array<double, 2>>, 3>* bounds)
140{
141 double* origin = id->GetOrigin();
142 int* dims = id->GetDimensions();
143 double* spacing = id->GetSpacing();
144 if (attributeType == vtkDataObject::POINT)
145 {
146 // no bounds for point grid
147 for (int axis = 0; axis < 3; ++axis)
148 {
149 (*coord)[axis].resize(dims[axis]);
150 for (int i = 0; i < dims[axis]; ++i)
151 {
152 (*coord)[axis][i] = origin[axis] + spacing[axis] * i;
153 }
154 }
155 }
156 else if (attributeType == vtkDataObject::CELL)
157 {
158 for (int axis = 0; axis < 3; ++axis)
159 {
160 (*coord)[axis].resize(dims[axis] - 1);
161 (*bounds)[axis].resize(dims[axis] - 1);
162 // number of cells are number of points - 1.
163 for (int i = 0; i < dims[axis] - 1; ++i)
164 {
165 (*coord)[axis][i] = origin[axis] + spacing[axis] * (i + 0.5);
166
167 (*bounds)[axis][i][0] = origin[axis] + spacing[axis] * i;
168 (*bounds)[axis][i][1] = origin[axis] + spacing[axis] * (i + 1);
169 }
170 }
171 }
172 else
173 {
174 std::ostringstream ostr;
175 ostr << "Invalid attribute type: " << attributeType;
176 throw std::runtime_error(ostr.str());
177 }
178}
179
180struct BlankToFillValueWorker
181{

Callers 1

WriteDataMethod · 0.85

Calls 5

GetOriginMethod · 0.45
GetDimensionsMethod · 0.45
GetSpacingMethod · 0.45
resizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected