From c78ae075e9fb6cd4eb2b5461d3da7377e691b66b Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Sat, 23 Aug 2014 01:39:14 +0000 Subject: [PATCH] Significant changes to use the trivial walker instead of the specialized walker here defined. --- src/meshlabplugins/filter_plymc/plymc.h | 6 +- src/meshlabplugins/filter_plymc/volume.h | 84 ++++++++++++++---------- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/meshlabplugins/filter_plymc/plymc.h b/src/meshlabplugins/filter_plymc/plymc.h index 74f97da88..d7f03d67b 100644 --- a/src/meshlabplugins/filter_plymc/plymc.h +++ b/src/meshlabplugins/filter_plymc/plymc.h @@ -40,7 +40,7 @@ #include #include -#include "trivial_walker.h" +//#include "trivial_walker.h" // local optimization #include #include @@ -455,7 +455,9 @@ void Process(vcg::CallBackPos *cb=0) if(cb) cb(50,"Step 2: Marching Cube..."); else printf("Step 2: Marching Cube...\n"); /**********************/ - walker.BuildMesh(me,VV,mc,currentSubBox,currentSubBoxRes); + walker.Init(VV,currentSubBox); + walker.BuildMesh(me,VV,mc,0); + // walker.BuildMesh(me,VV,mc,currentSubBox,currentSubBoxRes); typename MCMesh::VertexIterator vi; Box3f bbb; bbb.Import(VV.SubPart); diff --git a/src/meshlabplugins/filter_plymc/volume.h b/src/meshlabplugins/filter_plymc/volume.h index 3826ae5f8..ef7d38d12 100644 --- a/src/meshlabplugins/filter_plymc/volume.h +++ b/src/meshlabplugins/filter_plymc/volume.h @@ -383,6 +383,18 @@ public: } /************************************/ // Funzioni di accesso ai dati + bool ValidCell(const Point3i &p1, const Point3i &p2) const + { + if(!cV(p1.X(),p1.Y(),p1.Z()).B() ) return false; + if(!cV(p2.X(),p1.Y(),p1.Z()).B() ) return false; + if(!cV(p1.X(),p2.Y(),p1.Z()).B() ) return false; + if(!cV(p2.X(),p2.Y(),p1.Z()).B() ) return false; + if(!cV(p1.X(),p1.Y(),p2.Z()).B() ) return false; + if(!cV(p2.X(),p1.Y(),p2.Z()).B() ) return false; + if(!cV(p1.X(),p2.Y(),p2.Z()).B() ) return false; + if(!cV(p2.X(),p2.Y(),p2.Z()).B() ) return false; + return true; + } float Val(const int &x,const int &y,const int &z) const { if(!cV(x,y,z).B()) return 1000; @@ -1217,44 +1229,44 @@ void SlicedPPM( const char * filename,const char *tag,int SliceNum=1) fclose(fp); } } - template < class VertexPointerType > - void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v) - { - float f1 = Val(p1.X(), p1.Y(), p1.Z()); - float f2 = Val(p2.X(), p2.Y(), p2.Z()); - float u = (float) f1/(f1-f2); - v->P().X() = (float) p1.X()*(1-u) + u*p2.X(); - v->P().Y() = (float) p1.Y(); - v->P().Z() = (float) p1.Z(); - v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); - v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); - } +template < class VertexPointerType > +void GetXIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, float /*thr*/) +{ + float f1 = Val(p1.X(), p1.Y(), p1.Z()); + float f2 = Val(p2.X(), p2.Y(), p2.Z()); + float u = (float) f1/(f1-f2); + v->P().X() = (float) p1.X()*(1-u) + u*p2.X(); + v->P().Y() = (float) p1.Y(); + v->P().Z() = (float) p1.Z(); + v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); + v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); +} - template < class VertexPointerType > - void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v) - { - float f1 = Val(p1.X(), p1.Y(), p1.Z()); - float f2 = Val(p2.X(), p2.Y(), p2.Z()); - float u = (float) f1/(f1-f2); - v->P().X() = (float) p1.X(); - v->P().Y() = (float) p1.Y()*(1-u) + u*p2.Y(); - v->P().Z() = (float) p1.Z(); - v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); - v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); - } +template < class VertexPointerType > +void GetYIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, float /*thr*/) +{ + float f1 = Val(p1.X(), p1.Y(), p1.Z()); + float f2 = Val(p2.X(), p2.Y(), p2.Z()); + float u = (float) f1/(f1-f2); + v->P().X() = (float) p1.X(); + v->P().Y() = (float) p1.Y()*(1-u) + u*p2.Y(); + v->P().Z() = (float) p1.Z(); + v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); + v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); +} - template < class VertexPointerType> - void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v) - { - float f1 = Val(p1.X(), p1.Y(), p1.Z()); - float f2 = Val(p2.X(), p2.Y(), p2.Z()); - float u = (float) f1/(f1-f2); - v->P().X() = (float) p1.X(); - v->P().Y() = (float) p1.Y(); - v->P().Z() = (float) p1.Z()*(1-u) + u*p2.Z(); - v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); - v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); - } +template < class VertexPointerType> +void GetZIntercept(const vcg::Point3i &p1, const vcg::Point3i &p2, VertexPointerType &v, float /*thr*/) +{ + float f1 = Val(p1.X(), p1.Y(), p1.Z()); + float f2 = Val(p2.X(), p2.Y(), p2.Z()); + float u = (float) f1/(f1-f2); + v->P().X() = (float) p1.X(); + v->P().Y() = (float) p1.Y(); + v->P().Z() = (float) p1.Z()*(1-u) + u*p2.Z(); + v->Q()=cV(p1.X(), p1.Y(), p1.Z()).Q(); + v->C()=cV(p1.X(), p1.Y(), p1.Z()).C4b(); +} };