From: Eduardo DAVILA Date: Tue, 21 Feb 2017 14:58:41 +0000 (+0100) Subject: #3063 BBTK Feature New Normal - New box VectorFilterDouble in std package X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtk.git;a=commitdiff_plain;h=84454af9be8cecfbf41ca7c0198c65efe60f9b48 #3063 BBTK Feature New Normal - New box VectorFilterDouble in std package --- diff --git a/packages/std/src/bbstdVectorFilterDouble.cxx b/packages/std/src/bbstdVectorFilterDouble.cxx new file mode 100644 index 0000000..0fb6621 --- /dev/null +++ b/packages/std/src/bbstdVectorFilterDouble.cxx @@ -0,0 +1,199 @@ +//===== +// 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 "bbstdVectorFilterDouble.h" +#include "bbstdPackage.h" +namespace bbstd +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,VectorFilterDouble) +BBTK_BLACK_BOX_IMPLEMENTATION(VectorFilterDouble,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 VectorFilterDouble::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') + + std::vector< std::vector * > pLstVec; + std::vector< std::vector * > pLstVecOut; + std::vector In0 = bbGetInputIn0(); + std::vector In1 = bbGetInputIn1(); + std::vector In2 = bbGetInputIn2(); + std::vector In3 = bbGetInputIn3(); + std::vector In4 = bbGetInputIn4(); + std::vector In5 = bbGetInputIn5(); + std::vector In6 = bbGetInputIn6(); + std::vector In7 = bbGetInputIn7(); + std::vector In8 = bbGetInputIn8(); + std::vector In9 = bbGetInputIn9(); + + if (bbGetInputIn0().size()!=0) { pLstVec.push_back( &In0 ); } + if (bbGetInputIn1().size()!=0) { pLstVec.push_back( &In1 ); } + if (bbGetInputIn2().size()!=0) { pLstVec.push_back( &In2 ); } + if (bbGetInputIn3().size()!=0) { pLstVec.push_back( &In3 ); } + if (bbGetInputIn4().size()!=0) { pLstVec.push_back( &In4 ); } + if (bbGetInputIn5().size()!=0) { pLstVec.push_back( &In5 ); } + if (bbGetInputIn6().size()!=0) { pLstVec.push_back( &In6 ); } + if (bbGetInputIn7().size()!=0) { pLstVec.push_back( &In7 ); } + if (bbGetInputIn8().size()!=0) { pLstVec.push_back( &In8 ); } + if (bbGetInputIn9().size()!=0) { pLstVec.push_back( &In9 ); } + + std::vector Out0; + std::vector Out1; + std::vector Out2; + std::vector Out3; + std::vector Out4; + std::vector Out5; + std::vector Out6; + std::vector Out7; + std::vector Out8; + std::vector Out9; + + pLstVecOut.push_back( &Out0 ); + pLstVecOut.push_back( &Out1 ); + pLstVecOut.push_back( &Out2 ); + pLstVecOut.push_back( &Out3 ); + pLstVecOut.push_back( &Out4 ); + pLstVecOut.push_back( &Out5 ); + pLstVecOut.push_back( &Out6 ); + pLstVecOut.push_back( &Out7 ); + pLstVecOut.push_back( &Out8 ); + pLstVecOut.push_back( &Out9 ); + + + if (bbGetInputType()==0) // Erase duplicate lines + { + bool okSizeVec=true; + int ipLstvec; + for (ipLstvec=1;ipLstvec=2) + { + for (i=0;i=2 + } // for pLstVec + } // Type==2 + + + bbSetOutputOut0( Out0 ); + bbSetOutputOut1( Out1 ); + bbSetOutputOut2( Out2 ); + bbSetOutputOut3( Out3 ); + bbSetOutputOut4( Out4 ); + bbSetOutputOut5( Out5 ); + bbSetOutputOut6( Out6 ); + bbSetOutputOut7( Out7 ); + bbSetOutputOut8( Out8 ); + bbSetOutputOut9( Out9 ); +} +//===== +// 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 VectorFilterDouble::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputType(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 VectorFilterDouble::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 VectorFilterDouble::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbstd + + diff --git a/packages/std/src/bbstdVectorFilterDouble.h b/packages/std/src/bbstdVectorFilterDouble.h new file mode 100644 index 0000000..e2e685d --- /dev/null +++ b/packages/std/src/bbstdVectorFilterDouble.h @@ -0,0 +1,85 @@ +//===== +// 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 __bbstdVectorFilterDouble_h_INCLUDED__ +#define __bbstdVectorFilterDouble_h_INCLUDED__ +#include "bbstd_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +namespace bbstd +{ + +class bbstd_EXPORT VectorFilterDouble + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(VectorFilterDouble,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(Type,int); + BBTK_DECLARE_INPUT(k1,double); + BBTK_DECLARE_INPUT(In0,std::vector); + BBTK_DECLARE_INPUT(In1,std::vector); + BBTK_DECLARE_INPUT(In2,std::vector); + BBTK_DECLARE_INPUT(In3,std::vector); + BBTK_DECLARE_INPUT(In4,std::vector); + BBTK_DECLARE_INPUT(In5,std::vector); + BBTK_DECLARE_INPUT(In6,std::vector); + BBTK_DECLARE_INPUT(In7,std::vector); + BBTK_DECLARE_INPUT(In8,std::vector); + BBTK_DECLARE_INPUT(In9,std::vector); + BBTK_DECLARE_OUTPUT(Out0,std::vector); + BBTK_DECLARE_OUTPUT(Out1,std::vector); + BBTK_DECLARE_OUTPUT(Out2,std::vector); + BBTK_DECLARE_OUTPUT(Out3,std::vector); + BBTK_DECLARE_OUTPUT(Out4,std::vector); + BBTK_DECLARE_OUTPUT(Out5,std::vector); + BBTK_DECLARE_OUTPUT(Out6,std::vector); + BBTK_DECLARE_OUTPUT(Out7,std::vector); + BBTK_DECLARE_OUTPUT(Out8,std::vector); + BBTK_DECLARE_OUTPUT(Out9,std::vector); + 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(VectorFilterDouble,bbtk::AtomicBlackBox); + BBTK_NAME("VectorFilterDouble"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(VectorFilterDouble,Type,"default (0) 0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points",int,""); + BBTK_INPUT(VectorFilterDouble,k1,"default (0) nothing (Type0), k1=new size vectors (Type 1) , ",double,""); + BBTK_INPUT(VectorFilterDouble,In0,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In1,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In2,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In3,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In4,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In5,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In6,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In7,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In8,"Input vector",std::vector,""); + BBTK_INPUT(VectorFilterDouble,In9,"Input vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out0,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out1,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out2,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out3,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out4,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out5,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out6,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out7,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out8,"Output vector",std::vector,""); + BBTK_OUTPUT(VectorFilterDouble,Out9,"Output vector",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(VectorFilterDouble); +//===== +// 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 bbstd + +#endif // __bbstdVectorFilterDouble_h_INCLUDED__ + diff --git a/packages/vtk/src/bbvtkSphereList.cxx b/packages/vtk/src/bbvtkSphereList.cxx index 7b91170..616f088 100644 --- a/packages/vtk/src/bbvtkSphereList.cxx +++ b/packages/vtk/src/bbvtkSphereList.cxx @@ -77,7 +77,6 @@ void SphereList::GetPoint(int i, double &px,double &py,double &pz) { pz = bbGetInputlstPointZ()[i]*spc[2]; } -printf("EED SphereList::GetPoint() %f %f %f\n",px,py,pz); } @@ -99,104 +98,91 @@ void SphereList::GetColor(int i, double &cr,double &cg,double &cb) } } - - void SphereList::Process() { -printf ("EED SphereList::Process Start\n"); - int iMin, iMax; - double px = 0.0; - double py = 0.0; - double pz = 0.0; - - double cr = 0.0; - double cg = 0.0; - double cb = 0.0; - -/* -== igualar la lista de objetos - si la lista es igual nada que hacer - si la nueva lista es las corta que la lista existente borrar los actores - si la lista es mas larga que la lista existente crear los actores -== acualizar la lista de objetos -*/ - - if (bbGetInputRenderer()!=NULL) { -// If it is not the first time Process is executed, the actors have already been created. The only thing to do is to update the opacity. - if (sphereActor.size() != 0) - { - for (int i = 0; i < sphereActor.size(); i++) + int sizeLstX=bbGetInputlstPointX().size(); + int sizeLstY=bbGetInputlstPointY().size(); + int sizeLstZ=bbGetInputlstPointZ().size(); + int sizeLstActors=sphereActor.size(); + if ((sizeLstX==sizeLstY) &&(sizeLstX==sizeLstZ)) + { + if (sizeLstActors>sizeLstX) + { + int i; + int diff=sizeLstActors-sizeLstX; + for (i=0;iRemoveActor( sphereActor[0] ); + vtkspheresourceLst[0]->Delete(); + sphereActor[0]->Delete(); + vtkspheresourceLst.erase( vtkspheresourceLst.begin() ); + sphereActor.erase( sphereActor.begin() ); + } // for + } // if size + + if (sizeLstActors SetThetaResolution(20); + newSphere -> SetPhiResolution(20); + newSphere -> SetRadius( 1 ); + vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New(); + newMapper -> SetInput( newSphere -> GetOutput() ); + vtkActor * newActor = vtkActor::New(); + sphereActor.push_back(newActor); + newActor -> SetMapper(newMapper); + newActor -> SetOrigin(0, 0, 0); + if ( bbGetInputTransform()!=NULL ) + { + newActor->SetUserTransform( bbGetInputTransform() ); + } + bbGetInputRenderer()->AddActor( newActor ); + } // for + } // if size + + // Refresh data + for (int i = 0; i < sphereActor.size() ; i++) { + double px = 0.0; + double py = 0.0; + double pz = 0.0; + double cr = 0.0; + double cg = 0.0; + double cb = 0.0; GetPoint(i, px,py,pz); GetColor(i, cr,cg,cb); sphereActor[i] ->SetPosition( px,py,pz ); -printf("EED SphereList::Process() %f %f %f\n",px,py,pz); sphereActor[i] -> GetProperty() -> SetOpacity( bbGetInputOpacity() ); sphereActor[i] -> GetProperty() -> SetColor( cr,cg,cb ); vtkspheresourceLst[i] -> SetRadius( GetRadio(i) ); } // for i - } else { - iMin=0; - iMax=bbGetInputlstPointX().size(); -// printf("EED SphereList::Process iMax=%d \n", iMax); -// for (int i = 0; i < iMax; i++) -// { -// std::cout << "CM SphereList::Process i=" << i << " bbGetInputlstPointX()[i]=" << bbGetInputlstPointX()[i] << std::endl; -// std::cout << "CM SphereList::Process i=" << i << " bbGetInputlstPointY()[i]=" << bbGetInputlstPointY()[i] << std::endl; -// std::cout << "CM SphereList::Process i=" << i << " bbGetInputlstPointZ()[i]=" << bbGetInputlstPointZ()[i] << std::endl; -// } // for i - - // If the vector Y or respectively the vector Z has a different size from the vector X, the position value py or respectively pz is set to 0. - for ( int i=iMin ; i SetThetaResolution(20); - newSphere -> SetPhiResolution(20); - newSphere -> SetRadius( GetRadio(i) ); - vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New(); - newMapper -> SetInput( newSphere -> GetOutput() ); - - vtkActor * newActor = vtkActor::New(); - sphereActor.push_back(newActor); - newActor -> SetMapper(newMapper); - newActor -> SetOrigin(0, 0, 0); - newActor -> GetProperty() -> SetColor(cr,cg,cb); - newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() ); - newActor -> SetPosition( px,py,pz ); - - if ( bbGetInputTransform()!=NULL ) - { - newActor->SetUserTransform( bbGetInputTransform() ); - } - - if (bbGetInputRenderer()!=NULL) - { - bbGetInputRenderer() -> AddActor( newActor ); - } - - } // for - - if (sphereActor.size() != 0) + if (sphereActor.size() != 0) { // Sets the output. bbSetOutputActorList(sphereActor); } - - } // if (sphereActor.size() != 0) - } // if (bbGetInputRenderer()!=NULL) + + } else { + printf("EED Warning! SphereList::Process Lst XYZ are not of the same size.\n"); + }// if sizeLst + } else { + printf("EED Warning! SphereList::Process Render not assigned.\n"); + }// if Renderer -printf ("EED SphereList::Process END\n"); +//==================================================================== } + void SphereList::bbUserSetDefaultValues() {