Quantization.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @file Quantization.cpp
  3. * @brief Quantization of one-dimensional signals with a standard range of [0,1] (Implementation)
  4. * @author Erik Rodner, Alexander Freytag
  5. * @date 01/09/2012
  6. */
  7. #include <iostream>
  8. #include "Quantization.h"
  9. using namespace NICE;
  10. Quantization::Quantization( )
  11. {
  12. this->ui_numBins = 1;
  13. }
  14. Quantization::Quantization( uint _numBins,
  15. NICE::Vector * v_upperBounds
  16. )
  17. {
  18. }
  19. Quantization::~Quantization()
  20. {
  21. }
  22. uint Quantization::getNumberOfBins() const
  23. {
  24. return this->ui_numBins;
  25. }
  26. // ---------------------- STORE AND RESTORE FUNCTIONS ----------------------
  27. void Quantization::restore ( std::istream & _is,
  28. int _format
  29. )
  30. {
  31. if ( _is.good() )
  32. {
  33. std::string tmp;
  34. bool b_endOfBlock ( false ) ;
  35. while ( !b_endOfBlock )
  36. {
  37. _is >> tmp; // start of block
  38. if ( this->isEndTag( tmp, "Quantization" ) )
  39. {
  40. b_endOfBlock = true;
  41. continue;
  42. }
  43. tmp = this->removeStartTag ( tmp );
  44. if ( tmp.compare("ui_numBins") == 0 )
  45. {
  46. _is >> this->ui_numBins;
  47. }
  48. else
  49. {
  50. std::cerr << "WARNING -- unexpected Quantization object -- " << tmp << " -- for restoration... aborting" << std::endl;
  51. throw;
  52. }
  53. _is >> tmp; // end of block
  54. tmp = this->removeEndTag ( tmp );
  55. }
  56. }
  57. else
  58. {
  59. std::cerr << "Quantization::restore -- InStream not initialized - restoring not possible!" << std::endl;
  60. }
  61. }
  62. void Quantization::store ( std::ostream & _os,
  63. int _format
  64. ) const
  65. {
  66. // show starting point
  67. _os << this->createStartTag( "Quantization" ) << std::endl;
  68. _os << this->createStartTag( "ui_numBins" ) << std::endl;
  69. _os << this->ui_numBins << std::endl;
  70. _os << this->createEndTag( "ui_numBins" ) << std::endl;
  71. // done
  72. _os << this->createEndTag( "Quantization" ) << std::endl;
  73. }