[Insight-users] itk::fem::MaterialLinearElasticity::Read
Lara Vigneron
Lara . Vigneron at ulg . ac . be
Thu, 22 May 2003 18:00:13 +0200
--------------EA80494FA60EB6895D16BDEE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Luis,
I work on a Linux platform. This is what I obtain when I use the
Exception for the code:
itk::fem::MaterialLinearElasticity::Pointer mat_1;
mat_1 = itk::fem::MaterialLinearElasticity::New();
std::ifstream inFile;
inFile.open( matfilename1.c_str() );
if ( inFile.fail() ) cout<<"inFile is not open\n";
cout<<"matfilename="<<matfilename1<<"\n";
if (!inFile) cout<<"inFile is false\n";
else cout<<"inFile is true\n";
try
{
mat_1->Read( inFile ,(void*) NULL);
}
catch( itk::ExceptionObject & ee )
{
std::cerr << "Exception caught " << std::endl;
std::cerr << ee << std::endl;
}
catch( ... )
{
std::cerr << "Unknown exception caught" << std::endl;
}
inFile.close();
This is what I obtain:
matfilename=mat1.txt //so it's correct
inFile is true
Exception caught
itk::FEMExceptionIO (0x82334f0)
Location: "FEMLightObject::Read"
File:
/home/vigneron/InsightToolkit-1.2.0/Code/Numerics/FEM/itkFEMLightObject.cxx
Line: 48
Description: IO error in FEM class: Error reading FEM object!
And this line 48 corresponds in the function void FEMLightObject::Read(
std::istream& f, void* ) to:
if( !f )
{
throw FEMExceptionIO(__FILE__,__LINE__,"FEMLightObject::Read","Error
reading FEM object!");
}
Do you have an idea of the problem?
Thank you, Lara
Luis Ibanez wrote:
> Hi Lara,
>
> Does the program 'aborts' ?
>
> In that case you may be facing an uncaught exception.
> It will be helpful to put the Read in between a
> try/catch block like
>
> try
> {
> ..Read..
> }
> catch( itk::ExceptionObject & ee )
> {
> std::cerr << "Exception caught " << std::endl;
> std::cerr << ee << std::endl;
> }
> catch( ... )
> {
> std::cerr << "Unknown exception caught" << std::endl;
> }
>
> The printed message may provide enough information
> to figure out the real source of the problem.
>
> In what platform are you running ?
> Could you run in a debugger ?
>
> Please let us know what you find.
>
> Luis
>
> ---------------------------------------
> Lara Vigneron wrote:
> > Hi Luis,
> >
> > Thank you for your suggestion. I try to open the file with your code
> > lines but
> > it doesn't seem to change anything...
> >
> > Do you think to some other reason my program aborts?
> >
> > Thank you,
> >
> > Lara
> >
> >
> >
> > Luis Ibanez wrote:
> >
> >> Hi Lara,
> >>
> >> Is there any reason for opening the file
> >> in the way you are doing now ?
> >>
> >> A far simpler way may be the following:
> >>
> >> std::ifstream inFile;
> >> inFile.open( matfilename1.c_str() );
> >>
> >> if( inFile.fail() ) return -1;
> >>
> >> and then
> >>
> >> mat_1->Read( inFile ,(void*) NULL);
> >>
> >> inFile.close();
> >>
> >> The NULL seems to be ok, since the
> >> MaterialLinearElasticity doesn't use
> >> this argument in the Read() method.
> >>
> >> Regards,
> >>
> >> Luis
> >>
> >>
> > --
> > Lara VIGNERON
> >
> > Signal Processing Group
> >
> > University of Liege
> > Institut Montefiore
> > Sart-Tilman, Batiment B28
> > B-4000 Liege
> > BELGIUM
> >
> > Tel: +32-(0)4-366.26.42
> > Fax: +32-(0)4-366.29.84
> > Lara . Vigneron at ulg . ac . be
> >
> >
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at public . kitware . com
> http://public . kitware . com/mailman/listinfo/insight-users
--
Lara VIGNERON
Signal Processing Group
University of Liege
Institut Montefiore
Sart-Tilman, Batiment B28
B-4000 Liege
BELGIUM
Tel: +32-(0)4-366.26.42
Fax: +32-(0)4-366.29.84
Lara . Vigneron at ulg . ac . be
--------------EA80494FA60EB6895D16BDEE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi Luis,
<p>I work on a Linux platform. This is what I obtain when I use the Exception
for the code:
<p> itk::fem::MaterialLinearElasticity::Pointer mat_1;
<br> mat_1 = itk::fem::MaterialLinearElasticity::New();
<br>
<br> std::ifstream inFile;
<br> inFile.open( matfilename1.c_str() );
<p> if ( inFile.fail() ) cout<<"inFile is not open\n";
<br> cout<<"matfilename="<<matfilename1<<"\n";
<p> if (!inFile) cout<<"inFile is false\n";
<br> else cout<<"inFile is true\n";
<br>
<br> try
<br> {
<br> mat_1->Read( inFile ,(void*) NULL);
<br> }
<br> catch( itk::ExceptionObject & ee )
<br> {
<br> std::cerr << "Exception caught " <<
std::endl;
<br> std::cerr << ee << std::endl;
<br> }
<br> catch( ... )
<br> {
<br> std::cerr << "Unknown exception caught"
<< std::endl;
<br> }
<br>
<p> inFile.close();
<br>
<br>
<p>This is what I obtain:
<p>matfilename=mat1.txt //so it's correct
<br>inFile is true
<p>Exception caught
<br>
<br>itk::FEMExceptionIO (0x82334f0)
<br>Location: "FEMLightObject::Read"
<br>File: /home/vigneron/InsightToolkit-1.2.0/Code/Numerics/FEM/itkFEMLightObject.cxx
<br>Line: 48
<br>Description: IO error in FEM class: Error reading FEM object!
<br>
<br>
<br>
<p>And this line 48 corresponds in the function void FEMLightObject::Read(
std::istream& f, void* ) to:
<p>if( !f )
<br> {
<br> throw FEMExceptionIO(__FILE__,__LINE__,"FEMLightObject::Read","Error
reading FEM object!");
<br> }
<p>Do you have an idea of the problem?
<p>Thank you, Lara
<br>
<br>
<p>Luis Ibanez wrote:
<blockquote TYPE=CITE>Hi Lara,
<p>Does the program 'aborts' ?
<p>In that case you may be facing an uncaught exception.
<br>It will be helpful to put the Read in between a
<br>try/catch block like
<p>try
<br>{
<br> ..Read..
<br>}
<br>catch( itk::ExceptionObject & ee )
<br>{
<br> std::cerr << "Exception caught " <<
std::endl;
<br> std::cerr << ee << std::endl;
<br>}
<br>catch( ... )
<br>{
<br> std::cerr << "Unknown exception caught" <<
std::endl;
<br>}
<p>The printed message may provide enough information
<br>to figure out the real source of the problem.
<p>In what platform are you running ?
<br>Could you run in a debugger ?
<p>Please let us know what you find.
<p> Luis
<p>---------------------------------------
<br>Lara Vigneron wrote:
<br>> Hi Luis,
<br>>
<br>> Thank you for your suggestion. I try to open the file with your code
<br>> lines but
<br>> it doesn't seem to change anything...
<br>>
<br>> Do you think to some other reason my program aborts?
<br>>
<br>> Thank you,
<br>>
<br>> Lara
<br>>
<br>>
<br>>
<br>> Luis Ibanez wrote:
<br>>
<br>>> Hi Lara,
<br>>>
<br>>> Is there any reason for opening the file
<br>>> in the way you are doing now ?
<br>>>
<br>>> A far simpler way may be the following:
<br>>>
<br>>> std::ifstream inFile;
<br>>> inFile.open( matfilename1.c_str() );
<br>>>
<br>>> if( inFile.fail() ) return -1;
<br>>>
<br>>> and then
<br>>>
<br>>> mat_1->Read( inFile ,(void*) NULL);
<br>>>
<br>>> inFile.close();
<br>>>
<br>>> The NULL seems to be ok, since the
<br>>> MaterialLinearElasticity doesn't use
<br>>> this argument in the Read() method.
<br>>>
<br>>> Regards,
<br>>>
<br>>> Luis
<br>>>
<br>>>
<br>> --
<br>> Lara VIGNERON
<br>>
<br>> Signal Processing Group
<br>>
<br>> University of Liege
<br>> Institut Montefiore
<br>> Sart-Tilman, Batiment B28
<br>> B-4000 Liege
<br>> BELGIUM
<br>>
<br>> Tel: +32-(0)4-366.26.42
<br>> Fax: +32-(0)4-366.29.84
<br>> Lara . Vigneron at ulg . ac . be
<br>>
<br>>
<p>_______________________________________________
<br>Insight-users mailing list
<br>Insight-users at public . kitware . com
<br><a href="http://public . kitware . com/mailman/listinfo/insight-users">http://public . kitware . com/mailman/listinfo/insight-users</a></blockquote>
<pre>--
Lara VIGNERON
Signal Processing Group
University of Liege
Institut Montefiore
Sart-Tilman, Batiment B28
B-4000 Liege
BELGIUM
Tel: +32-(0)4-366.26.42
Fax: +32-(0)4-366.29.84
Lara . Vigneron at ulg . ac . be</pre>
</html>
--------------EA80494FA60EB6895D16BDEE--