<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hello,</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">I am trying to apply an affine transform to a polydata that further intialize a contour widget.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">The problem is that at the initialization, the ContourWidget can't find the points from polydata.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0);
background-color: transparent; font-style: normal; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">Can you tell me how can I combine ContourWidget with AffineWidget in an optimal way?</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">Below is the code with my solution that does not work because at the initialization requires the points from poly data.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="font-family:
'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">Thank you!</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; ">I defined the<span style="font-weight: bold;"> vtkAffineCallback</span> class:</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal; "><br></div><div style="background-color: transparent; "><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">class vtkAffineCallback : public vtkCommand</font></div><div style="background-color:
transparent; "><font face="times new roman, new york, times, serif">{</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">public:</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> static vtkAffineCallback *New() </font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> { return new vtkAffineCallback; }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> virtual void Execute(vtkObject *caller, unsigned long, void*);</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> vtkAffineCallback():TranformF(0),AffineRep(0) </font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">
{</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> this->Transform = vtkTransform::New();</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> ~vtkAffineCallback()</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> {</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> this->Transform->Delete();</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times,
serif"> vtkTransformPolyDataFilter *TranformF;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> vtkAffineRepresentation2D *AffineRep;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> vtkTransform *Transform;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">};</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> </font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">void vtkAffineCallback::Execute(vtkObject*, unsigned long vtkNotUsed(event), void*)</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">{</font></div><div style="background-color: transparent; "><font face="times new
roman, new york, times, serif"> this->AffineRep->GetTransform(this->Transform);</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif"> this->TransformF->SetTransform(this->Transform);</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">}</font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; "><font face="times new roman, new york, times, serif"><br></font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; "><font face="times new roman, new york, times, serif">/<span style="font-weight: bold;">/MAIN</span></font></div><div style="background-color: transparent; "><font face="times new
roman, new york, times, serif"><div style="background-color: transparent; ">int main( int argc, char *argv[] )</div><div style="background-color: transparent; ">{</div><div style="background-color: transparent; ">...</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Use a Dicomreader and a PlaneImageWidget to visualize the images</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">...</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Generate an ellipse as PolyData</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times,
serif; font-style: normal; ">...</div><div style="background-color: transparent; font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Apply a <span style="color: rgb(0, 0, 0); background-color: transparent; "> </span><span style="background-color: transparent; ">vtkTransformPolyDataFilter to the ellipse => <span style="color: rgb(255, 0, 0);">f_ellipse object</span></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Create the affine widget</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">....</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal;
">//<span style="font-weight: bold;">AffineCallback</span></div><div style="background-color: transparent; "><div style="background-color: transparent; ">vtkSmartPointer<vtkAffineCallback> affineCallback = vtkSmartPointer<vtkAffineCallback>::New();</div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span>affineCallback->TransformF=f_ellipse;</div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span>affineCallback->AffineRep = vtkAffineRepresentation2D::SafeDownCast(affineWidget>GetRepresentation());</div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span></div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span>affineWidget->AddObserver(vtkCommand::InteractionEvent,affineCallback);</div><div style="background-color:
transparent; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>affineWidget->AddObserver(vtkCommand::EndInteractionEvent,affineCallback);</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">...</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Create a ContourWidget</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">...</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; ">//Initialize the Contour Widget</div><div style="background-color: transparent;
">contourWidget->Initialize(<span style="color: rgb(255, 0, 0);">f_ellipse</span>->GetOutput());<br></div></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 16px; font-family: 'times new roman', 'new york', times, serif; font-style: normal; "><br></div></font></div></div></div></body></html>