[vtkusers] Can we add a check to see if we have at least 2 nodes when vtkContourWidget is in Manipulate state?

Mengda Wu wumengda at gmail.com
Fri Jan 22 23:20:21 EST 2016


OK. I did not initialize it with a polydata but just used the method
vtkContourWidget::Initialize(). I believe it means that there is no point
in it.
Then I set the state to Manipulate immediately with SetWidgetState(
vtkContourWidget::Manipulate);

After that, using some other code, I got the point from the pick point on
vtkImagePlaneWidget and added it to vtkContourWidget with vtkContourWidget->
GetContourRepresentation()->AddNodeAtWorldPosition(point);

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:

vtkLine::Intersection(double * a1, double * a2, double * b1, double * b2,
double & u, double & v) Line 117
vtkContourRepresentation::FindClosestPointOnContour(int X, int Y, double *
closestWorldPos, int * idx) Line 808
vtkContourRepresentation::AddNodeOnContour(int X, int Y) Line 896

Mengda

On Fri, Jan 22, 2016 at 3:07 PM, Yumin Yuan <yumin.yuan at kitware.com> wrote:

> Hi Mengda,
>
> I will suggest to figure out why it is crashing first. Even with only one
> node, it should still work.
>
> 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?
>
> Yumin
>
> On Fri, Jan 22, 2016 at 10:40 AM, Mengda Wu <wumengda at gmail.com> wrote:
>
>> Hi all,
>>
>>    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
>>
>> So I hope you can change the following function to
>>
>> void vtkContourWidget::SelectAction( vtkAbstractWidget *w )
>> {
>>
>> ................
>> ................
>>
>>   switch ( self->WidgetState )
>>     {
>>     case vtkContourWidget::Start:
>>     case vtkContourWidget::Define:
>> ................
>> ................
>>     case vtkContourWidget::Manipulate:
>>       {
>>       if ( rep->ActivateNode( X, Y ) )
>>         {
>> ................
>> ................
>>         }
>>       else if ( rep->GetNumberOfNodes()>1 && rep->AddNodeOnContour( X, Y
>> ) )   //Ensure the number of nodes is at least 2
>>         {
>> ................
>> ................
>>         }
>> ................
>> ................
>> }
>>
>>
>>
>> _______________________________________________
>> 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
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160122/cd0e15a5/attachment.html>


More information about the vtkusers mailing list