Question

I am working on the cutting problem, and I need to figure out how to represent the solution.

For example look at this image, where the gray areas are unused material.

enter image description here

Can you please recommend me possible representations? By the way I am using c++ for this.

Thanks

Was it helpful?

Solution

You could use a vector of structs std::vector<sub> areas; like

struct sub
{
  size_t x, y;
  size_t extent_x, extent_y;
  sub (void) : x(0U), y(0U), extent_x(0U), extent_y(0U) { }
};

Where (x,y) as well as (x+extent_x, y+extent_y) are mapped on the Points of the total image. This vector may either store used or unused parts of the Image.

OTHER TIPS

The 2D image looks like a system memory. Gray area is un-allocated memory and white space is allocated memory. The solution can be similar to memory management done by OS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top