[vtkusers] create a vtkPolydata from a list of PointId

cerina cerine-baratelli at hotmail.fr
Sun Sep 9 11:50:50 EDT 2012


Hi all,
when i pick on the mesh, i retrieve a list of pointId that are not ordered (
eg: 1,5, 17...).So i want to create a polydata from those points.I try to do
that, 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->GetNumberOfPoints();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());

I want then to change the points of this newdata with a list of vtkPoints
that i stored:
 while(i<nbrcor)//nbcor : is the number of points that i stored in the
vector &lt;b>sommet*
 {
	newpoints->InsertNextPoint(sommet[si][0],sommet[si][1],sommet[si][2]);
	i++;
	  }
newdata->SetPoints(newpoints);

but nothing is ok, the program is blocked.
Also I tried to insert my newpoints like this:
for(int n=0;n<nbrcor;n++)
			{
				double* somm=sommet[n];
			newdata->GetPoints()->InsertNextPoint(somm); 
            newdata->GetVerts()->InsertNextCell(n+1); 
           
newdata->GetVerts()->InsertCellPoint(newdata->GetPoints()->GetNumberOfPoints()-1); 
            newdata->Update();
			}
			polydata->GetPoints()->Modified();
			polydata->Modified();
			polydata->Update();
But, also, nothing is going on. any help please.
		 

Best regards,
Cerina



--
View this message in context: http://vtk.1045678.n5.nabble.com/create-a-vtkPolydata-from-a-list-of-PointId-tp5715958.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list