Splitter.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Splitter.hpp 1644 2009-01-27 19:26:14Z ckiesch $"
00002 
00005 
00006 //============================================================================
00007 //
00008 //  This file is part of GPSTk, the GPS Toolkit.
00009 //
00010 //  The GPSTk is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU Lesser General Public License as published
00012 //  by the Free Software Foundation; either version 2.1 of the License, or
00013 //  any later version.
00014 //
00015 //  The GPSTk is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU Lesser General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU Lesser General Public
00021 //  License along with GPSTk; if not, write to the Free Software Foundation,
00022 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //  
00024 //  Copyright 2004, The University of Texas at Austin
00025 //
00026 //============================================================================
00027 
00028 #ifndef VPLOT_SPLITTER_H
00029 #define VPLOT_SPLITTER_H
00030 
00031 #include <vector>
00032 #include <list>
00033 #include <map>
00034 #include <memory>
00035 
00036 #include "Path.hpp"
00037 
00038 namespace vplot
00039 {
00044   class Splitter
00045   {
00046   public:
00057     static std::pair<std::list<vdraw::Path*>*,std::list<vdraw::Path*>*> 
00058       splith(double splitter, vdraw::Path* p, bool top, bool bottom, bool continuous=false);
00059 
00067     static std::list<vdraw::Path*>* splitvgap(double gap, vdraw::Path* p);
00068 
00071     inline static bool inBox(const std::pair<double,double>& p, 
00072         double minX, double maxX, double minY, double maxY)
00073     {
00074       return !((p.first<minX || p.first>maxX) || (p.second<minY || p.second>maxY));
00075     }
00076 
00109     static std::pair<double,double> intersectBox(
00110         const std::pair<double,double> inside, const std::pair<double,double> outside, 
00111         double minX, double maxX, double minY, double maxY);
00112 
00124     static std::auto_ptr< std::list< vdraw::Path > > interpToBox(double minX, double maxX, double minY, double maxY, const vdraw::Path& p);
00125 
00136     static std::auto_ptr< vdraw::Path > cropToBox(double minX, double maxX, double minY, double maxY, const vdraw::Path& p);
00137 
00138   private:
00141     static inline double intersecth(double y, const std::pair<double,double>& p1, const std::pair<double,double>& p2)
00142     {
00143       double ratio = (y - p1.second) / (p2.second - p1.second);
00144       double xdist = p2.first - p1.first;
00145       return p1.first + xdist*ratio;
00146     }
00147 
00150     static inline double intersectv(double x, const std::pair<double,double>& p1, const std::pair<double,double>& p2)
00151     {
00152       double ratio = (x - p1.first) / (p2.first - p1.first);
00153       double ydist = p2.second - p1.second;
00154       return p1.second + ydist*ratio;
00155     }
00156   };
00157 }
00158 
00159 #endif

Generated on Tue May 22 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1