fshake3d
0.0.1
FreeformDensity3DSurfaceEditor
|
00001 #include "io_fmix.hpp" 00002 const char* header1 = "# fmix file"; 00003 const char* header2 = "xmean xsd ymean ysd alpha"; 00004 void io_fmix::save(std::ostream& os, FunctionMixer& fm) 00005 { 00006 /* 00007 os << header1 << "\n" 00008 << header2 << "\n"; 00009 */ 00010 os.precision(64); 00011 size_t n = fm.getHotSpotCount(); 00012 for (size_t i = 0; i < n ; ++i ) 00013 { 00014 HotSpot& hs = fm.getHotSpotAtIndex(i); 00015 os << std::scientific << hs.getXMean() << " " 00016 << hs.getXSD() << " " 00017 << hs.getYMean() << " " 00018 << hs.getYSD() << " " 00019 << hs.getAlpha() << "\n"; 00020 } 00021 } 00022 void io_fmix::load(std::istream& is, FunctionMixer& fm) 00023 { 00024 /* 00025 char mLineBuf[1024]; 00026 size_t nheaderlines = 2; 00027 while (nheaderlines--) 00028 { 00029 is.getline( mLineBuf, sizeof(mLineBuf) ); 00030 00031 } 00032 if (strcmp(mLineBuf,header1) != 0) 00033 return; 00034 */ 00035 fm.clear(); 00036 while ( ! is.eof() ) 00037 { 00038 double xmean,xsd,ymean,ysd, alpha; 00039 is >> std::scientific >> xmean 00040 >> xsd 00041 >> ymean 00042 >> ysd 00043 >> alpha; 00044 if ( !is.fail() ) 00045 { 00046 fm.addHotSpot( new HotSpot(xmean,ymean,xsd,ysd,alpha) ); 00047 } 00048 } 00049 fm.updateElevationGrid(); 00050 } 00051