Newer
Older
// Copyright 2017 Istituto Nazionale di Fisica Nucleare
//
// Licensed under the EUPL
import G = require("./globals");
import * as $ from "jquery";
import * as img from "./draw";
let oldFolderParent: string = "";
let oldFolder: string = "";
//inizio leggendo tutti gli elementi da inserire nell'albero (caratterizzati
//dall'avere un url di riferimento)
//per ogni elemento controllo se si tratta di una cartella o di un documento
for (let i: number = 0; i < entry.length; i++) {
let path: string[] = entry[i].childNodes[0].nodeValue.split("");
//cartella, creo l'oggetto corrsipondente
if (path[path.length - 1] == "/") {
let folderName: string[] = entry[i].childNodes[0].nodeValue.split("/");
let Folder = {
text: folderName[folderName.length - 2],
nodes: []
}
//posiziono la radice del file system, ne memorizzo il path e il padre
if (first) {
tree.push(Folder);
oldFolder = entry[i].childNodes[0].nodeValue;
oldFolderParent =
oldFolder.slice(0, oldFolder.lastIndexOf(folderName[folderName.length - 2]));
//per ogni cartella determino la relazione con la cartella precedente
let newFolder: string = entry[i].childNodes[0].nodeValue;
let newFolderParent: string =
newFolder.slice(0, newFolder.lastIndexOf(folderName[folderName.length - 2]));
//cartella sorella con quella memorizzata
if (newFolderParent == oldFolderParent) {
oldFolder = newFolder;
insertOBJinFS(Folder, tree, folderName, 0);
} else if (newFolderParent == oldFolder) {
oldFolder = newFolder;
oldFolderParent = newFolderParent;
insertOBJinFS(Folder, tree, folderName, 0);
//nessuno dei casi precedenti
} else {
//arretro nell'albero fino a trovare lo stesso padre. Per fare questo
//tolgo al padre memorizzato in precedenza prima "/" poi il nome dell'
//ultima cartella
while (newFolderParent != oldFolderParent) {
oldFolderParent = oldFolderParent.slice(0, oldFolderParent.length - 1);
oldFolderParent = oldFolderParent.slice(0, (oldFolderParent.lastIndexOf("/") + 1));
}
oldFolder = newFolder;
insertOBJinFS(Folder, tree, folderName, 0);
}
}
//documento, creo l'oggetto corrispondente e lo inserisco nell'albero
let fileName: string[] = entry[i].childNodes[0].nodeValue.split("/");
let filePath: string = entry[i].childNodes[0].nodeValue;
let File = {
text: fileName[fileName.length - 1],
icon: "glyphicon glyphicon-file",
selectedIcon: "glyphicon glyphicon-file",
url: filePath
}
insertOBJinFS(File, tree, fileName, 1);
}
}
}
//funzione che posiziona l'oggetto passato in input nell'albero
//determino la profondità dell'oggetto (se è un file devo aggiungere 1 a causa di "/")
let depth: number = objfsName.length;
if (type) depth++;
//in base alla profondità determino a quale oggetto agganciare quello in input
let treePosition: any;
let l: number = tree.length - 1;
switch (depth) {
case 6: treePosition = tree; break;
case 7: treePosition = tree[l].nodes; break;
case 8: treePosition =
tree[l].nodes[tree[l].nodes.length - 1].nodes; break;
case 9: treePosition =
tree[l].nodes[tree[l].nodes.length - 1].nodes[tree[l].nodes[tree[l].nodes.length - 1].nodes.length - 1].nodes;
break;
case 10: treePosition =
tree[l].nodes[tree[l].nodes.length - 1].nodes[tree[l].nodes[tree[l].nodes.length - 1].nodes.length - 1].nodes[tree[l].nodes[tree[l].nodes.length - 1].nodes[tree[l].nodes[tree[l].nodes.length - 1].nodes.length - 1].nodes.length - 1].nodes;
break;
treePosition[treePosition.length - 1].nodes.push(objfs);
}
//funzione che dato l'url di un file, lo apre e lo legge passandone il contenuto
//alla funzione readData(). Questa funzione è invocata quando viene selezionato
//un file dall'albero
let fileName: string[] = url.split("/");
console.log("Try to open " + fileName[fileName.length - 1] + " ...");
let txtFile: any = new XMLHttpRequest();
txtFile.open("GET", url, true);
if (txtFile.readyState === 4) {
if (txtFile.status === 200) {
txtFile.send(null);
}
let xMin = 0;
let yMin = 0;
let xMax = 0;
let yMax = 0;
let step = 0; //dimensione di un pixel in micorn
let direction = 'u'; // read direction ('r' -> row, 'c' -> column, 'u' -> undefined)
//scorro l'array soffermandomi solo sulle righe "intestazione delle x". Devo
//determinare ascisse e cordinate minime e massime, il passo e la direzione di
//scansione
for (let i = 0; i < lines.length; i++) {
if (parseInt(lines[i]) > 17000 && lines[i][0] == '5') {
if (xMin == 0) { //se sono alla prima intestazione salvo la x e la y
xMin = parseInt(lines[i]);
yMin = parseInt(lines[i + 1]);
i++;
} else { //definisco passo e direzione di scansione dalla seconda intestazione
if (parseInt(lines[i]) == xMin) {
direction = 'c';
step = Math.abs(yMin - +lines[i + 1]); // the unary + converts to number
//se sto leggendo per colonne determino xMax leggendo dalla fine
for (let j: number = lines.length; j > i; j--) {
//se la riga è "intestazione x" memorizzo xMax e lo confronto con xMin
if (parseInt(lines[j]) > 17000 && lines[j][0] == '5') {
xMax = parseInt(lines[j]);
if (xMax < xMin) { let t: number = xMax; xMax = xMin; xMin = t; }
break;
}
}
} else {
direction = 'r';
step = Math.abs(xMin - +lines[i]); // the unary + converts to number
//se sto leggendo per righe determino yMax leggendo dalla fine
for (let j: number = lines.length; j > i; j--) {
//se la riga è "intestazione y" memorizzo yMax e lo confronto con yMin
if (parseInt(lines[j]) > 17000 && lines[j][0] == '6') {
yMax = parseInt(lines[j]);
if (yMax < yMin) { let t: number = yMax; yMax = yMin; yMin = t; }
break;
}
}
}
break;
}
}
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
//A seconda della direzione di lettura determino o yMin e yMax, o xMin e xMax
for (let i: number = 2; i < lines.length; i++) {
if (direction == 'c') { //se leggo per colonne devo deterinare yMin e yMax
//mi soffermo sulle righe "intestazione y"
if (parseInt(lines[i]) > 17000 && lines[i][0] == '6') {
if (yMin > parseInt(lines[i])) {
yMin = parseInt(lines[i]);
}
if (yMax < parseInt(lines[i])) {
yMax = parseInt(lines[i]);
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (parseInt(lines[i]) == xMin + (step * 2)) { break; }
} else { //se leggo per righe devo deterinare xMin e xMax
//mi soffermo sulle righe "intestazione x"
if (parseInt(lines[i]) > 17000 && lines[i][0] == '5') {
if (xMin > parseInt(lines[i])) {
xMin = parseInt(lines[i]);
}
if (xMax < parseInt(lines[i])) {
xMax = parseInt(lines[i]);
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (parseInt(lines[i]) == yMin + 2000) { break; }
}
}
metadata = { xMin, xMax, yMin, yMax, step, direction };
return metadata;
}
// version working on an array of numbers, obtained from the array of string lines
{
let metadata = new G.Metadata();
let xMin: number = 0, yMin: number = 0, xMax: number = 0, yMax: number = 0;
let step: number = 0; //dimensione di un pixel in micorn
let direction: string = 'u'; //direzione di lettura
//scorro l'array soffermandomi solo sulle righe "intestazione delle x". Devo
//determinare ascisse e cordinate minime e massime, il passo e la direzione di
//scansione
for (let i = 0; i < lines.length; i++) {
let p = lines[i];
if (lines[i] > 17000 && lines[i].toString()[0] == '5') {
if (xMin == 0) { //se sono alla prima intestazione salvo la x e la y
xMin = lines[i];
yMin = lines[i + 1];
i++;
} else { //definisco passo e direzione di scansione dalla seconda intestazione
if (lines[i] == xMin) {
direction = 'c';
step = Math.abs(yMin - lines[i + 1]); // the unary + converts to number
//se sto leggendo per colonne determino xMax leggendo dalla fine
for (let j: number = lines.length; j > i; j--) {
//se la riga è "intestazione x" memorizzo xMax e lo confronto con xMin
if (lines[j] > 17000 && lines[j].toString()[0] == '5') {
xMax = lines[j];
if (xMax < xMin) { let t: number = xMax; xMax = xMin; xMin = t; }
break;
}
}
} else {
direction = 'r';
step = Math.abs(xMin - lines[i]); // the unary + converts to number
//se sto leggendo per righe determino yMax leggendo dalla fine
for (let j: number = lines.length; j > i; j--) {
//se la riga è "intestazione y" memorizzo yMax e lo confronto con yMin
if (lines[j] > 17000 && lines[j].toString()[0] == '6') {
yMax = lines[j];
if (yMax < yMin) { let t: number = yMax; yMax = yMin; yMin = t; }
break;
}
}
}
break;
}
}
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
//A seconda della direzione di lettura determino o yMin e yMax, o xMin e xMax
for (let i: number = 2; i < lines.length; i++) {
if (direction == 'c') { //se leggo per colonne devo deterinare yMin e yMax
//mi soffermo sulle righe "intestazione y"
if (lines[i] > 17000 && lines[i].toString()[0] == '6') {
if (yMin > lines[i]) {
yMin = lines[i];
}
if (yMax < lines[i]) {
yMax = lines[i];
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (lines[i] == xMin + (step * 2)) { break; }
} else { //se leggo per righe devo deterinare xMin e xMax
//mi soffermo sulle righe "intestazione x"
if (lines[i] > 17000 && lines[i].toString()[0] == '5') {
if (xMin > lines[i]) {
xMin = lines[i];
}
if (xMax < lines[i]) {
xMax = lines[i];
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (lines[i] == yMin + 2000) { break; }
}
}
metadata = { xMin, xMax, yMin, yMax, step, direction };
export function get_metadata(lines: string[]): G.Metadata;
export function get_metadata(lines: number[]): G.Metadata;
export function get_metadata(lines): G.Metadata
{
if (Array.isArray(lines)) {
let e = lines[0];
if (typeof e == "string") {
return get_metadata_str(lines);
} else if (typeof e == "number") {
return get_metadata_num(lines);
} else {
// error
}
} else {
// error;
}
}
// La funzione readImage() prende in ingresso il file di input memorizzato nella
// stringa "fileString". La funzione riempie la matrice "DataMatrix" con i dati
// in modo che essi siano memorizzati in un formato più leggibile. Sono ricavate
// anche altre variabili necessarie per il resto del codice.
export function readImage(content: string): G.Image
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
{
return readImage_num(content);
}
/*export*/ function readImage_num(content: string): G.Image
{
let lines = content.split("\n").map(Number);
const metadata = get_metadata(lines);
//coordinate minime e massime in entrambe le dimensioni
const { yMin, xMin, xMax, yMax, step, direction } = metadata;
// Risolvo gli shift
for (let i = 0; i < lines.length; i++) {
if (lines[i] > 17000 && lines[i] < 60000000) { // this is an x-coordinate
if (direction == 'c' && (lines[i] / 1000) % 2 != 0) {
// increment the y-coordinate of odd columns
lines[i + 1] += step;
} else if (direction == 'r' && (lines[i + 1] / 1000) % 2 != 0) {
// increment the x-coordinate of even rows
lines[i] += step;
}
}
}
//Definisco le dimensioni della matrice DataMatrix e la inizializzo
let xDim: number;
let yDim: number;
if (direction == 'c') {
xDim = (xMax - xMin) / step + 1;
yDim = (yMax - yMin) / step - 2;
} else {
xDim = (xMax - xMin) / step - 2;
yDim = (yMax - yMin) / step + 1;
}
let image = new G.Image();
image.width = xDim;
image.height = yDim;
image.DataMatrix = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
image.DataMatrix[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
image.DataMatrix[i][j] = new Array(G.Image.depth);
for (let k: number = 0; k < G.Image.depth; k++) {
image.DataMatrix[i][j][k] = 0;
}
}
}
//riempio la matrice DataMatrix eliminando i bordi
let x: number, y: number;
let write: boolean;
for (let i = 0; i < lines.length; i++) {
//riga "intestazione x": memorizzo le x e le y del punto e avanzo al conteggio
if (lines[i] > 17000 && lines[i].toString()[0] == '5') {
x = lines[i] - xMin;
y = lines[i + 1] - yMin;
if (x != 0) { x /= step; }
if (y != 0) { y /= step; }
i++;
//non è un pixel del bordo e sto leggendo per colonne: i successivi valori
//sono da considerare
if (direction == 'c' && y != 0 && y != 1 && y != (yMax - yMin) / step &&
y != (yMax - yMin) / step + 1) {
write = true;
y -= 2; //aggiorno la y con i bordi tagliati
} else if (direction == 'r' && x != 0 && x != 1 && x != (xMax - xMin) / step &&
x != (xMax - xMin) / step + 1) {
//non è un pixel del bordo e sto leggendo per righe: i successivi valori
//sono da considerare
write = true;
x -= 2; //aggiorno la x con i bordi tagliati
} else {
//pixel del bordo: i valori successivi sono da ignorare
write = false;
}
//conteggio da considerare (non del bordo)
} else if (lines[i] < 17000 && write == true) {
image.DataMatrix[xDim - x - 1][yDim - y - 1][lines[i]] += 1;
}
}
G.nOfCounts = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
G.nOfCounts[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
G.nOfCounts[i][j] = G.sumVect(image.DataMatrix[i][j], 0, image.DataMatrix[i][j].length);
}
}
G.maxAbsolute = G.findMax(G.nOfCounts, { x: 0, y: 0 }, { x: xDim - 1, y: yDim - 1 });
G.setDataForCompleteChart(image);
return image;
}
/*export*/ function readImage_str(content: string): G.Image
{
let lines = content.split("\n");
const metadata = get_metadata(lines);
//coordinate minime e massime in entrambe le dimensioni
const xMin = metadata.xMin;
const yMin = metadata.yMin;
const xMax = metadata.xMax;
const yMax = metadata.yMax;
const step = metadata.step; //dimensione di un pixel in micorn
const direction = metadata.direction; //direzione di lettura
//Risolvo gli shift
for (let i = 0; i < lines.length; i++) {
//se leggo per colonne allora aggiungo 1 alle y di tutte le colonne dispari
if (direction == 'c' && parseInt(lines[i]) > 17000 &&
lines[i][0] == '5' && (parseInt(lines[i]) / 1000) % 2 != 0) {
lines[i + 1] = (parseInt(lines[i + 1]) + step).toString();
}
//se leggo per righe allora aggiungo 1 alle x di tutte le righe dispari
else if (direction == 'r' && parseInt(lines[i]) > 17000 &&
lines[i][0] == '5' && (parseInt(lines[i + 1]) / 1000) % 2 != 0) {
lines[i] = (parseInt(lines[i]) + step).toString();
}
}
//Definisco le dimensioni della matrice DataMatrix e la inizializzo
let xDim: number;
let yDim: number;
if (direction == 'c') {
xDim = (xMax - xMin) / step + 1;
yDim = (yMax - yMin) / step - 2;
} else {
xDim = (xMax - xMin) / step - 2;
yDim = (yMax - yMin) / step + 1;
}
let image = new G.Image();
image.width = xDim;
image.height = yDim;
image.DataMatrix = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
image.DataMatrix[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
image.DataMatrix[i][j] = new Array(G.Image.depth);
for (let k: number = 0; k < G.Image.depth; k++) {
image.DataMatrix[i][j][k] = 0;
}
}
}
//riempio la matrice DataMatrix eliminando i bordi
let x: number, y: number;
let write: boolean;
for (let i = 0; i < lines.length; i++) {
//riga "intestazione x": memorizzo le x e le y del punto e avanzo al conteggio
if (parseInt(lines[i]) > 17000 && lines[i][0] == '5') {
x = (parseInt(lines[i]) - xMin);
y = (parseInt(lines[i + 1]) - yMin);
if (x != 0) { x /= step; }
if (y != 0) { y /= step; }
i++;
//non è un pixel del bordo e sto leggendo per colonne: i successivi valori
//sono da considerare
if (direction == 'c' && y != 0 && y != 1 && y != (yMax - yMin) / step &&
y != (yMax - yMin) / step + 1) {
write = true;
y -= 2; //aggiorno la y con i bordi tagliati
} else if (direction == 'r' && x != 0 && x != 1 && x != (xMax - xMin) / step &&
x != (xMax - xMin) / step + 1) {
//non è un pixel del bordo e sto leggendo per righe: i successivi valori
//sono da considerare
write = true;
x -= 2; //aggiorno la x con i bordi tagliati
} else {
//pixel del bordo: i valori successivi sono da ignorare
write = false;
}
//conteggio da considerare (non del bordo)
} else if (parseInt(lines[i]) < 17000 && write == true) {
image.DataMatrix[xDim - x - 1][yDim - y - 1][parseInt(lines[i])] += 1;
}
}
G.nOfCounts = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
G.nOfCounts[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
G.nOfCounts[i][j] = G.sumVect(image.DataMatrix[i][j], 0, image.DataMatrix[i][j].length);
}
}
G.maxAbsolute = G.findMax(G.nOfCounts, { x: 0, y: 0 }, { x: xDim - 1, y: yDim - 1 });
G.setDataForCompleteChart(image);
console.log("File open with succes");
return image;
}
/*export*/ function readImage_lc(content: string): G.Image
{
let newOrigin = { xp: 0, yp: 0 }; //origine nel caso di zoom
let passo: number = 0; //dimensione di un pixel in micorn
let readMode: string = 'u'; //direzione di lettura
//coordinate minime e massime in entrambe le dimensioni
let xMin: number = 0, yMin: number = 0, xMax: number = 0, yMax: number = 0;
//array con il contenuto del file di input suddiviso per righe
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
//scorro l'array soffermandomi solo sulle righe "intestazione delle x". Devo
//determinare ascisse e cordinate minime e massime, il passo e la direzione di
//scansione
for (let i: number = 0; i < fileStringArray.length; i++) {
if (parseInt(fileStringArray[i]) > 17000 && fileStringArray[i][0] == '5') {
if (xMin == 0) { //se sono alla prima intestazione salvo la x e la y
xMin = parseInt(fileStringArray[i]);
yMin = parseInt(fileStringArray[i + 1]);
i++;
} else { //definisco passo e direzione di scansione dalla seconda intestazione
if (parseInt(fileStringArray[i]) == xMin) {
readMode = 'c';
passo = Math.abs(yMin - fileStringArray[i + 1]);
//se sto leggendo per colonne determino xMax leggendo dalla fine
for (let j: number = fileStringArray.length; j > i; j--) {
//se la riga è "intestazione x" memorizzo xMax e lo confronto con xMin
if (parseInt(fileStringArray[j]) > 17000 && fileStringArray[j][0] == '5') {
xMax = parseInt(fileStringArray[j]);
if (xMax < xMin) { let t: number = xMax; xMax = xMin; xMin = t; }
break;
}
}
} else {
readMode = 'r';
passo = Math.abs(xMin - fileStringArray[i]);
//se sto leggendo per righe determino yMax leggendo dalla fine
for (let j: number = fileStringArray.length; j > i; j--) {
//se la riga è "intestazione y" memorizzo yMax e lo confronto con yMin
if (parseInt(fileStringArray[j]) > 17000 && fileStringArray[j][0] == '6') {
yMax = parseInt(fileStringArray[j]);
if (yMax < yMin) { let t: number = yMax; yMax = yMin; yMin = t; }
break;
}
}
}
break;
}
}
} //alert(xMin + " " + xMax + " " + yMin + " " + yMax + " " + passo);
//A seconda della direzione di lettura determino o yMin e yMax, o xMin e xMax
for (let i: number = 2; i < fileStringArray.length; i++) {
if (readMode == 'c') { //se leggo per colonne devo deterinare yMin e yMax
//mi soffermo sulle righe "intestazione y"
if (parseInt(fileStringArray[i]) > 17000 && fileStringArray[i][0] == '6') {
if (yMin > parseInt(fileStringArray[i])) {
yMin = parseInt(fileStringArray[i]);
}
if (yMax < parseInt(fileStringArray[i])) {
yMax = parseInt(fileStringArray[i]);
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (parseInt(fileStringArray[i]) == xMin + (passo * 2)) { break; }
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
//mi soffermo sulle righe "intestazione x"
if (parseInt(fileStringArray[i]) > 17000 && fileStringArray[i][0] == '5') {
if (xMin > parseInt(fileStringArray[i])) {
xMin = parseInt(fileStringArray[i]);
}
if (xMax < parseInt(fileStringArray[i])) {
xMax = parseInt(fileStringArray[i]);
}
}
//alla terza colonna posso uscire perché ho già tutte le informazioni
if (parseInt(fileStringArray[i]) == yMin + 2000) { break; }
}
} //alert(xMin + " " + xMax + " " + yMin + " " + yMax + " " + passo);
//Risolvo gli shift
for (let i: number = 0; i < fileStringArray.length; i++) {
//se leggo per colonne allora aggiungo 1 alle y di tutte le colonne dispari
if (readMode == 'c' && parseInt(fileStringArray[i]) > 17000 &&
fileStringArray[i][0] == '5' && (parseInt(fileStringArray[i]) / 1000) % 2 != 0) {
fileStringArray[i + 1] = (parseInt(fileStringArray[i + 1]) + passo).toString();
}
//se leggo per righe allora aggiungo 1 alle x di tutte le righe dispari
else if (readMode == 'r' && parseInt(fileStringArray[i]) > 17000 &&
fileStringArray[i][0] == '5' && (parseInt(fileStringArray[i + 1]) / 1000) % 2 != 0) {
fileStringArray[i] = (parseInt(fileStringArray[i]) + passo).toString();
}
}
//Definisco le dimensioni della matrice DataMatrix e la inizializzo
if (readMode == 'c') {
xDim = (xMax - xMin) / passo + 1;
yDim = (yMax - yMin) / passo - 2;
xDim = (xMax - xMin) / passo - 2;
yDim = (yMax - yMin) / passo + 1;
let image = new G.Image();
image.width = xDim;
image.height = yDim;
image.DataMatrix = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
image.DataMatrix[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
image.DataMatrix[i][j] = new Array(G.Image.depth);
for (let k: number = 0; k < G.Image.depth; k++) {
image.DataMatrix[i][j][k] = 0;
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
//riempio la matrice DataMatrix eliminando i bordi
for (let i: number = 0; i < fileStringArray.length; i++) {
//riga "intestazione x": memorizzo le x e le y del punto e avanzo al conteggio
if (parseInt(fileStringArray[i]) > 17000 && fileStringArray[i][0] == '5') {
x = (parseInt(fileStringArray[i]) - xMin);
y = (parseInt(fileStringArray[i + 1]) - yMin);
if (x != 0) { x /= passo; }
if (y != 0) { y /= passo; }
i++;
//non è un pixel del bordo e sto leggendo per colonne: i successivi valori
//sono da considerare
if (readMode == 'c' && y != 0 && y != 1 && y != (yMax - yMin) / passo &&
y != (yMax - yMin) / passo + 1) {
write = true;
y -= 2; //aggiorno la y con i bordi tagliati
}
//non è un pixel del bordo e sto leggendo per righe: i successivi valori
//sono da considerare
else if (readMode == 'r' && x != 0 && x != 1 && x != (xMax - xMin) / passo &&
x != (xMax - xMin) / passo + 1) {
write = true;
x -= 2; //aggiorno la x con i bordi tagliati
}
//pixel del bordo: i valori successivi sono da ignorare
else { write = false; }
} else if (parseInt(fileStringArray[i]) < 17000 && write == true) {
image.DataMatrix[xDim - x - 1][yDim - y - 1][parseInt(fileStringArray[i])] += 1;
G.nOfCounts = new Array(xDim);
for (let i: number = 0; i < xDim; i++) {
G.nOfCounts[i] = new Array(yDim);
for (let j: number = 0; j < yDim; j++) {
G.nOfCounts[i][j] = G.sumVect(image.DataMatrix[i][j], 0, image.DataMatrix[i][j].length);
G.maxAbsolute = G.findMax(G.nOfCounts, { x: 0, y: 0 }, { x: xDim - 1, y: yDim - 1 });