Commit 167905bb authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

updated comments

parent 7a24e258
...@@ -25,26 +25,21 @@ ...@@ -25,26 +25,21 @@
#ifndef __COLOURCONVERTER_H__ #ifndef __COLOURCONVERTER_H__
#define __COLOURCONVERTER_H__ #define __COLOURCONVERTER_H__
#include <iostream>
#include "Geometry/vector_gen.h" #include "Geometry/vector_gen.h"
#include "Geometry/matrix.h" #include "Geometry/matrix.h"
#include "Utils/cgognStream.h"
// #define DISPLAY
namespace CGoGN { namespace CGoGN {
namespace Utils { namespace Utils {
/** /*!
* Supported colour spaces * \class ColourConverter
*/ * \brief Class for switching between different tri-channel color-spaces
enum ColourEncoding *
{
C_RGB = 0,
C_XYZ = 1,
C_Luv = 2,
C_Lab = 3
} ;
/**
* Class for colour conversions between the enumerated colour spaces. * Class for colour conversions between the enumerated colour spaces.
* Usage : * Usage :
* VEC3 colRGB ; // current colour in RGB for example * VEC3 colRGB ; // current colour in RGB for example
...@@ -56,34 +51,45 @@ enum ColourEncoding ...@@ -56,34 +51,45 @@ enum ColourEncoding
template <typename REAL> template <typename REAL>
class ColourConverter class ColourConverter
{ {
public: // types public: // types
typedef Geom::Vector<3,REAL> VEC3 ; /**
* \enum ColourEncoding
* Supported colour spaces
*/
enum ColourEncoding
{
C_RGB = 0,
C_XYZ = 1,
C_Luv = 2,
C_Lab = 3
} ;
typedef Geom::Vector<3,REAL> VEC3 ; /*!< Triplet for color encoding */
public: // methods public: // methods
/** /**
* Constructor * \brief Constructor
* @param col a VEC3 colour * @param col a VEC3 colour
* @param enc the colour space of provided colour * @param enc the colour space of provided colour
*/ */
ColourConverter(VEC3 col, enum ColourEncoding enc) ; ColourConverter(const VEC3& col, const enum ColourEncoding& enc) ;
/** /**
* Destructor * \brief Destructor
*/ */
~ColourConverter() ; ~ColourConverter() ;
/** /**
* getR * \brief getR
* @return original value (in its original space) * @return original value (in its original space)
*/ */
VEC3 getOriginal() ; VEC3 getOriginal() ;
/** /**
* getR * \brief getR
* @return enc value of provided colour * @return value of provided colour
*/ */
VEC3 getColour(enum ColourEncoding enc) ; VEC3 getColour(enum ColourEncoding enc) ;
/** /**
* getR * \brief getR
* @return RGB value of provided colour * @return RGB value of provided colour
*/ */
VEC3 getRGB() ; VEC3 getRGB() ;
...@@ -104,10 +110,7 @@ public: // methods ...@@ -104,10 +110,7 @@ public: // methods
VEC3 getXYZ() ; VEC3 getXYZ() ;
public: // members public: // members
/** enum ColourEncoding originalEnc ; /*!< Colour space of original (unaltered) data */
* Colour space of original (unaltered) data
*/
enum ColourEncoding originalEnc ;
private: // private members private: // private members
VEC3 *RGB ; VEC3 *RGB ;
...@@ -126,7 +129,6 @@ private: // private members ...@@ -126,7 +129,6 @@ private: // private members
void convertLabToXYZ() ; void convertLabToXYZ() ;
private: // private constants private: // private constants
// D65 reference white // D65 reference white
static const REAL Xn = 0.950456 ; static const REAL Xn = 0.950456 ;
static const REAL Yn = 1.0 ; static const REAL Yn = 1.0 ;
......
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
*******************************************************************************/ *******************************************************************************/
namespace CGoGN { namespace CGoGN {
namespace Utils { namespace Utils {
template<typename REAL> template<typename REAL>
ColourConverter<REAL>::ColourConverter(VEC3 col, enum ColourEncoding enc) : ColourConverter<REAL>::ColourConverter(const VEC3& col, const enum ColourEncoding& enc) :
RGB(NULL), RGB(NULL),
Luv(NULL), Luv(NULL),
Lab(NULL), Lab(NULL),
...@@ -36,26 +37,34 @@ ColourConverter<REAL>::ColourConverter(VEC3 col, enum ColourEncoding enc) : ...@@ -36,26 +37,34 @@ ColourConverter<REAL>::ColourConverter(VEC3 col, enum ColourEncoding enc) :
switch(originalEnc) { switch(originalEnc) {
case(C_RGB): case(C_RGB):
if (!(-0.001 < col[0] && col[0] < 1.001 && -0.001 < col[1] && col[1] < 1.001 && -0.001 < col[2] && col[2] < 1.001)) #ifdef DEBUG
CGoGNerr << "Warning : an unvalid RGB color was entered in ColourConverter constructor" << CGoGNendl ; if (!(-0.001 < col[0] && col[0] < 1.001 && -0.001 < col[1] && col[1] < 1.001 && -0.001 < col[2] && col[2] < 1.001))
std::cerr << "Warning : an unvalid RGB color was entered in ColourConverter constructor" << std::endl ;
#endif
RGB = new VEC3(col) ; RGB = new VEC3(col) ;
break ; break ;
case (C_Luv) : case (C_Luv) :
if (!(-0.001 < col[0] && col[0] < 100.001 && -83.001 < col[1] && col[1] < 175.001 && -134.001 < col[2] && col[2] < 108.001)) #ifdef DEBUG
CGoGNerr << "Warning : an unvalid Luv color was entered in ColourConverter constructor" << CGoGNendl ; if (!(-0.001 < col[0] && col[0] < 100.001 && -83.001 < col[1] && col[1] < 175.001 && -134.001 < col[2] && col[2] < 108.001))
std::cerr << "Warning : an unvalid Luv color was entered in ColourConverter constructor" << std::endl ;
#endif
Luv = new VEC3(col) ; Luv = new VEC3(col) ;
break ; break ;
case (C_XYZ) : case (C_XYZ) :
if (!(-0.001 < col[0] && col[0] < 1.001 && -0.001 < col[1] && col[1] < 1.001 && -0.001 < col[2] && col[2] < 1.001)) #ifdef DEBUG
CGoGNerr << "Warning : an unvalid XYZ color was entered in ColourConverter constructor" << CGoGNendl ; if (!(-0.001 < col[0] && col[0] < 1.001 && -0.001 < col[1] && col[1] < 1.001 && -0.001 < col[2] && col[2] < 1.001))
std::cerr << "Warning : an unvalid XYZ color was entered in ColourConverter constructor" << std::endl ;
#endif
XYZ = new VEC3(col) ; XYZ = new VEC3(col) ;
break ; break ;
case (C_Lab) : case (C_Lab) :
if (!(-0.001 < col[0] && col[0] < 100.001 && -86.001 < col[1] && col[1] < 98.001 && -108.001 < col[2] && col[2] < 95.001)) #ifdef DEBUG
CGoGNerr << "Warning : an unvalid Lab color was entered in ColourConverter constructor" << CGoGNendl ; if (!(-0.001 < col[0] && col[0] < 100.001 && -86.001 < col[1] && col[1] < 98.001 && -108.001 < col[2] && col[2] < 95.001))
std::cerr << "Warning : an unvalid Lab color was entered in ColourConverter constructor" << std::endl ;
#endif
Lab = new VEC3(col) ; Lab = new VEC3(col) ;
break ; break ;
} }
...@@ -281,8 +290,10 @@ void ColourConverter<REAL>::convertLabToXYZ() { ...@@ -281,8 +290,10 @@ void ColourConverter<REAL>::convertLabToXYZ() {
template<typename REAL> template<typename REAL>
bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncoding to) { bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncoding to) {
if (to == from) { if (to == from) {
CGoGNerr << "ColourConverter::convert(from,to) : conversion into same colour space" << CGoGNendl ; #ifdef DEBUG
return false ; std::cout << "WARNING ColourConverter::convert(from,to) : conversion into same colour space" << std::endl ;
#endif
return true ;
} }
switch(from) { switch(from) {
...@@ -305,7 +316,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin ...@@ -305,7 +316,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin
convertXYZtoLab() ; convertXYZtoLab() ;
break ; break ;
default : default :
CGoGNerr << "Colour conversion not supported" << CGoGNendl ; std::cerr << "Colour conversion not supported" << std::endl ;
return false ; return false ;
} }
break ; break ;
...@@ -333,7 +344,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin ...@@ -333,7 +344,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin
} }
break ; break ;
default : default :
CGoGNerr << "Colour conversion not supported" << CGoGNendl ; std::cerr << "Colour conversion not supported" << std::endl ;
return false ; return false ;
} }
break ; break ;
...@@ -353,7 +364,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin ...@@ -353,7 +364,7 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin
convertXYZtoLab() ; convertXYZtoLab() ;
break ; break ;
default : default :
CGoGNerr << "Colour conversion not supported" << CGoGNendl ; std::cerr << "Colour conversion not supported" << std::endl ;
return false ; return false ;
} }
break ; break ;
...@@ -381,22 +392,21 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin ...@@ -381,22 +392,21 @@ bool ColourConverter<REAL>::convert(enum ColourEncoding from, enum ColourEncodin
} }
break ; break ;
default : default :
CGoGNerr << "Colour conversion not supported" << CGoGNendl ; std::cerr << "Colour conversion not supported" << std::endl ;
return false ; return false ;
} }
break ; break ;
default : default :
CGoGNerr << "Colour conversion not supported" << CGoGNendl ; std::cerr << "Colour conversion not supported" << std::endl ;
return false ; return false ;
} }
return true ; return true ;
} }
} // namespace Utils } // namespace Utils
} // namespace CGoGN } // namespace CGoGN
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment