00001 #include "poly_assertions.h"
00002 #include "tester.h"
00003
00004
00005 void
00006 assert_poly_combinatorics( const Polyhedron& poly,
00007 int n_facets, int n_halfedges, int n_vertices )
00008 {
00009
00010
00011 CPPUNIT_ASSERT_EQUAL( n_facets, int(poly.size_of_facets()) );
00012 CPPUNIT_ASSERT_EQUAL( n_halfedges, int(poly.size_of_halfedges()) );
00013 CPPUNIT_ASSERT_EQUAL( n_vertices, int(poly.size_of_vertices()) );
00014 }
00015
00016
00017
00018 Polyhedron::Halfedge_const_handle
00019 locate_vertex( const Polyhedron& poly,
00020 const Point& p )
00021 {
00022 Polyhedron::Halfedge_const_iterator it;
00023 for( it = poly.halfedges_begin(); it != poly.halfedges_end(); ++it )
00024 {
00025 if ( it->vertex()->point() == p ) break;
00026 }
00027 CPPUNIT_ASSERT( it != poly.halfedges_end() );
00028
00029
00030
00031
00032
00033 return Polyhedron::Halfedge_const_handle(&*it);
00034 }
00035
00036
00037
00038 Polyhedron::Halfedge_const_handle
00039 locate_halfedge( const Polyhedron& poly,
00040 const Point& p,
00041 const Point& q )
00042 {
00043 Polyhedron::Halfedge_const_iterator it;
00044 for( it = poly.halfedges_begin(); it != poly.halfedges_end(); ++it )
00045 {
00046 if ( it->vertex()->point() == q &&
00047 it->opposite()->vertex()->point() == p )
00048 break;
00049 }
00050
00051 CPPUNIT_ASSERT_MESSAGE( string("cannot find halfedge: ")
00052 + CppUnit::cgal_assertion_traits<Point>::toString(p) + ":"
00053 + CppUnit::cgal_assertion_traits<Point>::toString(q),
00054 it != poly.halfedges_end() );
00055
00056
00057 return Polyhedron::Halfedge_const_handle(&*it);
00058 }
00059
00060
00061 Polyhedron::Facet_const_handle
00062 check_facet( const Polyhedron& poly,
00063 const Point& p1,
00064 const Point& p2,
00065 const Point& p3 )
00066 {
00067 Polyhedron::Halfedge_const_handle h = locate_halfedge(poly,p3,p1);
00068
00069 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00070 h = h->next();
00071 CPPUNIT_ASSERT( h->vertex()->point() == p2 );
00072 h = h->next();
00073 CPPUNIT_ASSERT( h->vertex()->point() == p3 );
00074 h = h->next();
00075 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00076
00077 return h->facet();
00078 }
00079
00080
00081 Polyhedron::Facet_const_handle
00082 check_facet( const Polyhedron& poly,
00083 const Point& p1,
00084 const Point& p2,
00085 const Point& p3,
00086 const Point& p4 )
00087 {
00088 Polyhedron::Halfedge_const_handle h = locate_halfedge(poly,p4,p1);
00089
00090 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00091 h = h->next();
00092 CPPUNIT_ASSERT( h->vertex()->point() == p2 );
00093 h = h->next();
00094 CPPUNIT_ASSERT( h->vertex()->point() == p3 );
00095 h = h->next();
00096 CPPUNIT_ASSERT( h->vertex()->point() == p4 );
00097 h = h->next();
00098 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00099
00100 return h->facet();
00101 }
00102
00103
00104 Polyhedron::Facet_const_handle
00105 check_facet( const Polyhedron& poly,
00106 const Point& p1,
00107 const Point& p2,
00108 const Point& p3,
00109 const Point& p4,
00110 const Point& p5 )
00111 {
00112 Polyhedron::Halfedge_const_handle h = locate_halfedge(poly,p5,p1);
00113
00114 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00115 h = h->next();
00116 CPPUNIT_ASSERT( h->vertex()->point() == p2 );
00117 h = h->next();
00118 CPPUNIT_ASSERT( h->vertex()->point() == p3 );
00119 h = h->next();
00120 CPPUNIT_ASSERT( h->vertex()->point() == p4 );
00121 h = h->next();
00122 CPPUNIT_ASSERT( h->vertex()->point() == p5 );
00123 h = h->next();
00124 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00125
00126 return h->facet();
00127 }
00128
00129
00130 Polyhedron::Facet_const_handle
00131 check_facet( const Polyhedron& poly,
00132 const Point& p1,
00133 const Point& p2,
00134 const Point& p3,
00135 const Point& p4,
00136 const Point& p5,
00137 const Point& p6 )
00138 {
00139 Polyhedron::Halfedge_const_handle h = locate_halfedge(poly,p6,p1);
00140
00141 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00142 h = h->next();
00143 CPPUNIT_ASSERT( h->vertex()->point() == p2 );
00144 h = h->next();
00145 CPPUNIT_ASSERT( h->vertex()->point() == p3 );
00146 h = h->next();
00147 CPPUNIT_ASSERT( h->vertex()->point() == p4 );
00148 h = h->next();
00149 CPPUNIT_ASSERT( h->vertex()->point() == p5 );
00150 h = h->next();
00151 CPPUNIT_ASSERT( h->vertex()->point() == p6 );
00152 h = h->next();
00153 CPPUNIT_ASSERT( h->vertex()->point() == p1 );
00154
00155 return h->facet();
00156 }
00157