From b4bccbf5753e369d869f867d036f1eecca90ed17 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Aug 2013 14:50:33 +0200 Subject: [PATCH] compil visual 2010 --- ThirdParty/CMakeLists.txt | 1 + ThirdParty/OpenNL/CMakeOptions.txt | 5 ++- ThirdParty/OpenNL/src/NL/nl_cholmod.c | 58 ++++++++++++++++++--------- include/Utils/textures.hpp | 6 +-- src/Utils/svg.cpp | 2 +- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 2c58b97cb..65323b899 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -17,6 +17,7 @@ ENDIF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug") IF(WIN32) SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib) #release added by visual INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/) + INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse) ELSE(WIN32) SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE}) ENDIF(WIN32) diff --git a/ThirdParty/OpenNL/CMakeOptions.txt b/ThirdParty/OpenNL/CMakeOptions.txt index 22ef14b9a..2d77d5cbd 100644 --- a/ThirdParty/OpenNL/CMakeOptions.txt +++ b/ThirdParty/OpenNL/CMakeOptions.txt @@ -66,8 +66,9 @@ SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/OpenNL/CMakeModules) # CHOLMOD ########### SET(USE_CHOLMOD TRUE) -find_package(SuiteSparse REQUIRED) - +IF (NOT WIN32) + find_package(SuiteSparse REQUIRED) +ENDIF (NOT WIN32) ########### # CNC ########### diff --git a/ThirdParty/OpenNL/src/NL/nl_cholmod.c b/ThirdParty/OpenNL/src/NL/nl_cholmod.c index 35c326403..c8984ba3f 100644 --- a/ThirdParty/OpenNL/src/NL/nl_cholmod.c +++ b/ThirdParty/OpenNL/src/NL/nl_cholmod.c @@ -65,23 +65,34 @@ typedef struct { NLboolean nlFactorize_CHOLMOD() { + NLSparseMatrix* M; + NLuint n; + NLuint nnz; + cholmod_sparse* cA; + NLRowColumn* Ci; + cholmod_context* context; + NLuint i,j,count ; + int* colptr; + int* rowind; + double* a; + /* OpenNL Context */ - NLSparseMatrix* M = &(nlCurrentContext->M) ; - NLuint n = nlCurrentContext->n ; - NLuint nnz = nlSparseMatrixNNZ(M) ; /* Number of Non-Zero coeffs */ + M = &(nlCurrentContext->M) ; + n = nlCurrentContext->n ; + nnz = nlSparseMatrixNNZ(M) ; /* Number of Non-Zero coeffs */ - cholmod_context* context = (cholmod_context*)(nlCurrentContext->direct_solver_context) ; + context = (cholmod_context*)(nlCurrentContext->direct_solver_context) ; if(context == NULL) { nlCurrentContext->direct_solver_context = malloc(sizeof(cholmod_context)) ; context = (cholmod_context*)(nlCurrentContext->direct_solver_context) ; } /* CHOLMOD variables */ - cholmod_sparse* cA = NULL ; + cA = NULL ; /* Temporary variables */ - NLRowColumn* Ci = NULL ; - NLuint i,j,count ; + Ci = NULL ; + /* Sanity checks */ nl_assert(M->storage & NL_MATRIX_STORE_COLUMNS) ; @@ -95,9 +106,9 @@ NLboolean nlFactorize_CHOLMOD() { */ cA = cholmod_allocate_sparse(n, n, nnz, NL_FALSE, NL_TRUE, -1, CHOLMOD_REAL, &(context->c)) ; - int* colptr = (int*)(cA->p) ; - int* rowind = (int*)(cA->i) ; - double* a = (double*)(cA->x) ; + colptr = (int*)(cA->p) ; + rowind = (int*)(cA->i) ; + a = (double*)(cA->x) ; count = 0 ; for(i = 0; i < n; i++) { @@ -134,26 +145,33 @@ NLboolean nlFactorize_CHOLMOD() { NLboolean nlSolve_CHOLMOD() { + cholmod_dense* cx; + NLuint i ; + NLdouble* b; + NLdouble* x; + NLuint n; + /* Temporary variables */ + double* cbx; + double* cxx; + cholmod_context* context; + /* OpenNL Context */ - NLdouble* b = nlCurrentContext->b ; - NLdouble* x = nlCurrentContext->x ; - NLuint n = nlCurrentContext->n ; + b = nlCurrentContext->b ; + x = nlCurrentContext->x ; + n = nlCurrentContext->n ; - cholmod_context* context = (cholmod_context*)(nlCurrentContext->direct_solver_context) ; + context = (cholmod_context*)(nlCurrentContext->direct_solver_context) ; nl_assert(context != NULL) ; /* CHOLMOD variables */ - cholmod_dense* cx = NULL ; - - /* Temporary variables */ - NLuint i ; + cx = NULL ; /* * Step 1: convert right-hand side into CHOLMOD representation * ----------------------------------------------------------- */ - double* cbx = (double*)(context->cb->x) ; + cbx = (double*)(context->cb->x) ; for(i = 0; i < n; i++) cbx[i] = b[i] ; @@ -169,7 +187,7 @@ NLboolean nlSolve_CHOLMOD() { * ------------------------ */ - double* cxx = (double*)(cx->x) ; + cxx = (double*)(cx->x) ; for(i = 0; i < n; i++) x[i] = cxx[i] ; diff --git a/include/Utils/textures.hpp b/include/Utils/textures.hpp index 0b975ae74..6b2c3b7e5 100644 --- a/include/Utils/textures.hpp +++ b/include/Utils/textures.hpp @@ -546,7 +546,7 @@ Image* Image::scaleNearestToNewImage(const COORD& newSize) double p0 = inc0/2.0 - 0.5; for (unsigned int i=0; i< newSize[0]; ++i) { - newImg->texel(i) = this->texel( (unsigned int)(rint(p0)) ); + newImg->texel(i) = this->texel( (unsigned int)(p0+0.5) ); p0 += inc0; } } @@ -561,7 +561,7 @@ Image* Image::scaleNearestToNewImage(const COORD& newSize) double p0 = inc0/2.0 - 0.5; for (unsigned int i=0; i< newSize[0]; ++i) { - newImg->texel(i,j) = this->texel( (unsigned int)(rint(p0)), (unsigned int)(rint(p1)) ); + newImg->texel(i,j) = this->texel( (unsigned int)(p0+0.5), (unsigned int)(p1+0.5) ); p0 += inc0; } p1 += inc1; @@ -582,7 +582,7 @@ Image* Image::scaleNearestToNewImage(const COORD& newSize) double p0 = inc0/2.0 - 0.5; for (unsigned int i=0; i< newSize[0]; ++i) { - newImg->texel(i,j,k) = this->texel( (unsigned int)(rint(p0)), (unsigned int)(rint(p1)), (unsigned int)(rint(p2)) ); + newImg->texel(i,j,k) = this->texel( (unsigned int)(p0+0.5), (unsigned int)(p1+0.5), (unsigned int)(p2+0.5) ); p0 += inc0; } p1 += inc1; diff --git a/src/Utils/svg.cpp b/src/Utils/svg.cpp index 8248e0a19..e2da12337 100644 --- a/src/Utils/svg.cpp +++ b/src/Utils/svg.cpp @@ -707,7 +707,7 @@ void SVGOut::write() { if (m_attFact > 0.0f) { - float da = float( pow(double(itd-vds.begin()),m_attFact) / pow(double(vds.size()),m_attFact)); + float da = float( pow(double(itd-vds.begin()),double(m_attFact)) / pow(double(vds.size()),double(m_attFact))); (*it)->m_objs[itd->obj]->saveOneDepthAttenuation(*m_out,da,itd->id, m_bbX1-m_bbX0); } else -- GitLab