[vtkusers] Please, how to get vtkPolydata with a texture applied from vtkActor?

alican alican1812 at hotmail.com
Sat Jan 20 13:08:21 EST 2018


I have an actor that is set with polydata clipped from another polydata. 
Afterward I am adding a texture to this actor. All works as expected.

Now, in another place of my program I want to get a polydata, including
texture, from this actor
and append it to another polydata using vtkAppendPolyData filter. How can I
do this? 
If I am using actor->getMapper()-> getInput() there is no texture.
Thanks.
AC
	

        vtkSmartPointer<vtkSphere> sphereSource =
vtkSmartPointer<vtkSphere>::New();
	sphereSource->SetRadius(radius);
	sphereSource->SetCenter(closestPoint);
	sphereSource->Modified();

	vtkSmartPointer<vtkClipPolyData> clipper =
vtkSmartPointer<vtkClipPolyData>::New();
	clipper->SetInputData(somePolyData);
	clipper->SetValue(0);
	clipper->InsideOutOn();
	clipper->SetClipFunction(sphereSource);
	clipper->Modified();
	clipper->Update();

	vtkSmartPointer<vtkTextureMapToPlane> tmapper =
vtkSmartPointer<vtkTextureMapToPlane>::New();
	tmapper->SetInputConnection(clipper->GetOutputPort());

	vtkSmartPointer<vtkPNGReader> pngReader =
vtkSmartPointer<vtkPNGReader>::New();
	pngReader->SetFileName(texture.toUtf8());
	pngReader->Update();
	vtkSmartPointer<vtkOpenGLTexture> atext =
vtkSmartPointer<vtkOpenGLTexture>::New();
	atext->SetInputConnection(pngReader->GetOutputPort());
	atext->InterpolateOff();
	atext->SetRepeat(false);
	atext->SetEdgeClamp(false);
	atext->Update();

	vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
	mapper->SetInputData(clipper->GetOutput());
	mapper->Update();
	mapper->SetInputConnection(tmapper->GetOutputPort());
	vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
        actor->SetMapper(mapper);
	actor->SetTexture(atext);
	actor->Modified();

	myView->addActor(actor);
	myView->update();





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list