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

Method CreateStructuredGridOutput

IO/EnSight/core/EnSightDataSet.cxx:2280–2345  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2278
2279//------------------------------------------------------------------------------
2280void EnSightDataSet::CreateStructuredGridOutput(const GridOptions& opts, vtkStructuredGrid* output)
2281{
2282 int dimensions[3];
2283 int numPts, numCells;
2284 this->ReadDimensions(opts.HasRange, dimensions, numPts, numCells);
2285 output->SetDimensions(dimensions);
2286
2287 vtkNew<vtkPoints> points;
2288 points->SetNumberOfPoints(numPts);
2289
2290 auto readComponent = [&](vtkIdType count)
2291 {
2292 vtkNew<vtkFloatArray> buffer;
2293 buffer->SetNumberOfTuples(count);
2294 this->GeometryFile.ReadArray(buffer->WritePointer(0, count), count);
2295 return buffer;
2296 };
2297
2298 vtkNew<vtkFloatArray> ptsArray;
2299 ptsArray->SetNumberOfComponents(3);
2300 ptsArray->SetNumberOfTuples(numPts);
2301
2302 for (int i = 0; i < 3; i++)
2303 {
2304 auto buffer = readComponent(numPts);
2305 ptsArray->CopyComponent(i, buffer, 0);
2306 }
2307 points->SetData(ptsArray);
2308 output->SetPoints(points);
2309
2310 if (opts.IBlanked)
2311 {
2312 std::vector<int> data(numPts, 0);
2313 this->ReadOptionalValues(numPts, data.data());
2314 for (int i = 0; i < numPts; i++)
2315 {
2316 if (!data[i])
2317 {
2318 output->BlankPoint(i);
2319 }
2320 }
2321 }
2322
2323 if (opts.WithGhost)
2324 {
2325 this->ProcessGhostCells(numCells, output);
2326 }
2327
2328 // it's not clear in the user manual if it is required for the node id section to be preceded by
2329 // 'node_ids'. The old reader makes this assumption
2330 auto result = this->GeometryFile.ReadNextLine();
2331 if (result.second.find("node_ids") != std::string::npos)
2332 {
2333 this->ProcessNodeIds(numPts, output);
2334 result = this->GeometryFile.ReadNextLine();
2335 }
2336
2337 if (result.second.find("element_ids") != std::string::npos)

Callers 1

ReadGeometryMethod · 0.95

Calls 15

ReadDimensionsMethod · 0.95
ReadOptionalValuesMethod · 0.95
ProcessGhostCellsMethod · 0.95
ProcessNodeIdsMethod · 0.95
ProcessElementIdsMethod · 0.95
ReadNextLineMethod · 0.80
GoBackOneLineMethod · 0.80
SetDimensionsMethod · 0.45
SetNumberOfPointsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
ReadArrayMethod · 0.45
WritePointerMethod · 0.45

Tested by

no test coverage detected