problem in cutting a png image in vtk

In my code i commit a mistake in mapping , see the last four lines there mapping line is given ..
this is that line 
///  callback->mapper=pngMapper;////// this  that line 
  boxWidget->AddObserver( vtkCommand::InteractionEvent, callback );
  boxWidget->On();
  interactor->Start();

 

above mapping is given for plane because it is poly data so poly data mapper is used and source is 3d image of poly data iamge so they called a common mapper,so they called common mapper of poly data mapper is called .

but in my code i have differentmappers are used so how to create a mapper for png and how o achieve this 

please guys try to help me for this please ,

this is my error: cannot convert 'vtkSmartPointer<vtkDataSetMapper>' to 'vtkPolyDataMapper*' in assignment

 i have attached a code below ,.....

#include <vtkSmartPointer.h>
// For the rendering pipeline setup:
#include <vtkConeSource.h>

 
#include <vtkPNGReader.h>
#include <vtkDataSetMapper.h>
#include <vtkClipDataSet.h>
#include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
// For boxthreed:
//#include <boxthreed.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
#include <vtkPlane.h>
#include <vtkClipPolyData.h>
#include "boxthreed.h"
#include "planerep.h"

 
class vtkMyCallback : public vtkCommand
{public:  static
    vtkMyCallback *New()
    {    return new vtkMyCallback;
    }  virtual void Execute( vtkObject *caller, unsigned long, void* )
    {
        vtkSmartPointer<vtkTransform> t =
                vtkSmartPointer<vtkTransform>::New();
        boxthreed *widget = reinterpret_cast<boxthreed*>(caller);
        widget->GetTransform( t );
      //  widget->GetPlanes(this->Plane);
        widget->getmapper(this->mapper);

 
   //  widget->GetProp3D()->SetUserTransform( t );

 
    }
  vtkMyCallback():Plane(0),Actor(0){}
    vtkPlane *Plane;
    vtkActor *Actor;
    vtkPolyDataMapper *mapper;
//  vtkDataSetMapper *mapper;
    };

 
int main( int vtkNotUsed( argc ), char* vtkNotUsed( argv )[] )
{
//  vtkSmartPointer<vtkConeSource> cone =
//    vtkSmartPointer<vtkConeSource>::New();

 
    vtkSmartPointer<vtkPNGReader> pngreader =
      vtkSmartPointer<vtkPNGReader>::New();
      pngreader->SetFileName("/home/sara/Desktop/sankar/vtk/png  /imagee.png");

 

 

 
  vtkSmartPointer<vtkPlane> plane =
    vtkSmartPointer<vtkPlane>::New();

 
  vtkSmartPointer<vtkClipDataSet> clipper =
    vtkSmartPointer<vtkClipDataSet>::New();
//  clipper->SetClipFunction(plane);
  clipper->InsideOutOn();
    clipper->SetInputConnection(pngreader->GetOutputPort());

 
  vtkSmartPointer<vtkDataSetMapper> pngMapper =
    vtkSmartPointer<vtkDataSetMapper>::New();
  pngMapper->SetInputConnection( pngreader->GetOutputPort() );
//  pngMapper->SetInputConnection(clipper->GetOutputPort());

 
//  pngMapper->AddClippingPlane(plane);

 

 

 
  vtkSmartPointer<vtkActor> pngActor =
    vtkSmartPointer<vtkActor>::New();
  pngActor->SetMapper( pngMapper );

 

 
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor( pngActor );
  renderer->SetBackground( 0.1, 0.2, 0.4 );

 
  vtkSmartPointer<vtkRenderWindow> window =
    vtkSmartPointer<vtkRenderWindow>::New();
  window->AddRenderer( renderer );
  window->SetSize( 300, 300 );

 
  vtkSmartPointer<vtkRenderWindowInteractor> interactor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  interactor->SetRenderWindow( window );

 
  vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
    vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
  interactor->SetInteractorStyle( style );

 
  vtkSmartPointer<boxthreed> boxWidget =
          vtkSmartPointer<boxthreed>::New();
  boxWidget->SetInteractor( interactor );
  boxWidget->SetProp3D( pngActor );

 
  boxWidget->SetPlaceFactor( 1.25 );
  // Make the box 1.25x larger than the actor
  boxWidget->PlaceWidget();
  vtkSmartPointer<vtkMyCallback> callback =
          vtkSmartPointer<vtkMyCallback>::New();
  callback->Plane=plane;
  callback->Actor=pngActor;
  callback->mapper=pngMapper;
  boxWidget->AddObserver( vtkCommand::InteractionEvent, callback );
  boxWidget->On();
  interactor->Start();

 
  return EXIT_SUCCESS;
}

 

Started by sankar at September 20, 2018 - 9:42 PM