quadricRGBfunctions.h 1.97 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 * quadricLF.h
 *
 *  Created on: Nov 4, 2010
 *      Author: kenneth
 */

#ifndef QUADRICLF_H_
#define QUADRICLF_H_


#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"

using namespace CGoGN;

enum channel {RED=0, GREEN, BLUE};
#define COLCHANNELS 3

template <typename REAL>
class QuadricRGBfunctions {
public:
	typedef Geom::Vector<3,REAL> VEC3;
	typedef Geom::Vector<6,REAL> VEC6;
	typedef Geom::Matrix<6,6,REAL> MATRIX66;

	typedef Geom::Matrix<3,3,REAL> MATRIX33;
	typedef Quadric<REAL> QUADRIC;
	typedef MATRIX33 FRAME;
	typedef Geom::Matrix<3,6,REAL> RGBFUNCTIONS;

private:
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
33
	MATRIX66 A;
Pierre Kraemer's avatar
Pierre Kraemer committed
34 35 36 37 38 39 40 41 42 43
	VEC6 b[COLCHANNELS];
	REAL c[COLCHANNELS];


public:
	static std::string CGoGNnameOfType() ;

	QuadricRGBfunctions();
	QuadricRGBfunctions(int i);
	QuadricRGBfunctions(const QuadricRGBfunctions&);
44
	QuadricRGBfunctions(const RGBFUNCTIONS&, const REAL gamma = REAL(0), const REAL alpha = REAL(0)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
45

46
	virtual ~QuadricRGBfunctions() {} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
47 48 49 50 51 52 53

	REAL operator() (const RGBFUNCTIONS&) const;

	bool findOptimizedRGBfunctions(RGBFUNCTIONS& lff) const;

	void operator += (const QuadricRGBfunctions&) ;
	void operator -= (const QuadricRGBfunctions&) ;
54 55
	void operator *= (const REAL v) ;
	void operator /= (const REAL v) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
56 57 58

	void zero () ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
59 60 61 62 63 64 65 66 67
	friend std::ostream& operator<< (std::ostream &out, const QuadricRGBfunctions& q) {
		out << "quadricRGBf : " << std::endl ;
		out << "q.A" << "= " << q.A << std::endl ;
		for (unsigned int i = 0 ; i < 3 ; ++i) {
			out << "q.b["<<i<<"] = " << q.b[i] << std::endl ;
			out << "q.c["<<i<<"] = " << q.c[i] << std::endl ;
		}
		return out ;
	} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70
	friend std::istream& operator>> (std::istream &in, const QuadricRGBfunctions&) {return in;};

private :
71 72 73 74
	void buildIntegralMatrix_A(MATRIX66 &, const REAL alpha) const;
	void buildIntegralMatrix_b(MATRIX66 &, const REAL alpha) const;
	void buildIntegralMatrix_c(MATRIX66 &, const REAL alpha) const;
	void buildRotateMatrix(MATRIX66 &N, const REAL gamma) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
75 76 77 78 79 80 81

};


#include "quadricRGBfunctions.hpp"

#endif /* QUADRICLF_H_ */