00001 #include <cutting/Polyhedron_Interval.h>
00002 #include "tester.h"
00003 #include "poly_assertions.h"
00004
00005
00006 class cutting_Polyhedron_Interval_test1 : public CppUnit::TestCase
00007 {
00008
00009 Point a,b,c;
00010 Polyhedron poly;
00011 Polyhedron::Facet_handle fh0;
00012
00013
00014 Point p,q,r,s;
00015
00016
00017 Point t,u,v,w;
00018
00019
00020 public:
00021
00022 void setUp()
00023 {
00024 a = Point( 0,0,0 );
00025 b = Point( 100,0,0 );
00026 c = Point( 0,100,0 );
00027
00028 poly.make_triangle(a,b,c);
00029 fh0 = poly.facets_begin();
00030
00031 p = Point(40,0,0);
00032 q = Point(40,60,0);
00033 r = Point(80,0,0);
00034 s = Point(80,20,0);
00035
00036 t = Point(0,40,0);
00037 u = Point(60,40,0);
00038 v = Point(0,80,0);
00039 w = Point(20,80,0);
00040 }
00041
00042
00043 void tearDown()
00044 {
00045 poly.erase_all();
00046 }
00047
00048
00049 void assert_full_triple( const FacetTriple& ft )
00050 {
00051 CPPUNIT_ASSERT( ft.low != 0 );
00052 CPPUNIT_ASSERT( ft.middle != 0 );
00053 CPPUNIT_ASSERT( ft.high != 0 );
00054 }
00055
00056 void cut_x()
00057 {
00058 FacetTriple ft = cutting( poly, *fh0, 0, 40,80 );
00059 assert_full_triple( ft );
00060
00061 Polyhedron::Facet_const_handle fh;
00062
00063 fh = check_facet( poly, a,p,q,c );
00064 CPPUNIT_ASSERT( &*fh == ft.low );
00065
00066 fh = check_facet( poly, p,r,s,q );
00067 CPPUNIT_ASSERT( &*fh == ft.middle );
00068
00069 fh = check_facet( poly, r,b,s );
00070 CPPUNIT_ASSERT( &*fh == ft.high );
00071
00072 }
00073
00074 void cut_y()
00075 {
00076 FacetTriple ft = cutting( poly, *fh0, 1, 40,80 );
00077 assert_full_triple( ft );
00078
00079 Polyhedron::Facet_const_handle fh;
00080
00081 fh = check_facet( poly, a,b,u,t);
00082 CPPUNIT_ASSERT( &*fh == ft.low );
00083
00084 fh = check_facet( poly, t,u,w,v );
00085 CPPUNIT_ASSERT( &*fh == ft.middle );
00086
00087 fh = check_facet( poly, v,w,c );
00088 CPPUNIT_ASSERT( &*fh == ft.high );
00089
00090 }
00091
00092
00093 void cut_xy()
00094 {
00095 FacetTriple ft = cutting( poly, *fh0, 0, 40,80 );
00096 assert_full_triple( ft );
00097
00098 Polyhedron::Facet_const_handle fh;
00099
00100 ft = cutting( poly, *ft.middle, 1, 40,80 );
00101 Point p4040 = Point(40,40,0);
00102
00103 fh = check_facet( poly, p,r,s,u,p4040 );
00104 CPPUNIT_ASSERT( &*fh == ft.low );
00105
00106 fh = check_facet( poly, p4040,u,q );
00107 CPPUNIT_ASSERT( &*fh == ft.middle );
00108
00109 CPPUNIT_ASSERT( 0 == ft.high );
00110
00111 fh = check_facet( poly, a,p,p4040,q,c );
00112 fh = check_facet( poly, r,b,s );
00113 }
00114
00115 void cut_z()
00116 {
00117 FacetTriple ft = cutting( poly, *fh0, 2, -1,1 );
00118 Polyhedron::Facet_const_handle fh;
00119
00120 CPPUNIT_ASSERT( 0 == ft.low );
00121
00122 fh = check_facet( poly, a,b,c );
00123 CPPUNIT_ASSERT( &*fh == ft.middle );
00124
00125 CPPUNIT_ASSERT( 0 == ft.high );
00126 }
00127
00128
00129
00130 CPPUNIT_TEST_SUITE( cutting_Polyhedron_Interval_test1 );
00131 CPPUNIT_TEST( cut_x );
00132 CPPUNIT_TEST( cut_y );
00133 CPPUNIT_TEST( cut_xy );
00134 CPPUNIT_TEST( cut_z );
00135 CPPUNIT_TEST_SUITE_END();
00136 };
00137
00138
00139 CPPUNIT_TEST_SUITE_REGISTRATION( cutting_Polyhedron_Interval_test1 );
00140
00141