ContentAccumulator<_T>& operator += ( const typename Content<_T>::Vector & content ) { contentVector.insert( contentVector.end(), content.begin(), content.end() ); return *this; }
void Sort() { // if(allow_rotation) // std::transform(contentVector.begin(), contentVector.end(), contentVector.begin(), MakeHorizontal()); std::sort( contentVector.begin(), contentVector.end(), GreatestWidthThenGreatestHeightSort() ); }
ContentAccumulator<_T>& operator += ( const Content<_T> & content ) { contentVector.push_back( content ); return *this; }
bool Place(const typename Content<_T>::Vector &contentVector, typename Content<_T>::Vector &remainder) { bool placedAll = true; for( typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++ ) { const Content<_T> & content = *itor; if( Place( content ) == false ) { placedAll = false; remainder.push_back( content ); } } return placedAll; }
bool Fits( const Content<_T> &content ) const { if( (content.coord.x + content.size.w) > w ) return false; if( (content.coord.y + content.size.h) > h ) return false; for(typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++) { if( content.intersects( *itor ) ) return false; } return true; }
static bool Place( Vector &canvasVector, const typename Content<_T>::Vector &contentVector, typename Content<_T>::Vector &remainder ) { typename Content<_T>::Vector todo = contentVector; for( typename Vector::iterator itor = canvasVector.begin(); itor != canvasVector.end(); itor++ ) { Canvas <_T> &canvas = *itor; remainder.clear(); canvas.Place(todo, remainder); todo = remainder; } if(remainder.size()==0) return true; return false; }
bool Use(const Content<_T> &content) { const Size &size = content.size; const Coord &coord = content.coord; topLefts.push_front ( Coord( coord.x + size.w, coord.y ) ); topLefts.push_back ( Coord( coord.x , coord.y + size.h ) ); contentVector.push_back( content ); needToSort = true; return true; }
bool CollectContent( typename Content<_T>::Vector &contentVector ) const { int z = 0; for(typename Canvas<_T>::Vector::const_iterator itor = canvasArray.begin(); itor != canvasArray.end(); itor++) { const typename Content<_T>::Vector &contents = itor->GetContents(); for(typename Content<_T>::Vector::const_iterator itor = contents.begin(); itor != contents.end(); itor++) { Content<_T> content = *itor; content.coord.z = z; contentVector.push_back( content ); } z++; } return true; }
bool HasContent() const { return ( contentVector.size() > 0) ; }