]> Creatis software - creaVtk.git/commitdiff
#3282 creaVtk Feature New Normal PolyDataInfo
authorEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Thu, 5 Sep 2019 14:54:05 +0000 (16:54 +0200)
committerEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Thu, 5 Sep 2019 14:54:05 +0000 (16:54 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.h
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h

index 3939f547890db00092076fde792d500c178c19e7..8922cfad2afd4ea01f9f938534cb565195efc877 100644 (file)
@@ -29,26 +29,63 @@ void GrayLevel::Process()
 //    vtkImageData  *m_image  =  vtkImageData::New();
 //    m_image = bbGetInputImage();
 
-    double grayLevel = -9999;
-    std::vector<double> coord = bbGetInputCoordinate();
-
+    double grayLevel                   = -9999;
+    std::vector<double> coord  = bbGetInputCoordinate();
+       double px,py,pz;
        if (bbGetInputImage()!=NULL)
        {
-               grayLevel = bbGetInputImage()->GetScalarComponentAsDouble(coord[0],coord[1],coord[2],0);
-       }
+               double spc[3];
+               bbGetInputImage()->GetSpacing(spc);
+               if (coord.size()>=2)
+               { 
+                       if (bbGetInputWithSpacing()==true)
+                       {
+                               px = round(coord[0])/spc[0];
+                               py = round(coord[1])/spc[1];
+                               pz = round(coord[2])/spc[2];
+                       } else {
+                               px = round(coord[0]);
+                               py = round(coord[1]);
+                               pz = round(coord[2]);
+                       }// if
+                       grayLevel = bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0);
+               } // coord
+               std::vector<double> lstGL;
+               std::vector<double> lstX = bbGetInputLstPointsX();
+               std::vector<double> lstY = bbGetInputLstPointsY();
+               std::vector<double> lstZ = bbGetInputLstPointsZ();
+               if ( (lstX.size()==lstY.size()) && (lstY.size()==lstZ.size()) )
+               {
+                       long int i,size=lstX.size();
+                       for (i=0;i<size;i++)
+                       {       
+                               if (bbGetInputWithSpacing()==true)
+                               {
+                                       px = round(lstX[i])/spc[0];
+                                       py = round(lstY[i])/spc[1];
+                                       pz = round(lstZ[i])/spc[2];
+                               } else {
+                                       px = round(lstX[i]);
+                                       py = round(lstY[i]);
+                                       pz = round(lstZ[i]);                                    
+                               }// if
+                               lstGL.push_back( bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0) );
+                       }// for 
+                       bbSetOutputLstGrayLevel(lstGL);
+               } // if size of Lst
+       } // InputImage
        bbSetOutputGrayLevel(grayLevel);
-    
 }
+
 //===== 
 // 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 GrayLevel::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
    bbSetInputImage(NULL);
-  
+   bbSetInputWithSpacing(false);
 }
 //===== 
 // 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)
index 20e06f821aae006d3f0096fee23fea3dc0aa7515..1023f8df5fa82a3f156b9d6443bd38679ecf24e5 100644 (file)
@@ -21,8 +21,13 @@ class bbcreaVtk_EXPORT GrayLevel
 // 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(Image,vtkImageData*);
+  BBTK_DECLARE_INPUT(WithSpacing,bool);
   BBTK_DECLARE_INPUT(Coordinate,std::vector<double>);
+  BBTK_DECLARE_INPUT(LstPointsX,std::vector<double>);
+  BBTK_DECLARE_INPUT(LstPointsY,std::vector<double>);
+  BBTK_DECLARE_INPUT(LstPointsZ,std::vector<double>);
   BBTK_DECLARE_OUTPUT(GrayLevel,double);
+  BBTK_DECLARE_OUTPUT(LstGrayLevel,std::vector<double>);
   BBTK_PROCESS(Process);
   void Process();
 //===== 
@@ -31,13 +36,21 @@ class bbcreaVtk_EXPORT GrayLevel
 };
 
 BBTK_BEGIN_DESCRIBE_BLACK_BOX(GrayLevel,bbtk::AtomicBlackBox);
-BBTK_NAME("GrayLevel");
-BBTK_AUTHOR("Monica ESPINOSA");
-BBTK_DESCRIPTION("No Description.");
-BBTK_CATEGORY("empty");
-BBTK_INPUT(GrayLevel,Image,"Image",vtkImageData*,"");
-BBTK_INPUT(GrayLevel,Coordinate,"Coordinate Of Point ",std::vector<double>,"");
-BBTK_OUTPUT(GrayLevel,GrayLevel,"GrayLevel",double,"");
+ BBTK_NAME("GrayLevel");
+ BBTK_AUTHOR("Monica ESPINOSA");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+
+ BBTK_INPUT(GrayLevel,Image,"Image",vtkImageData*,"");
+ BBTK_INPUT(GrayLevel,WithSpacing,"default (false)  With spacing of the image",bool,"");
+ BBTK_INPUT(GrayLevel,Coordinate,"Coordinate Of Point ",std::vector<double>,"");
+ BBTK_INPUT(GrayLevel,LstPointsX," List of points in X",std::vector<double>,"");
+ BBTK_INPUT(GrayLevel,LstPointsY," List of points in X",std::vector<double>,"");
+ BBTK_INPUT(GrayLevel,LstPointsZ," List of points in X",std::vector<double>,"");
+
+ BBTK_OUTPUT(GrayLevel,GrayLevel,"GrayLevel",double,"");
+ BBTK_OUTPUT(GrayLevel,LstGrayLevel,"List of GrayLevels for the list of points",std::vector<double>,"");
+
 BBTK_END_DESCRIBE_BLACK_BOX(GrayLevel);
 //===== 
 // 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)
index 5aa1f2d7f33d3ec773a26af7e4480ad67c848c16..68c02e156ce236977da7f110bbceb0e5b437a665 100644 (file)
@@ -38,6 +38,38 @@ void PolyDataInfo::Process()
                bbSetOutputNumberOfPolys( bbGetInputIn()->GetNumberOfPolys() );
                bbSetOutputNumberOfStrips( bbGetInputIn()->GetNumberOfStrips() );
                bbSetOutputNumberOfVerts( bbGetInputIn()->GetNumberOfVerts() );
+
+               if (bbGetInputPoints()==true)
+               {
+                       std::vector<double> lstIds;
+                       std::vector<double> lstPointsX;
+                       std::vector<double> lstPointsY;
+                       std::vector<double> lstPointsZ;
+                       double p1[3];
+                       double p2[3];
+                       long int i,size= bbGetInputIn()->GetNumberOfPoints();
+                       for (i=0;i<size;i++)
+                       {
+                               if (bbGetInputIdsPoints()==true)
+                               {
+                                       lstIds.push_back(i);
+                               } // IdsPoints
+                               if (bbGetInputTransform()!=NULL)
+                               {
+                                       bbGetInputIn()->GetPoint(i,p1);
+                                       bbGetInputTransform()->TransformPoint(p1,p2);
+                               } else {
+                                       bbGetInputIn()->GetPoint(i,p2);
+                               }
+                               lstPointsX.push_back(p2[0]);
+                               lstPointsY.push_back(p2[1]);
+                               lstPointsZ.push_back(p2[2]);
+                       } // for i
+                       bbSetOutputLstIdsPoints(lstIds);
+                       bbSetOutputLstPointsX(lstPointsX);
+                       bbSetOutputLstPointsY(lstPointsY);
+                       bbSetOutputLstPointsZ(lstPointsZ);
+               } // Points
        } else {
                bbSetOutputNumberOfCells(-1);
                bbSetOutputNumberOfLines(-1);
@@ -65,6 +97,9 @@ void PolyDataInfo::bbUserSetDefaultValues()
    bbSetOutputNumberOfPolys(-9999);
    bbSetOutputNumberOfStrips(-9999);
    bbSetOutputNumberOfVerts(-9999);
+   bbSetInputIdsPoints(false);
+   bbSetInputPoints(false);
+   bbSetInputTransform(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)
index b33617203479354782bcce3b04a3d0f55541e511..3bafe68d606ff804a88b6e684afb6da0ea03c9f5 100644 (file)
@@ -9,6 +9,7 @@
 #include "iostream"
 
 #include "vtkPolyData.h"
+#include "vtkLinearTransform.h"
 
 namespace bbcreaVtk
 {
@@ -21,7 +22,11 @@ class bbcreaVtk_EXPORT PolyDataInfo
 //===== 
 // 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 , vtkPolyData* );
+  BBTK_DECLARE_INPUT( In                               , vtkPolyData* );
+  BBTK_DECLARE_INPUT( Points                   , bool );
+  BBTK_DECLARE_INPUT( IdsPoints                , bool );
+  BBTK_DECLARE_INPUT( Transform                , vtkLinearTransform* );
+
   BBTK_DECLARE_OUTPUT( NumberOfCells   , double );
   BBTK_DECLARE_OUTPUT( NumberOfLines   , double );
   BBTK_DECLARE_OUTPUT( NumberOfPoints  , double );
@@ -29,6 +34,11 @@ class bbcreaVtk_EXPORT PolyDataInfo
   BBTK_DECLARE_OUTPUT( NumberOfPolys   , double );
   BBTK_DECLARE_OUTPUT( NumberOfStrips  , double );
   BBTK_DECLARE_OUTPUT( NumberOfVerts   , double );
+  BBTK_DECLARE_OUTPUT( LstIdsPoints    , std::vector<double> );
+  BBTK_DECLARE_OUTPUT( LstPointsX              , std::vector<double> );
+  BBTK_DECLARE_OUTPUT( LstPointsY              , std::vector<double> );
+  BBTK_DECLARE_OUTPUT( LstPointsZ              , std::vector<double> );
+
   BBTK_PROCESS(Process);
   void Process();
 //===== 
@@ -43,6 +53,9 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataInfo,bbtk::AtomicBlackBox);
   BBTK_CATEGORY("empty");
 
   BBTK_INPUT(PolyDataInfo,In,"vtkPolyData", vtkPolyData* ,"");
+  BBTK_INPUT(PolyDataInfo,IdsPoints,"(default false) Extract ids of the mesh or not.", bool ,"");
+  BBTK_INPUT(PolyDataInfo,Points,"(default false) Extract points of the mesh or not.", bool ,"");
+  BBTK_INPUT(PolyDataInfo,Transform,"vtkTransform", vtkLinearTransform* ,"");
 
   BBTK_OUTPUT(PolyDataInfo,NumberOfCells,"Number of Cells",double,"");
   BBTK_OUTPUT(PolyDataInfo,NumberOfLines,"Number of Lines",double,"");
@@ -51,6 +64,11 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(PolyDataInfo,bbtk::AtomicBlackBox);
   BBTK_OUTPUT(PolyDataInfo,NumberOfPolys,"Number of Ploys",double,"");
   BBTK_OUTPUT(PolyDataInfo,NumberOfStrips,"Number of Strips",double,"");
   BBTK_OUTPUT(PolyDataInfo,NumberOfVerts,"Number of Verts",double,"");
+  BBTK_OUTPUT(PolyDataInfo,LstIdsPoints,"List of Ids of points (if input Ids=true)",std::vector<double>,"");
+  BBTK_OUTPUT(PolyDataInfo,LstPointsX,"List of X of points (if input Points=true)",std::vector<double>,"");
+  BBTK_OUTPUT(PolyDataInfo,LstPointsY,"List of Y of points (if input Points=true)",std::vector<double>,"");
+  BBTK_OUTPUT(PolyDataInfo,LstPointsZ,"List of Z of points (if input Points=true)",std::vector<double>,"");
+
 
 BBTK_END_DESCRIBE_BLACK_BOX(PolyDataInfo);
 //=====