[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>&nbsp;itk::fem::MaterialLinearElasticity::Pointer mat_1;
<br>&nbsp;mat_1 = itk::fem::MaterialLinearElasticity::New();
<br>&nbsp;
<br>&nbsp;std::ifstream&nbsp; inFile;
<br>&nbsp;inFile.open( matfilename1.c_str() );
<p>&nbsp;if ( inFile.fail() ) cout&lt;&lt;"inFile is not open\n";
<br>&nbsp;cout&lt;&lt;"matfilename="&lt;&lt;matfilename1&lt;&lt;"\n";
<p>&nbsp; if (!inFile) cout&lt;&lt;"inFile is false\n";
<br>&nbsp; else cout&lt;&lt;"inFile is true\n";
<br>&nbsp;
<br>&nbsp;try
<br>&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp; mat_1->Read( inFile ,(void*) NULL);
<br>&nbsp;&nbsp; }
<br>&nbsp;catch( itk::ExceptionObject &amp; ee )
<br>&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught " &lt;&lt;
std::endl;
<br>&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; ee &lt;&lt; std::endl;
<br>&nbsp;&nbsp; }
<br>&nbsp;catch( ... )
<br>&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Unknown exception caught"
&lt;&lt; std::endl;
<br>&nbsp;&nbsp; }
<br>&nbsp;
<p>&nbsp;&nbsp;&nbsp; inFile.close();
<br>&nbsp;
<br>&nbsp;
<p>This is what I obtain:
<p>matfilename=mat1.txt&nbsp; //so it's correct
<br>inFile is true
<p>Exception caught
<br>&nbsp;
<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>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p>And this line 48 corresponds in the function void FEMLightObject::Read(
std::istream&amp; f, void* ) to:
<p>if( !f )
<br>&nbsp; {
<br>&nbsp;&nbsp;&nbsp; throw FEMExceptionIO(__FILE__,__LINE__,"FEMLightObject::Read","Error
reading FEM object!");
<br>&nbsp; }
<p>Do you have an idea of the problem?
<p>Thank you, Lara
<br>&nbsp;
<br>&nbsp;
<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>&nbsp;&nbsp; ..Read..
<br>}
<br>catch( itk::ExceptionObject &amp; ee )
<br>{
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Exception caught " &lt;&lt;
std::endl;
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; ee &lt;&lt; std::endl;
<br>}
<br>catch( ... )
<br>{
<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Unknown exception caught" &lt;&lt;
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&nbsp; ?
<br>Could you run in a debugger ?
<p>Please let us know what you find.
<p>&nbsp;&nbsp; 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>>>&nbsp;&nbsp;&nbsp;&nbsp; std::ifstream&nbsp; inFile;
<br>>>&nbsp;&nbsp;&nbsp;&nbsp; inFile.open( matfilename1.c_str() );
<br>>>
<br>>>&nbsp;&nbsp;&nbsp;&nbsp; if( inFile.fail() ) return -1;
<br>>>
<br>>> and then
<br>>>
<br>>>&nbsp;&nbsp;&nbsp;&nbsp; mat_1->Read( inFile ,(void*) NULL);
<br>>>
<br>>>&nbsp;&nbsp;&nbsp;&nbsp; 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>>>&nbsp;&nbsp;&nbsp; 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>--&nbsp;
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>
&nbsp;</html>

--------------EA80494FA60EB6895D16BDEE--