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

hexahedron.cc

00001 #include "Hexahedron_3.h"
00002 #include "hexa_poly_intersect.h"
00003 #include "tester.h"
00004 
00005 
00006 class hexahedron_test : public CppUnit::TestCase
00007 {
00008     typedef CGAL::Point_3<Exact_rep>   Point;
00009     typedef CGAL::Plane_3<Exact_rep>   Plane;
00010     typedef Polyhedron::Point          PolyPoint;
00011 
00012     Hexahedron_3* hp;
00013 
00014     Polyhedron poly;
00015 
00016 
00017 public:
00018 
00019     void setUp()
00020     {
00021         hp = new Hexahedron_3( Point(0,0,0),
00022                                Point(1,0,0),
00023                                Point(1,1,0),
00024                                Point(0,1,0),
00025                                Point(0,0,1),
00026                                Point(0,1,1),
00027                                Point(1,0,1),
00028                                Point(1,1,1) );
00029 
00030         poly.make_triangle( PolyPoint(50,-101,50,100),
00031                             PolyPoint(101,50,50,100),
00032                             PolyPoint(50,101,50,100) );
00033 
00034         poly.facets_begin()->label = 0;
00035     }
00036 
00037 
00038     void tearDown()
00039     {
00040         delete hp;
00041         poly.erase_all();
00042     }
00043 
00044 
00045 
00046     void t_01()
00047     {
00048         CPPUNIT_ASSERT_EQUAL( Plane(0,-1,0,0), hp->plane_0164() );  // Y = 0
00049         CPPUNIT_ASSERT_EQUAL( Plane(1,0,0,-1), hp->plane_1276() );  // X = 1
00050         CPPUNIT_ASSERT_EQUAL( Plane(0,1,0,-1), hp->plane_2357() );  // Y = 1
00051         CPPUNIT_ASSERT_EQUAL( Plane(-1,0,0,0), hp->plane_0453() );  // X = 0
00052         CPPUNIT_ASSERT_EQUAL( Plane(0,0,1,-1), hp->plane_4675() );  // Z = 1
00053         CPPUNIT_ASSERT_EQUAL( Plane(0,0,-1,0), hp->plane_0321() );  // Z = 0
00054     }
00055 
00056 
00057     void t_02()
00058     {
00059         CPPUNIT_ASSERT_EQUAL( 1, int(poly.size_of_facets()) );
00060         CPPUNIT_ASSERT_EQUAL( 6, int(poly.size_of_halfedges()) );
00061         CPPUNIT_ASSERT_EQUAL( 3, int(poly.size_of_vertices()) );
00062 
00063         slice_poly_with_hexa(poly,*hp);
00064 
00065         poly.normalize_border();
00066         CPPUNIT_ASSERT_EQUAL( 9, int(poly.size_of_border_halfedges()) );
00067 
00068         CPPUNIT_ASSERT_EQUAL( 4, int(poly.size_of_facets()) );
00069         CPPUNIT_ASSERT_EQUAL( 24, int(poly.size_of_halfedges()) );
00070         CPPUNIT_ASSERT_EQUAL( 9, int(poly.size_of_vertices()) );
00071     }
00072 
00073 
00074     void t_03()
00075     {
00076         CPPUNIT_ASSERT_EQUAL( 1, int(poly.size_of_facets()) );
00077         CPPUNIT_ASSERT_EQUAL( 6, int(poly.size_of_halfedges()) );
00078         CPPUNIT_ASSERT_EQUAL( 3, int(poly.size_of_vertices()) );
00079 
00080         label_poly_with_hexa(poly,*(poly.facets_begin()),*hp,1);
00081 
00082         poly.normalize_border();
00083         CPPUNIT_ASSERT_EQUAL( 9, int(poly.size_of_border_halfedges()) );
00084 
00085         CPPUNIT_ASSERT_EQUAL( 4, int(poly.size_of_facets()) );
00086         CPPUNIT_ASSERT_EQUAL( 24, int(poly.size_of_halfedges()) );
00087         CPPUNIT_ASSERT_EQUAL( 9, int(poly.size_of_vertices()) );
00088 
00089         int label_count = 0;
00090         Polyhedron::Facet_const_iterator it;
00091         for( it = poly.facets_begin(); it != poly.facets_end(); ++it )
00092         {
00093             if ( it->label != 0 ) {
00094                 CPPUNIT_ASSERT_EQUAL( 1, it->label );
00095                 CPPUNIT_ASSERT( ++label_count == 1 );
00096             }
00097         }
00098 
00099     }
00100 
00101 
00102 
00103     CPPUNIT_TEST_SUITE( hexahedron_test );
00104     CPPUNIT_TEST( t_01 );
00105     CPPUNIT_TEST( t_02 );
00106     CPPUNIT_TEST( t_03 );
00107     CPPUNIT_TEST_SUITE_END();
00108 };
00109 
00110 
00111 CPPUNIT_TEST_SUITE_REGISTRATION( hexahedron_test );
00112 
00113 

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