From 13b1a8f1d9cc0db30309233ff556736d15de31d4 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 3 Dec 2015 22:58:08 +0000 Subject: [PATCH] Renamed VertexTMark into EmptyMark to reflect its nature (do nothing) and be easier to be used in other context (e.g. as a dummy marker functor for edges) --- vcg/complex/algorithms/closest.h | 56 +++++++++++++++++++------ vcg/complex/algorithms/point_sampling.h | 2 +- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/vcg/complex/algorithms/closest.h b/vcg/complex/algorithms/closest.h index 0b805c8e..44993013 100644 --- a/vcg/complex/algorithms/closest.h +++ b/vcg/complex/algorithms/closest.h @@ -29,8 +29,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include @@ -64,17 +67,29 @@ namespace vcg { FaceTmark(){} FaceTmark(MESH_TYPE *m) {this->SetMesh(m);} }; + + template + class EdgeTmark:public Tmark + { + public: + EdgeTmark(){} + EdgeTmark(MESH_TYPE *m) {this->SetMesh(m);} + }; + template - class VertTmark + class EmptyTMark { public: typedef typename MESH_TYPE::VertexType VertexType; - inline VertTmark(){} - inline VertTmark(MESH_TYPE *){} + typedef typename MESH_TYPE::EdgeType EdgeType; + inline EmptyTMark(){} + inline EmptyTMark(MESH_TYPE *){} inline void UnMarkAll() const {} inline bool IsMarked(VertexType*) const { return false; } inline void Mark(VertexType*) const {} + inline bool IsMarked(EdgeType*) const { return false; } + inline void Mark(EdgeType*) const {} inline void SetMesh(void * /*m=0*/) const {} }; @@ -190,7 +205,7 @@ namespace vcg { { typedef typename GRID::ScalarType ScalarType; typedef Point3 Point3x; - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); typedef vcg::vertex::PointDistanceFunctor VDistFunct; @@ -206,7 +221,7 @@ namespace vcg { { typedef typename GRID::ScalarType ScalarType; typedef Point3 Point3x; - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); typedef vcg::vertex::PointScaledDistanceFunctor VDistFunct; @@ -223,7 +238,7 @@ namespace vcg { { typedef typename GRID::ScalarType ScalarType; typedef Point3 Point3x; - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); typedef vcg::vertex::PointNormalDistanceFunctor VDistFunct; @@ -266,7 +281,7 @@ namespace vcg { const typename GRID::CoordType & _p, const typename GRID::ScalarType & _maxDist, OBJPTRCONTAINER & _objectPtrs,DISTCONTAINER & _distances, POINTCONTAINER & _points) { - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); typedef vcg::vertex::PointDistanceFunctor VDistFunct; @@ -301,7 +316,7 @@ namespace vcg { DISTCONTAINER & _distances, POINTCONTAINER & _points) { - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); typedef vcg::vertex::PointDistanceFunctor VDistFunct; @@ -327,7 +342,7 @@ namespace vcg { const vcg::Box3 _bbox, OBJPTRCONTAINER & _objectPtrs) { - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; MarkerVert mv; mv.SetMesh(&mesh); return(gr.GetInBox/**/(mv,_bbox,_objectPtrs)); @@ -452,14 +467,14 @@ namespace vcg { }; template - class ClosestVertexIterator:public vcg::ClosestIterator, VertTmark > + class ClosestVertexIterator:public vcg::ClosestIterator, EmptyTMark > { public: typedef GRID GridType; typedef MESH MeshType; - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; typedef vcg::vertex::PointDistanceFunctor VDistFunct; - typedef vcg::ClosestIterator > ClosestBaseType; + typedef vcg::ClosestIterator > ClosestBaseType; VDistFunct fn; ClosestVertexIterator(GridType &_Si):ClosestBaseType(_Si,fn){} @@ -490,7 +505,7 @@ namespace vcg { /// this is for meshes with 2D coordinates template - typename MESH::FaceType * GetClosestEdgeBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p, + typename MESH::EdgeType * GetClosestEdge2DBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p, const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist, typename GRID::CoordType &_closestPt) { @@ -503,6 +518,21 @@ namespace vcg { return (gr.GetClosest(PDistFunct,mf,_p,_maxDist,_minDist,_closestPt)); } + /// this is for meshes with 3D coordinates + template + typename MESH::EdgeType * GetClosestEdgeBase( MESH & mesh,GRID & gr,const typename GRID::CoordType & _p, + const typename GRID::ScalarType _maxDist,typename GRID::ScalarType & _minDist, + typename GRID::CoordType &_closestPt) + { + typedef typename GRID::ScalarType ScalarType; + typedef EmptyTMark MarkerEdge; + MarkerEdge mf; + mf.SetMesh(&mesh); + vcg::edge::PointDistanceFunctor PDistFunct; + _minDist=_maxDist; +// return (gr.GetClosest(PDistFunct,mf,_p,_maxDist,_minDist,_closestPt)); + return vcg::GridClosest(gr,PDistFunct,mf, _p,_maxDist,_minDist,_closestPt); + } } // end namespace tri } // end namespace vcg diff --git a/vcg/complex/algorithms/point_sampling.h b/vcg/complex/algorithms/point_sampling.h index de511be2..bf739f8a 100644 --- a/vcg/complex/algorithms/point_sampling.h +++ b/vcg/complex/algorithms/point_sampling.h @@ -1507,7 +1507,7 @@ static bool checkPoissonDisk(SampleSHT & sht, const Point3 & p, Scal { // get the samples closest to the given one std::vector closests; - typedef VertTmark MarkerVert; + typedef EmptyTMark MarkerVert; static MarkerVert mv; Box3f bb(p-Point3f(radius,radius,radius),p+Point3f(radius,radius,radius));