From 66af095d92390fd3abd4f46c965f9ef7319e5089 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Thu, 4 Jun 2015 18:22:40 +0200 Subject: [PATCH] testing Utils --- Apps/Tests/CMakeLists.txt | 3 +- Apps/Tests/Utils/CMakeLists.txt | 18 +++ Apps/Tests/Utils/colorMaps.cpp | 3 + Apps/Tests/Utils/colourConverter.cpp | 14 +++ Apps/Tests/Utils/qem.cpp | 19 ++++ Apps/Tests/Utils/quadricRGBfunctions.cpp | 11 ++ Apps/Tests/Utils/quantization.cpp | 21 ++++ Apps/Tests/Utils/shared_mem.cpp | 17 +++ Apps/Tests/Utils/sphericalHarmonics.cpp | 15 +++ Apps/Tests/Utils/test_utils.cpp | 26 +++++ Apps/Tests/Utils/textures.cpp | 25 ++++ CGoGN/include/Geometry/frame.h | 2 +- CGoGN/include/Utils/colourConverter.h | 18 ++- CGoGN/include/Utils/colourConverter.hpp | 119 +++++++++++--------- CGoGN/include/Utils/qem.hpp | 12 +- CGoGN/include/Utils/quadricRGBfunctions.h | 10 +- CGoGN/include/Utils/quadricRGBfunctions.hpp | 9 ++ CGoGN/include/Utils/quantization.h | 12 +- CGoGN/include/Utils/quantization.hpp | 11 +- CGoGN/include/Utils/textures.hpp | 30 +---- 20 files changed, 289 insertions(+), 106 deletions(-) create mode 100644 Apps/Tests/Utils/CMakeLists.txt create mode 100644 Apps/Tests/Utils/colorMaps.cpp create mode 100644 Apps/Tests/Utils/colourConverter.cpp create mode 100644 Apps/Tests/Utils/qem.cpp create mode 100644 Apps/Tests/Utils/quadricRGBfunctions.cpp create mode 100644 Apps/Tests/Utils/quantization.cpp create mode 100644 Apps/Tests/Utils/shared_mem.cpp create mode 100644 Apps/Tests/Utils/sphericalHarmonics.cpp create mode 100644 Apps/Tests/Utils/test_utils.cpp create mode 100644 Apps/Tests/Utils/textures.cpp diff --git a/Apps/Tests/CMakeLists.txt b/Apps/Tests/CMakeLists.txt index 8ce8ce899..e69e231ab 100644 --- a/Apps/Tests/CMakeLists.txt +++ b/Apps/Tests/CMakeLists.txt @@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 2.6) project(testing) -add_subdirectory(Geometry) add_subdirectory(Algo) +add_subdirectory(Geometry) +add_subdirectory(Utils) #define exec to compile diff --git a/Apps/Tests/Utils/CMakeLists.txt b/Apps/Tests/Utils/CMakeLists.txt new file mode 100644 index 000000000..edfd19a3f --- /dev/null +++ b/Apps/Tests/Utils/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.6) + +project(testing_utils) + +add_executable( test_utils + test_utils.cpp + colorMaps.cpp + colourConverter.cpp + qem.cpp + quadricRGBfunctions.cpp + quantization.cpp +# shared_mem.cpp + sphericalHarmonics.cpp + textures.cpp ) + +target_link_libraries( test_utils + ${CGoGN_LIBS} ${CGoGN_EXT_LIBS}) + diff --git a/Apps/Tests/Utils/colorMaps.cpp b/Apps/Tests/Utils/colorMaps.cpp new file mode 100644 index 000000000..bd2164730 --- /dev/null +++ b/Apps/Tests/Utils/colorMaps.cpp @@ -0,0 +1,3 @@ +// +// TODO template instead of float + diff --git a/Apps/Tests/Utils/colourConverter.cpp b/Apps/Tests/Utils/colourConverter.cpp new file mode 100644 index 000000000..cf54432ec --- /dev/null +++ b/Apps/Tests/Utils/colourConverter.cpp @@ -0,0 +1,14 @@ +#include "Utils/colourConverter.h" + + +template class CGoGN::Utils::ColourConverter; +template class CGoGN::Utils::ColourConverter; + + +int test_colourConverter() +{ + + return 0; +} + + diff --git a/Apps/Tests/Utils/qem.cpp b/Apps/Tests/Utils/qem.cpp new file mode 100644 index 000000000..24121c391 --- /dev/null +++ b/Apps/Tests/Utils/qem.cpp @@ -0,0 +1,19 @@ +#include "Utils/qem.h" + + +template class CGoGN::Utils::Quadric; +template class CGoGN::Utils::Quadric; + +template class CGoGN::Utils::QuadricNd; +template class CGoGN::Utils::QuadricNd; + + +template class CGoGN::Utils::QuadricHF; +template class CGoGN::Utils::QuadricHF; + + +int test_qem() +{ + + return 0; +} diff --git a/Apps/Tests/Utils/quadricRGBfunctions.cpp b/Apps/Tests/Utils/quadricRGBfunctions.cpp new file mode 100644 index 000000000..a36ab4a65 --- /dev/null +++ b/Apps/Tests/Utils/quadricRGBfunctions.cpp @@ -0,0 +1,11 @@ + +#include "Utils/quadricRGBfunctions.h" + +template class CGoGN::Utils::QuadricRGBfunctions; +template class CGoGN::Utils::QuadricRGBfunctions; + +int test_quadricRGBfunctions() +{ + + return 0; +} \ No newline at end of file diff --git a/Apps/Tests/Utils/quantization.cpp b/Apps/Tests/Utils/quantization.cpp new file mode 100644 index 000000000..fd316e0df --- /dev/null +++ b/Apps/Tests/Utils/quantization.cpp @@ -0,0 +1,21 @@ +#include "Utils/quantization.h" +#include "Geometry/vector_gen.h" + +using namespace CGoGN; + +template struct Utils::CodeVector; +template struct Utils::CodeVector; +template struct Utils::CodeVector; + + + +template class Utils::Quantization; +template class Utils::Quantization; +template class Utils::Quantization; + + +int test_quantization() +{ + + return 0; +} diff --git a/Apps/Tests/Utils/shared_mem.cpp b/Apps/Tests/Utils/shared_mem.cpp new file mode 100644 index 000000000..962a27ea2 --- /dev/null +++ b/Apps/Tests/Utils/shared_mem.cpp @@ -0,0 +1,17 @@ +#include "Utils/shared_mem.h" +#include "Geometry/vector_gen.h" + +template class CGoGN::Utils::SharedMemSeg; +template class CGoGN::Utils::SharedMemSeg; +template class CGoGN::Utils::SharedMemSeg; + +template class CGoGN::Utils::SharedMemSeg; + + +int test_shared_mem() +{ + + return 0; +} + + diff --git a/Apps/Tests/Utils/sphericalHarmonics.cpp b/Apps/Tests/Utils/sphericalHarmonics.cpp new file mode 100644 index 000000000..196e8b852 --- /dev/null +++ b/Apps/Tests/Utils/sphericalHarmonics.cpp @@ -0,0 +1,15 @@ +#include "Utils/sphericalHarmonics.h" + + +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; +template class CGoGN::Utils::SphericalHarmonics; + + +int test_sphericalHarmonics() +{ + + return 0; +} + diff --git a/Apps/Tests/Utils/test_utils.cpp b/Apps/Tests/Utils/test_utils.cpp new file mode 100644 index 000000000..7bdd5917e --- /dev/null +++ b/Apps/Tests/Utils/test_utils.cpp @@ -0,0 +1,26 @@ +#include + + +// no header files test function names from cpp files +//extern int test_colorMaps(); +extern int test_colourConverter(); +extern int test_qem(); +extern int test_quadricRGBfunctions(); +extern int test_quantization(); +//extern int test_shared_mem(); +extern int test_sphericalHarmonics(); +extern int test_texture(); + + +int main() +{ + //test_colorMaps(); + test_colourConverter(); + test_qem(); + test_quadricRGBfunctions(); + test_quantization(); +// test_shared_mem(); + test_sphericalHarmonics(); + test_texture(); + return 0; +} diff --git a/Apps/Tests/Utils/textures.cpp b/Apps/Tests/Utils/textures.cpp new file mode 100644 index 000000000..39cb089ec --- /dev/null +++ b/Apps/Tests/Utils/textures.cpp @@ -0,0 +1,25 @@ +#include "Utils/textures.h" + + +template class CGoGN::Utils::Filter<2>; +template class CGoGN::Utils::Filter<3>; + + +template class CGoGN::Utils::ImageData<2, unsigned char>; +template class CGoGN::Utils::Image<2, unsigned char>; +template class CGoGN::Utils::Texture<2, unsigned char>; + +template class CGoGN::Utils::ImageData<2, int>; +template class CGoGN::Utils::Image<2, int>; +template class CGoGN::Utils::Texture<2, int>; + +template class CGoGN::Utils::ImageData<2, double>; +template class CGoGN::Utils::Image<2, double>; +template class CGoGN::Utils::Texture<2, double>; + + +int test_texture() +{ + + return 0; +} \ No newline at end of file diff --git a/CGoGN/include/Geometry/frame.h b/CGoGN/include/Geometry/frame.h index fe8d47e7d..867729f46 100644 --- a/CGoGN/include/Geometry/frame.h +++ b/CGoGN/include/Geometry/frame.h @@ -218,7 +218,7 @@ private : // private constants //static const REAL Zy = -0.685222 ; //static const REAL Zz = 0.339219 ; - // only integral static const cana be init inline in standard C++ (float init is gcc extension) + // only integral static const can be init inline in standard C++ (float init is gcc extension) static const REAL Xx; static const REAL Xy; static const REAL Xz; diff --git a/CGoGN/include/Utils/colourConverter.h b/CGoGN/include/Utils/colourConverter.h index 3973be7a8..923ea16f2 100644 --- a/CGoGN/include/Utils/colourConverter.h +++ b/CGoGN/include/Utils/colourConverter.h @@ -167,13 +167,21 @@ private: // private members private: // private constants // D65 reference white - static constexpr REAL Xn = 0.950456 ; - static constexpr REAL Yn = 1.0 ; - static constexpr REAL Zn = 1.088754 ; + //static constexpr REAL Xn = 0.950456 ; + //static constexpr REAL Yn = 1.0 ; + //static constexpr REAL Zn = 1.088754 ; - static constexpr REAL un = 0.197832 ; - static constexpr REAL vn = 0.468340 ; + //static constexpr REAL un = 0.197832 ; + //static constexpr REAL vn = 0.468340 ; + + // constexpr not supported in VS2013 + static const REAL Xn; + static const REAL Yn; + static const REAL Zn; + + static const REAL un; + static const REAL vn; } ; } // namespace Utils diff --git a/CGoGN/include/Utils/colourConverter.hpp b/CGoGN/include/Utils/colourConverter.hpp index a9e0249aa..3841b3b2d 100644 --- a/CGoGN/include/Utils/colourConverter.hpp +++ b/CGoGN/include/Utils/colourConverter.hpp @@ -22,12 +22,29 @@ * * *******************************************************************************/ +#include + namespace CGoGN { namespace Utils { +template +const REAL ColourConverter::Xn = REAL(0.950456); + +template +const REAL ColourConverter::Yn = REAL(1.0); + +template +const REAL ColourConverter::Zn = REAL(1.088754); + +template +const REAL ColourConverter::un = REAL(0.197832); + +template +const REAL ColourConverter::vn = REAL(0.468340); + template ColourConverter::ColourConverter(const VEC3& col, const enum ColourEncoding& enc) : RGB(NULL), @@ -209,17 +226,17 @@ ColourConverter::convertRGBtoXYZ() { Geom::Matrix<3,3,REAL> M ; - M(0,0) = 0.412453 ; - M(0,1) = 0.357580 ; - M(0,2) = 0.180423 ; + M(0,0) = REAL(0.412453); + M(0, 1) = REAL(0.357580); + M(0, 2) = REAL(0.180423); - M(1,0) = 0.212671 ; - M(1,1) = 0.715160 ; - M(1,2) = 0.072169 ; + M(1, 0) = REAL(0.212671); + M(1, 1) = REAL(0.715160); + M(1, 2) = REAL(0.072169); - M(2,0) = 0.019334 ; - M(2,1) = 0.119193 ; - M(2,2) = 0.950227 ; + M(2, 0) = REAL(0.019334); + M(2, 1) = REAL(0.119193); + M(2, 2) = REAL(0.950227); VEC3 c = M * (*RGB) ; @@ -235,17 +252,17 @@ ColourConverter::convertXYZtoRGB() { Geom::Matrix<3,3,REAL> M ; - M(0,0) = 3.240479 ; - M(0,1) = -1.537150 ; - M(0,2) = -0.498535 ; + M(0, 0) = REAL(3.240479); + M(0, 1) = REAL(-1.537150); + M(0, 2) = REAL(-0.498535); - M(1,0) = -0.969256 ; - M(1,1) = 1.875992 ; - M(1,2) = 0.041556 ; + M(1, 0) = REAL(-0.969256); + M(1, 1) = REAL(1.875992); + M(1, 2) = REAL(0.041556); - M(2,0) = 0.055648 ; - M(2,1) = -0.204043 ; - M(2,2) = 1.057311 ; + M(2, 0) = REAL(0.055648); + M(2, 1) = REAL(-0.204043); + M(2, 2) = REAL(1.057311); VEC3 c = M * (*XYZ) ; @@ -274,7 +291,7 @@ ColourConverter::convertRGBtoHSV() const REAL diff = max - min ; V = max ; - S = max == 0. ? 0 : diff / max ; + S = max == 0.0f ? 0.0f : diff / max ; if (max == min) @@ -312,7 +329,7 @@ ColourConverter::convertHSVtoRGB() const REAL& S = (*HSV)[1] ; const REAL& V = (*HSV)[2] ; - const int i = std::floor(H * 6); + const int i = int(std::floor(H * 6)); const REAL f = H * 6 - i; const REAL p = V * (1 - S); const REAL q = V * (1 - f * S); @@ -355,7 +372,7 @@ ColourConverter::convertRGBtoHSL() REAL& L = c[2] ; const REAL sum = max + min ; - L = sum / 2. ; + L = sum / 2.0f ; if (max == min) { @@ -365,7 +382,7 @@ ColourConverter::convertRGBtoHSL() else { const REAL diff = max - min ; - S = L > 0.5 ? diff / (2 - sum) : diff / sum ; + S = L > 0.5f ? diff / (2 - sum) : diff / sum ; if (max == r) { @@ -401,7 +418,7 @@ ColourConverter::hue2rgb(const REAL& p, const REAL& q, REAL t) if(t < 1/2.) return q ; if(t < 2/3.) - return p + (q - p) * (2/3. - t) * 6 ; + return p + (q - p) * (REAL(2.0/3.0) - t) * 6.0f ; return p ; } @@ -429,9 +446,9 @@ ColourConverter::convertHSLtoRGB() { const REAL q = L < 0.5 ? L * (1 + S) : L + S - L * S; const REAL p = 2 * L - q ; - r = hue2rgb(p, q, H + 1/3.) ; + r = hue2rgb(p, q, H + REAL(1./3.)); g = hue2rgb(p, q, H) ; - b = hue2rgb(p, q, H - 1/3.) ; + b = hue2rgb(p, q, H - REAL(1./3.)) ; } if (RGB != NULL) @@ -452,13 +469,13 @@ ColourConverter::convertXYZtoLuv() REAL Ydiv = Y/Yn ; if (Ydiv > 0.008856) - L = 116.0 * pow(Ydiv,1.0/3.0) - 16.0 ; + L = 116.0f* pow(Ydiv,1.0f/3.0f) - 16.0f ; else // near black - L = 903.3 * Ydiv ; + L = 903.3f * Ydiv ; - REAL den = X + 15.0 * Y + 3 * Z ; - REAL u1 = (4.0 * X) / den ; - REAL v1 = (9.0 * Y) / den ; + REAL den = X + 15.0f * Y + 3 * Z ; + REAL u1 = (4.0f * X) / den ; + REAL v1 = (9.0f * Y) / den ; u = 13*L * (u1 - un) ; v = 13*L * (v1 - vn) ; @@ -479,16 +496,16 @@ ColourConverter::convertLuvToXYZ() REAL &v = (*Luv)[2] ; if (L > 8.0) - Y = pow(((L+16.0) / 116.0),3) ; + Y = pow(((L+16.0f) / 116.0f),3) ; else // near black - Y = Yn * L / 903.3 ; + Y = Yn * L / 903.3f ; - REAL den = 13.0 * L ; + REAL den = 13.0f * L ; REAL u1 = u/den + un ; REAL v1 = v/den + vn ; - den = 4.0*v1 ; - X = Y * 9.0 * u1 / den ; - Z = Y * (12.0 - 3.0*u1 - 20.0*v1) / den ; + den = 4.0f*v1 ; + X = Y * 9.0f * u1 / den ; + Z = Y * (12.0f - 3.0f*u1 - 20.0f*v1) / den ; if (XYZ != NULL) *XYZ = VEC3(X,Y,Z) ; @@ -511,19 +528,19 @@ ColourConverter::convertXYZtoLab() static REAL f(REAL x) { if (x > 0.008856) - return pow(x,1.0/3.0) ; + return pow(x,1.0f/3.0f) ; else - return 7.787 * x + 16.0/116.0 ; + return 7.787f * x + 16.0f/116.0f ; } } ; if (Y > 0.008856) - L = 116.0f * pow(Y,1.0f/3.0) - 16 ; + L = 116.0f * pow(Y,1.0f/3.0f) - 16 ; else // near black - L = 903.3 * Y ; + L = 903.3f * Y ; - a = 500.0 * (Local::f(X/Xn) - Local::f(Y/Yn)) ; - b = 200.0 * (Local::f(Y/Yn) - Local::f(Z/Zn)) ; + a = 500.0f * (Local::f(X/Xn) - Local::f(Y/Yn)) ; + b = 200.0f * (Local::f(Y/Yn) - Local::f(Z/Zn)) ; if (Lab != NULL) *Lab = VEC3(L,a,b) ; @@ -545,21 +562,21 @@ ColourConverter::convertLabToXYZ() { static REAL f(REAL x) { - if (x > 0.206893) - return pow(x,3.0) ; + if (x > 0.206893f) + return pow(x,3.0f) ; else - return x / 7.787 - 16.0/903.3 ; + return x / 7.787f - REAL(16.0/903.3) ; } } ; - if (L > 8.0) - Y = pow(((L+16.0) / 116.0),3) ; + if (L > 8.0f) + Y = pow(((L+16.0f) / 116.0f),3) ; else // near black - Y = L / 903.3 ; + Y = L / 903.3f ; - REAL nom = (L+16.0) / 116.0 ; - X = Xn * Local::f( nom + a/500.0) ; - Z = Zn * Local::f( nom - b/200.0) ; + REAL nom = (L+16.0f) / 116.0f ; + X = Xn * Local::f( nom + a/500.0f) ; + Z = Zn * Local::f( nom - b/200.0f) ; if (XYZ != NULL) *XYZ = VEC3(X,Y,Z) ; diff --git a/CGoGN/include/Utils/qem.hpp b/CGoGN/include/Utils/qem.hpp index 222aff553..148dfe996 100644 --- a/CGoGN/include/Utils/qem.hpp +++ b/CGoGN/include/Utils/qem.hpp @@ -263,7 +263,7 @@ QuadricNd::operator() (const VECNp& v) const for (unsigned int i = 0 ; i < N ; ++i) hv[i] = v[i] ; - return evaluate(v) ; + return evaluate(hv) ; // v instead of hv !!! } template @@ -340,7 +340,7 @@ template QuadricHF::QuadricHF(const Geom::Tensor3d* T, const REAL& gamma, const REAL& alpha): m_noAlphaRot(fabs(alpha) < 1e-13) { - const unsigned int nbcoefs = ((T[0].order() + 1) * (T[0].order() + 2)) / 2. ; + const unsigned int nbcoefs = int(((T[0].order() + 1) * (T[0].order() + 2)) / 2.0f ); // 2D rotation const Geom::Matrix33d R = buildRotateMatrix(gamma) ; @@ -469,7 +469,7 @@ QuadricHF& QuadricHF::operator /= (const REAL& v) { std::cout << "Warning: QuadricHF::operator /= should not be used !" << std::endl ; - const REAL& inv = 1. / v ; + const REAL& inv = 1.0f / v ; (*this) *= inv ; @@ -538,7 +538,7 @@ QuadricHF::evalR3(const std::vector& coefs) const for (unsigned int i = 0 ; i < coefs.size() ; ++i) tmp[i] = coefs[i][c] ; res[c] = tmp.transpose() * m_A * tmp ; // A - res[c] -= 2. * (m_b[c]).transpose() * tmp ; // - 2b + res[c] -= 2.0f * (m_b[c]).transpose() * tmp ; // - 2b res[c] += m_c[c] ; // + c } @@ -1192,8 +1192,8 @@ template Geom::Tensor3d* QuadricHF::tensorsFromCoefs(const std::vector& coefs) { - const unsigned int& N = coefs.size() ; - const unsigned int& degree = (sqrt(1+8*N) - 3) / REAL(2) ; + unsigned int N = (unsigned int)(coefs.size()) ; + unsigned int degree = (unsigned int)((sqrt(1 + 8 * N) - 3.0) / 2.0); Geom::Tensor3d *A = new Geom::Tensor3d[3] ; for (unsigned int col = 0 ; col < 3 ; ++col) diff --git a/CGoGN/include/Utils/quadricRGBfunctions.h b/CGoGN/include/Utils/quadricRGBfunctions.h index 10c33a5a8..5ceec45c2 100644 --- a/CGoGN/include/Utils/quadricRGBfunctions.h +++ b/CGoGN/include/Utils/quadricRGBfunctions.h @@ -30,11 +30,16 @@ #include "Geometry/matrix.h" #include "Utils/cgognStream.h" -using namespace CGoGN; +namespace CGoGN +{ +namespace Utils +{ + enum channel {RED=0, GREEN, BLUE}; #define COLCHANNELS 3 + template class QuadricRGBfunctions { public: @@ -92,6 +97,9 @@ private : }; +} +} + #include "quadricRGBfunctions.hpp" #endif /* QUADRICLF_H_ */ diff --git a/CGoGN/include/Utils/quadricRGBfunctions.hpp b/CGoGN/include/Utils/quadricRGBfunctions.hpp index 30579041f..1e170ad08 100644 --- a/CGoGN/include/Utils/quadricRGBfunctions.hpp +++ b/CGoGN/include/Utils/quadricRGBfunctions.hpp @@ -25,6 +25,12 @@ #ifndef QUADRICLF_HPP_ #define QUADRICLF_HPP_ +namespace CGoGN +{ + +namespace Utils +{ + template std::string QuadricRGBfunctions::CGoGNnameOfType() { return std::string("QuadricColFuncs"); @@ -447,4 +453,7 @@ void QuadricRGBfunctions::zero () { } } + +} +} #endif /* QUADRICLF_HPP_ */ diff --git a/CGoGN/include/Utils/quantization.h b/CGoGN/include/Utils/quantization.h index d6f78fbf0..1d99d6cca 100644 --- a/CGoGN/include/Utils/quantization.h +++ b/CGoGN/include/Utils/quantization.h @@ -25,6 +25,9 @@ #ifndef __QUANTIZATION_H__ #define __QUANTIZATION_H__ +#include +#include + #define epsSplitVector 0.00001f #define epsilonDistortion 0.0001f @@ -35,10 +38,7 @@ namespace CGoGN { -namespace Algo -{ - -namespace PMesh +namespace Utils { template @@ -101,9 +101,7 @@ private: } ; -} //namespace PMesh - -} //namespace Algo +} //namespace Utils } //namespace CGoGN diff --git a/CGoGN/include/Utils/quantization.hpp b/CGoGN/include/Utils/quantization.hpp index 07bc6165e..a805fcb6c 100644 --- a/CGoGN/include/Utils/quantization.hpp +++ b/CGoGN/include/Utils/quantization.hpp @@ -22,15 +22,14 @@ * * *******************************************************************************/ +#include "Utils/cgognStream.h" + #include namespace CGoGN { -namespace Algo -{ - -namespace PMesh +namespace Utils { template @@ -378,8 +377,6 @@ float Quantization::determinant(float* matrice) } } -} //namespace PMesh - -} //namespace Algo +} //namespace Utils } //namespace CGoGN diff --git a/CGoGN/include/Utils/textures.hpp b/CGoGN/include/Utils/textures.hpp index 7a1df46d2..e3f8ff20d 100644 --- a/CGoGN/include/Utils/textures.hpp +++ b/CGoGN/include/Utils/textures.hpp @@ -47,14 +47,10 @@ m_size(img.m_size), m_sizeSub(img.m_sizeSub), m_localAlloc(true) { - if (img.m_qimg == NULL) + if (img.m_data_ptr != NULL) { - if (img.m_data_ptr != NULL) - { - m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; - memcpy(m_data_ptr, img.m_data_ptr, sizeof(TYPE)*m_sizeSub[DIM-1]); - this->m_qimg = NULL; - } + m_data_ptr = new TYPE[m_sizeSub[DIM-1]]; + memcpy(m_data_ptr, img.m_data_ptr, sizeof(TYPE)*m_sizeSub[DIM-1]); } } @@ -113,11 +109,6 @@ void ImageData::computeSub() template < unsigned int DIM, typename TYPE > void ImageData::create(TYPE* data, const COORD& size) { - // first free old image if exist - if (this->m_qimg != NULL) - { - delete this->m_qmg; - } else if (m_data_ptr!=NULL) { delete[] m_data_ptr; @@ -126,7 +117,6 @@ void ImageData::create(TYPE* data, const COORD& size) m_size = size; computeSub(); m_data_ptr = data; - this->m_qimg = NULL; } template < unsigned int DIM, typename TYPE > @@ -273,20 +263,6 @@ Image::~Image() // this->m_data_ptr = NULL; } -/* -template < unsigned int DIM, typename TYPE > -void Image::swap(Image& img) -{ - if ((this->m_qimg != NULL) && (img.m_qimg != NULL)) - { - QImage* ptr = this->m_qimg; - this->m_qimg = img.m_qimg; - img.m_qimg = ptr; - } - - ImageData::swap(img); -} -*/ template < unsigned int DIM, typename TYPE > bool Image::load(const unsigned char *ptr, unsigned int w, unsigned int h, unsigned int bpp) -- GitLab