arrows have orientations

This commit is contained in:
Adrien Bourmault 2021-06-21 14:26:09 +02:00
parent 349b851f48
commit 8c48856994
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
5 changed files with 109 additions and 16 deletions

View File

@ -26,7 +26,8 @@ INCDIR=include
SRCDIR=src
DEBDIR=debian
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/main.o
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/model.o \
$(BINDIR)/main.o
CLIOBJ= $(BINDIR)/cli.o
.DEFAULT_GOAL:= all

View File

@ -40,7 +40,7 @@ struct {
int x;
int y;
int z;
int o;
int siteId;
} typedef Arrow_t;
struct {
@ -51,7 +51,7 @@ struct {
struct {
char *label;
int arrowId;
int narrow;
} typedef Site_t;
struct {
@ -119,8 +119,20 @@ struct {
//
// Server
//
struct {
pthread_t *id;
bool pleaseStop;
} typedef Server_t;
/* -------------------------------------------------------------------------- */
//
// Model
//
struct {
int id;
int space_xmax;
int space_ymax;
int space_zmax;
int siteNumber;
} typedef Model_t;

26
include/model.h Normal file
View File

@ -0,0 +1,26 @@
//=-------------------------------------------------------------------------=//
// Model definitions //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#ifndef BASE_H
#include "../include/base.h"
#endif
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model);

View File

@ -21,8 +21,10 @@
#include "../include/base.h"
#include "../include/scheduler.h"
#include "../include/model.h"
#define ARROW_NUMBER 6
#define SITE_NUMBER 2
#define MAX_CYCLES 10
#define MAX_THREAD 0
#define XMAX 30
@ -35,25 +37,21 @@
void *launchScheduler(void *args)
{
Scheduler_t *scheduler0;
Model_t *model0;
//
// Creating structure for the Scheduler
//
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
scheduler0->globalDrawingSpace =
(Space_t*) calloc(1, sizeof(Space_t));
scheduler0->globalDrawingSpace->space =
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
// Creating structure for the model
model0 = (Model_t*) calloc(1, sizeof(Model_t));
// Preparing global drawing space
ModelPrepareSpace(scheduler0->globalDrawingSpace, model0);
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
scheduler0->arrowList->array =
(Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
scheduler0->arrowList->size = ARROW_NUMBER;
printLog("Populating a random arrow list...\n");

56
src/model.c Normal file
View File

@ -0,0 +1,56 @@
//=-------------------------------------------------------------------------=//
// Model management module //
// //
// Copyright © 2021 The Gem-graph Project //
// //
// This file is part of gem-graph. //
// //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU Affero General Public License as //
// published by the Free Software Foundation, either version 3 of the //
// License, or (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU Affero General Public License for more details. //
// //
// You should have received a copy of the GNU Affero General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include "../include/base.h"
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model)
{
globalDrawingSpace->size = (model->space_xmax+1) * (model->space_ymax+1) * (model->space_zmax+1);
globalDrawingSpace->xmax = model->space_xmax;
globalDrawingSpace->ymax = model->space_ymax;
globalDrawingSpace->zmax = model->space_zmax;
globalDrawingSpace->space =
(SpaceUnit_t*) calloc(globalDrawingSpace->size, sizeof(SpaceUnit_t));
for (int i = 0; i < globalDrawingSpace->size; i++) {
globalDrawingSpace->space[i].nsite = model->siteNumber;
globalDrawingSpace->space[i].sites = (Site_t*) calloc(model->siteNumber, sizeof(Site_t));
}
}
void ModelPrepareArrows(Space_t *globalDrawingSpace, ArrowArray_t *arrowList,
Model_t *model)
{
#define ARROW_NUMBER 6
arrowList->array = (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
arrowList->size = ARROW_NUMBER;
// Creating some arrows
globalDrawingSpace->space[3].sites[1].narrow = 1;
arrowList->array[0].siteId = 1;
arrowList->array[0].x = 3;
globalDrawingSpace->space[4].sites[0].narrow = 1;
arrowList->array[1].siteId = 0;
arrowList->array[1].x = 4;
}