diff --git a/vcg/complex/trimesh/create/emc_lookup_table.h b/vcg/complex/trimesh/create/emc_lookup_table.h index 68d8f9a0..fde806dd 100644 --- a/vcg/complex/trimesh/create/emc_lookup_table.h +++ b/vcg/complex/trimesh/create/emc_lookup_table.h @@ -925,4 +925,4 @@ namespace vcg }; //end of class EMCLookUpTable }; // end of namespace tri }; // end of namespace vcg -#endif // __VCG_EMC_LOOK_UP_TABLE \ No newline at end of file +#endif // __VCG_EMC_LOOK_UP_TABLE diff --git a/vcg/complex/trimesh/create/extended_marching_cubes.h b/vcg/complex/trimesh/create/extended_marching_cubes.h index b5f194a8..70f5d1b1 100644 --- a/vcg/complex/trimesh/create/extended_marching_cubes.h +++ b/vcg/complex/trimesh/create/extended_marching_cubes.h @@ -74,11 +74,15 @@ namespace vcg class ExtendedMarchingCubes { public: -#ifdef _WIN64 +#if defined(__GNUC__) + typedef unsigned int size_t; +#else +#ifdef _WIN64 typedef unsigned __int64 size_t; #else typedef _W64 unsigned int size_t; #endif +#endif typedef typename vcg::tri::Allocator< TRIMESH_TYPE > AllocatorType; typedef typename TRIMESH_TYPE::ScalarType ScalarType; typedef typename TRIMESH_TYPE::VertexType VertexType; @@ -457,4 +461,4 @@ namespace vcg } // end of namespace tri }; // end of namespace vcg -#endif // __VCG_EXTENDED_MARCHING_CUBES \ No newline at end of file +#endif // __VCG_EXTENDED_MARCHING_CUBES diff --git a/vcg/complex/trimesh/create/marching_cubes.h b/vcg/complex/trimesh/create/marching_cubes.h index fcecaead..c35dc51b 100644 --- a/vcg/complex/trimesh/create/marching_cubes.h +++ b/vcg/complex/trimesh/create/marching_cubes.h @@ -67,11 +67,15 @@ namespace vcg public: enum Dimension {X, Y, Z}; +#if defined(__GNUC__) + typedef unsigned int size_t; +#else #ifdef _WIN64 typedef unsigned __int64 size_t; #else typedef _W64 unsigned int size_t; #endif +#endif typedef typename vcg::tri::Allocator< TRIMESH_TYPE > AllocatorType; typedef typename TRIMESH_TYPE::ScalarType ScalarType; typedef typename TRIMESH_TYPE::VertexType VertexType; @@ -735,4 +739,4 @@ namespace vcg }; // end of namespace tri }; // end of namespace vcg -#endif //__VCG_MARCHING_CUBES \ No newline at end of file +#endif //__VCG_MARCHING_CUBES diff --git a/vcg/math/lin_algebra.h b/vcg/math/lin_algebra.h index 58c0b3fd..251a5fe8 100644 --- a/vcg/math/lin_algebra.h +++ b/vcg/math/lin_algebra.h @@ -5,6 +5,18 @@ namespace vcg /** \addtogroup math */ /* @{ */ + /*! + * + */ + template< typename TYPE > + static void JacobiRotate(Matrix44 &A, TYPE s, TYPE tau, int i,int j,int k,int l) + { + TYPE g=A[i][j]; + TYPE h=A[k][l]; + A[i][j]=g-s*(h+g*tau); + A[k][l]=h+s*(g-h*tau); + }; + /*! * Computes all eigenvalues and eigenvectors of a real symmetric matrix . * On output, elements of the input matrix above the diagonal are destroyed. @@ -97,18 +109,33 @@ namespace vcg } }; - /*! - * - */ - template< typename TYPE > - void JacobiRotate(Matrix44 &A, TYPE s, TYPE tau, int i,int j,int k,int l) + + // Computes (a^2 + b^2)^(1/2) without destructive underflow or overflow. + template + inline static TYPE pythagora(TYPE a, TYPE b) { - TYPE g=A[i][j]; - TYPE h=A[k][l]; - A[i][j]=g-s*(h+g*tau); - A[k][l]=h+s*(g-h*tau); + TYPE abs_a = fabs(a); + TYPE abs_b = fabs(b); + if (abs_a > abs_b) + return abs_a*sqrt(1.0+sqr(abs_b/abs_a)); + else + return (abs_b == 0.0 ? 0.0 : abs_b*sqrt(1.0+sqr(abs_a/abs_b))); }; + template + inline static TYPE sign(TYPE a, TYPE b) + { + return (b >= 0.0 ? fabs(a) : -fabs(a)); + }; + + template + inline static TYPE sqr(TYPE a) + { + TYPE sqr_arg = a; + return (sqr_arg == 0 ? 0 : sqr_arg*sqr_arg); + } + + /*! * Given a matrix Am×n, this routine computes its singular value decomposition, * i.e. A=U·W·VT. The matrix A will be destroyed! @@ -149,7 +176,7 @@ namespace vcg s += A[k][i]*A[k][i]; } f=A[i][i]; - g = -vcg::sign( sqrt(s), f ); + g = -sign( sqrt(s), f ); h = f*g - s; A[i][i]=f-g; for (j=l; j(sqrt(s),f); + g = -sign(sqrt(s),f); h = f*g - s; A[i][l] = f-g; for (k=l; k(f,g); + h = pythagora(f,g); W[i] = h; h = 1.0/h; c = g*h; @@ -407,30 +434,5 @@ namespace vcg delete []tmp; }; - // Computes (a^2 + b^2)^(1/2) without destructive underflow or overflow. - template - inline TYPE pythagora(TYPE a, TYPE b) - { - TYPE abs_a = fabs(a); - TYPE abs_b = fabs(b); - if (abs_a > abs_b) - return abs_a*sqrt(1.0+sqr(abs_b/abs_a)); - else - return (abs_b == 0.0 ? 0.0 : abs_b*sqrt(1.0+sqr(abs_a/abs_b))); - }; - - template - inline TYPE sign(TYPE a, TYPE b) - { - return (b >= 0.0 ? fabs(a) : -fabs(a)); - }; - - template - inline TYPE sqr(TYPE a) - { - TYPE sqr_arg = a; - return (sqr_arg == 0 ? 0 : sqr_arg*sqr_arg); - } - /*! @} */ }; // end of namespace \ No newline at end of file