Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to cut a png image in vtk by Qt..!
Forum Updated to NodeBB v4.3 + New Features

how to cut a png image in vtk by Qt..!

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sankarapandiyanS Offline
    sankarapandiyanS Offline
    sankarapandiyan
    wrote on last edited by
    #1

    i have done a code but for the png the mapping is some what different ,
    see the last four lines of the code

    callback->Plane=plane;
    callback->Actor=pngActor;
    ///////callback->mapper=pngMapper;//////// this is the line which i have commit some mistake ..but ,i dontknow how to resolve this

    i have a error like this
    : error: cannot convert 'vtkSmartPointer<vtkDataSetMapper>' to 'vtkPolyDataMapper*' in assignment

    and this is my code,

           #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;
    }

    jsulmJ 1 Reply Last reply
    0
    • sankarapandiyanS sankarapandiyan

      i have done a code but for the png the mapping is some what different ,
      see the last four lines of the code

      callback->Plane=plane;
      callback->Actor=pngActor;
      ///////callback->mapper=pngMapper;//////// this is the line which i have commit some mistake ..but ,i dontknow how to resolve this

      i have a error like this
      : error: cannot convert 'vtkSmartPointer<vtkDataSetMapper>' to 'vtkPolyDataMapper*' in assignment

      and this is my code,

             #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;
      }

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sankarapandiyan said in how to cut a png image in vtk by Qt..!:

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

      It's completely unrelated to Qt. You're assigning a variable of wrong type.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by sankarapandiyan
        #3

        @jsulm i have build a vtk here in qt

        jsulmJ 1 Reply Last reply
        0
        • sankarapandiyanS sankarapandiyan

          @jsulm i have build a vtk here in qt

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sankarapandiyan So what?

          callback->Plane=plane;
          callback->Actor=pngActor;
          ///////callback->mapper=pngMapper;
          

          This isn't related to Qt. This is code using VTK not Qt.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • sankarapandiyanS Offline
            sankarapandiyanS Offline
            sankarapandiyan
            wrote on last edited by sankarapandiyan
            #5

            @jsulm yes sure this is the vtk code ... but implemented in qt only .. thats why i post a ques here ..

            jsulmJ 1 Reply Last reply
            0
            • sankarapandiyanS sankarapandiyan

              @jsulm yes sure this is the vtk code ... but implemented in qt only .. thats why i post a ques here ..

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @sankarapandiyan Take a look at the error message and fix your code.
              "but implemented in qt only" - Qt is not a programming language, you're implementing it in C++.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              sankarapandiyanS 2 Replies Last reply
              0
              • jsulmJ jsulm

                @sankarapandiyan Take a look at the error message and fix your code.
                "but implemented in qt only" - Qt is not a programming language, you're implementing it in C++.

                sankarapandiyanS Offline
                sankarapandiyanS Offline
                sankarapandiyan
                wrote on last edited by
                #7

                @jsulm yes sure ... but for png we have using different mappers and for poly data image we are using different mappers that is the problem i dont know how to create mappers of the different one with seperately/...

                jsulmJ 1 Reply Last reply
                0
                • sankarapandiyanS sankarapandiyan

                  @jsulm yes sure ... but for png we have using different mappers and for poly data image we are using different mappers that is the problem i dont know how to create mappers of the different one with seperately/...

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @sankarapandiyan I guess you need to get the RAW pointer (vtkDataSetMapper*) from vtkSmartPointer<vtkDataSetMapper> and assign it and not the vtkSmartPointer

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  sankarapandiyanS 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @sankarapandiyan Take a look at the error message and fix your code.
                    "but implemented in qt only" - Qt is not a programming language, you're implementing it in C++.

                    sankarapandiyanS Offline
                    sankarapandiyanS Offline
                    sankarapandiyan
                    wrote on last edited by
                    #9

                    @jsulm ok sure yes you are right..

                    1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @sankarapandiyan I guess you need to get the RAW pointer (vtkDataSetMapper*) from vtkSmartPointer<vtkDataSetMapper> and assign it and not the vtkSmartPointer

                      sankarapandiyanS Offline
                      sankarapandiyanS Offline
                      sankarapandiyan
                      wrote on last edited by
                      #10

                      @jsulm sure.. i will try

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved