hex::Path Class Reference

#include <hex.h>

Inheritance diagram for hex::Path:

hex::svg::Identity List of all members.

Detailed Description

A sequence of adjacent hexes.

Definition at line 315 of file hex.h.

Public Member Functions

Area to_area (void) const
const std::list< Hex * > & hexes (void) const
int length (void) const
 in units of I
std::string steps (void) const
std::string str (void) const
 Path (void)
 Required for list<Path>.
 Path (const std::list< Hex * > &hexes)
 Path (Hex *start, const std::string &steps) throw (hex::out_of_range,hex::invalid_argument)
 A Path starting at start, and proceeding in directions from steps.
 Path (Hex *from, const Hex *to) throw ()
 Calculates a minimum-length path between two hexes.


Constructor & Destructor Documentation

hex::Path::Path ( void   )  [inline]

Required for list<Path>.

Definition at line 325 of file hex.h.

hex::Path::Path ( const std::list< Hex * > &  hexes  )  [inline]

Definition at line 326 of file hex.h.

00326 : _hexes(hexes) {}

hex::Path::Path ( Hex start,
const std::string &  steps 
) throw (hex::out_of_range,hex::invalid_argument)

A Path starting at start, and proceeding in directions from steps.

Definition at line 101 of file path.cc.

00103   : _hexes( path(start,steps) )
00104 {}

hex::Path::Path ( Hex from,
const Hex to 
) throw ()

Calculates a minimum-length path between two hexes.

The result is one of many possible solutions.

Definition at line 107 of file path.cc.

00108   : _hexes( path(from,hex::steps(from,to)) )
00109 {}


Member Function Documentation

Area hex::Path::to_area ( void   )  const

Definition at line 32 of file path.cc.

00033 {
00034   std::set<Hex*> result;
00035   std::copy(_hexes.begin(), _hexes.end(), std::inserter(result,result.end()));
00036   return result;
00037 }

const std::list<Hex*>& hex::Path::hexes ( void   )  const [inline]

Definition at line 320 of file hex.h.

Referenced by hex::svg::Document::draw_path().

00320 { return _hexes; }

int hex::Path::length ( void   )  const

in units of I

Definition at line 41 of file path.cc.

Referenced by hex::Boundary::is_container().

00042 {
00043   return int( _hexes.size() );
00044 }

std::string hex::Path::steps ( void   )  const

Definition at line 48 of file path.cc.

References hex::steps().

Referenced by str().

00049 {
00050   std::string result ="";
00051   const Hex* curr =NULL;
00052   for(std::list<Hex*>::const_iterator h=_hexes.begin(); h!=_hexes.end(); ++h)
00053   {
00054     if(curr)
00055         result += hex::steps(curr,*h);
00056     curr = *h;
00057   }
00058   return result;
00059 }

std::string hex::Path::str ( void   )  const

Definition at line 63 of file path.cc.

References steps().

00064 {
00065   assert(!this->_hexes.empty());
00066   std::string result =this->_hexes.front()->str();
00067   result+=":"+this->steps();
00068   return result;
00069 }


The documentation for this class was generated from the following files:
Generated on Thu Feb 21 00:00:55 2008 for libhex by  doxygen 1.5.1