// ====================================================================== // // Copyright (c) 2000 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------- // // release : $CGAL_Revision: CGAL-2.5-I-20 $ // release_date : $CGAL_Date: 2002/08/27 $ // // file : include/CGAL/geowin_support.h // package : GeoWin (1.6.2) // maintainer : Matthias Baesken // revision : 1.6.2 // revision_date : 30 August 2002 // author(s) : Matthias Baesken, Ulrike Bartuschka, Stefan Naeher // // coordinator : Matthias Baesken, Trier () // ====================================================================== #ifndef CGAL_GEOWIN_SUPPORT_H #define CGAL_GEOWIN_SUPPORT_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if (__LEDA__ < 410) // fix problem with missing prefixing for d3 rays ... #if !defined(LEDA_ROOT_INCL_ID) #define LEDA_ROOT_INCL_ID 420047 #include #endif #include #if LEDA_ROOT_INCL_ID == 420047 #undef LEDA_ROOT_INCL_ID #include #endif typedef d3_ray leda_d3_ray; #else #include #endif typedef CGAL::Cartesian DEFREP; typedef CGAL::Point_2< DEFREP > CGALPoint; typedef CGAL::Vector_2< DEFREP > CGALVector; typedef std::list CGALPointlist; typedef CGAL::Segment_2< DEFREP > CGALSegment; typedef std::list CGALSegmentlist; typedef CGAL::Circle_2< DEFREP > CGALCircle; typedef std::list CGALCirclelist; typedef CGAL::Line_2< DEFREP > CGALLine; typedef std::list CGALLinelist; typedef CGAL::Ray_2< DEFREP > CGALRay; typedef std::list CGALRaylist; typedef CGAL::Triangle_2< DEFREP > CGALTriangle; typedef std::list CGALTrianglelist; typedef CGAL::Iso_rectangle_2< DEFREP> CGALRectangle; typedef std::list CGALRectanglelist; typedef CGAL::Polygon_traits_2< DEFREP > mypolyTraits; typedef CGAL::Polygon_2 CGALPolygon; typedef std::list CGALPolygonlist; //3d - points typedef CGAL::Point_3< DEFREP > CGALPoint_3; typedef std::list CGALPoint_3_list; //3d - segments typedef CGAL::Segment_3< DEFREP > CGALSegment_3; typedef std::list CGALSegment_3_list; //3d - lines typedef CGAL::Line_3< DEFREP > CGALLine_3; typedef std::list CGALLine_3_list; //3d - rays typedef CGAL::Ray_3< DEFREP > CGALRay_3; typedef std::list CGALRay_3_list; //3d - triangles typedef CGAL::Triangle_3< DEFREP > CGALTriangle_3; typedef std::list CGALTriangle_3_list; //3d - tetrahedra typedef CGAL::Tetrahedron_3< DEFREP > CGALTetrahedron_3; typedef std::list CGALTetrahedron_3_list; #if defined GEOWIN_USE_NAMESPACE || defined LEDA_NAMESPACE #if !defined GEOWIN_NAMESPACE_NAME #define GEOWIN_NAMESPACE_NAME leda #endif #if !defined(GEOWIN_BEGIN_NAMESPACE) #define GEOWIN_BEGIN_NAMESPACE namespace GEOWIN_NAMESPACE_NAME { #define GEOWIN_END_NAMESPACE } #endif #else #define GEOWIN_BEGIN_NAMESPACE #define GEOWIN_END_NAMESPACE #endif // LEDA namespace support #if !defined(LEDA_BEGIN_NAMESPACE) #define LEDA_BEGIN_NAMESPACE #endif #if !defined(LEDA_END_NAMESPACE) #define LEDA_END_NAMESPACE #endif namespace CGAL { // ---------------------------------------------------------------------- // get rid of the member function calls for coordinate access ... // ---------------------------------------------------------------------- // CGAL ... template double x_double(const CGAL::Point_2& obj) { return CGAL::to_double(obj.x()); } template double y_double(const CGAL::Point_2& obj) { return CGAL::to_double(obj.y()); } // LEDA rat kernel ... double x_double(const leda_rat_point& obj) { return CGAL::to_double(obj.xcoord()); } double y_double(const leda_rat_point& obj) { return CGAL::to_double(obj.ycoord()); } // ---------------------------------------------------------------------- template leda_point convert_to_leda(const CGAL::Point_2& obj) { double x = CGAL::to_double(obj.x()); double y = CGAL::to_double(obj.y()); leda_point p(x,y); return p; } template leda_segment convert_to_leda(const CGAL::Segment_2& obj) { CGAL::Point_2 p1=obj.source(); CGAL::Point_2 p2=obj.target(); leda_segment seg(CGAL::to_double(p1.x()), CGAL::to_double(p1.y()), CGAL::to_double(p2.x()), CGAL::to_double(p2.y()) ); return seg; } template leda_circle convert_to_leda(const CGAL::Circle_2& c) { CGAL::Point_2 p1=c.center(); double radius= ::sqrt(CGAL::to_double(c.squared_radius())); leda_point lp(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_circle lc(lp,radius); return lc; } template leda_line convert_to_leda(const CGAL::Line_2& l) { CGAL::Point_2 p1=l.point(1); CGAL::Point_2 p2=l.point(2); leda_point lp1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point lp2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_line lc(lp1,lp2); return lc; } template leda_ray convert_to_leda(const CGAL::Ray_2& r) { CGAL::Point_2 p1=r.source(); CGAL::Point_2 p2=r.point(1); leda_point lp1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point lp2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_ray rc(lp1,lp2); return rc; } template leda_polygon convert_to_leda(const CGAL::Polygon_2& p) { typedef typename CGAL::Polygon_2::Vertex_const_iterator VCIT; VCIT it=p.vertices_begin(); VCIT st=p.vertices_end(); leda_list lp; while (it != st) { lp.append(leda_point(x_double(*it),y_double(*it))); it++; } leda_polygon ph(lp); return ph; } template leda_polygon convert_to_leda(const CGAL::Triangle_2& t) { CGAL::Point_2 p1= t[1]; CGAL::Point_2 p2= t[2]; CGAL::Point_2 p3= t[3]; leda_point lp1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point lp2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_point lp3(CGAL::to_double(p3.x()), CGAL::to_double(p3.y())); leda_list L; if (t.orientation()== CGAL::LEFT_TURN) { L.append(lp1); L.append(lp2); L.append(lp3); } else { L.push(lp1); L.push(lp2); L.push(lp3); } return leda_polygon(L); } template leda_rectangle convert_to_leda(const CGAL::Iso_rectangle_2& t) { CGAL::Point_2 p1= t.min(); CGAL::Point_2 p2= t.max(); leda_point lp1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point lp2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); return leda_rectangle(lp1,lp2); } } // end namespace CGAL ... LEDA_BEGIN_NAMESPACE ps_file& operator<<(ps_file& F,const leda_d3_point& obj); LEDA_END_NAMESPACE namespace CGAL { template leda_d3_point convert_to_leda(const CGAL::Point_3& obj) { leda_d3_point p(CGAL::to_double(obj.x()), CGAL::to_double(obj.y()), CGAL::to_double(obj.z()) ); return p; } template leda_d3_segment convert_to_leda(const CGAL::Segment_3& obj) { leda_d3_segment s(convert_to_leda(obj.source()), convert_to_leda(obj.target())); return s; } template leda_d3_line convert_to_leda(const CGAL::Line_3& obj) { leda_d3_line l(convert_to_leda(obj.point(0)), convert_to_leda(obj.point(1))); return l; } template leda_d3_ray convert_to_leda(const CGAL::Ray_3& obj) { leda_d3_ray r(convert_to_leda(obj.source()), convert_to_leda(obj.point(1))); return r; } // d2 projection into xy - plane ... template leda_polygon convert_to_leda(const CGAL::Triangle_3& obj) { CGAL::Point_3 p1 = obj[0]; CGAL::Point_3 p2 = obj[1]; CGAL::Point_3 p3 = obj[2]; leda_point pl1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point pl2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_point pl3(CGAL::to_double(p3.x()), CGAL::to_double(p3.y())); leda_list Lh; if (orientation(pl1,pl2,pl3)== CGAL::LEFT_TURN) { Lh.append(pl1); Lh.append(pl2); Lh.append(pl3); } else { Lh.push(pl1); Lh.push(pl2); Lh.push(pl3); } leda_polygon pol(Lh); return pol; } // d2 projection into xy - plane template leda_polygon convert_to_leda(const CGAL::Tetrahedron_3& obj) { CGAL::Point_3 p1 = obj[0]; CGAL::Point_3 p2 = obj[1]; CGAL::Point_3 p3 = obj[2]; CGAL::Point_3 p4 = obj[3]; leda_point pl1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point pl2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_point pl3(CGAL::to_double(p3.x()), CGAL::to_double(p3.y())); leda_point pl4(CGAL::to_double(p4.x()), CGAL::to_double(p4.y())); leda_list Lh; Lh.append(pl1); Lh.append(pl2); Lh.append(pl3); Lh.append(pl4); leda_list Lres = CONVEX_HULL(Lh); leda_polygon pol(Lres); return pol; } } // end namespace CGAL ... LEDA_BEGIN_NAMESPACE // output operators for the ps_file ... template ps_file& operator<<(ps_file& F,const CGAL::Point_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Segment_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Circle_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Line_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Ray_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Polygon_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Triangle_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Iso_rectangle_2& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Point_3& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Segment_3& o) { leda_d3_segment seg = CGAL::convert_to_leda(o); F << seg.project_xy(); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Line_3& o) { leda_d3_line l = CGAL::convert_to_leda(o); leda_line m; if (l.project_xy(m)){ // projection is a line ... F << m; } else { // ... a point ... F << leda_point(l.point1().xcoord(), l.point1().ycoord()); } return F; } template ps_file& operator<<(ps_file& F,const CGAL::Ray_3& o) { leda_d3_ray r = CGAL::convert_to_leda(o); leda_ray m; if (r.project_xy(m)){ // projection is a line ... F << m; } else { // ... a point ... F << leda_point(r.point1().xcoord(), r.point1().ycoord()); } return F; } template ps_file& operator<<(ps_file& F,const CGAL::Triangle_3& o) { F << CGAL::convert_to_leda(o); return F; } template ps_file& operator<<(ps_file& F,const CGAL::Tetrahedron_3& obj) { CGAL::Point_3 p1 = obj[0]; CGAL::Point_3 p2 = obj[1]; CGAL::Point_3 p3 = obj[2]; CGAL::Point_3 p4 = obj[3]; leda_point pl1(CGAL::to_double(p1.x()), CGAL::to_double(p1.y())); leda_point pl2(CGAL::to_double(p2.x()), CGAL::to_double(p2.y())); leda_point pl3(CGAL::to_double(p3.x()), CGAL::to_double(p3.y())); leda_point pl4(CGAL::to_double(p4.x()), CGAL::to_double(p4.y())); F << leda_segment(pl1,pl2); F << leda_segment(pl1,pl3); F << leda_segment(pl1,pl4); F << leda_segment(pl2,pl3); F << leda_segment(pl2,pl4); F << leda_segment(pl3,pl4); return F; } LEDA_END_NAMESPACE static void geowin_generate_circle_segments(leda_list& LS, leda_circle C, int n) { leda_list L; leda_point p = C.point1(), q = C.point2(), r = C.point3(); leda_rat_point rp(p), rq(q), rr(r); leda_rat_circle R(rp,rq,rr); double d = (2*LEDA_PI)/n; double eps = 0.001; double a = 0; for(int i=0; i < n; i++) { leda_rat_point pp = R.point_on_circle(a,eps); L.append(pp); a += d; } // now generate the segments desribing the circle ... #if defined(LEDA_NAMESPACE) leda::list_item lit = L.first(); #else list_item lit = L.first(); #endif while(lit && L.succ(lit)) { LS.append(leda_segment(L[lit].to_point(), L[L.succ(lit)].to_point())); lit = L.succ(lit); } LS.append(leda_segment(L.tail().to_point(), L.head().to_point())); } #include #include // intersects box and bounding box functions ... GEOWIN_BEGIN_NAMESPACE template bool geowin_IntersectsBox(const CGAL::Point_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Segment_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Circle_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Line_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Ray_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Polygon_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Triangle_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Iso_rectangle_2& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Point_3& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Segment_3& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Line_3& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Ray_3& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Triangle_3& obj, double x1,double y1,double x2, double y2,bool f); template bool geowin_IntersectsBox(const CGAL::Tetrahedron_3& obj, double x1,double y1,double x2, double y2,bool f); // ---------------------------------------------- // templates for the functions for the containers // ---------------------------------------------- template void geowin_redraw_fcn(const std::list& L, leda_window& w, leda_color c, leda_color, double x1, double y1, double x2, double y2) { #if defined (__GNUC__) typename std::list::const_iterator it = L.begin(), stop = L.end(); #else std::list::const_iterator it = L.begin(), stop = L.end(); #endif while( it != stop ) { if ( geowin_IntersectsBox(*it, x1, y1, x2, y2,true) ) { w.set_color(c); w << *it; } it++; } } GEOWIN_END_NAMESPACE #include #include GEOWIN_BEGIN_NAMESPACE // new geowin_init_default_type ... template class geo_scene_traits { leda_string description; public: typedef CONT CONTAINER; typedef typename CONT::value_type MYTYPE; leda_string get_name() { return description; } leda_string (*geowin_info_fcn)(const CONTAINER& L); bool (*geowin_IntersectsBox)(const MYTYPE& obj, double x1,double y1,double x2, double y2,bool f); void (*geowin_BoundingBox)(const MYTYPE& obj, double& x1, double& x2,double& y1, double& y2); void (*geowin_Translate)(MYTYPE& obj, double dx, double dy); void (*geowin_Rotate)(MYTYPE& obj, double dx, double dy,double a); void (*geowin_generate_objects)(GeoWin& gw, CONTAINER& L); geo_scene_traits(leda_string (*f1)(const CONTAINER& ), \ bool (*f2)(const MYTYPE&, double, double, double, double,bool ), \ void (*f3)(const MYTYPE&, double&, double&, double&, double& ), \ void (*f4)(MYTYPE&, double, double), void (*f5)(MYTYPE&, double, double, double), \ void (*f6)(GeoWin&, CONTAINER&), leda_string scene_type_name) { description = scene_type_name; geowin_info_fcn = f1; geowin_IntersectsBox = f2; geowin_BoundingBox = f3; geowin_Translate = f4; geowin_Rotate = f5; geowin_generate_objects = f6; } }; #if (__LEDA__ < 410) template void geowin_init_default_type(geo_scene_traits tr) { CONT* t; GeoEditScene* sc = make_edit_prototype(t, tr.get_name()); sc->set_redraw_fcn(0); sc->set_info_fcn(tr.geowin_info_fcn); sc->set_box_intersection_fcn(tr.geowin_IntersectsBox); sc->set_get_bounding_box_fcn(tr.geowin_BoundingBox); sc->set_move_fcn(tr.geowin_Translate); sc->set_rotate_fcn(tr.geowin_Rotate); sc->set_generate_fcn(tr.geowin_generate_objects); } #endif // 2d Points ... template const char* leda_tname(CGAL::Point_2* p) { return "CGALPoint"; } template bool geowin_IntersectsBox(const CGAL::Point_2& obj, double x1,double y1,double x2, double y2,bool f) { double xw= CGAL::to_double(obj.x()); double yw= CGAL::to_double(obj.y()); if (x1<=xw && x2>=xw && y1<=yw && y2>=yw) return true; return false; } template void geowin_BoundingBox(const CGAL::Point_2& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Point_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); obj = obj + vec; } template void geowin_Rotate(CGAL::Point_2& obj, double x, double y, double a) { typedef typename REP::RT RT; leda_point p2(CGAL::to_double(obj.x()), CGAL::to_double(obj.y())); p2 = p2.rotate(leda_point(x,y), a); obj = CGAL::Point_2(RT(p2.xcoord()), RT(p2.ycoord())); } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-point"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { typedef typename REP::RT RT; leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Point_2 p; leda_point mp; forall(mp,H){ p= CGAL::Point_2(RT(mp.xcoord()), RT(mp.ycoord())); L.push_front(p); } } // 3d output ... template void cgal_Point_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_point p = CGAL::convert_to_leda(*iter); G.new_node(leda_d3_point(p.xcoord(), p.ycoord(),0)); } H.join(G); } // Segments template const char* leda_tname(CGAL::Segment_2* p) { return "CGALSegment"; } template bool geowin_IntersectsBox(const CGAL::Segment_2& obj, double x1,double y1,double x2, double y2,bool f) { CGAL::Point_2 p1,p2; p1=obj.source(); p2=obj.target(); leda_segment seg( CGAL::to_double(p1.x()),CGAL::to_double(p1.y()),CGAL::to_double(p2.x()),CGAL::to_double(p2.y()) ); return geowin_IntersectsBox(seg,x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Segment_2& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Segment_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Segment_2& obj, double x, double y, double a) { typedef typename REP::RT RT; CGAL::Point_2 p1,p2; p1=obj.source(); p2=obj.target(); leda_segment hlp( CGAL::to_double(p1.x()), CGAL::to_double(p1.y()), CGAL::to_double(p2.x()), CGAL::to_double(p2.y()) ); hlp = hlp.rotate(leda_point(x,y), a); p1= CGAL::Point_2( RT((hlp.source()).xcoord()), RT((hlp.source()).ycoord()) ); p2= CGAL::Point_2( RT((hlp.target()).xcoord()), RT((hlp.target()).ycoord())); obj = CGAL::Segment_2(p1,p2); } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-segment"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { typedef typename REP::RT RT; leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Segment_2 p; leda_segment mp; forall(mp,H){ CGAL::Point_2 pa(RT(mp.source().xcoord()), RT(mp.source().ycoord())); CGAL::Point_2 pb(RT(mp.target().xcoord()), RT(mp.target().ycoord())); p= CGAL::Segment_2(pa,pb); L.push_front(p); } } // 3d output ... template void cgal_Segment_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_segment s = CGAL::convert_to_leda(*iter); leda_node v1 = G.new_node(leda_d3_point(s.source().xcoord(),s.source().ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(s.target().xcoord(),s.target().ycoord(),0)); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // Circles template void convert_from_leda(const leda_circle& c, CGAL::Circle_2& cir) { typedef typename REP::RT RT; leda_point lp=c.center(); double sr= c.radius()*c.radius(); CGAL::Point_2 p1(RT(lp.xcoord()), RT(lp.ycoord())); cir = CGAL::Circle_2(p1, RT(sr)); } template const char* leda_tname(CGAL::Circle_2* p) { return "CGALCircle"; } template bool geowin_IntersectsBox(const CGAL::Circle_2& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Circle_2& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Circle_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.orthogonal_transform(translate); } template void geowin_Rotate(CGAL::Circle_2& obj, double x, double y, double a) { leda_circle hlp=CGAL::convert_to_leda(obj); hlp = hlp.rotate(leda_point(x,y), a); convert_from_leda(hlp,obj); } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-circle"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Circle_2 c; leda_circle mp; forall(mp,H){ convert_from_leda(mp,c); L.push_front(c); } } // 3d output ... template void cgal_Circle_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_circle c = CGAL::convert_to_leda(*iter); leda_list LS; geowin_generate_circle_segments(LS,c,30); leda_segment siter; forall(siter,LS){ leda_node v1 = G.new_node(leda_d3_point(siter.source().xcoord(),siter.source().ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(siter.target().xcoord(),siter.target().ycoord(),0)); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } } H.join(G); } // Lines template void convert_from_leda(const leda_line& l, CGAL::Line_2& lc) { typedef typename REP::RT RT; leda_point lp1=l.point1(); leda_point lp2=l.point2(); CGAL::Point_2 p1(RT(lp1.xcoord()), RT(lp1.ycoord())); CGAL::Point_2 p2(RT(lp2.xcoord()), RT(lp2.ycoord())); lc = CGAL::Line_2(p1,p2); } template const char* leda_tname(CGAL::Line_2* p) { return "CGALLine"; } template bool geowin_IntersectsBox(const CGAL::Line_2& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Line_2& obj, double& x1, double& x2, double& y1, double& y2) { geowin_BoundingBox(CGAL::convert_to_leda(obj),x1,x2,y1,y2); } template void geowin_Translate(CGAL::Line_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Line_2& obj, double x, double y, double a) { leda_line hlp=CGAL::convert_to_leda(obj); hlp = hlp.rotate(leda_point(x,y), a); convert_from_leda(hlp,obj); } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-Line"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Line_2 obj; leda_line mp; forall(mp,H){ convert_from_leda(mp,obj); L.push_front(obj); } } // 3d output ... template void cgal_Line_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_line li = CGAL::convert_to_leda(*iter); leda_point pm((li.point1().xcoord()+li.point2().xcoord())/2,(li.point1().ycoord()+li.point2().ycoord())/2); leda_vector v = li.point1() - li.point2(); v= v * 50; leda_point p1=pm+v, p2=pm-v; leda_node v1 = G.new_node(leda_d3_point(p1.xcoord(),p1.ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(p2.xcoord(),p2.ycoord(),0)); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // Rays template void convert_from_leda(const leda_ray& r, CGAL::Ray_2& rc) { typedef typename REP::RT RT; leda_point lp1=r.point1(); leda_point lp2=r.point2(); CGAL::Point_2 p1(RT(lp1.xcoord()), RT(lp1.ycoord())); CGAL::Point_2 p2(RT(lp2.xcoord()), RT(lp2.ycoord())); rc = CGAL::Ray_2(p1,p2); } template const char* leda_tname(CGAL::Ray_2* p) { return "CGALRay"; } template bool geowin_IntersectsBox(const CGAL::Ray_2& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Ray_2& obj, double& x1, double& x2, double& y1, double& y2) { geowin_BoundingBox(CGAL::convert_to_leda(obj),x1,x2,y1,y2); } template void geowin_Translate(CGAL::Ray_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Ray_2& obj, double x, double y, double a) { leda_ray hlp=CGAL::convert_to_leda(obj); hlp = hlp.rotate(leda_point(x,y), a); convert_from_leda(hlp,obj); } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-Ray"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Ray_2 obj; leda_ray mp; forall(mp,H){ convert_from_leda(mp,obj); L.push_front(obj); } } // 3d output ... template void cgal_Ray_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_ray r = CGAL::convert_to_leda(*iter); leda_vector v = r.point2() - r.point1(); v= v * 50; leda_point p1=r.source(), p2=p1 + v; leda_node v1 = G.new_node(leda_d3_point(p1.xcoord(),p1.ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(p2.xcoord(),p2.ycoord(),0)); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // Triangles template void convert_from_leda(const leda_polygon& p, CGAL::Triangle_2& tr) { typedef typename REP::RT RT; leda_list L=p.vertices(); leda_point lp1,lp2,lp3; lp1= L.pop(); lp2= L.pop(); lp3= L.pop(); CGAL::Point_2 p1(RT(lp1.xcoord()), RT(lp1.ycoord())); CGAL::Point_2 p2(RT(lp2.xcoord()), RT(lp2.ycoord())); CGAL::Point_2 p3(RT(lp3.xcoord()), RT(lp3.ycoord())); tr= CGAL::Triangle_2(p1,p2,p3); } template const char* leda_tname(CGAL::Triangle_2* t) { return "CGALTriangle"; } template bool geowin_IntersectsBox(const CGAL::Triangle_2& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Triangle_2& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Triangle_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Triangle_2& obj, double x, double y, double a) { leda_polygon hlp=CGAL::convert_to_leda(obj); hlp = hlp.rotate(leda_point(x,y), a); convert_from_leda(hlp,obj); } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-triangle"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Triangle_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_point p0 = CGAL::convert_to_leda((*iter).vertex(0)); leda_point p1 = CGAL::convert_to_leda((*iter).vertex(1)); leda_point p2 = CGAL::convert_to_leda((*iter).vertex(2)); leda_node v0 = G.new_node(leda_d3_point(p0.xcoord(),p0.ycoord(),0)); leda_node v1 = G.new_node(leda_d3_point(p1.xcoord(),p1.ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(p2.xcoord(),p2.ycoord(),0)); leda_edge e1 = G.new_edge(v0,v1); leda_edge e2 = G.new_edge(v1,v0); leda_edge e3 = G.new_edge(v1,v2); leda_edge e4 = G.new_edge(v2,v1); leda_edge e5 = G.new_edge(v2,v0); leda_edge e6 = G.new_edge(v0,v2); G.set_reversal(e1,e2); G.set_reversal(e3,e4); G.set_reversal(e5,e6); } H.join(G); } // Rectangles template void convert_from_leda(const leda_rectangle& r, CGAL::Iso_rectangle_2& rc) { typedef typename REP::RT RT; leda_point lp1= r.lower_left(); leda_point lp2= r.upper_right(); CGAL::Point_2 p1(RT(lp1.xcoord()),RT(lp1.ycoord())); CGAL::Point_2 p2(RT(lp2.xcoord()),RT(lp2.ycoord())); rc = CGAL::Iso_rectangle_2(p1,p2); } template const char* leda_tname(CGAL::Iso_rectangle_2* t) { return "CGALRectangle"; } template bool geowin_IntersectsBox(const CGAL::Iso_rectangle_2& obj, double x1,double y1,double x2, double y2,bool f) { typedef typename REP::RT RT; CGAL::Point_2 pa; pa = CGAL::Point_2(RT(x1), RT(y1)); CGAL::Point_2 pb; pb = CGAL::Point_2(RT(x2), RT(y2)); CGAL::Iso_rectangle_2 r2(pa,pb); return CGAL::do_intersect(obj,r2); } template void geowin_BoundingBox(const CGAL::Iso_rectangle_2& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Iso_rectangle_2& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Iso_rectangle_2& obj, double x, double y, double a) { } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-rectangle"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Iso_rectangle_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_point p0 = CGAL::convert_to_leda((*iter).vertex(0)); leda_point p1 = CGAL::convert_to_leda((*iter).vertex(1)); leda_point p2 = CGAL::convert_to_leda((*iter).vertex(2)); leda_point p3 = CGAL::convert_to_leda((*iter).vertex(3)); leda_node v0 = G.new_node(leda_d3_point(p0.xcoord(),p0.ycoord(),0)); leda_node v1 = G.new_node(leda_d3_point(p1.xcoord(),p1.ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(p2.xcoord(),p2.ycoord(),0)); leda_node v3 = G.new_node(leda_d3_point(p3.xcoord(),p3.ycoord(),0)); leda_edge e1 = G.new_edge(v0,v1); leda_edge e2 = G.new_edge(v1,v0); leda_edge e3 = G.new_edge(v1,v2); leda_edge e4 = G.new_edge(v2,v1); leda_edge e5 = G.new_edge(v2,v3); leda_edge e6 = G.new_edge(v3,v2); leda_edge e7 = G.new_edge(v3,v0); leda_edge e8 = G.new_edge(v0,v3); G.set_reversal(e1,e2); G.set_reversal(e3,e4); G.set_reversal(e5,e6); G.set_reversal(e7,e8); } H.join(G); } // Polygons template void convert_from_leda(const leda_polygon& p, CGAL::Polygon_2& rc) { typedef typename TRAITS::Point_2 POINT; typedef typename TRAITS::RT RT; leda_list pl= p.vertices(); std::list sl; leda_point akt; forall(akt,pl) sl.push_back(POINT(RT(akt.xcoord()), RT(akt.ycoord()))); rc = CGAL::Polygon_2(sl.begin(),sl.end()); } template const char* leda_tname(CGAL::Polygon_2* p) { return "CGALPolygon"; } template leda_window& operator >> (leda_window& w, CGAL::Polygon_2& obj) { leda_polygon p; w >> p; convert_from_leda(p, obj); return w; } template bool geowin_IntersectsBox(const CGAL::Polygon_2& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } // switch off the LEDA bbox version for pre-LEDA 4.3 ... // (because it is buggy in 4.2 and not present in 4.0/4.1) template void geowin_BoundingBox(const CGAL::Polygon_2& obj,double& x1, double& x2, double& y1, double& y2) { #if __LEDA__ < 430 || defined(CGAL_POLYGON_USE_BBOX_AND_AFFINE_TRANSFORMATIONS) CGAL::Bbox_2 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); #else leda_polygon hlp= CGAL::convert_to_leda(obj); leda_point xmin,ymin,xmax,ymax; hlp.bounding_box(xmin,ymin,xmax,ymax); x1 = xmin.xcoord(); x2 = xmax.xcoord(); y1 = ymin.ycoord(); y2 = ymax.ycoord(); #endif } template void geowin_Translate(CGAL::Polygon_2& obj, double dx, double dy) { #if defined(CGAL_POLYGON_USE_BBOX_AND_AFFINE_TRANSFORMATIONS) typedef typename TRAITS::Point_2 POINT; typedef typename TRAITS::RT RT; typedef typename POINT::R REP; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); obj = CGAL::transform(translate,obj); #else leda_polygon hlp= CGAL::convert_to_leda(obj); hlp = hlp.translate(dx,dy); convert_from_leda(hlp,obj); #endif } template void geowin_Rotate(CGAL::Polygon_2& obj, double x, double y, double a) { leda_polygon hlp=CGAL::convert_to_leda(obj); hlp = hlp.rotate(leda_point(x,y), a); convert_from_leda(hlp,obj); } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " CGAL-Polygons"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { leda_list H; geowin_generate_objects(gw,H); //convert the contents CGAL::Polygon_2 obj; leda_polygon mp; forall(mp,H){ convert_from_leda(mp,obj); L.push_front(obj); } } // 3d output ... template void cgal_Polygon_2_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); leda_list LS; for(;iter != L.end(); iter++) { leda_polygon p = CGAL::convert_to_leda(*iter); LS = p.segments(); leda_segment siter; forall(siter,LS) { leda_node v1 = G.new_node(leda_d3_point(siter.source().xcoord(),siter.source().ycoord(),0)); leda_node v2 = G.new_node(leda_d3_point(siter.target().xcoord(),siter.target().ycoord(),0)); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } } H.join(G); } // 3d Points ... template void convert_from_leda(const leda_d3_point& obj, CGAL::Point_3& p) { typedef typename REP::RT RT; p = CGAL::Point_3(RT(obj.xcoord()), RT(obj.ycoord()), RT(obj.zcoord()) ); } template const char* leda_tname(CGAL::Point_3* p) { return "CGALPoint_3"; } template leda_window& operator << (leda_window& w, const CGAL::Point_3& obj) { leda_point p(CGAL::to_double(obj.x()), CGAL::to_double(obj.y())); w << p; return w; } template leda_window& operator >> (leda_window& w, CGAL::Point_3& p) { typedef typename REP::RT RT; leda_point p1; if( w >> p1 ) p = CGAL::Point_3(RT(p1.xcoord()), RT(p1.ycoord()), RT(0)); return w; } template bool geowin_IntersectsBox(const CGAL::Point_3& obj, double x1,double y1,double x2, double y2,bool f) { double xw= CGAL::to_double(obj.x()); double yw= CGAL::to_double(obj.y()); if (x1<=xw && x2>=xw && y1<=yw && y2>=yw) return true; return false; } template void geowin_BoundingBox(const CGAL::Point_3& obj, double& x1, double& x2, double& y1, double& y2) { x1=CGAL::to_double(obj.x()); x2=CGAL::to_double(obj.x()); y1=CGAL::to_double(obj.y()); y2=CGAL::to_double(obj.y()); } template void geowin_Translate(CGAL::Point_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_2 vec; vec= CGAL::Vector_2(RT(dx), RT(dy)); CGAL::Aff_transformation_2 translate(CGAL::TRANSLATION, vec); CGAL::Point_2 pt(obj.x(), obj.y()); CGAL::Point_2 pt2 = pt.transform(translate); obj = CGAL::Point_3(pt2.x(),pt2.y(),obj.z()); } template void geowin_Rotate(CGAL::Point_3& obj, double x, double y, double a) { } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), "3d-point"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { leda_list H; geowin_generate_objects(gw,H); //convert CGAL::Point_3 obj; leda_d3_point mp; forall(mp,H){ convert_from_leda(mp,obj); L.push_back(obj); } } // 3d output ... template void cgal_Point_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_point p = CGAL::convert_to_leda(*iter); G.new_node(p); } H.join(G); } // 3d Segments template const char* leda_tname(CGAL::Segment_3* p) { return "CGALSegment_3"; } template leda_window& operator << (leda_window& w, const CGAL::Segment_3& obj) { leda_d3_segment seg3 = CGAL::convert_to_leda(obj); leda_segment seg(seg3.source().xcoord(),seg3.source().ycoord(), seg3.target().xcoord(),seg3.target().ycoord()); w << seg; return w; } template leda_window& operator >> (leda_window& w, CGAL::Segment_3& p) { typedef typename REP::RT RT; leda_segment seg; if( w >> seg ) { leda_point ps = seg.source(), pt = seg.target(); CGAL::Point_3 cps(RT(ps.xcoord()), RT(ps.ycoord()), RT(0)); CGAL::Point_3 cpt(RT(pt.xcoord()), RT(pt.ycoord()), RT(0)); p = CGAL::Segment_3(cps, cpt); } return w; } template bool geowin_IntersectsBox(const CGAL::Segment_3& obj, double x1,double y1,double x2, double y2,bool f) { leda_d3_segment seg3 = CGAL::convert_to_leda(obj); leda_segment seg(seg3.source().xcoord(),seg3.source().ycoord(), seg3.target().xcoord(),seg3.target().ycoord() ); return geowin_IntersectsBox(seg,x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Segment_3& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_3 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Segment_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_3 vec; vec= CGAL::Vector_3(RT(dx), RT(dy), RT(0)); CGAL::Aff_transformation_3 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Segment_3& obj, double x, double y, double a) { } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " d3-segment"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Segment_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_segment s = CGAL::convert_to_leda(*iter); leda_node v1 = G.new_node(s.source()); leda_node v2 = G.new_node(s.target()); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // 3d Lines template const char* leda_tname(CGAL::Line_3* p) { return "CGALLine_3"; } template leda_window& operator << (leda_window& w, const CGAL::Line_3& obj) { leda_d3_line l3 = CGAL::convert_to_leda(obj); leda_d3_point p1 = l3.point1(); leda_d3_point p2 = l3.point2(); if ((p1.xcoord()==p2.xcoord()) && (p1.ycoord()==p2.ycoord())) w << leda_point(p1.xcoord(), p1.ycoord()); else { leda_line l(leda_point(l3.point1().xcoord(),l3.point1().ycoord()), leda_point(l3.point2().xcoord(), l3.point2().ycoord())); w << l; } return w; } template leda_window& operator >> (leda_window& w, CGAL::Line_3& l) { typedef typename REP::RT RT; leda_line lh; if( w >> lh ) { leda_point ps = lh.point1(), pt = lh.point2(); CGAL::Point_3 cps(RT(ps.xcoord()), RT(ps.ycoord()), RT(0)); CGAL::Point_3 cpt(RT(pt.xcoord()), RT(pt.ycoord()), RT(0)); if (cps == cpt) cpt = CGAL::Point_3(RT(pt.xcoord()), RT(pt.ycoord()), RT(10)); l = CGAL::Line_3(cps, cpt); } return w; } template bool geowin_IntersectsBox(const CGAL::Line_3& obj, double x1,double y1,double x2, double y2,bool f) { leda_d3_line l3 = CGAL::convert_to_leda(obj); leda_segment seg(l3.point1().xcoord(),l3.point1().ycoord(), l3.point2().xcoord(),l3.point2().ycoord() ); return geowin_IntersectsBox(seg,x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Line_3& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Point_3 cps = obj.point(0), cpt = obj.point(1); CGAL::Segment_3 hobj(cps, cpt); CGAL::Bbox_3 bb= hobj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Line_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_3 vec; vec= CGAL::Vector_3(RT(dx), RT(dy), RT(0)); CGAL::Aff_transformation_3 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Line_3& obj, double x, double y, double a) { } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " d3-line"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Line_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_line l = CGAL::convert_to_leda(*iter); leda_d3_point pm((l.point1().xcoord()+l.point2().xcoord())/2, \ (l.point1().ycoord()+l.point2().ycoord())/2, \ (l.point1().zcoord()+l.point2().zcoord())/2); leda_vector v = l.point1() - l.point2(); v= v * 50; leda_d3_point p1=pm+v, p2=pm-v; leda_node v1 = G.new_node(p1); leda_node v2 = G.new_node(p2); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // 3d Ray template const char* leda_tname(CGAL::Ray_3* p) { return "CGALRay_3"; } template leda_window& operator << (leda_window& w, const CGAL::Ray_3& obj) { leda_d3_ray r3 = CGAL::convert_to_leda(obj); leda_d3_point p1 = r3.point1(); leda_d3_point p2 = r3.point2(); if ((p1.xcoord()==p2.xcoord()) && (p1.ycoord()==p2.ycoord())) w << leda_point(p1.xcoord(), p1.ycoord()); else { leda_ray r(leda_point(p1.xcoord(),p1.ycoord()), leda_point(p2.xcoord(), p2.ycoord())); w << r; } return w; } template leda_window& operator >> (leda_window& w, CGAL::Ray_3& r) { typedef typename REP::RT RT; leda_ray rh; if( w >> rh ) { leda_point ps = rh.point1(), pt = rh.point2(); CGAL::Point_3 cps(RT(ps.xcoord()), RT(ps.ycoord()), RT(0)); CGAL::Point_3 cpt(RT(pt.xcoord()), RT(pt.ycoord()), RT(0)); if (cps == cpt) cpt = CGAL::Point_3(RT(pt.xcoord()), RT(pt.ycoord()), RT(10)); r = CGAL::Ray_3(cps, cpt); } return w; } template bool geowin_IntersectsBox(const CGAL::Ray_3& obj, double x1,double y1,double x2, double y2,bool f) { leda_d3_ray r3 = CGAL::convert_to_leda(obj); leda_segment seg(r3.point1().xcoord(),r3.point1().ycoord(), r3.point2().xcoord(),r3.point2().ycoord() ); return geowin_IntersectsBox(seg,x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Ray_3& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Point_3 cps = obj.point(0), cpt = obj.point(1); CGAL::Segment_3 hobj(cps, cpt); CGAL::Bbox_3 bb= hobj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Ray_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_3 vec; vec= CGAL::Vector_3(RT(dx), RT(dy), RT(0)); CGAL::Aff_transformation_3 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Ray_3& obj, double x, double y, double a) { } // functions for the container template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " d3-ray"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Ray_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_ray r = CGAL::convert_to_leda(*iter); leda_vector v = r.point2() - r.point1(); v= v * 50; leda_d3_point p1=r.source(), p2=p1 + v; leda_node v1 = G.new_node(p1); leda_node v2 = G.new_node(p2); leda_edge e1 = G.new_edge(v1,v2); leda_edge e2 = G.new_edge(v2,v1); G.set_reversal(e1,e2); } H.join(G); } // 3d Triangles template const char* leda_tname(CGAL::Triangle_3* t) { return "CGALTriangle_3"; } template leda_window& operator << (leda_window& w, const CGAL::Triangle_3& obj) { w << CGAL::convert_to_leda(obj); return w; } template leda_window& operator >> (leda_window& w, CGAL::Triangle_3& obj) { typedef typename REP::RT RT; CGAL::Triangle_2 th; if (w >> th){ CGAL::Point_2 pa1(th.vertex(0)), pa2(th.vertex(1)), pa3(th.vertex(2)); CGAL::Point_3 p1(pa1.hx(), pa1.hy(), RT(0), pa1.hw()); CGAL::Point_3 p2(pa2.hx(), pa2.hy(), RT(0), pa2.hw()); CGAL::Point_3 p3(pa3.hx(), pa3.hy(), RT(0), pa3.hw()); obj = CGAL::Triangle_3(p1, p2, p3); } return w; } template bool geowin_IntersectsBox(const CGAL::Triangle_3& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Triangle_3& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_3 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Triangle_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_3 vec; vec= CGAL::Vector_3(RT(dx), RT(dy), RT(0)); CGAL::Aff_transformation_3 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Triangle_3& obj, double x, double y, double a) { } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %ss", L.size(), " 3d-triangle"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Triangle_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_point p0 = CGAL::convert_to_leda((*iter).vertex(0)); leda_d3_point p1 = CGAL::convert_to_leda((*iter).vertex(1)); leda_d3_point p2 = CGAL::convert_to_leda((*iter).vertex(2)); leda_node v0 = G.new_node(p0); leda_node v1 = G.new_node(p1); leda_node v2 = G.new_node(p2); leda_edge e1 = G.new_edge(v0,v1); leda_edge e2 = G.new_edge(v1,v0); leda_edge e3 = G.new_edge(v1,v2); leda_edge e4 = G.new_edge(v2,v1); leda_edge e5 = G.new_edge(v2,v0); leda_edge e6 = G.new_edge(v0,v2); G.set_reversal(e1,e2); G.set_reversal(e3,e4); G.set_reversal(e5,e6); } H.join(G); } // 3d tetrahedron ... template const char* leda_tname(CGAL::Tetrahedron_3* t) { return "CGALTetrahedron_3"; } template leda_window& operator << (leda_window& w, const CGAL::Tetrahedron_3& t) { w << CGAL::Segment_3( t[0], t[1]); w << CGAL::Segment_3( t[1], t[2]); w << CGAL::Segment_3( t[2], t[0]); w << CGAL::Segment_3( t[0], t[3]); w << CGAL::Segment_3( t[1], t[3]); w << CGAL::Segment_3( t[2], t[3]); return w; } template leda_window& operator >> (leda_window& w, CGAL::Tetrahedron_3& obj) { typedef typename REP::RT RT; CGAL::Triangle_3 q; w >> q; double x0 = CGAL::to_double( q[0].x()); double y0 = CGAL::to_double( q[0].y()); double x1, y1; w.read_mouse_seg(x0, y0, x1, y1); CGAL::Point_3 p = CGAL::Point_3( RT(x1), RT(y1), RT(0)); w << CGAL::Segment_3( q[0], p); w << CGAL::Segment_3( q[1], p); w << CGAL::Segment_3( q[2], p); obj = CGAL::Tetrahedron_3( q[0], q[1], q[2], p); return w; } template bool geowin_IntersectsBox(const CGAL::Tetrahedron_3& obj, double x1,double y1,double x2, double y2,bool f) { return geowin_IntersectsBox(CGAL::convert_to_leda(obj),x1,y1,x2,y2,f); } template void geowin_BoundingBox(const CGAL::Tetrahedron_3& obj,double& x1, double& x2, double& y1, double& y2) { CGAL::Bbox_3 bb= obj.bbox(); x1= bb.xmin(); x2=bb.xmax(); y1=bb.ymin(); y2=bb.ymax(); } template void geowin_Translate(CGAL::Tetrahedron_3& obj, double dx, double dy) { typedef typename REP::RT RT; CGAL::Vector_3 vec; vec= CGAL::Vector_3(RT(dx), RT(dy), RT(0)); CGAL::Aff_transformation_3 translate(CGAL::TRANSLATION, vec); obj = obj.transform(translate); } template void geowin_Rotate(CGAL::Tetrahedron_3& obj, double x, double y, double a) { } template leda_string geowin_info_fcn(const std::list >& L) { leda_string str("~~~\\black \\tt STL-list of %d %s", L.size(), " 3d-tetrahedra"); return str; } template void geowin_generate_objects(GeoWin& gw, std::list >& L) { } // 3d output ... template void cgal_Tetrahedron_3_d3(const T& L, leda_d3_window& W, GRAPH& H) { GRAPH G; typename T::const_iterator iter = L.begin(); for(;iter != L.end(); iter++) { leda_d3_point p0 = CGAL::convert_to_leda((*iter).vertex(0)); leda_d3_point p1 = CGAL::convert_to_leda((*iter).vertex(1)); leda_d3_point p2 = CGAL::convert_to_leda((*iter).vertex(2)); leda_d3_point p3 = CGAL::convert_to_leda((*iter).vertex(3)); leda_node v0 = G.new_node(p0); leda_node v1 = G.new_node(p1); leda_node v2 = G.new_node(p2); leda_node v3 = G.new_node(p3); leda_edge e1 = G.new_edge(v0,v1); leda_edge e2 = G.new_edge(v1,v0); leda_edge e3 = G.new_edge(v1,v2); leda_edge e4 = G.new_edge(v2,v1); leda_edge e5 = G.new_edge(v2,v0); leda_edge e6 = G.new_edge(v0,v2); leda_edge e7 = G.new_edge(v0,v3); leda_edge e8 = G.new_edge(v3,v0); leda_edge e9 = G.new_edge(v1,v3); leda_edge e10 = G.new_edge(v3,v1); leda_edge e11 = G.new_edge(v2,v3); leda_edge e12 = G.new_edge(v3,v2); G.set_reversal(e1,e2); G.set_reversal(e3,e4); G.set_reversal(e5,e6); G.set_reversal(e7,e8); G.set_reversal(e9,e10); G.set_reversal(e11,e12); } H.join(G); } GEOWIN_END_NAMESPACE #endif // CGAL_GEOWIN_SUPPORT