Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

Shape Class Reference

Inheritance diagram for Shape:

Inheritance graph
[legend]
Collaboration diagram for Shape:

Collaboration graph
[legend]

Detailed Description

Stores model shape.

It is uses by MarkMask to ask Field under shape.

Definition at line 14 of file Shape.h.

Public Types

typedef std::vector< V2t_marks
typedef t_marks::const_iterator const_iterator

Public Member Functions

 Shape (const std::string &shape)
 Read shape in format: "XXX.
const_iterator marksBegin () const
const_iterator marksEnd () const
int getW () const
int getH () const
std::string toString () const


Member Typedef Documentation

typedef t_marks::const_iterator Shape::const_iterator
 

Definition at line 17 of file Shape.h.

typedef std::vector<V2> Shape::t_marks
 

Definition at line 16 of file Shape.h.


Constructor & Destructor Documentation

Shape::Shape const std::string &  shape  ) 
 

Read shape in format: "XXX.

..
" ".XXXXX\n" "XX...X\n"

NOTE: rows does not need to have the same length

Exceptions:
LayoutException when shape has bad format

Definition at line 25 of file Shape.cpp.

00026 {
00027     int x = 0;
00028     int y = 0;
00029     int max_x = -1;
00030     int max_y = -1;
00031 
00032     for (unsigned int i = 0; i < shape.size(); ++i) {
00033         switch (shape[i]) {
00034             case '\n':
00035                 ++y;
00036                 x = 0;
00037                 break;
00038             case 'X':
00039                 m_marks.push_back(V2(x, y));
00040                 max_x = max(max_x, x);
00041                 max_y = max(max_y, y);
00042                 ++x;
00043                 break;
00044             case '.':
00045                 ++x;
00046                 break;
00047             default:
00048                 throw LayoutException(ExInfo("bad shape char")
00049                         .addInfo("char", shape[i])
00050                         .addInfo("shape", shape));
00051         }
00052     }
00053 
00054     m_w = max_x + 1;
00055     m_h = max_y + 1;
00056 }


Member Function Documentation

int Shape::getH  )  const [inline]
 

Definition at line 28 of file Shape.h.

00028 { return m_h; }

int Shape::getW  )  const [inline]
 

Definition at line 27 of file Shape.h.

00027 { return m_w; }

const_iterator Shape::marksBegin  )  const [inline]
 

Definition at line 25 of file Shape.h.

00025 { return m_marks.begin(); }

const_iterator Shape::marksEnd  )  const [inline]
 

Definition at line 26 of file Shape.h.

00026 { return m_marks.end(); }

std::string Shape::toString  )  const
 

Definition at line 60 of file Shape.cpp.

00061 {
00062     std::string result;
00063 
00064     t_marks::const_iterator end = m_marks.end();
00065     for (t_marks::const_iterator i = m_marks.begin(); i != end; ++i) {
00066         result.append(i->toString());
00067     }
00068     return result;
00069 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:56:48 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2