[Paraview] Applying Texture with Plugin
Brian C. Panneton (CONTR)
brian.c.panneton.ctr at us.army.mil
Mon Jul 25 11:08:21 EDT 2011
I am trying to make a simple plugin to automatically apply a texture to
a plane source. I am looking at this code for reference:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TextureMapPlane
So far I have figured out that I need to use a custom representation,
but I have not figure out where to place the code. By using
vtkMySpecialRepresentation as a base, I added a RequestData() which does
the following:
[code]
if(inputVector[0]->GetNumberOfInformationObjects()==1)
{
vtkDataObject* inputData =
vtkDataObject::GetData(inputVector[0], 0);
vtkSmartPointer<vtkPlaneSource> ps =
vtkPlaneSource::SafeDownCast(inputData);
if(ps != NULL)
{
ps->SetCenter(0.0, 0.0, 0.0);
ps->SetNormal(0.0, 0.0, 1.0);
vtkSmartPointer<vtkTextureMapToPlane> tp =
vtkSmartPointer<vtkTextureMapToPlane>::New();
tp->SetInput(ps->GetOutput());
this->Mapper->SetInputConnection(tp->GetOutputPort());
}
}
return this->Superclass::RequestData(info, inputVector, outVector);
[/code]
I then added AddToView() with the following:
[code]
vtkPVRenderView* rview = vtkPVRenderView::SafeDownCast(view);
if (rview)
{
imgReader->SetFileName("/share/panneton/Desktop/blue.png");
vtkSmartPointer<vtkTexture> texture =
vtkSmartPointer<vtkTexture>::New();
texture->SetInput(imgReader->GetOutput());
this->Actor->SetMapper(this->Mapper);
this->Actor->SetTexture(texture);
rview->GetRenderer()->AddActor(this->Actor);
rview->GetRenderer()->SetBackground(.1, .2, .3);
}
return this->Superclass::AddToView(view);
[/code]
This however does not seem to work. Am I going about this wrong?
Thanks,
Brian Panneton
More information about the ParaView
mailing list