Hey, I have gotten one version partially working. Problem is, it only copies the geometry on the first click - if I click again no new geometry copied is visible. Number of points and cells does grow in the poly data to be copied to. Any help would be greatly appreciated!
if (this->selectionModelPolyData->GetPoints() == 0) {
vtkNew<vtkPoints> initialPoints;
this->selectionModelPolyData->SetPoints(initialPoints);
}
if (this->selectionModelPolyData->GetNumberOfCells() == 0) {
vtkNew<vtkCellArray> initialArray;
this->selectionModelPolyData->SetPolys(initialArray);
}
// Copy new cells from clipped area
this->selectionModelPolyData->BuildLinks();
vtkSmartPointer<vtkCellIterator> iter = clipped->NewCellIterator();
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextCell())
{
vtkNew<vtkGenericCell> cell;
iter->GetCell(cell);
vtkSmartPointer<vtkPoints> iter_points = iter->GetPoints();
vtkNew<vtkTriangle> tri;
vtkNew<vtkIdList> temp_pts;
// Set new IDs for triangle
for (vtkIdType i = 0; i < iter_points->GetNumberOfPoints(); i++) {
double pos[3];
iter_points->GetPoint(i, pos);
vtkIdType id = this->selectionModelPolyData->GetPoints()->InsertNextPoint(pos);
// Insert point ids for cell
for (vtkIdType y = 0; y < iter_points->GetNumberOfPoints(); y++) {
tri->GetPointIds()->SetId(y, id);
}
temp_pts->InsertNextId(id);
}
this->selectionModelPolyData->InsertNextCell(VTKCellType::VTK_TRIANGLE, temp_pts);
}
this->selectionModelPolyData->Modified();