Data structure to represent a solution of 2D material cutting? [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this 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.
Can you please recommend me possible representations? By the way I am using c++ for this.
Thanks

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.

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.

Related

Calculating large numbers in C++ without external libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to write a program that will perform operations on float numbers higher than 10^100.
I can't use any arbitrary precision mathematics libraries that are not included in GCC package by default.
I have NO idea how how to go about it.
Can you point me in the right direction?
You can create a class that can store larger numbers. 12345678 equals to 1234 * 10e4 + 5678.
For large numbers I use string buffers and do manual computation on it. It is much overhead and slow but you get infinite precision.

External library treating polygons and calculating their fractal dimension [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking at a physical problem on an hexagonal 2d lattice. It's now a geometrical problem, only a subset of the edges of the lattice are of interest, I'm given this set. I should then restrict myself to the closed curves that I can compose with these edges. From these polygons I'd like to extract information such as their diameters (maximal distance between two of its points)) and their fractal dimension.
I still don't see how to it from the raw initial data (unordered array of edges) and so I'd like to know if there are packages/library that could help me. From drawing each one of these edges they could return the closed loops they form and after that, analyzing each of these polygons individually.
Thank you.
You can use the box-counting algorithm to compute the fractal dimension:http://en.m.wikipedia.org/wiki/Minkowski%E2%80%93Bouligand_dimension.

What's the best way to allocate HUGE amounts of memory? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm allocating 10 GB of RAM for tons of objects that I will need. I want to be able to squeeze every last byte of RAM I can before hitting some problem like null pointer.
I know the allocator returns continuous memory, so if I have scattered memory from other programs, the max continuous size will be quite small (I assume), or smaller than the actual amount of remaining free memory.
Is it better to allocate the entire size of continuous memory I need in one go (10GB) or is it better to allocate smaller non-contiguous chunks and link them together?
Which one is more likely to always return all the memory I need?

how to create structure array with dynamic size [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to create a structure of array dynamically but i dont know the exact size so it will be added whenever i want...
Consider the following example..
Struct abc
{
double **ptrPoints;
int size;
};
i am defining pointer variable
abc* obj;
i dont know the exact size will be so i can not defile like
obj = new abc[size];
the elements will be added whenever condition satisfied.. i want it like vector but i dont want to use it ....
Please suggest me any way to write the functionality like this...
Thank u
Look up vector. Does all the leg work for you.
Wonder why you do not want to use vector. But you may initially declare array of sufficient size. Then maintain a counter of the elements being used up. If it has no space then use realloc.
Seems the only solution except vectors.
See THIS for realloc

If you use new to allocate space, when must you free it? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
We created the binary tree structures in class which used new to create tnodes. I have to write freetree function for it.
I just have general question. If you use new to allocate space, when must you free it?
When you don't need the allocated space anymore.
struct Data { ... }
...
Data* data{new Data};
data->something();
doSomethingWithDataPtr(data);
delete data;
Obviously this example is very simple, but deciding when to delete allocated space is completely subjective... just make sure you eventually delete it. (Consider using smart pointers instead of new and delete to avoid mistakes).