]> Creatis software - creaVtk.git/commitdiff
#2913 creaVtk Feature New Normal - new box MHDFileInfo
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 13 Apr 2016 06:35:11 +0000 (08:35 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 13 Apr 2016 06:35:11 +0000 (08:35 +0200)
bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbg
bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbs
bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.cxx [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.h [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkReadMHDPlane.cxx

index 7b72cd015c5f867814eaba1126e641be98b9c78f..5614185cfcc74bbb59f96a7eba5ed84378edd873 100644 (file)
@@ -1,6 +1,6 @@
 # ----------------------------------
 # - BBTKGEditor v 1.4 BBG BlackBox Diagram file
-# - /home/davila/Creatis/creaVtk/bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbg
+# - /tmpEED/creaTools/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbg
 # ----------------------------------
 
 APP_START
@@ -9,62 +9,89 @@ DESCRIPTION:Description ??
 AUTHOR:Author ??
 COMPLEXBOX:FALSE
 COMPLEXINPUTS:0
-BOXES:5
+BOXES:7
 BOX
 vtk:LoadHola:Box00
 ISEXEC:FALSE
--24.200550:45.257301:-900.000000
-21.374450:35.257301:-900.000000
+-13.068558:72.467386:-900.000000
+32.506442:62.467386:-900.000000
 FIN_BOX
 BOX
 creaMaracasVisu:ViewerNV:Box01
 ISEXEC:FALSE
--17.749601:21.905419:-900.000000
-42.890399:11.905419:-900.000000
+-6.976145:43.852021:-900.000000
+38.598855:33.852021:-900.000000
+FIN_BOX
+BOX
+wx:LayoutSplit:Box02
+ISEXEC:TRUE
+-9.670623:-63.555971:-900.000000
+35.904377:-73.555971:-900.000000
 PORT
-nTypeView:"5"
+Orientation:"H"
+FIN_BOX
+BOX
+wx:LayoutLine:Box03
+ISEXEC:FALSE
+-61.355811:-33.011090:-900.000000
+-15.780811:-43.011090:-900.000000
 FIN_BOX
 BOX
-creaVtk:PlaneWidget:Box02
+wx:OutputText:Box04
 ISEXEC:FALSE
--48.010561:-16.304165:-900.000000
--2.435561:-26.304165:-900.000000
+-98.129016:-17.240669:-900.000000
+-52.554016:-27.240669:-900.000000
 PORT
-Active:"true"
+Title:"Center"
 FIN_BOX
 BOX
-wx:CommandButton:Box03
+wx:OutputText:Box05
 ISEXEC:FALSE
-32.053294:9.088705:-900.000000
-77.628294:-0.911295:-900.000000
+-45.570165:-16.275073:-900.000000
+0.004835:-26.275073:-900.000000
 PORT
-Label:"Run"
+Title:"normal"
 FIN_BOX
 BOX
-wx:LayoutSplit:Box04
-ISEXEC:TRUE
-13.089075:-50.759046:-900.000000
-58.664075:-60.759046:-900.000000
+creaVtk:PlaneWidget:Box06
+ISEXEC:FALSE
+-60.391943:23.106661:-900.000000
+-14.816943:13.106661:-900.000000
 PORT
-Proportion:"10"
+Active:"true"
 FIN_BOX
-CONNECTIONS:6
+CONNECTIONS:11
 CONNECTION
 Box00:Out:Box01:In
 NumberOfControlPoints:0
 CONNECTION
-Box01:Renderer1:Box02:Renderer
+Box01:Widget:Box02:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box03:Widget:Box02:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box05:Widget:Box03:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box04:Widget:Box03:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box01:Renderer1:Box06:Renderer
+NumberOfControlPoints:0
+CONNECTION
+Box00:Out:Box06:In
 NumberOfControlPoints:0
 CONNECTION
-Box00:Out:Box02:In
+Box06:Center:Box04:In
 NumberOfControlPoints:0
 CONNECTION
-Box03:Widget:Box04:Widget1
+Box06:Normal:Box05:In
 NumberOfControlPoints:0
 CONNECTION
-Box01:Widget:Box04:Widget2
+Box06:BoxChange:Box04:BoxExecute
 NumberOfControlPoints:0
 CONNECTION
-Box03:BoxChange:Box02:BoxExecute
+Box06:BoxChange:Box05:BoxExecute
 NumberOfControlPoints:0
 APP_END
index 27ff20903a43399637e88070175790237029624c..584882e380a04cee329453f1f252cf5c9b8fd779 100644 (file)
@@ -1,6 +1,6 @@
 # ----------------------------------
 # - BBTKGEditor v 1.4 BBS BlackBox Script
-# - /home/davila/Creatis/creaVtk/bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbs
+# - /tmpEED/creaTools/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/examplePlaneWidget.bbs
 # ----------------------------------
 
 # BBTK GEditor Script
@@ -10,41 +10,55 @@ include std
 include itkvtk
 include vtk
 include creaMaracasVisu
-include creaVtk
 include wx
+include creaVtk
 
 author "Author ??"
 description "Description ??"
 category "<VOID>"
 
-new LoadHola Box00
+new vtk:LoadHola Box00
+
+new creaMaracasVisu:ViewerNV Box01
 
-new ViewerNV Box01
-  set Box01.nTypeView "5"
+new wx:LayoutSplit Box02
+  set Box02.Orientation "H"
 
-new PlaneWidget Box02
-  set Box02.Active "true"
+new wx:LayoutLine Box03
 
-new CommandButton Box03
-  set Box03.Label "Run"
+new wx:OutputText Box04
+  set Box04.Title "Center"
 
-new LayoutSplit Box04
-  set Box04.Proportion "10"
+new wx:OutputText Box05
+  set Box05.Title "normal"
+
+new creaVtk:PlaneWidget Box06
+  set Box06.Active "true"
 
 
 connect Box00.Out Box01.In
 
-connect Box01.Renderer1 Box02.Renderer
+connect Box01.Widget Box02.Widget2
+
+connect Box03.Widget Box02.Widget1
+
+connect Box05.Widget Box03.Widget2
+
+connect Box04.Widget Box03.Widget1
+
+connect Box01.Renderer1 Box06.Renderer
+
+connect Box00.Out Box06.In
 
-connect Box00.Out Box02.In
+connect Box06.Center Box04.In
 
-connect Box03.Widget Box04.Widget1
+connect Box06.Normal Box05.In
 
-connect Box01.Widget Box04.Widget2
+connect Box06.BoxChange Box04.BoxExecute
 
-connect Box03.BoxChange Box02.BoxExecute
+connect Box06.BoxChange Box05.BoxExecute
 
 
 
 # Complex input ports
-exec Box04
+exec Box02
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.cxx
new file mode 100644 (file)
index 0000000..015e4ba
--- /dev/null
@@ -0,0 +1,126 @@
+//===== 
+// 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)
+//===== 
+#include "bbcreaVtkMHDFileInfo.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MHDFileInfo)
+BBTK_BLACK_BOX_IMPLEMENTATION(MHDFileInfo,bbtk::AtomicBlackBox);
+//===== 
+// 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 MHDFileInfo::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+  
+
+       std::string inputfilename;
+       inputfilename=bbGetInputFileName();
+
+
+       int dimX=-1,dimY=-1,dimZ=-1;
+       int dim=-1;
+       std::string formattype("VOID");
+       float spcX=-1,spcY=-1,spcZ=-1;
+       float ox=-1,oy=-1,oz=-1;
+       long int headersize=0;
+
+       char mystring[250];
+       char strTmp[30];
+       char strTmp2[30];
+       FILE *ffIn      = fopen(inputfilename.c_str(),"r");
+       if (ffIn!=NULL)
+       {
+               while(!feof(ffIn))
+               {
+           strcpy(mystring,"\n");
+                       fgets(mystring,250,ffIn);
+               if (strncmp("NDims",mystring,5)==0)                     { sscanf(mystring,"%s %s %d"            ,strTmp, strTmp, &dim);                                 }
+               if (strncmp("DimSize",mystring,6)==0)                   { sscanf(mystring,"%s %s %d %d %d"      ,strTmp, strTmp, &dimX, &dimY,&dimZ);   } 
+                       if (strncmp("ElementType",mystring,11)==0)              { sscanf(mystring,"%s %s %s"            ,strTmp, strTmp, strTmp2); formattype=strTmp2;                  }
+                       if (strncmp("ElementSpacing",mystring,11)==0)   { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &spcX,&spcY,&spcY);    }
+               if (strncmp("Offset",mystring,6)==0)                    { sscanf(mystring,"%s %s %f %f %f"      ,strTmp, strTmp, &ox, &oy, &oz);                }
+               if (strncmp("HeaderSize",mystring,10)==0)               { sscanf(mystring,"%s %s %ld"           ,strTmp, strTmp, &headersize);                  }
+       } // while
+               fclose(ffIn);
+       } // if
+
+       std::vector<int> LstDimSize;
+       LstDimSize.push_back(dimX);
+       LstDimSize.push_back(dimY);
+       LstDimSize.push_back(dimZ);
+
+       std::vector<double> LstSpacing;
+       LstSpacing.push_back((double)spcX);
+       LstSpacing.push_back((double)spcY);
+       LstSpacing.push_back((double)spcZ);
+
+       std::vector<double> LstOffset;
+       LstOffset.push_back((double)ox);
+       LstOffset.push_back((double)oy);
+       LstOffset.push_back((double)oz);
+
+       bbSetOutputDim( dim );
+       bbSetOutputDimSize( LstDimSize );
+       bbSetOutputElementType( formattype );
+       bbSetOutputElementSpacing( LstSpacing );
+       bbSetOutputOffset( LstOffset );
+       bbSetOutputHeaderSize( headersize );
+
+}
+//===== 
+// 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 MHDFileInfo::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+
+  
+}
+//===== 
+// 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 MHDFileInfo::bbUserInitializeProcessing()
+{
+
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    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 MHDFileInfo::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaVtk
+
+
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMHDFileInfo.h
new file mode 100644 (file)
index 0000000..890c407
--- /dev/null
@@ -0,0 +1,58 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbcreaVtkMHDFileInfo_h_INCLUDED__
+#define __bbcreaVtkMHDFileInfo_h_INCLUDED__
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT MHDFileInfo
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(MHDFileInfo,bbtk::AtomicBlackBox);
+//===== 
+// 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(FileName,std::string);
+  BBTK_DECLARE_OUTPUT(Dim,int);
+  BBTK_DECLARE_OUTPUT(DimSize,std::vector<int>);
+  BBTK_DECLARE_OUTPUT(ElementType,std::string);
+  BBTK_DECLARE_OUTPUT(ElementSpacing,std::vector<double>);
+  BBTK_DECLARE_OUTPUT(Offset,std::vector<double>);
+  BBTK_DECLARE_OUTPUT(HeaderSize,long int);
+  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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(MHDFileInfo,bbtk::AtomicBlackBox);
+  BBTK_NAME("MHDFileInfo");
+  BBTK_AUTHOR("Info-Dev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+
+  BBTK_INPUT(MHDFileInfo,FileName,"MHD file name",std::string,"");
+
+  BBTK_OUTPUT(MHDFileInfo,Dim,"Dimension",int,"");
+  BBTK_OUTPUT(MHDFileInfo,DimSize,"Size",std::vector<int>,"");
+  BBTK_OUTPUT(MHDFileInfo,ElementType,"Format type",std::string,"");
+  BBTK_OUTPUT(MHDFileInfo,ElementSpacing,"Spacing",std::vector<double>,"");
+  BBTK_OUTPUT(MHDFileInfo,Offset,"Offset",std::vector<double>,"");
+  BBTK_OUTPUT(MHDFileInfo,HeaderSize,"Format type",long int,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(MHDFileInfo);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbcreaVtk
+
+#endif // __bbcreaVtkMHDFileInfo_h_INCLUDED__
+
index 53b6691816034e4d0be558c9a6e3a5ba3251a905..6bb42f73c63da4b3eef6c1ea599c9d0cc0c0f968 100644 (file)
@@ -90,8 +90,8 @@ void ReadMHDPlane::Process()
                        newHeaderSize = sx*sy*bbGetInputSlice();
                                if (bbGetInputSlice()>=sz) {ok=false;}
                        } // if
-               if (strncmp("ElementType = MET_CHAR",mystring,24)==0)   { newHeaderSize=newHeaderSize*1; }
-               if (strncmp("ElementType = MET_UCHAR",mystring,24)==0)  { newHeaderSize=newHeaderSize*1; }
+               if (strncmp("ElementType = MET_CHAR",mystring,22)==0)   { newHeaderSize=newHeaderSize*1; }
+               if (strncmp("ElementType = MET_UCHAR",mystring,23)==0)  { newHeaderSize=newHeaderSize*1; }
                if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; }
                if (strncmp("ElementType = MET_USHORT",mystring,24)==0) { newHeaderSize=newHeaderSize*2; }
                if (strncmp("ElementType = MET_SHORT",mystring,23)==0)  { newHeaderSize=newHeaderSize*2; }