home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ledar34.zip / leda-r-3_4_tar / LEDA-3.4 / src / plane / _seg_set.c < prev    next >
C/C++ Source or Header  |  1996-09-03  |  2KB  |  67 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA 3.4
  4. +
  5. +  _seg_set.c
  6. +
  7. +  This file is part of the LEDA research version (LEDA-R) that can be 
  8. +  used free of charge in academic research and teaching. Any commercial
  9. +  use of this software requires a license which is distributed by the
  10. +  LEDA Software GmbH, Postfach 151101, 66041 Saarbruecken, FRG
  11. +  (fax +49 681 31104).
  12. +
  13. +  Copyright (c) 1991-1996  by  Max-Planck-Institut fuer Informatik
  14. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  15. +  All rights reserved.
  16. *******************************************************************************/
  17. #include <LEDA/segment_set.h>
  18.  
  19. segment  SegmentSet::key(seg_item it)
  20. { segment s(x0(it),y(it),x1(it),y(it)); 
  21.   return s.rotate(point(0,0),alpha);
  22.  }
  23.  
  24. seg_item SegmentSet::insert(segment s, GenPtr p)
  25. { segment t = s.rotate(point(0,0),-alpha);
  26.   double x0 = t.xcoord1();
  27.   double x1 = t.xcoord2();
  28.   double  y = t.ycoord1();
  29.   return segment_tree<double,double,GenPtr>::insert(x0,x1,y,p);
  30. }
  31.  
  32. seg_item SegmentSet::lookup(segment s)
  33. { segment t = s.rotate(point(0,0),-alpha);
  34.   double x0 = t.xcoord1();
  35.   double x1 = t.xcoord2();
  36.   double  y = t.ycoord1();
  37.   return segment_tree<double,double,GenPtr>::lookup(x0,x1,y);
  38. }
  39.  
  40. void     SegmentSet::del(segment s)
  41. { segment t = s.rotate(point(0,0),-alpha);
  42.   double x0 = t.xcoord1();
  43.   double x1 = t.xcoord2();
  44.   double  y = t.ycoord1();
  45.   (void)segment_tree<double,double,GenPtr>::del(x0,x1,y); 
  46. }
  47.  
  48. list<seg_item>  SegmentSet::intersection(segment q)
  49. { list<seg_tree_item> L;
  50.   segment t = q.rotate(point(0,0),-alpha);
  51.   double  x = t.xcoord1();
  52.   double y0 = t.ycoord1();
  53.   double y1 = t.ycoord2();
  54.   L = segment_tree<double,double,GenPtr>::query(x,y0,y1); 
  55.   return *((list<seg_item>*)&L);
  56. }
  57.  
  58. list<seg_item>  SegmentSet::intersection(line q)
  59. { list<seg_tree_item> L;
  60.   line t = q.rotate(-alpha);
  61.   double  x = t.x_proj(0);
  62.   L = segment_tree<double,double,GenPtr>::y_infinity_query(x); 
  63.   return *((list<seg_item>*)&L);
  64. }
  65.  
  66.