From 9f2ad553a3a50d687f0ce9f04f3a7d0b3322d56a Mon Sep 17 00:00:00 2001 From: Laurent Knoll <laurent.knoll@orange.com> Date: Sat, 24 Sep 2022 14:56:02 +0200 Subject: [PATCH] =?UTF-8?q?Export=20de=20la=20boite=20de=20petri=20par=20p?= =?UTF-8?q?oints=20et=20non=20par=20segments=20incurv=C3=A9s.=20Closes=20#?= =?UTF-8?q?5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/dataExporter.ts | 16 +++++++++++++++- src/steps/downloadStep.tsx | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/data/dataExporter.ts b/src/data/dataExporter.ts index e9fd78e..7872479 100644 --- a/src/data/dataExporter.ts +++ b/src/data/dataExporter.ts @@ -15,7 +15,21 @@ export class DataExporter { /** * Transforme un Path en CSV */ - public exportPathAsXYCsv(coords : Coords, close : boolean) : string { + public exportPathPointsAsXYCsv(coords : Coords, close : boolean) : string { + const path = coords.toRemovedPath(); + let data = ""; + for (let i = 0; i < path.length; i++) { + let point = path.getPointAt(i); + data += Math.round(point.x) + "\t" + Math.round(point.y) + "\n"; + } + return data; + } + + + /** + * Transforme un Path en CSV par segments + */ + public exportPathSegmentsAsXYCsv(coords : Coords, close : boolean) : string { const path = coords.toRemovedPath(); let data = ""; for (let i = 0; i < path.segments.length; i++) { diff --git a/src/steps/downloadStep.tsx b/src/steps/downloadStep.tsx index 4e76e0b..9a56ed0 100644 --- a/src/steps/downloadStep.tsx +++ b/src/steps/downloadStep.tsx @@ -75,7 +75,7 @@ export class DownloadStep extends Step<DownloadStepState> { * Téléchargement des données de la boîte de Petri */ private downloadPetriDishData() : void { - let data = this.dataExporter.exportPathAsXYCsv(this.props.lab.data.petriDishCoords, true); + let data = this.dataExporter.exportPathPointsAsXYCsv(this.props.lab.data.petriDishCoords, true); IoUtils.downloadData(this.state.petriDishDataFilename, "text/plain;charset=UTF-8", data); } @@ -83,7 +83,7 @@ export class DownloadStep extends Step<DownloadStepState> { * Téléchargement des données du mask */ private downloadBlobMaskData() : void { - let data = this.dataExporter.exportPathAsXYCsv(this.props.lab.data.blobMaskCoords, true); + let data = this.dataExporter.exportPathSegmentsAsXYCsv(this.props.lab.data.blobMaskCoords, true); IoUtils.downloadData(this.state.blobMaskDataFilename, "text/plain;charset=UTF-8", data); } -- GitLab