BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Kinetic/internal/Kernel/Cartesian_moving_weighted_point_3.h
Go to the documentation of this file.
00001 // Copyright (c) 2005  Stanford University (USA).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation; version 2.1 of the License.
00007 // See the file LICENSE.LGPL distributed with CGAL.
00008 //
00009 // Licensees holding a valid commercial license may use this file in
00010 // accordance with the commercial license agreement provided with the software.
00011 //
00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 //
00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kinetic_data_structures/include/CGAL/Kinetic/internal/Kernel/Cartesian_moving_weighted_point_3.h $
00016 // $Id: Cartesian_moving_weighted_point_3.h 39777 2007-08-08 15:30:58Z spion $
00017 // 
00018 //
00019 // Author(s)     : Daniel Russel <drussel@alumni.princeton.edu>
00020 
00021 #ifndef CGAL_KINETIC_CARTESIAN_WEIGHTED_MOVING_POINT_3_H_
00022 #define CGAL_KINETIC_CARTESIAN_WEIGHTED_MOVING_POINT_3_H_
00023 #include <CGAL/Kinetic/basic.h>
00024 #include <iostream>
00025 #include <CGAL/Kinetic/internal/Kernel/Cartesian_moving_point_3.h>
00026 
00027 CGAL_KINETIC_BEGIN_INTERNAL_NAMESPACE;
00028 
00029 template <class Coordinate_t>
00030 class Cartesian_moving_weighted_point_3
00031 {
00032 protected:
00033   typedef Cartesian_moving_weighted_point_3<Coordinate_t> This;
00034   typedef Cartesian_moving_point_3<Coordinate_t> Point;
00035 public:
00036   typedef Point Bare_point;
00037   typedef typename Point::Coordinate Coordinate;
00039   Cartesian_moving_weighted_point_3(const Point &pt,
00040                                     const Coordinate &w): point_(pt), weight_(w) {
00041   }
00042 
00043   Cartesian_moving_weighted_point_3(const Coordinate &x,
00044                                     const Coordinate &y,
00045                                     const Coordinate &z): point_(x,y,z), weight_(0) {
00046   }
00047 
00049   template <class Static_point>
00050   Cartesian_moving_weighted_point_3(const Static_point &pt): point_(pt.point()),
00051                                                              weight_(pt.weight()) {
00052   }
00053 
00054   bool operator==(const This & o) const {
00055     return weight() == o.weight() && point() == o.point();
00056   }
00057 
00059   Cartesian_moving_weighted_point_3(){}
00060 
00061   const Coordinate &weight() const
00062   {
00063     return weight_;
00064   }
00065 
00066   const Point &point() const
00067   {
00068     return point_;
00069   }
00070 
00071   bool is_constant() const
00072   {
00073     if (weight_.degree() >0) return false;
00074     return point_.is_constant();
00075   }
00076 
00078   template <class NV>
00079   This transformed_coordinates(const NV &nv) const
00080   {
00081     This ret(point_.transformed_coordinates(nv), nv(weight_));
00082     return ret;
00083   }
00084 
00085   template <class SK>
00086   struct Static_traits
00087   {
00088     typedef typename SK::Weighted_point Static_type;
00089     static Static_type to_static(const This &o, const typename SK::FT &t, const SK&) {
00090       //typedef Bare_point::Static_traits<SK> BPST;
00091       return Static_type(typename SK::Bare_point(o.point().x()(t),
00092                                                  o.point().y()(t),
00093                                                  o.point().z()(t)),
00094                          o.weight()(t));
00095     }
00096   };
00097 
00098   template <class Converter>
00099   struct Coordinate_converter
00100   {
00101     Coordinate_converter(const Converter &c): c_(c), pc_(c){}
00102     typedef Cartesian_moving_weighted_point_3<typename Converter::argument_type> argument_type;
00103     typedef Cartesian_moving_weighted_point_3<typename Converter::result_type> result_type;
00104 
00105     result_type operator()(const argument_type &i) const
00106     {
00107       return result_type(pc_(i.point()), c_(i.weight()));
00108     }
00109 
00110     Converter c_;
00111     typename Bare_point::template Coordinate_converter<Converter> pc_;
00112   };
00113 
00114 protected:
00115   Point point_;
00116   Coordinate weight_;
00117 };
00118 
00119 template <class Coordinate>
00120 std::ostream &operator<<(std::ostream &out, const Cartesian_moving_weighted_point_3<Coordinate> &point)
00121 {
00122   out << point.point() << ", " << point.weight();
00123   return out;
00124 }
00125 
00126 
00127 template <class Coordinate>
00128 std::istream &operator>>(std::istream &in,
00129                          Cartesian_moving_weighted_point_3<Coordinate> &point)
00130 {
00131   Coordinate w;
00132   typename Cartesian_moving_weighted_point_3<Coordinate>::Bare_point p;
00133   in >> p;
00134   char c;
00135   do {
00136     in >> c;
00137   }
00138    while (std::isspace(c,std::locale::classic() ));
00139 
00140   if (c != ',') {
00141     in.setstate(std::ios_base::failbit);
00142     return in;
00143   }
00144   in >> w;
00145   point= Cartesian_moving_weighted_point_3<Coordinate>(p,w);
00146   return in;
00147 }
00148 
00149 
00150 CGAL_KINETIC_END_INTERNAL_NAMESPACE;
00151 
00152 /*CGAL_KINETIC_BEGIN_NAMESPACE;
00153 
00154 template <>
00155 template <class Coord, class SK>
00156 class To_static<typename internal::Cartesian_moving_weighted_point_3<Coord>, typename SK::Weighted_point>:
00157 public To_static_base<typename Coord::NT,
00158 typename internal::Cartesian_moving_weighted_point_3<Coord>,
00159 typename SK::Weighted_point> {
00160 typedef To_static_base<typename Coord::NT,
00161 typename internal::Cartesian_moving_weighted_point_3<Coord>,
00162 typename SK::Weighted_point>  P;
00163 public:
00164 To_static(){}
00165 typename P::result_type operator()(const typename P::argument_type &arg) const {
00166 return typename P::result_type(typename SK::Bare_point(arg.point().x()(P::time()),
00167 arg.point().y()(P::time()),
00168 arg.point().z()(P::time())),
00169 arg.weight()(t_));
00170 }
00171 };
00172 CGAL_KINETIC_END_NAMESPACE*/
00173 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines