[Paraview] Applying Texture with Plugin

Brian C. Panneton (CONTR) brian.c.panneton.ctr at us.army.mil
Tue Jul 26 11:01:36 EDT 2011


I am able to set the color of the plane without an issue by using:

[code]
this->Actor->SetMapper(this->Mapper);
this->Property->SetColor(.8, .4, .2);
this->Actor->SetProperty(this->Property);
rview->GetRenderer()->AddActor(this->Actor);
rview->GetRenderer()->SetBackground(.1, .2, .3);
[/code]

So somehow, the texture is not loading properly. Does anyone know what 
is wrong here?

Thanks,
Brian

Brian C. Panneton (CONTR) wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: 
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview



More information about the ParaView mailing list