Manta Interactive Ray Tracer Development Mailing List

Text archives Help


Re: [Manta] r2145 - trunk/scenes


Chronological Thread 
  • From: Carson Brownlee <brownlee@cs.utah.edu>
  • To: "A.N.M. Imroz Choudhury" <roni@cs.utah.edu>
  • Cc: Thiago Ize <thiago@sci.utah.edu>, manta@sci.utah.edu
  • Subject: Re: [Manta] r2145 - trunk/scenes
  • Date: Mon, 10 Mar 2008 15:31:17 -0600

never heard of .good(). what's the difference between that and just using

while(in>>filename)
         fileNames.push_back(filename);
?

what was wrong with your initial loop was probably that the last word was read in fine at the last iteration of the loop, but then for the next iteration your inner while loop was reached and read in even though there may be nothing left to read.
Carson


On Mar 10, 2008, at 1:13 PM, A.N.M. Imroz Choudhury wrote:

Generally, streams become !good() *after* a failure to read (i.e., after
reaching eof and performing another read).  I usually end up writing a
loop like this:

while(true){
 in >> item;
 if(!in.good())
   break;
 fileNames.push_back(item);
}

I think this might be more correct than what you just committed, but I'm
not sure.  STL file streams don't seem to have good idioms for reading
in a loop like this...

roni

On Mon, 2008-03-10 at 11:30, Thiago Ize wrote:
Author: thiago
Date: Mon Mar 10 12:30:34 2008
New Revision: 2145

Modified:
  trunk/scenes/triangleSceneViewer.cc
Log:
My ifstream skills suck. Hopefully this is the
correct way to read in data. This might fix a
bug with the last frame in a .anim file being
repeated twice.


Modified: trunk/scenes/triangleSceneViewer.cc
= = = = = = = = ======================================================================
--- trunk/scenes/triangleSceneViewer.cc (original)
+++ trunk/scenes/triangleSceneViewer.cc Mon Mar 10 12:30:34 2008
@@ -155,7 +155,7 @@
    fileNames.clear();
    //read in data from modelName and
    ifstream in(modelName.c_str());
-    while (in) {
+    while (in.good()) {
      in >> modelName;
      fileNames.push_back(modelName);
    }





Archive powered by MHonArc 2.6.16.

Top of page