Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

poly_poly_intersect.C

00001 
00002 #include <vector>
00003 #include <CEP/intersection/Box_d_Box_d_batch.h>
00004 #include <boost/function_output_iterator.hpp>
00005 
00006 
00007 inline FacetBox make_FacetBox( Polyhedron::Facet& f ) 
00008 {
00009     return FacetBox(f);
00010 }
00011 
00012 
00017 template <class BoxPairOutIter>
00018 void poly_poly_intersect_box( Polyhedron& poly1,
00019                               Polyhedron& poly2,
00020                               BoxPairOutIter out )
00021 {
00022     std::vector<FacetBox> boxes1( poly1.size_of_facets() );
00023     std::transform( poly1.facets_begin(), poly1.facets_end(),
00024                     boxes1.begin(),
00025                     make_FacetBox );
00026 
00027     std::vector<FacetBox> boxes2( poly2.size_of_facets() );
00028     std::transform( poly2.facets_begin(), poly2.facets_end(),
00029                     boxes2.begin(),
00030                     make_FacetBox );
00031 
00032     CEP::intersection::Box_d_Box_d_batch
00033     ( boxes1.begin(), boxes1.end(), 
00034       boxes2.begin(), boxes2.end(),
00035       out );
00036 }
00037 
00038 
00039 template <class FPI_OutIter>
00040 struct poly_poly_intersection_filter {
00041     FPI_OutIter& out;
00042 
00043     poly_poly_intersection_filter( FPI_OutIter& o )
00044         : out(o) {};
00045 
00046     void operator() ( const FacetBox_pair& bp )
00047     { 
00048         Polyhedron::Facet& f1( bp.first.get_facet() );
00049         Polyhedron::Facet& f2( bp.second.get_facet() );
00050         CGAL::Object o_int = proper_intersection( f1, f2 );
00051 
00052         if ( !o_int.is_empty() )
00053             *out++ = Facet_pair_intersection( Facet_pair(f1,f2), o_int );
00054     }
00055 };
00056 
00057 
00064 template <class FPI_OutIter>
00065 void poly_poly_intersect_facet( Polyhedron& poly1,
00066                                 Polyhedron& poly2,
00067                                 FPI_OutIter out )
00068 {
00069     poly_poly_intersect_box
00070     ( poly1, 
00071       poly2,
00072       boost::make_function_output_iterator
00073       ( poly_poly_intersection_filter<FPI_OutIter>(out) )
00074     );
00075 }
00076 

Generated on Fri Oct 26 23:38:11 2001 for bicobj-intersection by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001