space dimension
This commit is contained in:
parent
bff453bb33
commit
de284948d7
|
@ -30,6 +30,11 @@
|
||||||
|
|
||||||
#define BASE_H
|
#define BASE_H
|
||||||
|
|
||||||
|
struct {
|
||||||
|
size_t size;
|
||||||
|
int *space;
|
||||||
|
} typedef IntArray_t;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
@ -60,11 +65,6 @@ struct {
|
||||||
SpaceUnit_t *space;
|
SpaceUnit_t *space;
|
||||||
} typedef Space_t;
|
} typedef Space_t;
|
||||||
|
|
||||||
struct {
|
|
||||||
size_t size;
|
|
||||||
int *space;
|
|
||||||
} typedef IntArray_t;
|
|
||||||
|
|
||||||
#define LOGMSG "[%s]"
|
#define LOGMSG "[%s]"
|
||||||
#define printLog(FORMAT, ...) printf(LOGMSG " " FORMAT, __func__, ##__VA_ARGS__)
|
#define printLog(FORMAT, ...) printf(LOGMSG " " FORMAT, __func__, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
|
26
src/main.c
26
src/main.c
|
@ -26,8 +26,11 @@
|
||||||
|
|
||||||
#define ARROW_NUMBER 150
|
#define ARROW_NUMBER 150
|
||||||
#define MAX_CYCLES 15
|
#define MAX_CYCLES 15
|
||||||
#define SPACE_SIZE 10000
|
|
||||||
#define MAX_THREAD 0
|
#define MAX_THREAD 0
|
||||||
|
#define XMAX 1000
|
||||||
|
#define YMAX 1000
|
||||||
|
#define ZMAX 0
|
||||||
|
#define SPACE_SIZE (XMAX+1) * (YMAX+1) * (ZMAX+1)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +56,9 @@ int main(int argc, char **argv)
|
||||||
scheduler0->globalDrawingSpace->space =
|
scheduler0->globalDrawingSpace->space =
|
||||||
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
|
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
|
||||||
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
|
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
|
||||||
|
scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
|
||||||
|
scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
|
||||||
|
scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
|
||||||
|
|
||||||
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
|
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
|
||||||
scheduler0->arrowList->array =
|
scheduler0->arrowList->array =
|
||||||
|
@ -61,12 +67,18 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
printLog("Populating a random arrow list...\n");
|
printLog("Populating a random arrow list...\n");
|
||||||
for (int i = 0; i < ARROW_NUMBER; i++) {
|
for (int i = 0; i < ARROW_NUMBER; i++) {
|
||||||
scheduler0->arrowList->array[i].x =
|
|
||||||
rand() % scheduler0->globalDrawingSpace->xmax;
|
if (scheduler0->globalDrawingSpace->xmax)
|
||||||
scheduler0->arrowList->array[i].y =
|
scheduler0->arrowList->array[i].x =
|
||||||
rand() % scheduler0->globalDrawingSpace->ymax;
|
rand() % (scheduler0->globalDrawingSpace->xmax + 1);
|
||||||
scheduler0->arrowList->array[i].z =
|
|
||||||
rand() % scheduler0->globalDrawingSpace->zmax;
|
if (scheduler0->globalDrawingSpace->ymax)
|
||||||
|
scheduler0->arrowList->array[i].y =
|
||||||
|
rand() % (scheduler0->globalDrawingSpace->ymax + 1);
|
||||||
|
|
||||||
|
if (scheduler0->globalDrawingSpace->zmax)
|
||||||
|
scheduler0->arrowList->array[i].z =
|
||||||
|
rand() % (scheduler0->globalDrawingSpace->zmax + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduler0->nmaxThread = MAX_THREAD;
|
scheduler0->nmaxThread = MAX_THREAD;
|
||||||
|
|
|
@ -49,15 +49,16 @@ static Center_t *findWorkArea(Center_t *centersList, Arrow_t *electedArrow,
|
||||||
{
|
{
|
||||||
register Center_t *currentCenter, *newCenter;
|
register Center_t *currentCenter, *newCenter;
|
||||||
|
|
||||||
currentCenter = centersList;
|
currentCenter = centersList->next;
|
||||||
newCenter = (Center_t*) malloc(sizeof(Center_t));
|
newCenter = (Center_t*) malloc(sizeof(Center_t));
|
||||||
|
|
||||||
while (currentCenter){
|
while (currentCenter){
|
||||||
if ( abs(electedArrow->x - currentCenter->x) <= ruleRadius
|
if ( (xmax && (abs(electedArrow->x - currentCenter->x) <= ruleRadius))
|
||||||
|| abs(electedArrow->y - currentCenter->y) <= ruleRadius
|
|| (ymax && (abs(electedArrow->y - currentCenter->y) <= ruleRadius))
|
||||||
|| abs(electedArrow->z - currentCenter->z) <= ruleRadius
|
|| (zmax && (abs(electedArrow->z - currentCenter->z) <= ruleRadius))
|
||||||
){
|
){
|
||||||
free(newCenter);
|
free(newCenter);
|
||||||
|
//printLog("Can't find a free area\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
currentCenter = currentCenter->next;
|
currentCenter = currentCenter->next;
|
||||||
|
|
Loading…
Reference in New Issue