[vtkusers] vtkCoordinate question

David Gobbi david.gobbi at gmail.com
Sun Feb 13 21:54:24 EST 2011


Glad to hear that people are using that class.  As a head's up,
though, I fixed my misspelling a couple days ago... now it's called
vtkLassoStencilSource.

 - David

On Sun, Feb 13, 2011 at 7:23 PM, Dean Inglis <dean.inglis at camris.ca> wrote:
> 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
> _______________________________________________
> 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