[Insight-users] itk::fem::MaterialLinearElasticity::Read
Lara Vigneron
Lara . Vigneron at ulg . ac . be
Thu, 22 May 2003 15:44:32 +0200
--------------DAA85ED11D7F37D80D03422D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Dear all,
I use the itk::fem::MaterialLinearElasticity class. And I want to set
the public attributes (E, A, I, nu, h, RhoC) of an object of this class
to different values than the default ones.
If I write for instance these code lines, the code works without
problem:
itk::fem::MaterialLinearElasticity::Pointer mat_1;
mat_1 = itk::fem::MaterialLinearElasticity::New();
mat_1->GN=0;
mat_1->E = 5;
mat_1->A = 5;
mat_1->I = 5;
mat_1->nu = 5;
mat_1->h = 5;
mat_1->RhoC = 5;
But I would like to use the itk::fem::MaterialLinearElasticity::Read
(std::istream & f, void * info) member function.
So I create a text file (mat1.txt) wherein I write:
E : 5.0
A : 5.0
I : 5.0
nu : 5.0
h : 5.0
RhoC : 5.0
Then, I write in my program the following code lines:
itk::fem::MaterialLinearElasticity::Pointer mat_1;
mat_1 = itk::fem::MaterialLinearElasticity::New();
// open the file mat1.txt associated before with matfilename1
filebuf fb;
if (fb.open(matfilename1.c_str(), ios::in) == 0) {
throw_error("Unable to open input file");
}
std::istream istr(&fb);
mat_1->GN=0;
mat_1->Read((std::istream&) istr,(void*) NULL);
// I try also:
// void *ptr;
// mat_1->Read((std::istream&) istr,(void*) ptr);
This code compiles but when I execute it, it aborts at the appeal of
Read
method.
Remarks:
(1) I use a NULL pointer because I don't need more information for the
MaterialLinearElasticity class.
(2) In the first case, I try also to keep values of E, A, ... from the
text file to see if problems could be due to the opening of the file but
it
works correctly.
Does anyone know what's wrong with my code?
Thanks a lot,
Lara
--
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
--------------DAA85ED11D7F37D80D03422D
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Dear all,
<p>I use the itk::fem::MaterialLinearElasticity class. And I want to set
<br>the public attributes (E, A, I, nu, h, RhoC) of an object of this class
<br>to different values than the default ones.
<p>If I write for instance these code lines, the code works without problem:
<p> itk::fem::MaterialLinearElasticity::Pointer mat_1;
<br> mat_1 = itk::fem::MaterialLinearElasticity::New();
<br> mat_1->GN=0;
<br> mat_1->E = 5;
<br> mat_1->A = 5;
<br> mat_1->I = 5;
<br> mat_1->nu = 5;
<br> mat_1->h = 5;
<br> mat_1->RhoC = 5;
<p>But I would like to use the itk::fem::MaterialLinearElasticity::Read
(std::istream & f, void * info) member function.
<br>So I create a text file (mat1.txt) wherein I write:
<p>E : 5.0
<br>A : 5.0
<br> I : 5.0
<br>nu : 5.0
<br>h : 5.0
<br>RhoC : 5.0
<p>Then, I write in my program the following code lines:
<p>itk::fem::MaterialLinearElasticity::Pointer mat_1;
<br>mat_1 = itk::fem::MaterialLinearElasticity::New();
<p>// open the file mat1.txt associated before with matfilename1
<br> filebuf fb;
<br> if (fb.open(matfilename1.c_str(), ios::in) == 0) {
<br> throw_error("Unable to open input file");
<br> }
<br> std::istream istr(&fb);
<p> mat_1->GN=0;
<br> mat_1->Read((std::istream&) istr,(void*) NULL);
<p>// I try also:
<br>// void *ptr;
<br>// mat_1->Read((std::istream&) istr,(void*) ptr);
<br>
<p>This code compiles but when I execute it, it aborts at the appeal of
Read
<br>method.
<p>Remarks:
<br>(1) I use a NULL pointer because I don't need more information for
the
<br>MaterialLinearElasticity class.
<p>(2) In the first case, I try also to keep values of E, A, ... from the
<br>text file to see if problems could be due to the opening of the file
but it
<br>works correctly.
<p>Does anyone know what's wrong with my code?
<p>Thanks a lot,
<p>Lara
<br>
<br>
<br>
<br>
<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>
--------------DAA85ED11D7F37D80D03422D--