[vtkusers] vtkCoordinate question

Dean Inglis dean.inglis at camris.ca
Sun Feb 13 21:23:47 EST 2011


the problem was with my vtkLassooStencilSource: the output spacing, origin
etc was not set: all I needed to do was SetInformationInput correctly
and it works fine.

Dean


Im using vtkBorderWidget/Representation to define a square ROI on an image.
vtkBorderRepresentation constructs its vtkPolyData geometry in display
coordinates
by taking a unit square with lower left corner set at 0, 0 in its local
model space
and then transforming the points to display coordinates internally by
translating and scaling.
I would like to recover the world coordinates of the four corners of the
border.

currently I do:

  vtkSmartPointer<vtkActor2DCollection> pc =
vtkSmartPointer<vtkActor2DCollection>::New();
  borderRep->GetActors2D( pc );
  vtkPolyData* borderPoly =
vtkPolyDataMapper2D::SafeDownCast(pc->GetLastActor2D()->GetMapper())->GetInput();

  vtkSmartPointer<vtkCoordinate> cr1 =
vtkSmartPointer<vtkCoordinate>::New();
  vtkSmartPointer<vtkCoordinate> cr2 =
vtkSmartPointer<vtkCoordinate>::New();
  cr1->SetCoordinateSystemToDisplay();
  cr2->SetCoordinateSystemToDisplay();
  cr1->SetViewport( renderer );
  cr2->SetViewport( renderer );

  vtkSmartPointer<vtkCoordinate> c1 = vtkSmartPointer<vtkCoordinate>::New();
  vtkSmartPointer<vtkCoordinate> c2 = vtkSmartPointer<vtkCoordinate>::New();
  c1->SetReferenceCoordinate( cr1 );
  c1->SetViewport( renderer );
  c2->SetReferenceCoordinate( cr2 );
  c2->SetViewport( renderer );

  cr1->SetValue( borderPoly->GetPoints()->GetPoint(0) );
  cr2->SetValue( borderPoly->GetPoints()->GetPoint(2) );

  double* worldPt1 = c1->GetComputedWorldValue(0);
  double* worldPt2 = c2->GetComputedWorldValue(0);

I can set the z coordinate of these points to the z location of the image
actor displaying the image,
 however, the world points do not match up.  Please see attached jpeg.   The
darker
rectangular region in the image should be the same size as the border
widget's rep.  The border
widget sets up the coordinates for a vtkLassooStencilSource in an image
stenciling pipeline.
Ive tried all sorts of variants on this but Im stymied as to why there is a
translation
and scale effect 




More information about the vtkusers mailing list