ccNormalCompressor.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //##########################################################################
  2. //# #
  3. //# CLOUDCOMPARE #
  4. //# #
  5. //# This program is free software; you can redistribute it and/or modify #
  6. //# it under the terms of the GNU General Public License as published by #
  7. //# the Free Software Foundation; version 2 or later of the License. #
  8. //# #
  9. //# This program is distributed in the hope that it will be useful, #
  10. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  11. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  12. //# GNU General Public License for more details. #
  13. //# #
  14. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  15. //# #
  16. //##########################################################################
  17. #ifndef CC_NORMAL_COMPRESSOR_HEADER
  18. #define CC_NORMAL_COMPRESSOR_HEADER
  19. //Local
  20. #include "qCC_db.h"
  21. #include "ccBasicTypes.h"
  22. //! Normal compressor
  23. class QCC_DB_LIB_API ccNormalCompressor
  24. {
  25. public:
  26. //! Compressed normals quantization level (number of directions: 2^(2*N+3))
  27. /** \warning Never pass a 'constant initializer' by reference
  28. **/
  29. static const unsigned char QUANTIZE_LEVEL = 9; //2097152 normals * 12 bytes = 24 Mb of memory
  30. //! Last valid normal code
  31. static const unsigned MAX_VALID_NORM_CODE = (1 << (QUANTIZE_LEVEL * 2 + 3)) - 1;
  32. //! Null normal code
  33. static const unsigned NULL_NORM_CODE = MAX_VALID_NORM_CODE + 1;
  34. //! Compression algorithm
  35. static unsigned Compress(const PointCoordinateType N[3]);
  36. //! Decompression algorithm
  37. static void Decompress(unsigned index, PointCoordinateType N[3], unsigned char level = QUANTIZE_LEVEL);
  38. //! Inverts a (compressed) normal
  39. static void InvertNormal(CompressedNormType &code);
  40. };
  41. #endif //CC_NORMAL_COMPRESSOR_HEADER