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

Function ReadPolyDataPiece

IO/HDF/vtkHDFReader.cxx:119–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117//----------------------------------------------------------------------------
118template <typename T, typename CacheT>
119bool ReadPolyDataPiece(T* impl, std::shared_ptr<CacheT> cache, vtkIdType pointOffset,
120 vtkIdType numberOfPoints, std::vector<vtkIdType>& cellOffsets,
121 std::vector<vtkIdType>& numberOfCells, std::vector<vtkIdType>& connectivityOffsets,
122 std::vector<vtkIdType>& numberOfConnectivityIds, int filePiece, vtkPolyData* pieceData,
123 const std::string& compositePath)
124{
125 auto readFromFileOrCache = [&](int tag, std::string name, vtkIdType offset, vtkIdType size)
126 {
127 std::string modifier = "_" + vtk::to_string(filePiece) + "_" + compositePath;
128 return ReadFromFileOrCache(impl, cache, tag, name, modifier, offset, size);
129 };
130 vtkSmartPointer<vtkDataArray> pointArray;
131 if ((pointArray = readFromFileOrCache(vtkHDFUtilities::GEOMETRY_ATTRIBUTE_TAG, "Points",
132 pointOffset, numberOfPoints)) == nullptr)
133 {
134 vtkErrorWithObjectMacro(nullptr, "Cannot read the Points array");
135 return false;
136 }
137
138 vtkNew<vtkPoints> points;
139 pieceData->SetPoints(points);
140
141 /* If cache is up to date with the geometry, avoid geometry load
142 * which would cause the MTime of the geometry to update.
143 * SetData would prevent us from using the MeshMTime correctly.
144 */
145 if (cache != nullptr && !cache->HasBeenUpdated && compositePath.empty())
146 {
147 return true;
148 }
149 points->SetData(pointArray);
150
151 std::vector<vtkSmartPointer<vtkCellArray>> cArrays;
152 for (std::size_t iTopo = 0; iTopo < vtkHDFUtilities::NUM_POLY_DATA_TOPOS; ++iTopo)
153 {
154 const auto& name = vtkHDFUtilities::POLY_DATA_TOPOS[iTopo];
155 vtkSmartPointer<vtkDataArray> offsetsArray;
156 if ((offsetsArray = readFromFileOrCache(vtkHDFUtilities::GEOMETRY_ATTRIBUTE_TAG,
157 (name + "/Offsets"), cellOffsets[iTopo], numberOfCells[iTopo] + 1)) == nullptr)
158 {
159 vtkErrorWithObjectMacro(nullptr, "Cannot read the Offsets array for " + name);
160 return false;
161 }
162 vtkSmartPointer<vtkDataArray> connectivityArray;
163 if ((connectivityArray = readFromFileOrCache(vtkHDFUtilities::GEOMETRY_ATTRIBUTE_TAG,
164 (name + "/Connectivity"), connectivityOffsets[iTopo], numberOfConnectivityIds[iTopo])) ==
165 nullptr)
166 {
167 vtkErrorWithObjectMacro(nullptr, "Cannot read the Connectivity array for " + name);
168 return false;
169 }
170 vtkNew<vtkCellArray> cellArray;
171 cellArray->SetData(offsetsArray, connectivityArray);
172 cArrays.emplace_back(cellArray);
173 }
174 pieceData->SetVerts(cArrays[0]);
175 pieceData->SetLines(cArrays[1]);
176 pieceData->SetPolys(cArrays[2]);

Callers 1

ReadMethod · 0.85

Calls 10

ReadFromFileOrCacheFunction · 0.85
SetVertsMethod · 0.80
SetLinesMethod · 0.80
SetPolysMethod · 0.80
SetStripsMethod · 0.80
to_stringFunction · 0.50
SetPointsMethod · 0.45
emptyMethod · 0.45
SetDataMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected