Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #14780

Re: Help in reading a .PLY file via C++

From nick_keighley_nospam@hotmail.com
Newsgroups comp.lang.c++
Subject Re: Help in reading a .PLY file via C++
Date 2012-03-06 07:16 -0800
Organization http://groups.google.com
Message-ID <1380722.174.1331047014082.JavaMail.geo-discussion-forums@vbxv4> (permalink)
References <44bef0c5-1d48-4a8a-84e7-bbda052c0113@t6g2000pba.googlegroups.com>

Show all headers | View raw


On Tuesday, March 6, 2012 9:05:23 AM UTC, Sweety Pie wrote:

> I need to read the values from this file and save only the numerical
> ones in a new file. How can I skip the header which is up to
> end_header word? how can read each value and save it
> Please help me
> This is the format of the file:
> ply
> format ascii 1.0
> obj_info is_cyberware_data 1
> obj_info is_mesh 0
> obj_info is_warped 0

<snip>

> end_header
> -0.06325 0.0359793 0.0420873
> -0.06275 0.0360343 0.0425949
> -0.0645 0.0365101 0.0404362

<snip>

> I have written this code:
> #include <iostream>
> #include <fstream>
> 
> using namespace std;
> 
> int main () {
>   char myString;
>   float aNumber;
> 
>   ifstream myfile ("test.txt");
> 
>   if (! myfile.is_open())
>   {
>      cout << "Error opening file";
>      exit (1);
>   }
> 
>   while (! myfile.eof() )
>   {
>    getline(myfile, myString);
>  if(myString !="end_header");
> 	myFile >> aNumber;
>   }

reread your spec. You want to
   - skip lines until end_header
   - read three numbers per line

that requires two loops, one for the skipping and one for the line reading.

what is the type of myString? What is the type of "end header"? are they the same? What should a C++ programmer normally use to store a string?

Where are you going to store the data? 

>   return 0;
> }
> 
> -----------------------------------------------------------------------------------
> but it is giving error still under getline word, this line (myFile >>
> aNumber;) and under the != operator

meet us half way. Tell us what the errors say.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Help in reading a .PLY file via C++ Sweety Pie <sweetyp198612@gmail.com> - 2012-03-06 01:05 -0800
  Re: Help in reading a .PLY file via C++ "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2012-03-06 11:07 +0100
  Re: Help in reading a .PLY file via C++ Quint Rankid <qbr567@gmail.com> - 2012-03-06 06:51 -0800
  Re: Help in reading a .PLY file via C++ nick_keighley_nospam@hotmail.com - 2012-03-06 07:16 -0800
    Re: Help in reading a .PLY file via C++ Sweety <sharmeen.ibrahim@gmail.com> - 2012-03-06 11:03 -0800
      Re: Help in reading a .PLY file via C++ "Asger Joergensen" <Junk@Asger-P.dk> - 2012-03-06 19:47 +0000
        Re: Help in reading a .PLY file via C++ Sweety <sharmeen.ibrahim@gmail.com> - 2012-03-06 11:57 -0800
          Re: Help in reading a .PLY file via C++ "Asger Joergensen" <Junk@Asger-P.dk> - 2012-03-06 20:18 +0000
            Re: Help in reading a .PLY file via C++ "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2012-03-07 09:42 +0100
              Re: Help in reading a .PLY file via C++ "Asger Joergensen" <Junk@Asger-P.dk> - 2012-03-07 08:51 +0000
              Re: Help in reading a .PLY file via C++ "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-03-07 10:37 +0100
  Re: Help in reading a .PLY file via C++ Christian Gollwitzer <auriocus@gmx.de> - 2012-03-06 21:06 +0100
    Re: Help in reading a .PLY file via C++ Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-03-07 11:32 +0000
      Re: Help in reading a .PLY file via C++ Sweety Pie <sweetyp198612@gmail.com> - 2012-03-07 11:45 -0800
        Re: Help in reading a .PLY file via C++ Quint Rankid <qbr567@gmail.com> - 2012-03-07 17:18 -0800
    Re: Help in reading a .PLY file via C++ Sweety Pie <sweetyp198612@gmail.com> - 2012-03-07 11:35 -0800
  Re: Help in reading a .PLY file via C++ Miles Bader <miles@gnu.org> - 2012-03-08 11:10 +0900

csiph-web