[vtkusers] create a vtkPolydata for a region (area)
cerina
cerine-baratelli at hotmail.fr
Sat Sep 8 15:11:34 EDT 2012
Hi all,
I tried , when i pick on the mesh, to create a polydata from all cells which
belongs to this region, but it didn't work, and the progam is blocked. Is
there any body who can correct my code:
vtkSmartPointer<vtkIdTypeArray> idss =
vtkSmartPointer<vtkIdTypeArray>::New();
for(int cc=0; cc<polydata->GetNumberOfCells();cc++)
{
if(PointsNode->GetValue(cc)==region)
{
idss->SetNumberOfComponents(1);
idss->InsertNextValue(cc);
}
}
vtkSmartPointer<vtkSelectionNode> selectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
selectionNode->SetFieldType(vtkSelectionNode::CELL);
selectionNode->SetContentType(vtkSelectionNode::INDICES);
selectionNode->SetSelectionList(idss);
vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
selection->AddNode(selectionNode);
vtkSmartPointer<vtkExtractSelection> extractSelection =
vtkSmartPointer<vtkExtractSelection>::New();
extractSelection->SetInput(0, this->reader->GetOutput());
extractSelection->SetInput(1, selection);
extractSelection->Update();
selected->ShallowCopy(extractSelection->GetOutput());
vtkSmartPointer<vtkPolyData> newdata =
vtkSmartPointer<vtkPolyData>::New();
newdata->SetPoints(selected->GetPoints());
newdata->SetPolys(selected->GetCells());
int numberOfSubdivisions = 1;
vtkSmartPointer< vtkLoopSubdivisionFilter > subdivisionFilter =
vtkSmartPointer<vtkLoopSubdivisionFilter>::New();
subdivisionFilter->SetNumberOfSubdivisions(numberOfSubdivisions);
subdivisionFilter->SetInput(newdata);
Best regards,
Cerina
--
View this message in context: http://vtk.1045678.n5.nabble.com/create-a-vtkPolydata-for-a-region-area-tp5715957.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list