[Insight-users] Bug in DeformableModel1.cxx

Quan Chen quanchen at gmail.com
Thu Oct 28 18:24:53 EDT 2004


It seems that the DeformableModel1.cxx and DeformableModel2.cxx are
not included in test suite. I am wondering if anyone has test those
examples. I did a test and find some bugs.

In DeformableModel1.cxx the mesh is constructed by
     meshSource->SetBinaryImage( maskReader->GetOutput() );
     meshSource->SetObjectValue( 1 );  //I modified this value for my mask
The meshSource was a input to the DeformableMesh3DFilter
     deformableModelFilter->SetInput(    meshSource->GetOutput()        );
...
Then the pipeline is updated:
     deformableModelFilter->Update();

However when I run this program, I got errors.
By further investigation, I find that the Update() didn't propagate to
the maskReader, I guess it is because the way the
inaryMask3DMeshSource implemented.  We use SetBinaryImage() instead of
SetInput(), so some necessary function call maybe missing.
I inserted the following code after meshSource->SetObjectValue( 1 ); :
            maskReader->Update();
            meshSource->Update();
            std::cout<<"Number of
Cells:"<<meshSource->GetOutput()->GetNumberOfCells()<<std::endl;
If I comment out the maskReader->Update(); the GetNumberOfCells() give
me value 0.

However, adding these code still give me error when   
deformableModelFilter->Update(); is executed.  I traced into
DeformableMesh3DFilter<TInputMesh, TOutputMesh>::Initialize() and find
that somehow the number of cells and nodes of the mesh doubled and the
input mesh probably freed since it is the zero pointer that cause the
crash.
If I comment out the meshSource->Update(), the program runs fine. 
Note that in the original program, there is no meshSource->Update(). 
So it seems that the only modification is just add an invocation of
FileReader's Update().  However, I would perfer that the Update() call
will propogate past the meshSource, and invoke the Update() of the
mesh source explicitly will cause the program not function correctly
still bugs me.

I remember I read the similiar problem in the maillist about the
meshSource->Update().  I checked again, it is from
http://www.itk.org/pipermail/insight-users/2004-July/009577.html  That
one used a different method to generate Mesh.  I am wondering whether
we should fix the mesh source class or we should fix the
DeformableMesh3DFilter.  Because if I just Updated the meshSource, the
DeformableMesh3DFilter should know that and don't attempt to update it
again.

BTW, in DeformableModel2.cxx, the meshSource is created by
SphereMeshSource.  the function Update() is invoked before the
DeformableMesh3DFilter::Update().  I didn't test it but I am guessing
it will produce the same problem.


More information about the Insight-users mailing list