[vtkusers] Window->Image coordinate conversions?

Bill Lorensen bill.lorensen at gmail.com
Fri Oct 23 12:21:22 EDT 2009


After an InitTraveral, NextActor should return the first actor. At
least that's what it did 10 years ago.

Can you run in a debugger?


On Fri, Oct 23, 2009 at 11:58 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Thu, Oct 22, 2009 at 11:32 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> You may need to:
>> ActorCollection->InitTraversal();
>> before:
>>  vtkActor* actor = ActorCollection->GetNextActor();
>
> Hm that didn't seem to change anything - I addeded InitTraversal on
> both the actor and renderer collections. Here is an updated function
> with outputs every couple of lines. The last output I see before the
> segfault is
> "Getting renderer...". I've never used these "collection" objects
> before, so I am likely doing something wrong with those. There doesn't
> seem to be a "GetFirstActor" function, so maybe "GetNextActor" is
> trying to get the second actor (which doesn't exist)? I'm not sure
> where the actor counter starts.
>
> void SelectionChangedCallbackFunction ( vtkObject* caller, long
> unsigned int eventId, void* clientData, void* callData )
> {
>  vtkstd::cout << "Selection changed callback" << vtkstd::endl;
>
>  unsigned int* rect = reinterpret_cast<unsigned int*> ( callData );
>  unsigned int pos1X = rect[0];
>  unsigned int pos1Y = rect[1];
>  unsigned int pos2X = rect[2];
>  unsigned int pos2Y = rect[3];
>
>  vtkstd::cout << "Start x: " << pos1X << " Start y: " << pos1Y << "
> End x: " << pos2X << " End y: " << pos2Y << vtkstd::endl;
>
>  vtkstd::cout << "Getting render window..." << vtkstd::endl;
>
>  vtkRenderWindow* ren = reinterpret_cast<vtkRenderWindow*>(caller);
>
>  vtkstd::cout << "Getting renderer..." << vtkstd::endl;
>  vtkRendererCollection* RendererCollection = ren->GetRenderers();
>  RendererCollection->InitTraversal();
>  vtkRenderer* renderer = RendererCollection->GetFirstRenderer();
>
>  if(renderer == NULL)
>  {
>    vtkstd::cout << "Invalid renderer!" << vtkstd::endl;
>    return;
>  }
>
>  vtkstd::cout << "Getting actor..." << vtkstd::endl;
>  vtkActorCollection* ActorCollection = renderer->GetActors();
>  ActorCollection->InitTraversal();
>  vtkActor* actor = ActorCollection->GetNextActor();
>
>  if(actor == NULL)
>  {
>    vtkstd::cout << "Invalid actor!" << vtkstd::endl;
>    return;
>  }
>
>  vtkImageActor* ImageActor = reinterpret_cast<vtkImageActor*>(actor);
>
>  vtkstd::cout << "Setting up point placer..." << vtkstd::endl;
>
>  vtkSmartPointer<vtkImageActorPointPlacer> ImageActorPointPlacer =
> vtkSmartPointer<vtkImageActorPointPlacer>::New();
>  ImageActorPointPlacer->SetImageActor(ImageActor);
>
>  double displayPos[2];
>  displayPos[0] = pos1X;
>  displayPos[1] = pos1Y;
>
>  double worldPos[3];
>  double worldOrient[9];
>
>  vtkstd::cout << "Compute world position..." << vtkstd::endl;
>
>  ImageActorPointPlacer->ComputeWorldPosition(renderer, displayPos,
> worldPos, worldOrient);
>
>  vtkstd::cout << "World pos: " << worldPos[0] << " " << worldPos[1]
> << " " << worldPos[2] << vtkstd::endl;
>
> }
>
> Any ideas?
>
> Thanks,
>
> David
> _______________________________________________
> 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 VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list