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

cutting_Polyhedron_Box_3.cc

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     // Input polyhedron
00011     Point a,b,c;
00012     Polyhedron poly;
00013     Polyhedron::Facet_handle fh0;
00014 
00015     // Points constructed by cut with (10,20) on X axis
00016     Point p,q,r,s;
00017 
00018     // Points constructed by subsequent cut with (10,20) on Y axis
00019     Point t,u,v,w;
00020 
00021     // Box to do the cutting
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         // The facets generated depend on the order of the cuts made.
00067         // These checks assume the cuts are made along axes 0-1-2, in
00068         // that order.  If that ever changes, these checks need to change.
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 

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