From 6cee7ca8cd98317ff5165c95c4d23ba1cf7ae393 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 19 Sep 2007 12:16:31 +0000 Subject: [PATCH] Overloaded Intersection function to compute trimesh-plane intersection,it return the set of faces that are contained into intersected cells. --- vcg/complex/intersection.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/vcg/complex/intersection.h b/vcg/complex/intersection.h index c8c0cbbb..c6f7736c 100644 --- a/vcg/complex/intersection.h +++ b/vcg/complex/intersection.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.11 2007/05/02 13:25:45 zifnab1974 +only use typename when necessary + Revision 1.10 2007/04/10 22:46:57 pietroni - line 152 changed call intersection to IntersectionPlaneTriangle because changing in function's name @@ -175,6 +178,41 @@ bool Intersection( /*TriMeshType & m, */ return true; } + +/** \addtogroup complex */ +/*@{*/ +/** + Compute the intersection between a trimesh and a plane. + given a plane return the set of faces that are contained + into intersected cells. +*/ +template < typename TriMeshType, class ScalarType, class IndexingType > +bool Intersection(Plane3 pl, + IndexingType *grid, + typename std::vector &v) +{ + typedef typename TriMeshType::FaceContainer FaceContainer; + typedef IndexingType GridType; + typename TriMeshType::FaceIterator fi; + v.clear(); + typename std::vector< typename GridType::Cell* > cells; + Intersect(*grid,pl,cells); + typename std::vector::iterator ic; + typename GridType::Cell fs,ls; + + for(ic = cells.begin(); ic != cells.end();++ic) + { + grid->Grid(*ic,fs,ls); + typename GridType::Link * lk = fs; + while(lk != ls){ + typename TriMeshType::FaceType & face = *(lk->Elem()); + v.push_back(&face); + lk++; + }//end while + }//end for + return true; +} + /*****************************************************************/ /*INTERSECTION RAY - MESH */ /* */