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

poly.cc

00001 #include "poly.h"
00002 
00003 #include <ostream>
00004 
00005 #include <CGAL/Point_3.h>
00006 #include <CGAL/Segment_3.h>
00007 #include <CGAL/Triangle_3.h>
00008 
00009 #include "set_point.h"
00010 
00011 #include <CEP/intersection/Box_d_Box_d.h>
00012 #include <CEP/intersection/Triangle_3_Triangle_3.h>
00013 
00014 
00015 typedef CGAL::Point_3<Exact_rep>            Point;
00016 typedef CGAL::Point_3<Exact_rep>            Segment;
00017 typedef CGAL::Triangle_3<Exact_rep>         Triangle;
00018 
00019 
00020 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Vertex& v )
00021 {
00022     return os << v.point();
00023 }
00024 
00025 
00026 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Halfedge& h )
00027 {
00028     os << "[" << *(h.opposite()->vertex()) << "] --> [";
00029     return os << *(h.vertex()) << "]";
00030 }
00031 
00032 
00033 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Facet& f )
00034 {
00035     Polyhedron::Halfedge_const_handle h = f.halfedge();
00036     do {
00037         os << "    " << h->vertex()->point() << std::endl;
00038         h = h->next();
00039     } while ( h != f.halfedge() );
00040     return os;
00041 }
00042 
00043 
00044 std::ostream& operator<< ( std::ostream& os, const Polyhedron& poly )
00045 {
00046     int i = 0;
00047     for( Polyhedron::Facet_const_iterator fi = poly.facets_begin();
00048          fi != poly.facets_end(); ++fi )
00049     {
00050         os << "Facet " << i++ << ":" << endl
00051            << *fi;
00052     }
00053     return os;
00054 }
00055 
00056 
00057 Triangle compute_facet_triangle( const Polyhedron::Facet& f ) {
00058     Polyhedron::Halfedge_const_handle h = f.halfedge();
00059     
00060     // Make sure face is a triangle
00061     CGAL_assertion( h->next()->next()->next() == h );
00062 
00063     Point a,b,c;
00064 
00065     set_point( a, h->opposite()->vertex()->point() );
00066     set_point( b, h->vertex()->point() );
00067     set_point( c, h->next()->vertex()->point() );
00068 
00069     return Triangle(a,b,c);
00070 }
00071 
00072 
00080 bool proper_do_intersect( const Polyhedron::Facet& f1, 
00081                           const Polyhedron::Facet& f2 )
00082 {
00083     if ( are_incident( f1, f2 ) )
00084         return false;
00085 
00086     Triangle T1 = compute_facet_triangle( f1 );
00087     Triangle T2 = compute_facet_triangle( f2 );
00088 
00089     return CEP::intersection::do_intersect( T1, T2 );
00090 }
00091 
00092 
00100 CGAL::Object proper_intersection( const Polyhedron::Facet& f1, 
00101                                   const Polyhedron::Facet& f2 )
00102 {
00103     if ( are_incident( f1, f2 ) )
00104         return CGAL::Object();
00105 
00106     Triangle T1 = compute_facet_triangle( f1 );
00107     Triangle T2 = compute_facet_triangle( f2 );
00108 
00109     return CEP::intersection::intersection( T1, T2 );
00110 }

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