From: eduardo.davila@creatis.insa-lyon.fr Date: Tue, 23 Jul 2024 08:29:56 +0000 (+0200) Subject: #3527 JavaScript IO interface X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b5227385cf392be7708600992cab3646d77c4f73;p=creaVtk.git #3527 JavaScript IO interface --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkHttpDataSetReader.xml b/bbtk_creaVtk_PKG/src/bbcreaVtkHttpDataSetReader.xml index e0d16387..d728ac1 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkHttpDataSetReader.xml +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkHttpDataSetReader.xml @@ -44,6 +44,7 @@ Here we include the standard header iostream.h -->
iostream
vtkImageData.h
+
vtkDataSet.h
-
typedef std::vector OutputTypeVectorString;
-
typedef std::vector OutputTypeVectorVtkImageData;
+
typedef std::vector    OutputTypeVectorString;
+
typedef std::vector  OutputTypeVectorVtkImageData;
+
typedef std::vector    OutputTypeVectorVtkDataSet;
- - + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.cxx index b538dce..258fca0 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.cxx @@ -34,10 +34,23 @@ void JSONDataSetWriter::Process() int i; - int sizeLstImages = bbGetInputLstImages().size(); + int sizeLstImages = bbGetInputLstImages().size(); + int sizeLstPolyData = bbGetInputLstPolyData().size(); int sizeLstFileNames = bbGetInputLstFileNames().size(); vtkImageData *image; + vtkPolyData *polydata; std::string filename; + + // vtkImageData + if ( (sizeLstFileNames==1) && (bbGetInputImage()!=NULL) ) + { + vtkJSONDataSetWriter *writer = vtkJSONDataSetWriter::New(); + writer->GetArchiver()->SetArchiveName( bbGetInputLstFileNames()[0].c_str() ); + writer->SetInputData( bbGetInputImage() ); + writer->Update(); + } // if Image + + // lst vtkImageData if ( (sizeLstImages>0) && (sizeLstImages==sizeLstFileNames) ) { for ( i=0 ; iGetArchiver()->SetArchiveName( bbGetInputLstFileNames()[0].c_str() ); + writer->SetInputData( bbGetInputPolyData() ); + writer->Update(); + } // if PolyData + + // lst vtkPolyData + if ( (sizeLstPolyData>0) && (sizeLstPolyData==sizeLstFileNames) ) + { + for ( i=0 ; iGetArchiver()->SetArchiveName( filename.c_str() ); + writer->SetInputData( polydata ); + writer->Update(); + } // if polydata + }// for + } // if size + } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void JSONDataSetWriter::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 -// bbSetInputIn(NULL); - + bbSetInputImage(NULL); + bbSetInputPolyData(NULL); } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void JSONDataSetWriter::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// if any } -//===== + +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void JSONDataSetWriter::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } -} -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.h b/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.h index 0a5231a..cd2e9eb 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkJSONDataSetWriter.h @@ -9,6 +9,7 @@ #include "iostream" #include +#include namespace bbcreaVtk { @@ -22,11 +23,14 @@ class bbcreaVtk_EXPORT JSONDataSetWriter // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== // BBTK_DECLARE_INPUT(In,vtkImageData*); - BBTK_DECLARE_INPUT(LstImages,std::vector ); - BBTK_DECLARE_INPUT(LstFileNames,std::vector ); + BBTK_DECLARE_INPUT(Image,vtkImageData*); + BBTK_DECLARE_INPUT(PolyData,vtkPolyData*); + BBTK_DECLARE_INPUT(LstImages,std::vector ); + BBTK_DECLARE_INPUT(LstPolyData,std::vector ); + BBTK_DECLARE_INPUT(LstFileNames,std::vector ); // BBTK_DECLARE_OUTPUT(Out,double); - BBTK_PROCESS(Process); - void Process(); + BBTK_PROCESS(Process); + void Process(); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -37,7 +41,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(JSONDataSetWriter,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(JSONDataSetWriter,LstImages,"Input Image",std::vector ,""); + BBTK_INPUT(JSONDataSetWriter,Image,"Input vtkImageData ",vtkImageData*,""); + BBTK_INPUT(JSONDataSetWriter,PolyData,"Input vtkPolyData ",vtkPolyData*,""); + BBTK_INPUT(JSONDataSetWriter,LstImages,"Input vtkImageData vector",std::vector ,""); + BBTK_INPUT(JSONDataSetWriter,LstPolyData,"Input vtkPolydata vector",std::vector ,""); BBTK_INPUT(JSONDataSetWriter,LstFileNames,"File Name",std::vector ,""); // BBTK_OUTPUT(JSONDataSetWriter,Out,"First output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(JSONDataSetWriter); diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx index 7ad5b0e..f89648d 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkMarchingCubes2.cxx @@ -13,7 +13,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(MarchingCubes2,bbtk::AtomicBlackBox); //===== void MarchingCubes2::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -27,7 +26,6 @@ void MarchingCubes2::Process() // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <