From 7db065556aa39ea5f61f42ca6724ee0aaf01c821 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 9 Aug 2014 00:21:07 +0000 Subject: [PATCH] Adapted the trivial walker of marching cube to float/double independence --- .../algorithms/create/mc_trivial_walker.h | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/vcg/complex/algorithms/create/mc_trivial_walker.h b/vcg/complex/algorithms/create/mc_trivial_walker.h index 049eb4e7..293bc68d 100644 --- a/vcg/complex/algorithms/create/mc_trivial_walker.h +++ b/vcg/complex/algorithms/create/mc_trivial_walker.h @@ -33,15 +33,16 @@ class SimpleVolume : public BasicGrid { public: typedef VOX_TYPE VoxelType; + typedef typename VoxelType::ScalarType ScalarType; const Point3i &ISize() {return siz;} /// Dimensioni griglia come numero di celle per lato - float Val(const int &x,const int &y,const int &z) const { + ScalarType Val(const int &x,const int &y,const int &z) const { return cV(x,y,z).V(); //else return numeric_limits::quiet_NaN( ); } - float &Val(const int &x,const int &y,const int &z) { + ScalarType &Val(const int &x,const int &y,const int &z) { return V(x,y,z).V(); //else return numeric_limits::quiet_NaN( ); } @@ -91,7 +92,7 @@ public: if(AxisVal==ZAxis) v->P().Z() = (float) p1.Z()*(1-u) + u*p2.Z(); else v->P().Z() = (float) p1.Z(); this->IPfToPf(v->P(),v->P()); - if(VoxelType::HasNormal()) v->N() = V(p1).N()*(1-u) + V(p2).N()*u; + if(VoxelType::HasNormal()) v->N().Import(V(p1).N()*(1-u) + V(p2).N()*u); } @@ -105,17 +106,18 @@ public: }; - +template class SimpleVoxel { private: - float _v; + _ScalarType _v; public: - float &V() {return _v;} - float V() const {return _v;} + typedef _ScalarType ScalarType; + ScalarType &V() {return _v;} + ScalarType V() const {return _v;} static bool HasNormal() {return false;} - vcg::Point3f N() const {return Point3f(0,0,0);} - vcg::Point3f &N() { static Point3f _p(0,0,0); return _p;} + vcg::Point3 N() const {return Point3(0,0,0);} + vcg::Point3 &N() { static Point3 _p(0,0,0); return _p;} }; class SimpleVoxelWithNormal