Commit 1c7c7d22 authored by Sylvain Thery's avatar Sylvain Thery

add Container to compile testing

parent bdbe88ff
......@@ -9,9 +9,8 @@
using namespace CGoGN;
template class Algo::LinearSolving::Coeff<float>;
template class Algo::LinearSolving::Coeff<double>;
// Vec3 ?
template struct Algo::LinearSolving::Coeff<float>;
template struct Algo::LinearSolving::Coeff<double>;
struct PFP1 : public PFP_DOUBLE
......
......@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.6)
project(testing)
add_subdirectory(Algo)
add_subdirectory(Container)
add_subdirectory(Geometry)
add_subdirectory(Utils)
......
cmake_minimum_required(VERSION 2.6)
project(testing_container)
add_executable( test_container
test_container.cpp
attributeContainer.cpp
attributeMultiVector.cpp
containerBrowser.cpp )
target_link_libraries( test_container
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
#include "Container/attributeContainer.h"
#include "Geometry/vector_gen.h"
using namespace CGoGN;
// char instantiation
template AttributeMultiVector<char>* AttributeContainer::addAttribute<char>(const std::string& attribName);
template void AttributeContainer::addAttribute<char>(const std::string& attribName, const std::string& typeName, unsigned int index);
template bool AttributeContainer::removeAttribute<char>(const std::string& attribName);
template bool AttributeContainer::removeAttribute<char>(unsigned int index);
template unsigned int AttributeContainer::getAttributeBlocksPointers<char>(unsigned int attrIndex, std::vector<char*>& vect_ptr, unsigned int& byteBlockSize) const;
template AttributeMultiVector<char>* AttributeContainer::getDataVector<char>(unsigned int attrIndex);
template AttributeMultiVector<char>* AttributeContainer::getDataVector<char>(const std::string& attribName);
template char& AttributeContainer::getData<char>(unsigned int attrIndex, unsigned int eltIndex) ;
template const char& AttributeContainer::getData<char>(unsigned int attrIndex, unsigned int eltIndex) const ;
template void AttributeContainer::setData<char>(unsigned int attrIndex, unsigned int eltIndex, const char& data);
// int instantiation
//
//template AttributeMultiVector<int>* AttributeContainer::addAttribute<int>(const std::string& attribName);
//template void AttributeContainer::addAttribute<int>(const std::string& attribName, const std::string& typeName, unsigned int index);
//template bool AttributeContainer::removeAttribute<int>(const std::string& attribName);
//template bool AttributeContainer::removeAttribute<int>(unsigned int index);
//template unsigned int AttributeContainer::getAttributeBlocksPointers<int>(unsigned int attrIndex, std::vector<int*>& vect_ptr, unsigned int& byteBlockSize) const;
//template AttributeMultiVector<int>* AttributeContainer::getDataVector<int>(unsigned int attrIndex);
//template AttributeMultiVector<int>* AttributeContainer::getDataVector<int>(const std::string& attribName);
//template int& AttributeContainer::getData<int>(unsigned int attrIndex, unsigned int eltIndex);
//template const int& AttributeContainer::getData<int>(unsigned int attrIndex, unsigned int eltIndex) const;
//template void AttributeContainer::setData<int>(unsigned int attrIndex, unsigned int eltIndex, const int& data);
//
//
//// double instantiation
//
//template AttributeMultiVector<double>* AttributeContainer::addAttribute<double>(const std::string& attribName);
//template void AttributeContainer::addAttribute<double>(const std::string& attribName, const std::string& typeName, unsigned int index);
//template bool AttributeContainer::removeAttribute<double>(const std::string& attribName);
//template bool AttributeContainer::removeAttribute<double>(unsigned int index);
//template unsigned int AttributeContainer::getAttributeBlocksPointers<double>(unsigned int attrIndex, std::vector<double*>& vect_ptr, unsigned int& byteBlockSize) const;
//template AttributeMultiVector<double>* AttributeContainer::getDataVector<double>(unsigned int attrIndex);
//template AttributeMultiVector<double>* AttributeContainer::getDataVector<double>(const std::string& attribName);
//template double& AttributeContainer::getData<double>(unsigned int attrIndex, unsigned int eltIndex);
//template const double& AttributeContainer::getData<double>(unsigned int attrIndex, unsigned int eltIndex) const;
//template void AttributeContainer::setData<double>(unsigned int attrIndex, unsigned int eltIndex, const double& data);
//
//
//// Geom::Vec4f instantiation
//
//template AttributeMultiVector<Geom::Vec4f>* AttributeContainer::addAttribute<Geom::Vec4f>(const std::string& attribName);
//template void AttributeContainer::addAttribute<Geom::Vec4f>(const std::string& attribName, const std::string& typeName, unsigned int index);
//template bool AttributeContainer::removeAttribute<Geom::Vec4f>(const std::string& attribName);
//template bool AttributeContainer::removeAttribute<Geom::Vec4f>(unsigned int index);
//template unsigned int AttributeContainer::getAttributeBlocksPointers<Geom::Vec4f>(unsigned int attrIndex, std::vector<Geom::Vec4f*>& vect_ptr, unsigned int& byteBlockSize) const;
//template AttributeMultiVector<Geom::Vec4f>* AttributeContainer::getDataVector<Geom::Vec4f>(unsigned int attrIndex);
//template AttributeMultiVector<Geom::Vec4f>* AttributeContainer::getDataVector<Geom::Vec4f>(const std::string& attribName);
//template Geom::Vec4f& AttributeContainer::getData<Geom::Vec4f>(unsigned int attrIndex, unsigned int eltIndex);
//template const Geom::Vec4f& AttributeContainer::getData<Geom::Vec4f>(unsigned int attrIndex, unsigned int eltIndex) const;
//template void AttributeContainer::setData<Geom::Vec4f>(unsigned int attrIndex, unsigned int eltIndex, const Geom::Vec4f& data);
int test_attributeContainer()
{
return 0;
}
\ No newline at end of file
#include "Container/attributeMultiVector.h"
#include "Geometry/vector_gen.h"
#include "Container/fakeAttribute.h"
using namespace CGoGN;
template class AttributeMultiVector<char>;
template class AttributeMultiVector<unsigned char>;
template class AttributeMultiVector<int>;
template class AttributeMultiVector<unsigned int>;
template class AttributeMultiVector<long int>;
template class AttributeMultiVector<unsigned long int>;
template class AttributeMultiVector<float>;
template class AttributeMultiVector<double>;
template class AttributeMultiVector<Geom::Vec3f>;
template class AttributeMultiVector< NoTypeNameAttribute<std::vector<Geom::Vec2i>::const_iterator> >;
int test_attributeMultiVector()
{
return 0;
}
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Container/containerBrowser.h"
using namespace CGoGN;
template class DartContainerBrowserSelector<EmbeddedMap2>;
template class DartContainerBrowserSelector<EmbeddedMap3>;
template class DartContainerBrowserSelector<EmbeddedGMap2>;
template class ContainerBrowserCellMarked<EmbeddedMap2, VERTEX>;
template class ContainerBrowserCellMarked<EmbeddedMap2, EDGE>;
template class ContainerBrowserCellMarked<EmbeddedMap2, FACE>;
template class ContainerBrowserCellMarked<EmbeddedGMap2, VERTEX>;
template class ContainerBrowserCellMarked<EmbeddedGMap2, EDGE>;
template class ContainerBrowserCellMarked<EmbeddedGMap2, FACE>;
template class ContainerBrowserCellMarked<EmbeddedMap3, VERTEX>;
template class ContainerBrowserCellMarked<EmbeddedMap3, EDGE>;
template class ContainerBrowserCellMarked<EmbeddedMap3, FACE>;
template class ContainerBrowserCellMarked<EmbeddedMap3, VOLUME>;
int test_containerBrowser()
{
return 0;
}
\ No newline at end of file
#include <iostream>
// no header files test function names from cpp files
extern int test_attributeContainer();
extern int test_attributeMultiVector();
extern int test_containerBrowser();
int main()
{
test_attributeContainer();
test_attributeMultiVector();
test_containerBrowser();
return 0;
}
#include <iostream>
#include <Geometry/matrix.h>
#define CGOGN_NO_STATIC_ASSERT 1
#include "Geometry/vector_gen.h"
using namespace CGoGN;
// template instantiation not possible (static assert pb);
template class Geom::Vector<2, short>;
template class Geom::Vector<2, float>;
template class Geom::Vector<2, double>;
template class Geom::Vector<3, short>;
template class Geom::Vector<3, float>;
template class Geom::Vector<3, double>;
template class Geom::Vector<4, short>;
template class Geom::Vector<4, float>;
template class Geom::Vector<4, double>;
template class Geom::Vector<11, short>;
template class Geom::Vector<11, float>;
template class Geom::Vector<11, double>;
int test_vector()
{
......
cmake_minimum_required(VERSION 2.6)
project(testing_utils)
add_executable( test_utils
test_utils.cpp
colorMaps.cpp
......@@ -17,3 +17,4 @@ target_link_libraries( test_utils
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
qt_use_cgogn_modules(test_utils)
#include "Utils/textures.h"
#define CGOGN_NO_STATIC_ASSERT 1
#include "Utils/textures.h"
template class CGoGN::Utils::Filter<1>;
template class CGoGN::Utils::Filter<2>;
template class CGoGN::Utils::Filter<3>;
///////////////// 1 ////////////////////////////////
template class CGoGN::Utils::ImageData<1, unsigned char>;
template class CGoGN::Utils::Image<1, unsigned char>;
template class CGoGN::Utils::Texture<1, unsigned char>;
template class CGoGN::Utils::ImageData<1, int>;
template class CGoGN::Utils::Image<1, int>;
template class CGoGN::Utils::Texture<1, int>;
template class CGoGN::Utils::ImageData<1, double>;
template class CGoGN::Utils::Image<1, double>;
template class CGoGN::Utils::Texture<1, double>;
template class CGoGN::Utils::ImageData<1, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Image<1, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Texture<1, CGoGN::Geom::Vec4f>;
///////////////// 2 //////////////////////////////////////
template class CGoGN::Utils::ImageData<2, unsigned char>;
template class CGoGN::Utils::Image<2, unsigned char>;
......@@ -17,6 +38,27 @@ template class CGoGN::Utils::ImageData<2, double>;
template class CGoGN::Utils::Image<2, double>;
template class CGoGN::Utils::Texture<2, double>;
template class CGoGN::Utils::ImageData<2, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Image<2, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Texture<2, CGoGN::Geom::Vec4f>;
////////////////// 3 /////////////////////////////////////
template class CGoGN::Utils::ImageData<3, unsigned char>;
template class CGoGN::Utils::Image<3, unsigned char>;
template class CGoGN::Utils::Texture<3, unsigned char>;
template class CGoGN::Utils::ImageData<3, int>;
template class CGoGN::Utils::Image<3, int>;
template class CGoGN::Utils::Texture<3, int>;
template class CGoGN::Utils::ImageData<3, double>;
template class CGoGN::Utils::Image<3, double>;
template class CGoGN::Utils::Texture<3, double>;
template class CGoGN::Utils::ImageData<3, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Image<3, CGoGN::Geom::Vec4f>;
template class CGoGN::Utils::Texture<3, CGoGN::Geom::Vec4f>;
int test_texture()
{
......
......@@ -709,7 +709,7 @@ void LoopSubdivision(typename PFP::MAP& map, EMBV& attributs)
{
double beta = betaF(n) ;
temp *= (beta / double(n));
emcp *= (1.0 - beta);
emcp *= (1.0f - beta);
emcp += temp;
}
attributs[*vert] = emcp;
......
......@@ -142,7 +142,7 @@ void AttributeContainer::addAttribute(const std::string& attribName, const std::
m_lineCost += sizeof(T) ;
// resize the new attribute so that it has the same size than others
amv->setNbBlocks(m_holesBlocks.size()) ;
amv->setNbBlocks(uint32(m_holesBlocks.size())) ;
m_nbAttributes++;
}
......@@ -205,7 +205,7 @@ unsigned int AttributeContainer::getAttributeBlocksPointers(unsigned int attrInd
AttributeMultiVector<T>* atm = dynamic_cast<AttributeMultiVector<T>*>(m_tableAttribs[attrIndex]);
assert((atm != NULL) || !"getAttributeBlocksPointers: wrong type");
return atm->getBlocksPointers(vect_ptr, byteBlockSize);
return atm->getBlocksPointers(reinterpret_cast<std::vector<void*>&>(vect_ptr), byteBlockSize);
}
/**************************************
......
......@@ -24,6 +24,7 @@
#include <sstream>
#include <cmath>
#include <cstdlib>
namespace CGoGN
{
......@@ -374,7 +375,7 @@ inline bool Vector<DIM, T>::isNormalized(const T& epsilon) const
template <unsigned int DIM, typename T>
inline bool Vector<DIM, T>::isOrthogonal(const Vector<DIM, T>& v, const T& epsilon) const
{
return (fabs(v * (*this)) < epsilon) ;
return (std::abs(v * (*this)) < epsilon) ;
}
template <unsigned int DIM, typename T>
......@@ -424,9 +425,9 @@ inline bool isNull(T x, int precision)
if (precision == 0)
return (x == 0) ;
else if (precision > 0)
return (fabs(x) < precision) ;
return (std::abs(x) < precision) ;
else
return (precision * fabs(x) < 1) ;
return (precision * std::abs(x) < 1) ;
}
/***
......
......@@ -501,7 +501,7 @@ QuadricHF<REAL>::findOptimizedCoefs(std::vector<VEC3>& coefs)
Eigen::VectorXd tmp(m_b[0].size()) ;
tmp = Ainv * m_b[c] ;
for (unsigned int i = 0 ; i < m_b[c].size() ; ++i)
coefs[i][c] = tmp[i] ;
coefs[i][c] = REAL(tmp[i]) ;
}
return true ;
......@@ -522,9 +522,9 @@ QuadricHF<REAL>::evaluate(const std::vector<VEC3>& coefs) const
res[c] += m_c[c] ; // + c
}
res /= 2*M_PI ; // max integral value over hemisphere
res /= REAL(2*M_PI) ; // max integral value over hemisphere
return (res[0] + res[1] + res[2]) / 3. ;
return (res[0] + res[1] + res[2]) / 3.0f ;
}
template <typename REAL>
......@@ -537,9 +537,9 @@ QuadricHF<REAL>::evalR3(const std::vector<VEC3>& coefs) const
Eigen::VectorXd tmp(coefs.size()) ;
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.0f * (m_b[c]).transpose() * tmp ; // - 2b
res[c] += m_c[c] ; // + c
res[c] = REAL(tmp.transpose() * m_A * tmp) ; // A
res[c] -= REAL(2.0f * (m_b[c]).transpose() * tmp) ; // - 2b
res[c] += REAL(m_c[c]) ; // + c
}
res /= 2*M_PI ; // max integral value over hemisphere
......@@ -573,7 +573,7 @@ QuadricHF<REAL>::rotate(const Geom::Tensor3d& T, const Geom::Matrix33d& R)
std::vector<unsigned int> q ; q.resize(T.order(), 0) ;
for (unsigned int j = 0 ; j < T.nbElem() ; ++j)
{
REAL P = T[j] ;
REAL P = REAL(T[j]) ;
for (unsigned int k = 0 ; k < T.order() ; ++k)
P *= R(q[k],p[k]) ;
S += P ;
......@@ -1188,6 +1188,7 @@ QuadricHF<REAL>::buildLowerLeftIntegralMatrix_C(const REAL& alpha, unsigned int
return C ;
}
template <typename REAL>
Geom::Tensor3d*
QuadricHF<REAL>::tensorsFromCoefs(const std::vector<VEC3>& coefs)
......@@ -1283,7 +1284,7 @@ QuadricHF<REAL>::coefsFromTensors(Geom::Tensor3d* A)
{
const unsigned int& degree = A[0].order() ;
std::vector<VEC3> coefs ;
coefs.resize(((degree + 1) * (degree + 2)) / REAL(2)) ;
coefs.resize(((degree + 1) * (degree + 2)) / 2) ;
std::vector<unsigned int> index ;
index.resize(degree,2) ;
......@@ -1356,4 +1357,3 @@ QuadricHF<REAL>::coefsFromTensors(Geom::Tensor3d* A)
} // Utils
} // CGOGN
......@@ -142,34 +142,34 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_A(MATRIX66 &M, const REAL al
REAL alphaAbs = alpha > 0 ? alpha : -alpha;
const REAL pi = 3.141592 ;
const REAL pi = 3.141592f ;
const REAL cosinus = cos(alpha);
const REAL cosinus = std::cos(alpha);
const REAL cos2 = cosinus*cosinus;
const REAL cos3 = cos2*cosinus;
const REAL sinus = sin(alpha);
const REAL sinAbs = sin(alphaAbs); // = - sin(alpha) si alpha < 0
const REAL sinus = std::sin(alpha);
const REAL sinAbs = std::sin(alphaAbs); // = - sin(alpha) si alpha < 0
// Line 1
M(0,0) = 2.0*(pi-alphaAbs)/5.0f;
M(0,1) = 2.0 * (pi - alphaAbs - cosinus*sinAbs) / 15.0 ;
M(0,0) = 2.0f*(pi-alphaAbs)/5.0f;
M(0,1) = 2.0f * (pi - alphaAbs - cosinus*sinAbs) / 15.0f ;
M(0,2) = 0;
M(0,3) = 0;
M(0,4) = sinAbs*pi / 8.0;
M(0,5) = 2.0*(pi-alphaAbs)/3.0;
M(0,4) = sinAbs*pi / 8.0f;
M(0,5) = 2.0f*(pi-alphaAbs)/3.0f;
// Line 2
M(1,0) = M(0,1);
M(1,1) = (-4.0 * sinAbs*cos3 + 6.0 * (pi - cosinus*sinAbs - alphaAbs)) / 15.0 ;
M(1,1) = (-4.0f * sinAbs*cos3 + 6.0f * (pi - cosinus*sinAbs - alphaAbs)) / 15.0f ;
M(1,2) = REAL(0);
M(1,3) = REAL(0);
M(1,4) = (sinus*cos2*pi + 2*sinus*pi) / 8.0;
M(1,5) = 2.0*(pi-cosinus*sinAbs-alphaAbs)/3.0;
M(1,4) = (sinus*cos2*pi + 2*sinus*pi) / 8.0f;
M(1,5) = 2.0f*(pi-cosinus*sinAbs-alphaAbs)/3.0f;
// LINE 3
M(2,0) = REAL(0);
M(2,1) = REAL(0);
M(2,2) = 2.0*(pi - alphaAbs - cosinus*sinAbs)/15.0;
M(2,2) = 2.0f*(pi - alphaAbs - cosinus*sinAbs)/15.0f;
M(2,3) = pi*sinus/8.0f;
M(2,4) = REAL(0) ;
M(2,5) = REAL(0) ;
......@@ -178,7 +178,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_A(MATRIX66 &M, const REAL al
M(3,0) = REAL(0) ;
M(3,1) = REAL(0) ;
M(3,2) = M(2,3);
M(3,3) = 2.0*(pi-alphaAbs)/3.0 ;
M(3,3) = 2.0f*(pi-alphaAbs)/3.0f ;
M(3,4) = REAL(0) ;
M(3,5) = REAL(0) ;
......@@ -187,8 +187,8 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_A(MATRIX66 &M, const REAL al
M(4,1) = M(1,4) ;
M(4,2) = REAL(0) ;
M(4,3) = REAL(0) ;
M(4,4) = 2.0 * (pi - cosinus*sinAbs - alphaAbs ) / 3.0 ;
M(4,5) = pi*sinus / 2.0 ;
M(4,4) = 2.0f * (pi - cosinus*sinAbs - alphaAbs ) / 3.0f ;
M(4,5) = pi*sinus / 2.0f ;
// Line 6
M(5,0) = M(0,5) ;
......@@ -196,7 +196,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_A(MATRIX66 &M, const REAL al
M(5,2) = REAL(0) ;
M(5,3) = REAL(0) ;
M(5,4) = M(4,5) ;
M(5,5) = 2.0*(pi-alphaAbs);
M(5,5) = 2.0f*(pi-alphaAbs);
}
......@@ -206,7 +206,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_b(MATRIX66 &M, const REAL al
// Int(phi=0..pi)(theta= -alpha..pi) variables*variablesRotated dTheta dPhi * coefs if alpha < 0
REAL alphaAbs = alpha > 0 ? alpha : -alpha;
const REAL pi = 3.141592 ;
const REAL pi = 3.141592f ;
const REAL cosinus = cos(alpha) ;
const REAL cos2 = cosinus*cosinus ;
......@@ -217,25 +217,25 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_b(MATRIX66 &M, const REAL al
const REAL sinAbs = sin(alphaAbs) ; // = - sin(alpha) si alpha < 0
// Line 1
M(0,0) = 2.0*(pi-alphaAbs)/5.0f;
M(0,1) = ( 6*cosinus*sinAbs - 8*sinAbs*cos3 - 2*alphaAbs + 2*pi ) / 15.0 ;
M(0,0) = 2.0f*(pi-alphaAbs)/5.0f;
M(0,1) = ( 6*cosinus*sinAbs - 8*sinAbs*cos3 - 2*alphaAbs + 2*pi ) / 15.0f ;
M(0,2) = 0;
M(0,3) = 0;
M(0,4) = (sinus*pi + 2*pi*cosinus*sinus) / 8.0 ;
M(0,5) = 2.0*(pi-alphaAbs)/3.0;
M(0,4) = (sinus*pi + 2*pi*cosinus*sinus) / 8.0f ;
M(0,5) = 2.0f*(pi-alphaAbs)/3.0f;
// Line 2
M(1,0) = 2 * (pi - cosinus*sinAbs - alphaAbs ) / 15.0 ;
M(1,1) = ( 6*cosinus*sinAbs - 2*alphaAbs + 2*pi - 16*sinAbs*cos5+4*cos2*pi - 4*alphaAbs * cos2 ) / 15.0 ;
M(1,0) = 2 * (pi - cosinus*sinAbs - alphaAbs ) / 15.0f ;
M(1,1) = ( 6*cosinus*sinAbs - 2*alphaAbs + 2*pi - 16*sinAbs*cos5+4*cos2*pi - 4*alphaAbs * cos2 ) / 15.0f ;
M(1,2) = 0;
M(1,3) = 0;
M(1,4) = (sinus*pi + 2* (pi*sinus*cos3+pi*cosinus*sinus)) / 8.0 ;
M(1,5) = 2.0*(pi-cosinus*sinAbs-alphaAbs) / 3.0;
M(1,4) = (sinus*pi + 2* (pi*sinus*cos3+pi*cosinus*sinus)) / 8.0f ;
M(1,5) = 2.0f*(pi-cosinus*sinAbs-alphaAbs) / 3.0f;
// LINE 3
M(2,0) = REAL(0);
M(2,1) = REAL(0);
M(2,2) = 2 * (sinAbs - cosinus*alphaAbs + cosinus*pi - 2*cos2*sinAbs) / 15.0 ;
M(2,2) = 2 * (sinAbs - cosinus*alphaAbs + cosinus*pi - 2*cos2*sinAbs) / 15.0f ;
M(2,3) = pi*sinus / 8.0f;
M(2,4) = REAL(0) ;
M(2,5) = REAL(0) ;
......@@ -243,26 +243,26 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_b(MATRIX66 &M, const REAL al
// Line 4
M(3,0) = REAL(0) ;
M(3,1) = REAL(0) ;
M(3,2) = ( sinus*pi + 2*pi*cosinus*sinus ) / 8.0 ;
M(3,3) = 2.0*(pi-alphaAbs)/3.0 ;
M(3,2) = ( sinus*pi + 2*pi*cosinus*sinus ) / 8.0f ;
M(3,3) = 2.0f*(pi-alphaAbs)/3.0f ;
M(3,4) = REAL(0) ;
M(3,5) = REAL(0) ;
// Line 5
M(4,0) = pi*sinus / 8.0 ;
M(4,1) = (sinus*pi + 4 * sinus * cos4 + 2*pi*cosinus*sinus) / 8.0 ;
M(4,0) = pi*sinus / 8.0f ;
M(4,1) = (sinus*pi + 4 * sinus * cos4 + 2*pi*cosinus*sinus) / 8.0f ;
M(4,2) = REAL(0) ;
M(4,3) = REAL(0) ;
M(4,4) = 2*(sinAbs - cosinus*alphaAbs + cosinus*pi - 2*cos2*sinAbs) / 3.0 ;
M(4,5) = pi*sinus / 2.0 ;
M(4,4) = 2*(sinAbs - cosinus*alphaAbs + cosinus*pi - 2*cos2*sinAbs) / 3.0f ;
M(4,5) = pi*sinus / 2.0f ;
// Line 6
M(5,0) = M(0,5) ;
M(5,1) = 2*cosinus*sinAbs + 2*(pi-4*sinAbs*cos3-alphaAbs) / 3.0 ;
M(5,1) = 2*cosinus*sinAbs + 2*(pi-4*sinAbs*cos3-alphaAbs) / 3.0f ;
M(5,2) = REAL(0) ;
M(5,3) = REAL(0) ;
M(5,4) = sinus*pi / 2.0 + pi*cosinus*sinus ;
M(5,5) = 2.0*(pi-alphaAbs);
M(5,4) = sinus*pi / 2.0f + pi*cosinus*sinus ;
M(5,5) = 2.0f*(pi-alphaAbs);
}
template <typename REAL>
......@@ -272,7 +272,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_c(MATRIX66 &M, const REAL al
REAL alphaAbs = alpha > 0 ? alpha : -alpha;
const REAL pi = 3.141592 ;
const REAL pi = 3.141592f ;
const REAL cosinus = cos(alpha);
const REAL cos2 = cosinus*cosinus ;
......@@ -283,25 +283,25 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_c(MATRIX66 &M, const REAL al
const REAL sinAbs = sin(alphaAbs); // = - sin(alpha) si alpha < 0
// Line 1
M(0,0) = 2.0*(pi-alphaAbs)/5.0f;
M(0,1) = 2.0 * (3*cosinus*sinAbs-4*sinAbs*cos3-alphaAbs+pi) / 15.0 ;
M(0,0) = 2.0f*(pi-alphaAbs)/5.0f;
M(0,1) = 2.0f * (3*cosinus*sinAbs-4*sinAbs*cos3-alphaAbs+pi) / 15.0f ;
M(0,2) = 0;
M(0,3) = 0;
M(0,4) = (sinus*pi + 2*pi*cosinus*sinus) / 8.0;
M(0,5) = 2.0*(pi-alphaAbs)/3.0;
M(0,4) = (sinus*pi + 2*pi*cosinus*sinus) / 8.0f;
M(0,5) = 2.0f*(pi-alphaAbs)/3.0f;
// Line 2
M(1,0) = M(0,1);
M(1,1) = (96*sinAbs*cos5 - 64*cos7*sinAbs+26*cosinus*sinAbs-68*sinAbs*cos3-6*alphaAbs+6*pi) / 15.0 ;
M(1,1) = (96*sinAbs*cos5 - 64*cos7*sinAbs+26*cosinus*sinAbs-68*sinAbs*cos3-6*alphaAbs+6*pi) / 15.0f ;
M(1,2) = 0;
M(1,3) = 0;
M(1,4) = (2*sinus*pi + pi * sinus*cos5 - pi*sinus*cos3 + 6*pi*cosinus*sinus + sinus*cos2*pi) / 8.0 ;
M(1,5) = 2*cosinus*sinAbs + (2*pi-8*sinAbs*cos3 - 2*alphaAbs) / 3.0 ;
M(1,4) = (2*sinus*pi + pi * sinus*cos5 - pi*sinus*cos3 + 6*pi*cosinus*sinus + sinus*cos2*pi) / 8.0f ;
M(1,5) = 2*cosinus*sinAbs + (2*pi-8*sinAbs*cos3 - 2*alphaAbs) / 3.0f ;
// LINE 3
M(2,0) = REAL(0);
M(2,1) = REAL(0);
M(2,2) = 2.0*(3*cosinus*sinAbs - 4*sinAbs*cos3 - alphaAbs + pi)/15.0;
M(2,2) = 2.0f*(3*cosinus*sinAbs - 4*sinAbs*cos3 - alphaAbs + pi)/15.0f;
M(2,3) = pi*sinus/8.0f + cosinus*sinus*pi / 4.0f;
M(2,4) = REAL(0) ;
M(2,5) = REAL(0) ;
......@@ -310,7 +310,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_c(MATRIX66 &M, const REAL al
M(3,0) = REAL(0) ;
M(3,1) = REAL(0) ;
M(3,2) = M(2,3);
M(3,3) = 2.0*(pi-alphaAbs)/3.0 ;
M(3,3) = 2.0f*(pi-alphaAbs)/3.0f ;
M(3,4) = REAL(0) ;
M(3,5) = REAL(0) ;
......@@ -320,7 +320,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_c(MATRIX66 &M, const REAL al
M(4,2) = REAL(0) ;
M(4,3) = REAL(0) ;
M(4,4) = M(1,5) ;
M(4,5) = pi*sinus / 2.0 + pi*cosinus*sinus ;
M(4,5) = pi*sinus / 2.0f + pi*cosinus*sinus ;
// Line 6
M(5,0) = M(0,5) ;
......@@ -328,7 +328,7 @@ void QuadricRGBfunctions<REAL>::buildIntegralMatrix_c(MATRIX66 &M, const REAL al
M(5,2) = REAL(0) ;
M(5,3) = REAL(0) ;
M(5,4) = M(4,5) ;
M(5,5) = 2.0*(pi-alphaAbs);
M(5,5) = 2.0f*(pi-alphaAbs);
}
......
......@@ -32,6 +32,8 @@ namespace CGoGN
namespace Utils
{
typedef unsigned int uint32;
template <typename VEC>
void zero(VEC& v)
{
......@@ -69,14 +71,15 @@ void Quantization<VEC>::computeMeanSourceVector()
template <typename VEC>
typename Quantization<VEC>::CodeVectorID Quantization<VEC>::nearestNeighbour(int v)
{
typedef typename VEC::DATA_TYPE REAL;
VEC x = sourceVectors[v] ;
float dist_min = std::numeric_limits<float>::max() ;
REAL dist_min = std::numeric_limits<REAL>::max();
CodeVectorID nearest = codeVectors.begin() ;
/* search minimum of squared length between v and each vector of codebook */
for(CodeVectorID cv = codeVectors.begin(); cv != codeVectors.end() ; ++cv)
{
VEC vec = x - cv->v ;
float l = vec.norm2() ;
REAL l = vec.norm2();
if(l < dist_min)
{
dist_min = l ;
......@@ -192,7 +195,7 @@ void Quantization<VEC>::vectorQuantizationInit()
CodeVector<VEC> mcv ;
mcv.v = meanSourceVector ;
mcv.regionNbVectors = sourceVectors.size() ;
mcv.regionNbVectors = uint32(sourceVectors.size()) ;
mcv.regionDistortion = distortion ;
codeVectors.push_back(mcv) ;
++nbCodeVectors ;
......@@ -205,7 +208,7 @@ void Quantization<VEC>::vectorQuantizationNbRegions(unsigned int nbRegions, std:
vectorQuantizationInit() ;
// do not want to have more codeVectors than sourceVectors
nbRegions = nbRegions > sourceVectors.size() ? sourceVectors.size() : nbRegions ;
nbRegions = nbRegions > uint32(sourceVectors.size()) ? uint32(sourceVectors.size()) : nbRegions;