00001 #include "hexa_poly_intersect.h"
00002 #include "poly_cut.h"
00003 #include "poly_intersect.h"
00004 #include <list>
00005 #include <iterator>
00006
00007
00008 typedef Polyhedron::Facet Facet;
00009
00010
00011
00012 bool
00013 is_inside( const Polyhedron::Facet& facet,
00014 const Hexahedron_3& hexa )
00015 {
00016 for( int i = 0; i < 6; ++i ) {
00017 if ( do_intersect_positive( facet, hexa.plane(i) ))
00018 return false;
00019 }
00020 return true;
00021 }
00022
00023
00024
00025
00026
00033 int
00034 slice_poly_with_hexa( Polyhedron& poly,
00035 Facet& facet,
00036 const Hexahedron_3& hexa )
00037 {
00038 Hexahedron_3::Plane planes[6];
00039
00040 for( int i = 0; i < 6; ++i )
00041 planes[i] = hexa.plane(i);
00042
00043 return cut( poly, facet,
00044 planes, planes + 6 );
00045 }
00046
00047
00048
00054 int
00055 label_poly_with_hexa( Polyhedron& poly,
00056 Facet& facet,
00057 const Hexahedron_3& hexa,
00058 int label )
00059 {
00060 std::list<Facet*> f_list;
00061
00062 slice_poly_with_hexa( poly, facet, hexa,
00063 std::back_inserter(f_list) );
00064
00065 Hexahedron_3::Plane planes[6];
00066
00067 for( int i = 0; i < 6; ++i )
00068 planes[i] = hexa.plane(i);
00069
00070 for( std::list<Facet*>::iterator f = f_list.begin();
00071 f != f_list.end(); ++f ) {
00072 if ( !do_intersect_positive( **f, planes, planes+6 ) )
00073 (*f)->label = label;
00074 }
00075
00076 return f_list.size();
00077 }
00078