Quantization.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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::size() const
  23. {
  24. return this->ui_numBins;
  25. }
  26. uint Quantization::getNumberOfBins() const
  27. {
  28. return this->ui_numBins;
  29. }
  30. // ---------------------- STORE AND RESTORE FUNCTIONS ----------------------
  31. void Quantization::restore ( std::istream & _is,
  32. int _format
  33. )
  34. {
  35. if ( _is.good() )
  36. {
  37. std::string tmp;
  38. bool b_endOfBlock ( false ) ;
  39. while ( !b_endOfBlock )
  40. {
  41. _is >> tmp; // start of block
  42. if ( this->isEndTag( tmp, "Quantization" ) )
  43. {
  44. b_endOfBlock = true;
  45. continue;
  46. }
  47. tmp = this->removeStartTag ( tmp );
  48. if ( tmp.compare("ui_numBins") == 0 )
  49. {
  50. _is >> this->ui_numBins;
  51. }
  52. else
  53. {
  54. std::cerr << "WARNING -- unexpected Quantization object -- " << tmp << " -- for restoration... aborting" << std::endl;
  55. throw;
  56. }
  57. _is >> tmp; // end of block
  58. tmp = this->removeEndTag ( tmp );
  59. }
  60. }
  61. else
  62. {
  63. std::cerr << "Quantization::restore -- InStream not initialized - restoring not possible!" << std::endl;
  64. }
  65. }
  66. void Quantization::store ( std::ostream & _os,
  67. int _format
  68. ) const
  69. {
  70. // show starting point
  71. _os << this->createStartTag( "Quantization" ) << std::endl;
  72. _os << this->createStartTag( "ui_numBins" ) << std::endl;
  73. _os << this->ui_numBins << std::endl;
  74. _os << this->createEndTag( "ui_numBins" ) << std::endl;
  75. // done
  76. _os << this->createEndTag( "Quantization" ) << std::endl;
  77. }