[vtkusers] "trade" vtkPoints between actors

Renil renilac at gmail.com
Tue Aug 6 16:44:34 EDT 2013


Hi Jeff Lee,

I tried following your suggestion, and used the example from the
wiki/examples, /deleteCells/.
I used a polydata to hold the points and changed the lines to spheres and
tried to remove the cells associated to one of the points.
It doesn't seem to be doing anything.

I'm probably not delete any cells, right?

*Code* below:

int main(int, char *[])
{
	vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
	points->InsertNextPoint(0,0,0);
	points->InsertNextPoint(1,0,0);
	points->InsertNextPoint(1,1,0);
	points->InsertNextPoint(0,1,0);
	
        // vtkSmartPointer<vtkCellArray> lines =
vtkSmartPointer<vtkCellArray>::New();
        // lines->InsertNextCell(points->GetNumberOfPoints());
	
	vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
	polydata->SetPoints(points);
	
	vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
	sphereSource->SetThetaResolution(20);
	sphereSource->SetPhiResolution(20);
	sphereSource->SetRadius(0.5);
	
	vtkSmartPointer<vtkGlyph3D> atomGlyphs =
vtkSmartPointer<vtkGlyph3D>::New();
	atomGlyphs ->SetInput(polydata);
	atomGlyphs ->SetSource(sphereSource->GetOutput());
	
	// Create the mapper & actor for the atoms
	vtkSmartPointer<vtkPolyDataMapper> atomMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
	atomMapper->SetInput(atomGlyphs->GetOutput());
	
	vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New();
	sphereActor->SetMapper(atomMapper);
	sphereActor->GetProperty()->SetColor(0.7, 0.7, 0.7);

	// Tell the polydata to build 'upward' links from points to cells.
	polydata->BuildLinks();
	vtkSmartPointer<vtkIdList> cellIds = vtkSmartPointer<vtkIdList>::New();
	polydata->GetPointCells(1, cellIds);
	
        // Mark a cell as deleted.
	for (int i = 0; cellIds->GetNumberOfIds();i++){
		polydata->DeleteCell(i);
	}
	
	// Remove the marked cell.
	polydata->RemoveDeletedCells();
	
	vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
	renderer->AddActor(sphereActor);
	vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
	renderWindow->AddRenderer(renderer);
	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
	renderWindowInteractor->SetRenderWindow(renderWindow);
	renderWindow->Render();
	renderWindowInteractor->Start();
	
	return EXIT_SUCCESS;
}




--
View this message in context: http://vtk.1045678.n5.nabble.com/trade-vtkPoints-between-actors-tp5722498p5722526.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list