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

Box_3.cc

00001 #include "Box_3.h"
00002 #include <ostream>
00003 
00004 
00005 // Static member initialization.
00006 int IndexBox::next_index = 0;
00007 
00008 
00009 std::ostream& operator<< ( std::ostream& os, const Box_3& b )
00010 {
00011     return os << "Box_3 intervals: " 
00012               << b.min(0) << ':' << b.max(0) << ' '
00013               << b.min(1) << ':' << b.max(1) << ' '
00014               << b.min(2) << ':' << b.max(2) << std::endl;
00015 }
00016 
00017 
00018 Box_3::Box_3( FT xmin, FT xmax, 
00019               FT ymin, FT ymax, 
00020               FT zmin, FT zmax )
00021 {
00022     low[0] = xmin;  low[1] = ymin;  low[2] = zmin;
00023     high[0] = xmax; high[1] = ymax; high[2] = zmax;
00024 }
00025 
00026 
00027 Box_3::Box_3( const Polyhedron::Facet& f )
00028 {
00029     Polyhedron::Halfedge_const_handle h = f.halfedge();
00030 
00031     low[0] = high[0] = CGAL::to_double( h->vertex()->point().x() );
00032     low[1] = high[1] = CGAL::to_double( h->vertex()->point().y() );
00033     low[2] = high[2] = CGAL::to_double( h->vertex()->point().z() );
00034 
00035     for( h = h->next(); h != f.halfedge(); h = h->next() ) {
00036         const Polyhedron::Point& p = h->vertex()->point();
00037 
00038         FT px = CGAL::to_double( p.x() );
00039         FT py = CGAL::to_double( p.y() );
00040         FT pz = CGAL::to_double( p.z() );
00041 
00042         if ( px < low[0] )          low[0] = px;
00043         else if ( px > high[0] )    high[0] = px;
00044 
00045         if ( py < low[1] )          low[1] = py;
00046         else if ( py > high[1] )    high[1] = py;
00047 
00048         if ( pz < low[2] )          low[2] = pz;
00049         else if ( pz > high[2] )    high[2] = pz;
00050     }
00051 }
00052 
00053 
00054 Box_3::Box_3( const Hexahedron_3& h )
00055 {
00056     low[0] = high[0] = CGAL::to_double( h.vertex(0).x() );
00057     low[1] = high[1] = CGAL::to_double( h.vertex(0).y() );
00058     low[2] = high[2] = CGAL::to_double( h.vertex(0).z() );
00059 
00060     for( int i = 1; i < 8; ++i ) {
00061         FT px = CGAL::to_double( h.vertex(i).x() );
00062         FT py = CGAL::to_double( h.vertex(i).y() );
00063         FT pz = CGAL::to_double( h.vertex(i).z() );
00064 
00065         if ( px < low[0] )              low[0] = px;
00066         else if ( px > high[0] )    high[0] = px;
00067 
00068         if ( py < low[1] )              low[1] = py;
00069         else if ( py > high[1] )    high[1] = py;
00070 
00071         if ( pz < low[2] )              low[2] = pz;
00072         else if ( pz > high[2] )    high[2] = pz;
00073     }
00074 }
00075 
00076 
00077 
00078 Box_3 
00079 make_bounding_box( const Polyhedron::Facet& f )
00080 {
00081     Box_3 box(f);
00082     return box;
00083 }
00084 
00085 
00086 Box_3 
00087 make_bounding_box( const Hexahedron_3& h )
00088 {
00089     Box_3 box(h);
00090     return box;
00091 }
00092 
00093 

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