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

oogl.C

00001 #include <ostream>
00002 #include <vector>
00003 
00004 
00005 
00006 template <class R>
00007 inline
00008 void write_oogl_point( std::ostream& os, const CGAL::Point_3<R>& p )
00009 {
00010     os << CGAL::to_double(p.x()) << " "
00011        << CGAL::to_double(p.y()) << " "
00012        << CGAL::to_double(p.z());
00013 }
00014 
00015 
00016 template <class R>
00017 inline
00018 void write_oogl_segment( std::ostream& os, const CGAL::Segment_3<R>& s )
00019 {
00020     write_oogl_point( os, s.source() );
00021     os << " ";
00022     write_oogl_point( os, s.target() );
00023 }
00024 
00025 
00031 template <class R, class ObjectIterator>
00032 inline
00033 void write_oogl_vect( std::ostream& os, 
00034                       ObjectIterator obj_begin,
00035                       ObjectIterator obj_end )
00036 {
00037     int n_polylines = 0;
00038     int n_vertices = 0;
00039     int n_colours = 0;
00040 
00041     CGAL::Point_3<R> p;
00042     CGAL::Segment_3<R> s;
00043 
00044     for( ObjectIterator i = obj_begin; i != obj_end; ++i ) {
00045         ++n_polylines;
00046 
00047         if ( assign(p,*i) )
00048             n_vertices += 1;
00049         else if ( assign(s,*i) )
00050             n_vertices += 2;
00051         else {
00052             std::cerr << "Yikes!" << std::endl;
00053             --n_polylines;
00054         }
00055     }
00056 
00057     os << "VECT" << std::endl
00058        << n_polylines << " "
00059        << n_vertices << " "
00060        << n_colours << std::endl;
00061 
00062     for( ObjectIterator i = obj_begin; i != obj_end; ++i ) {
00063         if ( assign(p,*i) )
00064             os << "1 ";
00065         else if ( assign(s,*i) )
00066             os << "2 ";
00067     }
00068     os << std::endl;
00069 
00070     for( ObjectIterator i = obj_begin; i != obj_end; ++i ) {
00071         os << "0 ";
00072     }
00073     os << std::endl;
00074 
00075     for( ObjectIterator i = obj_begin; i != obj_end; ++i ) {
00076         if ( assign(p,*i) )
00077             write_oogl_point( os, p );
00078         else if ( assign(s,*i) )
00079             write_oogl_segment( os, s );
00080         os << std::endl;
00081     }
00082 }
00083 
00084 

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