Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rectangle Packing Problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
problem description:

name: rectangle packing problem (2d bin packing, without rotation) see [1]

implementation: java, c or c++

application: merging many rectangular images to one big image containing all source images at rectangular regions

api overview:
needed is a analyser class that does the following
given is a collection of dimension-pairs (width;height)
after the analyse the result must give the "best" optimized for space (bounding box)
and a collection of rectangular regions with the same sizes given from the dimension collection.

example test code (not compileable):

Code:
list = new Vector();

list.add(new Dimension(100, 200));
list.add(new Dimension(130, 100));
list.add(new Dimension(134, 120));
list.add(new Dimension(330, 50));


Vector
 rectangles = new Vector();


Dimension
 boundingBox = [b]RectanglePacker[/b].analyse(list, rectangles);

System.out.println("bounding box size:"+boundingBox);

Enumeration
 e= rectangles.elements();

while (e.hasMoreElements())
{
 Rectangle
  rc = (Rectangle)e.nextElement();

 System.out.println(rc);
}



references:
1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top