⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 region.h

📁 在LINUX下运行的仿真机器人服务器源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C++ -*- *//* *Copyright:    Copyright (C) 2001 RoboCup Soccer Server Maintainance Group.    	Patrick Riley, Tom Howard, Itsuki Noda,	Mikhail Prokopenko, Jan Wendler     This file is a part of SoccerServer.    This code is free software; you can redistribute it and/or    modify it under the terms of the GNU Lesser General Public    License as published by the Free Software Foundation; either    version 2.1 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public    License along with this library; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *EndCopyright: *//* This files defines a class region to specify regions for the coach messages */#ifndef _H_REGION#define _H_REGION#include <memory>#include <iostream>#include <vector>#include <string>#include "vector.h"#include "visitor.h"#include "clangutil.h"#include "arithop.h"#include "hasa.h"#include <list>namespace rcss{  namespace clang  {    class PointSimple;    class PointRel;    class PointBall;    class PointPlayer;    class PointArith;    class Point    {    public: //      typedef util::Visitor10< PointSimple*,//         PointRel*,//         PointBall*,//         PointPlayer*,//         PointArith* > Visitor;//       typedef util::Visitor10< const PointSimple*,//         const PointRel*,//         const PointBall*,//         const PointPlayer*,//         const PointArith* > ConstVisitor;//       class TypeExtractor//         : public util::TypeExtractor10< PointSimple*,//         PointRel*,//         PointBall*,//         PointPlayer*,//         PointArith* >//       {//       protected://         void//         visit( PointSimple* pt )//         { setValue( pt ); }//         void//         visit( PointRel* pt )//         { setValue( pt ); }//         void//         visit( PointBall* pt )//         { setValue( pt ); }//         void//         visit( PointPlayer* pt )//         { setValue( pt ); }//         void//         visit( PointArith* pt )//         { setValue( pt ); }//       }; //       class ConstTypeExtractor//         : public util::TypeExtractor10< const PointSimple*,//         const PointRel*,//         const PointBall*,//         const PointPlayer*,//         const PointArith* >//       {//       protected://         void//         visit( const PointSimple* pt )//         { setValue( pt ); }//         void//         visit( const PointRel* pt )//         { setValue( pt ); }//         void//         visit( const PointBall* pt )//         { setValue( pt ); }//         void//         visit( const PointPlayer* pt )//         { setValue( pt ); }//         void//         visit( const PointArith* pt )//         { setValue( pt ); }//       };       Point()      {}      virtual       ~Point()       {}            virtual      std::ostream&       print( std::ostream& out ) const = 0;      virtual      std::ostream&      printPretty( std::ostream& out, const std::string& line_header ) const = 0;  //       virtual//       void//       accept( Visitor& v ) = 0;//       virtual//       void//       accept( ConstVisitor& v ) const = 0;      virtual      std::auto_ptr< Point >      deepCopy() const = 0;    };      inline      std::ostream&      operator <<(std::ostream & os, const rcss::clang::Point& r )      { return r.print(os); }           class PointSimple      : public Point    {    private:      geom::Vector2D M_vec;    public:      PointSimple()         : Point(),          M_vec()      {}      PointSimple( const double& x,                   const double& y )         : Point(),          M_vec( x, y )      {}      PointSimple( const geom::Vector2D& vec )         : Point(),          M_vec( vec )      {}      ~PointSimple() {}      std::ostream&      print( std::ostream& out ) const      { return out << "(pt " << M_vec.getX() << " " << M_vec.getY() << ")"; }      std::ostream&      printPretty( std::ostream& out, const std::string& line_header ) const      {         return out << line_header << "Point("                    << M_vec.getX() << ", " << M_vec.getY() << ")" << std::endl;       }            geom::Vector2D&      getVec()      { return M_vec; }      const geom::Vector2D&      getVec() const      { return M_vec; }      geom::Vector2D&      setVec( const geom::Vector2D& vec )      { M_vec = vec; return M_vec; }//       void//       accept( Visitor& v )//       { v.startVisit( this ); }//       void//       accept( ConstVisitor& v ) const//       { v.startVisit( this ); }        std::auto_ptr< Point >      deepCopy() const      { return std::auto_ptr< Point >( new PointSimple( *this ) ); }   };    class PointRel      : public Point    {    public:      PointRel()	    {}            PointRel( const double& x,                const double& y,                std::auto_ptr< Point > origin )         : Point(),          m_origin( origin ),          m_offset( x, y )      {}            PointRel( const PointSimple offset,                std::auto_ptr< Point > origin )         : Point(),          m_origin( origin ),          m_offset( offset )      {}      virtual      ~PointRel()      {}            std::ostream&       print( std::ostream& out ) const      {        out << "(pt " << m_offset.getVec().getX() << " "             << m_offset.getVec().getY() << " ";        if( getOrigin() == NULL )	    out << "(null)";        else	    out << *getOrigin();        return out << ")";      }            std::ostream&      printPretty( std::ostream& out, const std::string& line_header ) const      {        out << line_header << "Point-Relative(" << m_offset.getVec().getX()             << ", " << m_offset.getVec().getY() << " ";        if( getOrigin() == NULL )          out << "(null)";        else	    getOrigin()->printPretty( out, line_header + " " );        return out << ")" << std::endl;      }      //       void//       accept( Visitor& v )//       { v.startVisit( this ); }      //       void//       accept( ConstVisitor& v ) const//       { v.startVisit( this ); }            virtual      std::auto_ptr< Point >      deepCopy() const      {	  if( getOrigin() )	      return std::auto_ptr< Point >( new PointRel( m_offset, m_origin->deepCopy() ) ); 	  else	      return std::auto_ptr< Point >( new PointRel( m_offset, std::auto_ptr< Point >() ) );       }      PointSimple      getOffset() const      { return m_offset; }      void      set( const PointSimple& offset )      { m_offset = offset; }      const Point*      getOrigin() const      { return m_origin.get(); }    private:	std::auto_ptr< Point > m_origin;      PointSimple m_offset;    };    class PointBall      : public Point    {    public:      PointBall()         : Point()      {}            ~PointBall()      {}      std::ostream&      print( std::ostream& out ) const      { return out << "(pt ball)"; }            std::ostream&      printPretty( std::ostream& out, const std::string& line_header ) const      { return out << line_header << "Point-Ball" << std::endl; } //       void//       accept( Visitor& v )//       { v.startVisit( this ); }//       void//       accept( ConstVisitor& v ) const//       { v.startVisit( this ); }      std::auto_ptr< Point >      deepCopy() const      { return std::auto_ptr< Point >( new PointBall( *this ) ); }    };    class PointPlayer      : public Point    {    public:      PointPlayer()         : Point(),          M_our_side( false ),          M_unum()      {}      PointPlayer( const bool& our_side, const UNum& unum )         : Point(),          M_our_side( our_side ),          M_unum( unum )      {}      ~PointPlayer()      {}      std::ostream&      print( std::ostream& out ) const      {         return out << "(pt " << (M_our_side ? "our" : "opp")                    << " " << M_unum << ")";      }            std::ostream&       printPretty( std::ostream& out, const std::string& line_header ) const      {         return out << line_header << "Point-Player("                    << (M_our_side ? "our team" : "opponent")                   << " " << M_unum << ")" << std::endl;      }//       void//       accept( Visitor& v )//       { v.startVisit( this ); }//       void//       accept( ConstVisitor& v ) const//       { v.startVisit( this ); }      std::auto_ptr< Point >      deepCopy() const      { return std::auto_ptr< Point >( new PointPlayer( *this ) ); }       /* class specific */      bool       isOurSide() const      { return M_our_side; }            bool      isTheirSide() const      { return !M_our_side; }            UNum      getUNum() const      { return M_unum; }            void       setOurSide( const bool& our_side )      { M_our_side = our_side; }            void      setUNum( const UNum& num )      { M_unum = num; }          private:      bool M_our_side;      UNum M_unum;    };    class PointArith      : public Point    {    public:      PointArith()         : Point(),          M_arith_op( NULL ),          M_idx( 0 )      {}            PointArith( std::auto_ptr< Point > pt1, std::auto_ptr< Point > pt2,                  const util::ArithOp& arith_op )         : Point(),          M_arith_op( &arith_op ),          M_idx( 0 )      {        M_points[ 0 ] = pt1;        M_points[ 1 ] = pt2;      }            PointArith( const PointArith& pt )         : Point(),          M_arith_op( pt.M_arith_op ),          M_idx( 0 )      {        std::auto_ptr< Point > pt_copy1 = pt.M_points[ 0 ]->deepCopy();        M_points[ 0 ] = pt_copy1;        std::auto_ptr< Point > pt_copy2 = pt.M_points[ 1 ]->deepCopy();        M_points[ 1 ] = pt_copy2;      }            ~PointArith()      {}      PointArith&      operator=( const PointArith& pt )      {        std::auto_ptr< Point > pt_copy1 = pt.M_points[ 0 ]->deepCopy();        M_points[ 0 ] = pt_copy1;        std::auto_ptr< Point > pt_copy2 = pt.M_points[ 1 ]->deepCopy();        M_points[ 1 ] = pt_copy2;                M_idx = pt.M_idx;        return *this;      }      std::ostream&      print( std::ostream& out ) const      {        out << "(";        if( M_points[ 0 ].get() == NULL )          out << "(null)";        else          out << *(M_points[ 0 ]);        out << " ";        if( M_arith_op == NULL )          out << "(null)";        else        {          out << *M_arith_op;        }        out << " ";        if( M_points[ 1 ].get() == NULL )          out << "(null)";        else          out << *(M_points[ 1 ]);        return out << ")";      }            std::ostream&      printPretty( std::ostream& out, const std::string& line_header ) const      {         out << line_header << "Point-Arith" << std::endl;        if( M_points[ 0 ].get() == NULL )          out << line_header << " (null)\n";        else          M_points[ 0 ]->printPretty( out, line_header + " " );        if( M_points[ 1 ].get() == NULL )          out << line_header << " (null)\n";        else          M_points[ 1 ]->printPretty( out, line_header + " " );        if( M_arith_op == NULL )          out << line_header << " (null)\n";        else          out << line_header << " operation: " << *M_arith_op << std::endl;                return out;      } //       void//       accept( Visitor& v )//       { v.startVisit( this ); }//       void//       accept( ConstVisitor& v ) const//       { v.startVisit( this ); }      std::auto_ptr< Point >      deepCopy() const      { return std::auto_ptr< Point >( new PointArith( *this ) ); }      bool       setPoint( const int& i, std::auto_ptr< Point >& pt )      {        if (i < 0 || i > 1)          return false;        M_points[i] = pt;        return true;      }      void       setAllPoints( std::auto_ptr< Point >& pt0,                 std::auto_ptr< Point >& pt1 )      {        M_points[0] = pt0;        M_points[1] = pt1;      }      bool            setPoint( std::auto_ptr< Point >& pt )      {        M_points[ M_idx ] = pt;        M_idx = (M_idx + 1) % 2;        return true;      }      Point*       getPoint( const int& i )      { return (i>=0 && i<=1) ? M_points[i].get() : NULL; }      const util::ArithOp*      getOp() const      { return M_arith_op; }      const util::ArithOp&      setOp( const util::ArithOp& arith_op )      { return *(M_arith_op = &arith_op); }          private:      std::auto_ptr< Point > M_points[2];      const util::ArithOp* M_arith_op;      unsigned int M_idx;    };    class RegNull;    class RegQuad;    class RegArc;    class RegUnion;    class RegNamed;    class RegPoint;    class RegTri;    class RegRec;    class Region     {    public://       typedef util::Visitor10< RegNull*,//         RegQuad*,//         RegArc*,//         RegUnion*,//         RegNamed*,//         RegPoint*,//         RegTri*,//         RegRec* > Visitor;//       typedef util::Visitor10< const RegNull*,//         const RegQuad*,//         const RegArc*,//         const RegUnion*,//         const RegNamed*,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -