<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">&nbsp; static vtkAffineCallback *New()&nbsp;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; { return new vtkAffineCallback; }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; virtual void Execute(vtkObject *caller, unsigned long, void*);</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; vtkAffineCallback():TranformF(0),AffineRep(0)&nbsp;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp;
 &nbsp; {</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; &nbsp; this-&gt;Transform = vtkTransform::New();</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; ~vtkAffineCallback()</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; {</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; &nbsp; this-&gt;Transform-&gt;Delete();</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; &nbsp; }</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times,
 serif">&nbsp; vtkTransformPolyDataFilter *TranformF;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; vtkAffineRepresentation2D *AffineRep;</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; 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">&nbsp;</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">&nbsp; this-&gt;AffineRep-&gt;GetTransform(this-&gt;Transform);</font></div><div style="background-color: transparent; "><font face="times new roman, new york, times, serif">&nbsp; this-&gt;TransformF-&gt;SetTransform(this-&gt;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&nbsp;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&nbsp;<span style="color: rgb(0, 0, 0); background-color: transparent; ">&nbsp;</span><span style="background-color: transparent; ">vtkTransformPolyDataFilter to the ellipse =&gt; <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&lt;vtkAffineCallback&gt; affineCallback = vtkSmartPointer&lt;vtkAffineCallback&gt;::New();</div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span>affineCallback-&gt;TransformF=f_ellipse;</div><div style="background-color: transparent; "><span class="Apple-tab-span" style="white-space:pre">        </span>affineCallback-&gt;AffineRep = vtkAffineRepresentation2D::SafeDownCast(affineWidget&gt;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-&gt;AddObserver(vtkCommand::InteractionEvent,affineCallback);</div><div style="background-color:
 transparent; "><span class="Apple-tab-span" style="white-space: pre; ">        </span>affineWidget-&gt;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-&gt;Initialize(<span style="color: rgb(255, 0, 0);">f_ellipse</span>-&gt;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>