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

Method CopyCells

Common/DataModel/vtkPolyData.cxx:184–254  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

182
183//------------------------------------------------------------------------------
184void vtkPolyData::CopyCells(vtkPolyData* pd, vtkIdList* idList, vtkIncrementalPointLocator* locator)
185{
186 vtkIdType cellId, ptId, newId, newCellId, locatorPtId;
187 vtkIdType numPts, numCellPts, i;
188 vtkPoints* newPoints;
189 vtkIdList* pointMap = vtkIdList::New(); // maps old pt ids into new
190 vtkIdList *cellPts, *newCellPts = vtkIdList::New();
191 vtkGenericCell* cell = vtkGenericCell::New();
192 double x[3];
193 vtkPointData* outPD = this->GetPointData();
194 vtkCellData* outCD = this->GetCellData();
195
196 numPts = pd->GetNumberOfPoints();
197
198 if (this->GetPoints() == nullptr)
199 {
200 this->Points = vtkPoints::New();
201 }
202
203 newPoints = this->GetPoints();
204
205 pointMap->SetNumberOfIds(numPts);
206 for (i = 0; i < numPts; i++)
207 {
208 pointMap->SetId(i, -1);
209 }
210
211 // Filter the cells
212 for (cellId = 0; cellId < idList->GetNumberOfIds(); cellId++)
213 {
214 pd->GetCell(idList->GetId(cellId), cell);
215 cellPts = cell->GetPointIds();
216 numCellPts = cell->GetNumberOfPoints();
217
218 for (i = 0; i < numCellPts; i++)
219 {
220 ptId = cellPts->GetId(i);
221 if ((newId = pointMap->GetId(ptId)) < 0)
222 {
223 pd->GetPoint(ptId, x);
224 if (locator != nullptr)
225 {
226 if ((locatorPtId = locator->IsInsertedPoint(x)) == -1)
227 {
228 newId = newPoints->InsertNextPoint(x);
229 locator->InsertNextPoint(x);
230 pointMap->SetId(ptId, newId);
231 outPD->CopyData(pd->GetPointData(), ptId, newId);
232 }
233 else
234 {
235 newId = locatorPtId;
236 }
237 }
238 else
239 {
240 newId = newPoints->InsertNextPoint(x);
241 pointMap->SetId(ptId, newId);

Callers

nothing calls this directly

Calls 15

InsertNextCellMethod · 0.95
SetNumberOfIdsMethod · 0.80
InsertIdMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
GetPointDataMethod · 0.45
GetCellDataMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointsMethod · 0.45
SetIdMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetCellMethod · 0.45

Tested by

no test coverage detected