From 8950a71544a120e4bb854df3f2060dc8a128ba7d Mon Sep 17 00:00:00 2001 From: jpr Date: Mon, 24 Jul 2006 16:36:45 +0000 Subject: [PATCH] Sometimes, two values are *not separated by a white space. Fortunately, the second one is negative. I had better to rewrite atof (?!) eg "-0.00801272 0.0320147-7.09668e-005 -0.0501062 -0.0879057 -0.101794" --- Example/DenseMultiFramesToDicom.cxx | 59 ++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/Example/DenseMultiFramesToDicom.cxx b/Example/DenseMultiFramesToDicom.cxx index 97dd64f2..f8e408e3 100755 --- a/Example/DenseMultiFramesToDicom.cxx +++ b/Example/DenseMultiFramesToDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: DenseMultiFramesToDicom.cxx,v $ Language: C++ - Date: $Date: 2006/07/21 17:18:27 $ - Version: $Revision: 1.2 $ + Date: $Date: 2006/07/24 16:36:45 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -263,8 +263,8 @@ All pixels with zero strain values are outside the masks. std::cout << nx << " " << ny << " " << nf << std::endl; // Skip 4 lines. - for (int k=0; k<4; k++) - { + for (int k=0; k<5; k++) // 5 + { std::cout << "Comment line number : " << k << std::endl; std::getline(from, str1); std::cout << str1 << std::endl; } @@ -280,42 +280,73 @@ All pixels with zero strain values are outside the masks. for (int l=0; l> str1; + } //end eatwhite(from); + // std::cout << "------end eatwhite-----" << std::endl; + + // from >> str1; + // trouble : whe space is missing "-0.0990263-8.8778" + // is not interpreted as TWO values :-( + + int first = 1; + char previous = 'z'; + for(;;) + { + from.get(c); + //std::cout << "[" << c << "]" << std::endl; + if ( c == ' ') + break; + if ( first != 1 && c == '-' && previous != 'e') + { + from.putback(c); + std::cout << " One more gauffre in frame:" << std::dec << l + << ", line : " << j << " element " << i << std::endl; + break; + } + + first=0; + previous = c; + str1=str1+c; + } + val = (float)atof(str1.c_str()); - std::cout << " " << val; + std::cout << " " << val; *(f+ /*l*nx*ny + */j*nx+i) = val; if(from.eof()) { - std::cout << "Missing values at [" << j <<"," << i << "]" + std::cout << "Missing values at [" << std::dec << j <<"," << i << "]" << std::endl; break; } - l++; + //l++; } - std::cout << std::endl; + //std::cout << std::endl; //std::cout << std::endl << " line nb : " << j // << " line length : " << l << std::endl; @@ -475,7 +506,7 @@ std::cout << "Frame nb " << l << std::endl; if(from.eof()) { - std::cout << "Missing values at [" << j <<"," << i << "]" + std::cout << "Missing values at [" << std::dec << j <<"," << i << "]" << std::endl; break; } -- 2.45.2