Writing about quick convergency, small fixes.
[fic.git] / interfaces.cpp
blob48ee574fc9f13fd305b639c0cc0ed567b8a51e42
1 #include "interfaces.h"
2 #include "fileUtil.h"
4 using namespace std;
6 const IColorTransformer::Plane IColorTransformer::Plane::Empty(0,-1,-1,-1,0,UpdateInfo());
8 void IQuality2SquareError::completeSquareRangeErrors
9 ( float quality, int levelEnd, float *errors ) {
10 assert( checkBoundsFunc<float>(0,quality,1)==quality && levelEnd>2 && errors );
12 float (IQuality2SquareError::*func)(float,int)= &IQuality2SquareError::rangeSE;
14 for (int level=2; level<levelEnd; ++level)
15 errors[level]= (this->*func)( quality, powers[level*2] );
18 bool IRoot::allSettingsToFile(const char *fileName) {
19 try {
20 ofstream file( fileName, ios_base::binary|ios_base::trunc|ios_base::out );
21 file.exceptions( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
22 put( file, SettingsMagic );
23 saveAllSettings(file);
24 return true;
25 } catch(exception &e) {
26 return false;
30 bool IRoot::allSettingsFromFile(const char *fileName) {
31 assert(getMode()==Clear);
32 try {
33 ifstream file( fileName, ios_base::binary|ios_base::in );
34 file.exceptions( ifstream::eofbit | ifstream::failbit | ifstream::badbit );
35 if (get<Uint16>(file)!=SettingsMagic)
36 return false;
37 loadAllSettings(file);
38 return true;
39 } catch(exception &e) {
40 return false;