-
Notifications
You must be signed in to change notification settings - Fork 0
/
MARK.c
790 lines (623 loc) · 27.4 KB
/
MARK.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
//WATERMARK SUGLI SPAZI DESIDERATI IN BASE AGLI INDICI NEL FILE indexes
//FACCIO IN MODO DI SPOSTARE IL MINOR NUMERO DI PUNTI POSSIBILE -->
//SPOSTO DI 4.9cm I PUNTI DELLA PARTE OPPOSTA DEL VALORE DESIDERATO (No 5cm per i problemi coi float)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define XDIMENSION 1600
#define YDIMENSION 1600
#define ZDIMENSION 350
//Questi sono il numero di spazi che voglio marcare
#define XNUMBER 1600
#define YNUMBER 1600
#define ZNUMBER 350
#define DISPLACEMENT 0.050000
typedef struct {
float x;
float y;
float z;
float r;
} point;
typedef struct node {
point* point;
struct node* next;
} List;
typedef enum value {over, under};
typedef struct {
int index;
enum value value;
} indexesToMark;
int main() {
FILE *currentFrame;
int counter, numOfPoints, value, markingIndex, selectValue, i;
float currentValue, currentMean;
//I consider all the spaces with thickness 10cm (max relocation distance is 5cm)
int Xindexes[XNUMBER];
int Yindexes[YNUMBER];
int Zindexes[ZNUMBER];
time_t t;
//Array of pointers of the head of the list of points in every space to mark
List* Xspaces[XDIMENSION];
List* Yspaces[YDIMENSION];
List* Zspaces[ZDIMENSION];
List* newNode;
//List of bits representing the watermarking information
int bits[XNUMBER+YNUMBER+ZNUMBER];
int bitCounter;
currentFrame = fopen("/Users/miche/Desktop/bits.bin", "wb+");
if(currentFrame == NULL) {
printf("\nCannot open bits file\n");
}
for (int j = 0; j < XNUMBER+YNUMBER+ZNUMBER; j++) {
bits[j] = rand() % 2;
fwrite(&bits[j], sizeof(bits[j]), 1, currentFrame);
//printf("%d", bits[j]);
}
fclose(currentFrame);
//INDEX VECTOR INITIALIZATION
//The execution time of this phase is not considered in the watermarking execution time
//I save the values of the indexes to mark in the corresponding array
srand(time(&t));
//printf("1\n");
currentFrame = fopen("/Users/miche/Desktop/indexes.bin", "rb");
for (counter = 0; counter < XNUMBER; counter++) {
fread(&Xindexes[counter], sizeof(Xindexes[counter]), 1, currentFrame);
//printf("\nIndiciX: %d", Xindexes[counter]);
//Xindexes[counter] = counter;
}
if(counter < 1599) {
fread(&i, sizeof(i), 1, currentFrame);
counter++;
}
for (counter = 0; counter < YNUMBER; counter++) {
fread(&Yindexes[counter], sizeof(Yindexes[counter]), 1, currentFrame);
//Yindexes[counter] = counter;
}
if(counter < 1599) {
fread(&i, sizeof(i), 1, currentFrame);
counter++;
}
for (counter = 0; counter < ZNUMBER; counter++) {
fread(&Zindexes[counter], sizeof(Zindexes[counter]), 1, currentFrame);
//Zindexes[counter] = counter;
}
fclose(currentFrame);
//printf("? %d\n", Xindexes[928].index);
clock_t start = clock();
//I put a NULL value in all the heads in the arrays
for(counter = 0; counter < ZDIMENSION; counter++) {
Xspaces[counter] = NULL;
Yspaces[counter] = NULL;
Zspaces[counter] = NULL;
}
//I'm assuming that XDIMENSION and YDIMENSION have the same value
while(counter < XDIMENSION) {
Xspaces[counter] = NULL;
Yspaces[counter] = NULL;
counter++;
}
//Opening the frame to be read
//TODO: fare in modo che il file da aprire venga inserito come input nel programma dall'utente (argc, argv)
//currentFrame = fopen("/Users/miche/Desktop/velodyne/007032.bin", "rb");
currentFrame = fopen("/Users/miche/Desktop/velodyne/001578.bin", "rb");
if(currentFrame == NULL) {
printf("\nCannot open the file\n");
}
//Counting the number of points to correctly initialize the array
//I put the pointer in the file end
fseek(currentFrame, 0, SEEK_END);
//I count the number of bytes in the file
counter = ftell(currentFrame);
//The number of points is counter/16 because we have 4 float (32bits) coordinates for every point
counter = counter/16;
//DEBUG:
printf("\nHow many points? %d", counter);
//I put the pointer in the beginning of the file
rewind(currentFrame);
//This is the array with all the points
//printf("\narray");
point points[counter];
//printf("\narray");
//This variable represents the number of points and will never be changed
numOfPoints = counter;
//START PREPROCESSING PHASE
//Reading points in the file and copying them in the array
value = 0;
while(value != counter) {
//printf("\nCounter: %d ", counter);
//READ X VALUE
fread(&points[value].x, sizeof(points[value].x), 1, currentFrame);
//I select the correct space by dividing the x coord with the space thickness and adding half the max dimension (remind positive and negative values)
markingIndex = (points[value].x/0.1) + (XDIMENSION/2);
/*if(points[value].x < 0) {
printf("\nVALORE: %f INDEX: %d", points[value].x, markingIndex);
}*/
//printf("\n%d", markingIndex);
if(Xspaces[markingIndex] == NULL) {
/*if(markingIndex == 837) {
printf("\nValore: %f", points[value].x);
}*/
Xspaces[markingIndex] = (List *) malloc(sizeof(List));
Xspaces[markingIndex]->point = &points[value];
Xspaces[markingIndex]->next = NULL;
}
else {
newNode = (List *) malloc(sizeof(List));
newNode->point = &points[value];
newNode->next = Xspaces[markingIndex];
Xspaces[markingIndex] = newNode;
}
//READ Y VALUE
fread(&points[value].y, sizeof(points[value].y), 1, currentFrame);
//I select the correct space by dividing the y coord with the space thickness and adding 800
markingIndex = (points[value].y/0.1) + (YDIMENSION/2);
if(Yspaces[markingIndex] == NULL) {
Yspaces[markingIndex] = (List *) malloc(sizeof(List));
Yspaces[markingIndex]->point = &points[value];
Yspaces[markingIndex]->next = NULL;
}
else {
newNode = (List *) malloc(sizeof(List));
newNode->point = &points[value];
newNode->next = Yspaces[markingIndex];
Yspaces[markingIndex] = newNode;
}
//printf("Y: %f ", currentValue);
fread(&points[value].z, sizeof(points[value].z), 1, currentFrame);
//I select the correct space by dividing the x coord with the space thickness and adding 800
markingIndex = (points[value].z/0.1) + (ZDIMENSION/2);
if(Zspaces[markingIndex] == NULL) {
Zspaces[markingIndex] = (List *) malloc(sizeof(List));
Zspaces[markingIndex]->point = &points[value];
Zspaces[markingIndex]->next = NULL;
}
else {
newNode = (List *) malloc(sizeof(List));
newNode->point = &points[value];
newNode->next = Zspaces[markingIndex];
Zspaces[markingIndex] = newNode;
}
//printf("Z: %f ", currentValue);
//this is to read the reflectivity value that isn't needed for our scope
fread(&points[value].r, sizeof(points[value].r), 1, currentFrame);
//printf(" Counter: %d \n", counter);
value++;
}
//END PREPROCESSING PHASE
//I have finished to initialize the structures needed, so I don't have to read anymore and I can close the file
fclose(currentFrame);
//When I write results, I create a new file
//START WATERMARKING PHASE
/*
*****MARK ON X*****
*/
bitCounter = 0;
//I repeat the operation for all the values in the array of indexes of spaces to mark
for(counter = 0; counter < XNUMBER; counter++) {
//printf("\n\nXCycleX %d", counter);
//This is the head of the list of points in the desired region
newNode = Xspaces[Xindexes[counter]];
//printf(" 1 %d\n", Xindexes[counter]);
//At first I do the mean calculus
value = 0;
currentValue = 0;
while(newNode != NULL) {
currentValue = currentValue + newNode->point->x;
if(Xindexes[counter] == 1503) {
printf("\n\n\n\nVALORE: %f\n", newNode->point->x);
}
value++;
newNode = newNode->next;
}
/*if(Xindexes[counter] == 898) {
printf("\nNumero punti = %d", value);
}*/
//printf(" 2\n");
//printf("\nXCurrent value: %f \nXValue: %d", currentValue, value);
//I check if there are points in the space considered (else I proceed with no more computations)
if(value != 0) {
//TODO: check the calculus (see the warning)
//This is now the mean
currentValue = currentValue / value;
//printf("\nXMean: %f", currentValue);
//TODO: CHECK CONVERSION
currentMean = (Xindexes[counter]) - (XDIMENSION/2);
//printf("\nXCurrentMean: %f", currentMean);
/*dopo questo passaggio ho un'imprecisione per via di piccoli decimali (0,00000x), non credo sia un grosso problema
in quanto anche nella parte di estrazione del watermark ho la stessa situazione.
Si tratta di un problema legato ai float
*/
currentMean = (currentMean * 0.100000);
//printf("\nXCurrentMean: %f", currentMean);
currentMean = currentMean + 0.050000;
//currentMean = (roundf(currentMean*10))/10;
if(Xindexes[counter] == 1503) {
printf("\nXAverage value: %f", currentMean);
printf("\nValore medio (da modificare): %f", currentValue);
printf("\nbits[bitCounter] = %d", bits[bitCounter]);
}
//printf("\nXAverage value: %f", currentMean);
//I check if the values for the watermark are correct
if (bits[bitCounter] == 1) {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue < currentMean) {
//printf("\nRegion X [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean + 0.0050000;
newNode = Xspaces[Xindexes[counter]];
while (newNode != NULL) {
if (newNode->point->x < currentMean) {
if(newNode->point->x < (currentMean-0.01)) {
newNode->point->x = newNode->point->x + DISPLACEMENT;
} else {
newNode->point->x = newNode->point->x + 0.02;
}
}
if(Xindexes[counter] == 1503) {
printf("\n\n\n\nVALORE: %f\n", newNode->point->x);
}
newNode = newNode->next;
}
}
} else {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue >= currentMean) {
//printf("\nRegion X [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//printf("\nXModifico");
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean - 0.0050000;
newNode = Xspaces[Xindexes[counter]];
while (newNode != NULL) {
if (newNode->point->x >= currentMean) {
if(newNode->point->x > (currentMean + 0.01)) {
newNode->point->x = newNode->point->x - DISPLACEMENT;
} else {
newNode->point->x = newNode->point->x - 0.02;
}
}
if(Xindexes[counter] == 1503) {
printf("\n\n\n\nVALORE2: %f\n", newNode->point->x);
}
newNode = newNode->next;
}
}
}
bitCounter++;
}
}
/*
*****MARK ON Y*****
*/
//I repeat the operation for all the values in the array of indexes of spaces to mark
for(counter = 0; counter < YNUMBER; counter++) {
//printf("\n\nCycleY %d", counter);
//This is the head of the list of points in the desired region
newNode = Yspaces[Yindexes[counter]];
//At first I do the mean calculus
value = 0;
currentValue = 0;
while(newNode != NULL) {
currentValue = currentValue + newNode->point->y;
/*if(Yindexes[counter] == 840) {
printf("\n\n\n\nVALORE: %f\n", newNode->point->y);
}*/
value++;
newNode = newNode->next;
}
/*if(Yindexes[counter] == 840) {
printf("\nNumero punti = %d", value);
}*/
//printf("\nYCurrent value: %f \nYValue: %d", currentValue, value);
//I check if there are points in the space considered (else I proceed with no more computations)
if(value != 0) {
//TODO: check the calculus (see the warning)
//This is now the mean
currentValue = currentValue / value;
//printf("\nYMean: %f", currentValue);
//TODO: CHECK CONVERSION
currentMean = (Yindexes[counter]) - (YDIMENSION/2);
//printf("\nYCurrentMean: %f", currentMean);
/*dopo questo passaggio ho un'imprecisione per via di piccoli decimali (0,00000x), non credo sia un grosso problema
in quanto anche nella parte di estrazione del watermark ho la stessa situazione.
Si tratta di un problema legato ai float
*/
currentMean = (currentMean * 0.100000);
//printf("\nYCurrentMean: %f", currentMean);
currentMean = currentMean + 0.050000;
//currentMean = (roundf(currentMean*10))/10;
//printf("\nYAverage value: %f", currentMean);
/*if(Yindexes[counter] == 840) {
printf("\nXAverage value: %f", currentMean);
printf("\nValore medio (da modificare): %f", currentValue);
printf("\nbits[bitCounter] = %d", bits[bitCounter]);
}*/
//I check if the values for the watermark are correct
if (bits[bitCounter] == 1) {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue < currentMean) {
//printf("\nYModifico");
//printf("\nRegion Y [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean + 0.0050000;
newNode = Yspaces[Yindexes[counter]];
while (newNode != NULL) {
if (newNode->point->y < currentMean) {
if(newNode->point->y < (currentMean-0.01)) {
newNode->point->y = newNode->point->y + DISPLACEMENT;
} else {
newNode->point->y = newNode->point->y + 0.02;
}
}
newNode = newNode->next;
}
}
} else {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue >= currentMean) {
//printf("\nRegion CAMBIO Y [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//printf("\nYModifico");
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean - 0.0050000;
newNode = Yspaces[Yindexes[counter]];
while (newNode != NULL) {
if (newNode->point->y >= currentMean) {
if(newNode->point->y > (currentMean + 0.01)) {
newNode->point->y = newNode->point->y - DISPLACEMENT;
} else {
newNode->point->y = newNode->point->y - 0.02;
}
}
newNode = newNode->next;
}
}
}
bitCounter++;
}
}
/*
*****MARK ON Z*****
*/
//I repeat the operation for all the values in the array of indexes of spaces to mark
for(counter = 0; counter < ZNUMBER; counter++) {
//printf("\n\nCycleZ %d", counter);
//This is the head of the list of points in the desired region
newNode = Zspaces[Zindexes[counter]];
//At first I do the mean calculus
value = 0;
currentValue = 0;
while(newNode != NULL) {
currentValue = currentValue + newNode->point->z;
value++;
newNode = newNode->next;
}
//printf("\nZCurrent value: %f \nZValue: %d", currentValue, value);
//I check if there are points in the space considered (else I proceed with no more computations)
if(value != 0) {
//TODO: check the calculus (see the warning)
//This is now the mean
currentValue = currentValue / value;
//printf("\nZMean: %f", currentValue);
//TODO: CHECK CONVERSION
currentMean = (Zindexes[counter]) - (ZDIMENSION/2);
//printf("\nZCurrentMean: %f", currentMean);
/*dopo questo passaggio ho un'imprecisione per via di piccoli decimali (0,00000x), non credo sia un grosso problema
in quanto anche nella parte di estrazione del watermark ho la stessa situazione.
Si tratta di un problema legato ai float
*/
currentMean = (currentMean * 0.100000);
//printf("\nZCurrentMean: %f", currentMean);
currentMean = currentMean + 0.050000;
//currentMean = roundf(currentMean);
//printf("\nZAverage value: %f", currentMean);
//I check if the values for the watermark are correct
if (bits[bitCounter] == 1) {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue < currentMean) {
//printf("\nRegion Z [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//printf("\nZModifico");
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean + 0.0050000;
newNode = Zspaces[Zindexes[counter]];
while (newNode != NULL) {
if (newNode->point->z < currentMean) {
if(newNode->point->z < (currentMean-0.01)) {
newNode->point->z = newNode->point->z + DISPLACEMENT;
} else {
newNode->point->z = newNode->point->z + 0.02;
}
}
newNode = newNode->next;
}
}
} else {
//I check if I have to do some changes in point positions due to the watermark insertion
if (currentValue >= currentMean) {
//printf("\nRegion Z [ %f , %f ]", (currentMean - 0.05), (currentMean + 0.05));
//printf("\nZModifico");
//If I have to do changes, I check if I have to move the points 2,5cm or 5cm away
currentMean = currentMean - 0.0050000;
newNode = Zspaces[Zindexes[counter]];
while (newNode != NULL) {
if (newNode->point->z >= currentMean) {
if(newNode->point->z > (currentMean + 0.01)) {
newNode->point->z = newNode->point->z - DISPLACEMENT;
} else {
newNode->point->z = newNode->point->z - 0.02;
}
}
newNode = newNode->next;
}
}
}
bitCounter++;
}
}
//END WATERMARKING PHASE
//START WRITE-BACK PHASE
//Open the file where to write results
//printf("\nWrite back");
currentFrame = fopen("/Users/miche/Desktop/results.bin", "wb+");
if(currentFrame == NULL) {
printf("\nCannot open the file\n");
}
//printf("8\n");
for(counter = 0; counter < numOfPoints; counter++) {
fwrite(&points[counter].x, sizeof(points[counter].x), 1, currentFrame);
fwrite(&points[counter].y, sizeof(points[counter].y), 1, currentFrame);
fwrite(&points[counter].z, sizeof(points[counter].z), 1, currentFrame);
fwrite(&points[counter].r, sizeof(points[counter].r), 1, currentFrame);
}
fseek(currentFrame, 0, SEEK_SET);
//test visivo per verificare che scrivo i valori corretti nel file
/*
value = 0;
for(counter = 0; counter < numOfPoints; counter++) {
if(value != 100) {
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
value++;
}
else {
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("\nX: %f ", currentValue);
printf(" X: %f ", points[counter].x);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("\nY: %f ", currentValue);
printf(" Y: %f ", points[counter].y);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("\nZ: %f ", currentValue);
printf(" Z: %f ", points[counter].z);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("\nR: %f ", currentValue);
printf(" R: %f \n", points[counter].r);
value = 0;
}
}
*/
//TEST IF I WRITE CORRECT VALUES IN THE FILE
/*for(counter = 0; counter < numOfPoints; counter++) {
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
if(currentValue != points[counter].x) {
printf("\nERROR IN WRITE-BACK PHASE!!\n");
}
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
if(currentValue != points[counter].y) {
printf("\nERROR IN WRITE-BACK PHASE!!\n");
}
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
if(currentValue != points[counter].z) {
printf("\nERROR IN WRITE-BACK PHASE!!\n");
}
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
if(currentValue != points[counter].r) {
printf("\nERROR IN WRITE-BACK PHASE!!\n");
}
}*/
/*
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("\nX: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Y: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Z: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("R: %f \n", currentValue);
printf("ULTIMO VALORE: ");
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("X: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Y: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Z: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("R: %f \n", currentValue);
//printf("\nErrore? %d", value);
fseek(currentFrame, 0, SEEK_SET);
value = fread(¤tValue, sizeof(currentValue), 1, currentFrame);
//printf("\nErrore? %d", value);
printf("X: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Y: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Z: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("R: %f \n", currentValue);
value = fread(¤tValue, sizeof(currentValue), 1, currentFrame);
//printf("\nErrore? %d", value);
printf("X: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Y: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Z: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("R: %f ", currentValue);
fseek(currentFrame, 0, SEEK_END);
value = fread(¤tValue, sizeof(currentValue), 1, currentFrame);
//printf("\nErrore? %d", value);
printf("X: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Y: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("Z: %f ", currentValue);
fread(¤tValue, sizeof(currentValue), 1, currentFrame);
printf("R: %f ", currentValue);
*/
fclose(currentFrame);
//END WRITE-BACK PHASE
/*
//print last point
printf("\n\nX: %f ", points[counter-2].x);
printf("Y: %f ", points[counter-2].y);
printf("Z: %f ", points[counter-2].z);
printf("R: %f ", points[counter-2].r);
printf("\nLAST POINT ");
printf("X: %f ", points[counter-1].x);
printf("Y: %f ", points[counter-1].y);
printf("Z: %f ", points[counter-1].z);
printf("R: %f ", points[counter-1].r);
//print first point
printf("\nFIRST POINT ");
printf("X: %f ", points[0].x);
printf("Y: %f ", points[0].y);
printf("Z: %f ", points[0].z);
printf("R: %f ", points[0].r);
printf("\nSECOND POINT ");
printf("X: %f ", points[1].x);
printf("Y: %f ", points[1].y);
printf("Z: %f ", points[1].z);
printf("R: %f ", points[1].r);
*/
//newNode = Xspaces[837];
//counter = 0;
/*
while(NULL != newNode) {
printf("\nX = %f", (newNode->point)->x);
newNode = newNode->next;
counter++;
}
newNode = Yspaces[837];
counter = 0;
while(NULL != newNode) {
printf("\nY = %f", (newNode->point)->y);
newNode = newNode->next;
counter++;
}
newNode = Yspaces[9];
counter = 0;
while(NULL != newNode) {
printf("\nZ = %f", (newNode->point)->z);
newNode = newNode->next;
counter++;
}
*/
clock_t stop = clock();
double elapsed = (double) (stop - start) / CLOCKS_PER_SEC;
printf("\nTime elapsed: %.5f\n", elapsed);
printf("\nDisplacement: %f", DISPLACEMENT);
//printf("\nNumero di punti: %d", counter);
printf("\nFINITO");
return(0);
}