00001 #include <cutting/Polyhedron_Box_3.h>
00002 #include "tester.h"
00003 #include "poly_assertions.h"
00004
00005
00006
00007
00008 class cutting_Polyhedron_Box_3_test : public CppUnit::TestCase
00009 {
00010
00011 Point a,b,c;
00012 Polyhedron poly;
00013 Polyhedron::Facet_handle fh0;
00014
00015
00016 Point p,q,r,s;
00017
00018
00019 Point t,u,v,w;
00020
00021
00022 Box_3 box;
00023
00024 public:
00025
00026 void setUp()
00027 {
00028 a = Point( 0,0,0 );
00029 b = Point( 100,0,0 );
00030 c = Point( 0,100,0 );
00031
00032 poly.make_triangle(a,b,c);
00033 fh0 = poly.facets_begin();
00034
00035 p = Point(10,0,0);
00036 q = Point(10,90,0);
00037 r = Point(20,0,0);
00038 s = Point(20,80,0);
00039
00040 t = Point(10,10,0);
00041 u = Point(10,20,0);
00042 v = Point(20,10,0);
00043 w = Point(20,20,0);
00044
00045 box = Box_3( 10,20, 10,20, -1,1 );
00046 }
00047
00048
00049 void tearDown()
00050 {
00051 poly.erase_all();
00052 }
00053
00054
00055 void cut_with_box()
00056 {
00057 verr << "Initial polyhedron: " << endl << poly << endl << endl;
00058 Polyhedron::Facet* interior = cutting( poly, *fh0, box );
00059 verr << "Final polyhedron: " << endl << poly << endl << endl;
00060
00061 CPPUNIT_ASSERT( interior != 0 );
00062
00063 Polyhedron::Facet_const_handle fh = check_facet( poly, t,v,w,u );
00064 CPPUNIT_ASSERT( &*fh == interior );
00065
00066
00067
00068
00069 check_facet( poly, a,p,t,u,q,c );
00070 check_facet( poly, p,r,v,t );
00071 check_facet( poly, u,w,s,q );
00072 check_facet( poly, r,b,s,w,v );
00073
00074 }
00075
00076
00077 CPPUNIT_TEST_SUITE( cutting_Polyhedron_Box_3_test );
00078 CPPUNIT_TEST( cut_with_box );
00079 CPPUNIT_TEST_SUITE_END();
00080 };
00081
00082
00083 CPPUNIT_TEST_SUITE_REGISTRATION( cutting_Polyhedron_Box_3_test );
00084
00085