<div dir="ltr">Hi Mengda,<div><br></div><div>Since you are using the <span style="font-size:12.8px">vtkImagePlaneWidget to get the points and then inserting them programmatically into the vtkContourWidget, the vtkContourWidget should not be enabled while you are doing this. It seems like when you click in the render window, the </span><span style="font-size:12.8px">vtkContourWidget::SelectAction is also invoked (from your first email), which is not what you want. Try to disable the vtkContourWidget while you are interacting with the plane widget and inserting points into contour widget. You can enable the contour widget after you have done inserting points.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">HTH,</span></div><div><span style="font-size:12.8px">Yumin</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jan 22, 2016 at 11:20 PM, Mengda Wu <span dir="ltr"><<a href="mailto:wumengda@gmail.com" target="_blank">wumengda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><div dir="ltr"><span style="font-size:12.8px">OK. I did not initialize it with a polydata but just used the method vtkContourWidget::Initialize()</span><span style="font-size:12.8px">. I believe it means that there is no point in it.</span><br style="font-size:12.8px"><span style="font-size:12.8px">Then I set the state to Manipulate immediately with SetWidgetState(</span><span style="font-size:12.8px">vtkContourWidget::Manipulate);</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">After that, using some other code, I got the point from the pick point on vtkImagePlaneWidget and added it to vtkContourWidget with vtkContourWidget-></span><span style="font-size:12.8px">GetContourRepresentation()-></span><span style="font-size:12.8px">AddNodeAtWorldPosition(point);</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">The first point is fine but it crashes when I tried to add the second point. The crashes happened in vtkLine::Intersection with the call stack as follows:</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">vtkLine::Intersection(double * a1, double * a2, double * b1, double * b2, double & u, double & v) Line 117</span><br style="font-size:12.8px"><span style="font-size:12.8px">vtkContourRepresentation::</span><span style="font-size:12.8px">FindClosestPointOnContour(int X, int Y, double * closestWorldPos, int * idx) Line 808</span><br style="font-size:12.8px"><span style="font-size:12.8px">vtkContourRepresentation::</span><span style="font-size:12.8px">AddNodeOnContour(int X, int Y) Line 896</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Mengda</span></div></div></span><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Jan 22, 2016 at 3:07 PM, Yumin Yuan <span dir="ltr"><<a href="mailto:yumin.yuan@kitware.com" target="_blank">yumin.yuan@kitware.com</a>></span> wrote:<br></span><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Mengda,<div class="gmail_extra"><br></div><div class="gmail_extra">I will suggest to figure out why it is crashing first. Even with only one node, it should still work.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Also, assuming you are using this method vtkContourWidget::Initialize( vtkPolyData * poly, int state = 1, vtkIdList *idList = NULL ), your input poly doesn't have any points?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Yumin</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote"><div><div>On Fri, Jan 22, 2016 at 10:40 AM, Mengda Wu <span dir="ltr"><<a href="mailto:wumengda@gmail.com" target="_blank">wumengda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div> I would like to set the state of vtkContourWidget to Manipulate at initialize and add the nodes programmably instead of interactively. Everything is fine but I have to check the there are at least 2 nodes in the following, otherwise AddNodeOnContour will crash</div><div><br></div><div>So I hope you can change the following function to</div><div><br></div></div></blockquote></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr"><div></div><div>void vtkContourWidget::SelectAction( vtkAbstractWidget *w )<br></div><div>{</div><div><br></div><div>................</div><div>................</div><div><br></div><div><div> switch ( self->WidgetState )</div><div> {</div><div> case vtkContourWidget::Start:</div><div> case vtkContourWidget::Define:</div></div><div><div>................</div><div>................</div></div><div> case vtkContourWidget::Manipulate:<br></div><div><div> {</div><div> if ( rep->ActivateNode( X, Y ) )</div></div><div> {<br></div><div><div>................</div><div>................</div></div><div><div> }</div><div> else if ( rep->GetNumberOfNodes()>1 && rep->AddNodeOnContour( X, Y ) ) //Ensure the number of nodes is at least 2</div><div> {</div></div><div><div><div>................</div><div>................</div></div><div> }</div></div><div><div>................</div><div>................</div></div><div>}</div><div><br></div><div><br></div></div>
<br></div></div>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div></div>