[vtkusers] How to apply AffineWidget to PolyData directly

Dora Szasz dora.szasz at yahoo.com
Wed Sep 5 06:57:10 EDT 2012


Hello,

I am trying to apply an affine transform to a polydata that further intialize a contour widget.
The problem is that at the initialization, the ContourWidget can't find the points from polydata.

Can you tell me how can I combine ContourWidget with AffineWidget in an optimal way?

Below is the code with my solution that does not work because at the initialization requires the points from poly data.

Thank you!

I defined thevtkAffineCallback class:

class vtkAffineCallback : public vtkCommand
{
public:
  static vtkAffineCallback *New() 
    { return new vtkAffineCallback; }
  virtual void Execute(vtkObject *caller, unsigned long, void*);
  vtkAffineCallback():TranformF(0),AffineRep(0) 
    {
      this->Transform = vtkTransform::New();
    }
  ~vtkAffineCallback()
    {
      this->Transform->Delete();
    }
  vtkTransformPolyDataFilter *TranformF;
  vtkAffineRepresentation2D *AffineRep;
  vtkTransform *Transform;
};
 
void vtkAffineCallback::Execute(vtkObject*, unsigned long vtkNotUsed(event), void*)
{
  this->AffineRep->GetTransform(this->Transform);
  this->TransformF->SetTransform(this->Transform);
}

//MAIN
int main( int argc, char *argv[] )
{
...
//Use a Dicomreader and a PlaneImageWidget to visualize the images
...
//Generate an ellipse as PolyData
...
//Apply a  vtkTransformPolyDataFilter to the ellipse => f_ellipse object
//Create the affine widget
....
//AffineCallback
vtkSmartPointer<vtkAffineCallback> affineCallback = vtkSmartPointer<vtkAffineCallback>::New();
affineCallback->TransformF=f_ellipse;
affineCallback->AffineRep = vtkAffineRepresentation2D::SafeDownCast(affineWidget>GetRepresentation());
affineWidget->AddObserver(vtkCommand::InteractionEvent,affineCallback);
affineWidget->AddObserver(vtkCommand::EndInteractionEvent,affineCallback);
...
//Create a ContourWidget
...
//Initialize the Contour Widget
contourWidget->Initialize(f_ellipse->GetOutput());
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120905/53c96ccc/attachment.htm>


More information about the vtkusers mailing list