From: Eduardo DAVILA Date: Thu, 5 Sep 2019 14:54:05 +0000 (+0200) Subject: #3282 creaVtk Feature New Normal PolyDataInfo X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5b1af4fb7d491747f57465950509dc2fcc7b07a6;p=creaVtk.git #3282 creaVtk Feature New Normal PolyDataInfo --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx index 3939f54..8922cfa 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.cxx @@ -29,26 +29,63 @@ void GrayLevel::Process() // vtkImageData *m_image = vtkImageData::New(); // m_image = bbGetInputImage(); - double grayLevel = -9999; - std::vector coord = bbGetInputCoordinate(); - + double grayLevel = -9999; + std::vector 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 lstGL; + std::vector lstX = bbGetInputLstPointsX(); + std::vector lstY = bbGetInputLstPointsY(); + std::vector lstZ = bbGetInputLstPointsZ(); + if ( (lstX.size()==lstY.size()) && (lstY.size()==lstZ.size()) ) + { + long int i,size=lstX.size(); + for (i=0;iGetScalarComponentAsDouble( 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.h b/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.h index 20e06f8..1023f8d 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkGrayLevel.h @@ -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); + BBTK_DECLARE_INPUT(LstPointsX,std::vector); + BBTK_DECLARE_INPUT(LstPointsY,std::vector); + BBTK_DECLARE_INPUT(LstPointsZ,std::vector); BBTK_DECLARE_OUTPUT(GrayLevel,double); + BBTK_DECLARE_OUTPUT(LstGrayLevel,std::vector); 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,""); -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,""); + BBTK_INPUT(GrayLevel,LstPointsX," List of points in X",std::vector,""); + BBTK_INPUT(GrayLevel,LstPointsY," List of points in X",std::vector,""); + BBTK_INPUT(GrayLevel,LstPointsZ," List of points in X",std::vector,""); + + BBTK_OUTPUT(GrayLevel,GrayLevel,"GrayLevel",double,""); + BBTK_OUTPUT(GrayLevel,LstGrayLevel,"List of GrayLevels for the list of points",std::vector,""); + 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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx index 5aa1f2d..68c02e1 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.cxx @@ -38,6 +38,38 @@ void PolyDataInfo::Process() bbSetOutputNumberOfPolys( bbGetInputIn()->GetNumberOfPolys() ); bbSetOutputNumberOfStrips( bbGetInputIn()->GetNumberOfStrips() ); bbSetOutputNumberOfVerts( bbGetInputIn()->GetNumberOfVerts() ); + + if (bbGetInputPoints()==true) + { + std::vector lstIds; + std::vector lstPointsX; + std::vector lstPointsY; + std::vector lstPointsZ; + double p1[3]; + double p2[3]; + long int i,size= bbGetInputIn()->GetNumberOfPoints(); + for (i=0;iGetPoint(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) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h index b336172..3bafe68 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkPolyDataInfo.h @@ -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 ); + BBTK_DECLARE_OUTPUT( LstPointsX , std::vector ); + BBTK_DECLARE_OUTPUT( LstPointsY , std::vector ); + BBTK_DECLARE_OUTPUT( LstPointsZ , std::vector ); + 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,""); + BBTK_OUTPUT(PolyDataInfo,LstPointsX,"List of X of points (if input Points=true)",std::vector,""); + BBTK_OUTPUT(PolyDataInfo,LstPointsY,"List of Y of points (if input Points=true)",std::vector,""); + BBTK_OUTPUT(PolyDataInfo,LstPointsZ,"List of Z of points (if input Points=true)",std::vector,""); + BBTK_END_DESCRIBE_BLACK_BOX(PolyDataInfo); //=====