home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / DATAENGINE / engineutility.cpp < prev    next >
C/C++ Source or Header  |  1998-02-26  |  2KB  |  64 lines

  1. // engineutility.cpp
  2.  
  3. // Copyright (C) 1997  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING.LIB); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18.  
  19. #include <engineutility.h>
  20.  
  21. #include <geom_enum.h>
  22. #include <data_enum.h>
  23.  
  24. #include <line.h>
  25. #include <circle.h>
  26. #include <segment.h>
  27. #include <arc.h>
  28.  
  29. double DistanceHandleToPoint(const Handle& h, const Point& point)
  30. {
  31.  
  32.         switch(h.Type())
  33.         {
  34.         case POINT:
  35.                 {
  36.                 Point p(*(reinterpret_cast<const Point*>(h.PointsAt())));
  37.                 return p.Distance(point);
  38.                 }
  39.         case LINE:
  40.                 {
  41.                 Line l(*(reinterpret_cast<const Line*>(h.PointsAt())));
  42.                 return l.Distance(point);
  43.                 }
  44.         case SEGMENT:
  45.                 {
  46.                 Segment s(*(reinterpret_cast<const Segment*>(h.PointsAt())));
  47.                 return s.Distance(point);
  48.                 }
  49.     
  50.         case CIRCLE:
  51.                 {
  52.                 Circle c(*(reinterpret_cast<const Circle*>(h.PointsAt())));
  53.                 return c.Distance(point);
  54.                 }
  55.            case ARC:
  56.         {
  57.                 Arc a(*(reinterpret_cast<const Arc*>(h.PointsAt())));
  58.                 return a.Distance(point);
  59.         }
  60.         }
  61.         // for yet undetected cases:
  62.         return 1.e+99;
  63. }
  64.