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

poly.h

00001 #ifndef POLY_H   // -*- C++ -*-
00002 #define POLY_H
00003 
00004 #include "kernel_rep.h"
00005 #include "set_point.h"
00006 #include <ostream>
00007 
00008 
00016 // Kernel representation for polyhedra.
00017 //typedef CGAL::Cartesian<double>   HDS_rep;
00018 typedef Exact_rep HDS_rep;
00019 
00020 
00021 
00022 // HDS base types
00023 //
00024 #include <CGAL/Halfedge_data_structure_bases.h>
00025 
00026 typedef CGAL::Vertex_max_base< CGAL::Point_3<HDS_rep> >        HDS_V;
00027 typedef CGAL::Halfedge_max_base                                HDS_H;
00028 //typedef CGAL::Facet_max_base                                   HDS_F;
00029 
00030 class HDS_F : public CGAL::Facet_max_base 
00031 {
00032 public:
00033     int label;
00034 };
00035 
00036 
00037 
00038 // HDS type
00039 //
00040 #include <CGAL/Halfedge_data_structure_using_list.h>
00041 
00042 typedef CGAL::Halfedge_data_structure_using_list< HDS_V, HDS_H, HDS_F > HDS;
00043 
00044 
00045 // Polyhedron type
00046 //
00047 #include <CGAL/Polyhedron_default_traits_3.h>
00048 #include <CGAL/Polyhedron_3.h>
00049 
00050 typedef CGAL::Polyhedron_default_traits_3<HDS_rep>        Polyhedron_traits;
00051 typedef CGAL::Polyhedron_3<Polyhedron_traits,HDS>         Polyhedron;
00052 
00053 
00054 
00055 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Vertex& vertex );
00056 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Halfedge& edge );
00057 std::ostream& operator<< ( std::ostream& os, const Polyhedron::Facet& facet );
00058 std::ostream& operator<< ( std::ostream& os, const Polyhedron& polyhedron );
00059 
00060 
00061 // FIXME: find implementation!
00062 void write_off( std::ostream& os, const Polyhedron& P );
00063 
00064 /* If facets are triangles, we make 9 comparisons.
00065  * The alternate strategy of examining all facets incident to each vertex
00066  * requires 3*6 = 18 comparisons for regular vertices of a subdivision surface.
00067  */
00068 inline bool do_share_vertex( const Polyhedron::Facet& f1, 
00069                              const Polyhedron::Facet& f2 )
00070 {
00071     Polyhedron::Halfedge_around_facet_const_circulator h1 = f1.facet_begin();
00072     do {
00073         Polyhedron::Halfedge_around_facet_const_circulator h2 = f2.facet_begin();
00074         do {
00075             if ( &*(h1->vertex()) == &*(h2->vertex()) )
00076                 return true;
00077         } while (++h2 != f2.facet_begin());
00078     } while (++h1 != f1.facet_begin());
00079     return false;
00080 }
00081 
00082 
00083 inline bool do_share_edge( const Polyhedron::Facet& f1, 
00084                            const Polyhedron::Facet& f2 )
00085 {
00086     Polyhedron::Halfedge_around_facet_const_circulator h = f1.facet_begin();
00087 
00088     do {
00089         if ( &*(h->opposite()->facet()) == &f2 )
00090             return true;
00091         ++h;
00092     } while ( h != f1.facet_begin() );
00093     return false;
00094 }
00095 
00096 
00097 inline bool are_incident( const Polyhedron::Facet& f1, 
00098                           const Polyhedron::Facet& f2 )
00099 {
00100     return do_share_edge(f1,f2) || do_share_vertex(f1,f2);
00101 }
00102 
00103 
00105 bool proper_do_intersect( const Polyhedron::Facet& f1, 
00106                           const Polyhedron::Facet& f2 );
00107 
00109 CGAL::Object proper_intersection( const Polyhedron::Facet& f1, 
00110                                   const Polyhedron::Facet& f2 );
00111 
00112 
00113 inline CGAL::Point_3<Exact_rep>
00114 convert_to_exact( const Polyhedron::Point& point )
00115 {
00116     return point;
00117     //CGAL::Point_3<Exact_rep> p;
00118     //set_point( p, point );
00119     //return p;
00120 }
00121     
00122 
00123 
00124 
00125 
00126 #endif

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