// 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)
// 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();
//=====
};
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)
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);
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)
#include "iostream"
#include "vtkPolyData.h"
+#include "vtkLinearTransform.h"
namespace bbcreaVtk
{
//=====
// 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 );
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();
//=====
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,"");
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);
//=====