Пример #1
0
 ContentAccumulator<_T>& operator += ( const typename Content<_T>::Vector & content ) {
  
   contentVector.insert( contentVector.end(), content.begin(), content.end() );
  
   
   return *this;
 }
Пример #2
0
  void Sort() {
   
//  if(allow_rotation)
//    std::transform(contentVector.begin(), contentVector.end(), contentVector.begin(), MakeHorizontal());
    
    std::sort( contentVector.begin(), contentVector.end(), GreatestWidthThenGreatestHeightSort() );
  }
Пример #3
0
 ContentAccumulator<_T>& operator += ( const Content<_T> & content ) {
  
   contentVector.push_back( content );
  
   
   return *this;
 }
Пример #4
0
  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;
  }
Пример #5
0
        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;
        }
Пример #6
0
 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;
 }
Пример #7
0
 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;
 }
Пример #8
0
        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;
        }
Пример #9
0
 bool HasContent() const {
  
   return ( contentVector.size() > 0) ;
 }