17 #ifndef KATABATIC_GRID_H 18 #define KATABATIC_GRID_H 22 #include "hurricane/Point.h" 23 #include "hurricane/Box.h" 24 #include "hurricane/Collection.h" 31 using Hurricane::_TName;
32 using Hurricane::Record;
38 using Hurricane::getCollection;
51 inline bool isOnTopBorder (
unsigned int )
const;
52 inline bool isOnRightBorder (
unsigned int )
const;
55 inline unsigned int getRows ()
const;
57 inline unsigned int getIndex (
unsigned int c,
unsigned int r )
const;
58 inline unsigned int getRow (
unsigned int )
const;
59 inline unsigned int getColumn (
unsigned int )
const;
63 virtual Record* _getRecord ()
const;
64 virtual string _getString ()
const = 0;
74 inline unsigned int getSize ()
const;
79 Record* _getRecord ()
const;
80 string _getString ()
const;
81 inline string _getTypeName ()
const;
82 string _print ()
const;
85 vector<DbU::Unit> _graduations;
94 unsigned int _columns;
95 unsigned int _rawSize;
101 virtual void _postCreate ();
102 virtual void _preDestroy ();
113 inline string BaseGrid::Axis::_getTypeName ()
const {
return _TName(
"BaseGrid::Axis"); }
123 inline bool BaseGrid::isOnTopBorder (
unsigned int i )
const {
return getRow (i)+1 ==
getRows(); }
124 inline bool BaseGrid::isOnRightBorder (
unsigned int i )
const {
return getColumn(i)+1 ==
getColumns(); }
135 template<
typename GCellT>
140 inline GCellT* getGCell (
unsigned int index )
const;
141 inline GCellT* getGCell (
const Point p )
const;
142 inline GCellT* getGCell (
const Point p1,
const Point p2 )
const;
143 inline GCellT* getGCellLeft (
const GCellT* gcell )
const;
144 inline GCellT* getGCellRight (
const GCellT* gcell )
const;
145 inline GCellT* getGCellUp (
const GCellT* gcell )
const;
146 inline GCellT* getGCellDown (
const GCellT* gcell )
const;
147 inline vector<GCellT*>* getGCellVector ();
151 ,
unsigned int rowStart
152 ,
unsigned int rowStop );
154 ,
unsigned int columnStart
155 ,
unsigned int columnStop );
157 virtual Record* _getRecord ()
const;
161 vector<GCellT*> _gcells;
176 #include "katabatic/GridCollections.h" 177 #include "katabatic/GridBox.h" 185 template<
typename GCellT>
192 template<
typename GCellT>
197 template<
typename GCellT>
200 if ( ( index < 0 ) || ( index >= _rawSize ) )
return NULL;
202 return _gcells [ index ];
206 template<
typename GCellT>
209 if (not getBoundingBox().contains(p))
return NULL;
214 unsigned int column = _xGraduations.getGraduationNumber ( p.getX(), onColumn );
215 unsigned int row = _yGraduations.getGraduationNumber ( p.getY(), onRow );
217 return getGCell ( getIndex(column,row) );
221 template<
typename GCellT>
224 if (not getBoundingBox().contains(p1))
return NULL;
225 if (not getBoundingBox().contains(p2))
return NULL;
232 unsigned int column1 = _xGraduations.getGraduationNumber ( p1.getX(), onColumn1 );
233 unsigned int column2 = _xGraduations.getGraduationNumber ( p2.getX(), onColumn2 );
234 unsigned int row1 = _yGraduations.getGraduationNumber ( p1.getY(), onRow1 );
235 unsigned int row2 = _yGraduations.getGraduationNumber ( p2.getY(), onRow2 );
237 if ( row1 != row2 ) {
238 if ( onRow1 ) row1 = row2;
241 if ( column1 != column2 ) {
242 if ( onColumn1 ) column1 = column2;
245 return getGCell ( getIndex(column1,row1) );
249 template<
typename GCellT>
252 if ( !gcell )
return NULL;
254 unsigned int index = gcell->
getIndex();
255 if ( !getColumn(index) )
return NULL;
257 return getGCell ( index - 1 );
261 template<
typename GCellT>
264 if ( !gcell )
return NULL;
266 unsigned int index = gcell->
getIndex();
267 if ( getColumn(index) >= getColumns()-1 )
return NULL;
269 return getGCell ( index + 1 );
273 template<
typename GCellT>
276 if ( !gcell )
return NULL;
278 unsigned int index = gcell->
getIndex();
279 if ( getRow(index) >= getRows()-1 )
return NULL;
281 return getGCell ( index + getColumns() );
285 template<
typename GCellT>
288 if ( !gcell )
return NULL;
290 unsigned int index = gcell->
getIndex();
291 if ( !getRow(index) )
return NULL;
293 return getGCell ( index - getColumns() );
297 template<
typename GCellT>
304 template<
typename GCellT>
307 return getCollection(_gcells);
310 template<
typename GCellT>
312 ,
unsigned int rowStart
313 ,
unsigned int rowStop )
315 return Grid_Column<GCellT>(
this,column,rowStart,rowStop);
318 template<
typename GCellT>
320 ,
unsigned int columnStart
321 ,
unsigned int columnStop )
323 return Grid_Row<GCellT>(
this,row,columnStart,columnStop);
327 template<
typename GCellT>
330 Record* record = BaseGrid::_getRecord ();
331 record->add ( getSlot (
"_gcells", &_gcells ) );
342 #endif // KATABATIC_GRID_H
unsigned int getRows() const
Definition: Grid.h:118
void sort()
Definition: Grid.cpp:36
void addGraduation(DbU::Unit)
Definition: Grid.h:110
Abstract Base Class for Irregular Grid.
Definition: Grid.h:44
Template Class for Regular Grid.
Definition: Grid.h:136
const Axis & getXGrads() const
Definition: Grid.h:126
unsigned int getGraduationNumber(DbU::Unit pos, bool &onGraduation) const
Definition: Grid.cpp:42
const Box & getBoundingBox() const
Definition: Grid.h:116
BaseGrid(const Box &)
Definition: Grid.cpp:99
void destroy()
Definition: Grid.h:115
The namespace dedicated to Katabatic.
Definition: Katabatic.dox:13
unsigned int getRawSize() const
Definition: Grid.h:119
unsigned int getColumn(unsigned int) const
Definition: Grid.h:122
unsigned int getRow(unsigned int) const
Definition: Grid.h:121
const Axis & getYGrads() const
Definition: Grid.h:127
unsigned int getSize() const
Definition: Grid.h:111
Graduations on a BaseGrid Axis (H or V).
Definition: Grid.h:68
unsigned int getColumns() const
Definition: Grid.h:117
const DbU::Unit & operator[](unsigned int i) const
Definition: Grid.h:112
unsigned int getIndex(unsigned int c, unsigned int r) const
Definition: Grid.h:120
Grid(const Box &)
Definition: Grid.h:186