A
{AGUT2}=IWIK=
Hello all,
It's my fisrt post here and I am feeling a little stupid here, so go easy..
(Oh, and I've spent _hours_ searching...)
I am desperately trying to read in an ASCII "stereolithography" file (*.STL)
into my program. This has the following syntax...
Begin STL Snippet
**********
facet normal -0.00000904 -0.00002272 -1.00000000
outer loop
vertex -2.71325651 0.49965868 -0.00399721
vertex -1.14940957 0.00000000 -0.00400000
vertex -5.03708494 0.00000000 -0.00396485
endloop
endfacet
*********
End STL Snippet
I am putting the various numbers into a facet (an array of vectors) -
myArray[numOfFacets][4]; - from my vector class. Slots 0,1 & 2 are taken by
the vector components, and 3 by the normal, with numOfFAcets being
(drumroll...) the number of facets.
I have two problems..
1) I want to dynamically size the vector array, as the number of facets will
be different for different input files. HOWEVER, I read through the file and
I then 'numOfFacets++;' for each occurence of 'facet'. But, I get...
cfdcasdr1_1.cpp(54) : error C2057: expected constant expression
cfdcasdr1_1.cpp(54) : error C2466: cannot allocate an array of constant size
0
cfdcasdr1_1.cpp(54) : error C2133: 'myArray' : unknown size
.... upon compiling. (VC++ 6.0) Is there a way around this?
Also,
2) I have a 'while' loop to read the numbers in, doing a strtod() on them.
The problem is, I am relying on the program seeing the 'vertex' and 'normal'
part of the file to tell the program that the next (three) inputs are going
to be the vector's x, y and z coordinates.
unfortunately the...
if (buffer == "vertex")
{
}
....thing won't work with strings (AFAICT). How can I use the 'if' statement
to this end? I could to a strtod() - STRing TO Double - on everything, but
if it can't do it, it returns 0 - which the vector components can _also_ be,
so this is no help! :/
I would greatly appreciate any help you could give me.
Alexander Livingstone
It's my fisrt post here and I am feeling a little stupid here, so go easy..
(Oh, and I've spent _hours_ searching...)
I am desperately trying to read in an ASCII "stereolithography" file (*.STL)
into my program. This has the following syntax...
Begin STL Snippet
**********
facet normal -0.00000904 -0.00002272 -1.00000000
outer loop
vertex -2.71325651 0.49965868 -0.00399721
vertex -1.14940957 0.00000000 -0.00400000
vertex -5.03708494 0.00000000 -0.00396485
endloop
endfacet
*********
End STL Snippet
I am putting the various numbers into a facet (an array of vectors) -
myArray[numOfFacets][4]; - from my vector class. Slots 0,1 & 2 are taken by
the vector components, and 3 by the normal, with numOfFAcets being
(drumroll...) the number of facets.
I have two problems..
1) I want to dynamically size the vector array, as the number of facets will
be different for different input files. HOWEVER, I read through the file and
I then 'numOfFacets++;' for each occurence of 'facet'. But, I get...
cfdcasdr1_1.cpp(54) : error C2057: expected constant expression
cfdcasdr1_1.cpp(54) : error C2466: cannot allocate an array of constant size
0
cfdcasdr1_1.cpp(54) : error C2133: 'myArray' : unknown size
.... upon compiling. (VC++ 6.0) Is there a way around this?
Also,
2) I have a 'while' loop to read the numbers in, doing a strtod() on them.
The problem is, I am relying on the program seeing the 'vertex' and 'normal'
part of the file to tell the program that the next (three) inputs are going
to be the vector's x, y and z coordinates.
unfortunately the...
if (buffer == "vertex")
{
}
....thing won't work with strings (AFAICT). How can I use the 'if' statement
to this end? I could to a strtod() - STRing TO Double - on everything, but
if it can't do it, it returns 0 - which the vector components can _also_ be,
so this is no help! :/
I would greatly appreciate any help you could give me.
Alexander Livingstone