[Insight-users] Re: Some coding advice

Luis Ibanez luis.ibanez at kitware.com
Thu Mar 22 12:23:03 EST 2007


Hi Sonali,

You should check whether

     It_Node.GetPointer()

is NULL or not, before attemting
to access its member variables.

It is likely that this pointer is NULL,
which probably indicates that there is
a problem with the code that generates
the It_Node structure.

Please add a check for GetPointer()==NULL
and let us know what you find.


   Thanks


      Luis


============================
Sonali Barua wrote:
> Hello,
> 
> I am trying to run a code I am trying to develop for ITK in a loop:
> 
> for(It_Node.GoToBegin();!It_Node.IsAtEnd();++It_Node)
>    {
>      IdentifierType id=It_Node.GetPointer()->Identifier;
>      
>      prim->SetRootNodeIdentifier(id);  //this is a itkSetMacro
>      graph->Modified();
>      prim->Modified();
>      prim->Update();
>       std::cout<<" The distance of the minimumspanning tree is for 
> Rootnode Id: "<<id<<" is "<<prim->GetDistanceWeight()<<std::endl;
>     }
> I get a Seg Fault around the third Iteration at the 
> It_Node.GetPointer->Identifier part of the code.
> 
> I change the Graph that is set as an Input in the Prim object. Could 
> that be a problem?
> 
> 


More information about the Insight-users mailing list