From 0dc0d88e537d807525c5b209806adb9702b0ac03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 20 Jul 2009 21:01:06 +0200 Subject: [PATCH] Various small fixes in documentation and settings. --- fileUtil.h | 5 +++++ interfaces.h | 12 ++++++++---- kdTree.h | 2 +- modules/root.h | 2 +- modules/saupePredictor.h | 2 +- modules/stdEncoder.cpp | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fileUtil.h b/fileUtil.h index eac7508..4bdf7ec 100644 --- a/fileUtil.h +++ b/fileUtil.h @@ -3,7 +3,9 @@ #include "headers.h" +/** Stores a value in a stream, specialized for various types (portably) */ template inline void put(std::ostream &os,T i); +/** Reconstructs a value from a stream, see ::put function */ template inline T get(std::istream &is); @@ -48,10 +50,12 @@ template<> inline float get(std::istream &is) { return result; } +/** Converts a floating-point value from interval [0,1] to a bit sequence */ inline int float01ToBits(Real f,int bitCount) { int result= (int)std::ldexp(f,bitCount); return result==powers[bitCount] ? result-1 : result; } +/** Converts a bit sequnce to a floating-point value, the inverse to ::float01ToBits function */ inline Real float01FromBits(int bits,int bitCount) { return std::ldexp( Real(bits)+Real(0.5), -bitCount); } @@ -117,6 +121,7 @@ public: } }; +/** Reads a whole file into std::string (\p result), returns \p true on success */ inline bool file2string(const char *name,std::string &result) { using namespace std; ifstream file( name, ios_base::binary|ios_base::in ); diff --git a/interfaces.h b/interfaces.h index 93c97f5..990747e 100644 --- a/interfaces.h +++ b/interfaces.h @@ -21,7 +21,7 @@ namespace MTypes { typedef SMatrix::Const CSMatrix; ///< Used for passing constant pixels typedef std::vector MatrixList; ///< A list of pixel matrices - enum DecodeAct { Clear, Iterate }; ///< Possible decoding actions + enum DecodeAct { Clear, Iterate }; ///< Possible decoding actions \todo name clash, etc. struct PlaneBlock; // declared and described later in the file @@ -67,10 +67,14 @@ struct IRoot: public Interface { * can load in bigger size: dimension == orig_dim*2^\p zoom */ virtual bool fromStream(std::istream &file,int zoom=0) =0; - /** Shorthand: saves an encoded image to a file - returns true on success */ - bool toFile(const char *fileName) { + /** Shorthand: saves an encoded image to a file - returns the number of bytes written + * or \p false on failure */ + int toFile(const char *fileName) { std::ofstream file( fileName, ios_base::binary|ios_base::trunc|ios_base::out ); - return toStream(file); + if ( !toStream(file) ) + return false; + else + return file.tellp(); } /** Shorthand: loads image from a file - returns true on success, see ::fromStream */ bool fromFile(const char *fileName,int zoom=0) { diff --git a/kdTree.h b/kdTree.h index 0d86892..3eca43b 100644 --- a/kdTree.h +++ b/kdTree.h @@ -333,7 +333,7 @@ protected: } } /** Like ::getBounds, but it only works on vectors with indices from [\p beginIDs;\p endIDs) - * instead of [0;::count), \p boundsRes should be preallocated to store the result */ + * instead of [0,::count), \p boundsRes should be preallocated to store the result */ void getBounds(const int *beginIDs,const int *endIDs,Bounds boundsRes) const { using namespace FieldMath; ASSERT(endIDs>beginIDs); diff --git a/modules/root.h b/modules/root.h index a87a267..c0166e9 100644 --- a/modules/root.h +++ b/modules/root.h @@ -42,7 +42,7 @@ class MRoot: public IRoot { desc: "Maximum domain count for level 2 range blocks\n" "(for this purpose are different rotations\n" "of one domain counted as different domains)", - type: settingInt(0,15,30,IntLog2) + type: settingInt(0,18,30,IntLog2) } ) protected: diff --git a/modules/saupePredictor.h b/modules/saupePredictor.h index 7a6fa02..6f22a49 100644 --- a/modules/saupePredictor.h +++ b/modules/saupePredictor.h @@ -22,7 +22,7 @@ class MSaupePredictor: public IStdEncPredictor { }, { label: "Max. predicted part", desc: "The maximal part of domains predicted for a range block", - type: settingInt(-10,-5,0,IntLog2) + type: settingInt(-20,-10,0,IntLog2) } ) protected: diff --git a/modules/stdEncoder.cpp b/modules/stdEncoder.cpp index 7996d6a..a31f5b3 100644 --- a/modules/stdEncoder.cpp +++ b/modules/stdEncoder.cpp @@ -9,7 +9,7 @@ using namespace std; /** Quantizing stuff used by MStdEncoder \relates MStdEncoder */ namespace Quantizer { - /** Quantizes f that belongs to [0;possib/2^scale] into [0;possib-1] */ + /** Quantizes f that belongs to [0,\p possib/2^\p scale] into [0,\p possib-1] */ inline int quantizeByPower(Real f,int scale,int possib) { ASSERT( f>=0 && f<=possib/(Real)powers[scale] ); int result= (int)trunc(ldexp(f,scale)); -- 2.11.4.GIT