From: Eduardo DAVILA Date: Fri, 24 Nov 2017 10:16:57 +0000 (+0100) Subject: 3149 BBTK Feature New Normal - GetVectorPointer SetElementVector box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtk.git;a=commitdiff_plain;h=789ecd0eb75c3657333605b45faf47c5c37a29c6 3149 BBTK Feature New Normal - GetVectorPointer SetElementVector box --- diff --git a/packages/std/bbs/appli/exampleSetElementVector.bbg b/packages/std/bbs/appli/exampleSetElementVector.bbg new file mode 100644 index 0000000..783093b --- /dev/null +++ b/packages/std/bbs/appli/exampleSetElementVector.bbg @@ -0,0 +1,73 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBG BlackBox Diagram file +# - /tmpEED/creaTools/creatools_source/bbtk/packages/std/bbs/appli/exampleSetElementVector.bbg +# ---------------------------------- + +APP_START +CATEGORY: +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:FALSE +COMPLEXINPUTS:0 +BOXES:5 +BOX +std:GetVectorStringPointer:Box01 +ISEXEC:FALSE +6.522014:14.475352:-900.000000 +77.697014:4.475352:-900.000000 +PORT +In:"A B C D E" +FIN_BOX +BOX +std:SetElementVectorVectorString:Box02 +ISEXEC:FALSE +-11.680621:-19.993209:-900.000000 +59.494379:-29.993209:-900.000000 +PORT +I:"2" +PORT +Value:"2" +FIN_BOX +BOX +wx:OutputText:Box03 +ISEXEC:FALSE +-54.917469:-70.666633:-900.000000 +-9.342469:-80.666633:-900.000000 +FIN_BOX +BOX +wx:LayoutSplit:Box04 +ISEXEC:TRUE +-73.506336:-93.307343:-900.000000 +-27.931336:-103.307343:-900.000000 +FIN_BOX +BOX +wx:Slider:Box05 +ISEXEC:FALSE +-59.907189:56.689901:-900.000000 +-8.507189:46.689901:-900.000000 +PORT +ReactiveOnTrack:"true" +FIN_BOX +CONNECTIONS:7 +CONNECTION +Box05:Widget:Box04:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box05:BoxChange:Box03:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box05:BoxChange:Box02:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box05:Out:Box02:Value +NumberOfControlPoints:0 +CONNECTION +Box03:Widget:Box04:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box01:PVec:Box02:PVec +NumberOfControlPoints:0 +CONNECTION +Box02:Vec:Box03:In +NumberOfControlPoints:0 +APP_END diff --git a/packages/std/bbs/appli/exampleSetElementVector.bbs b/packages/std/bbs/appli/exampleSetElementVector.bbs new file mode 100644 index 0000000..615607e --- /dev/null +++ b/packages/std/bbs/appli/exampleSetElementVector.bbs @@ -0,0 +1,50 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBS BlackBox Script +# - /tmpEED/creaTools/creatools_source/bbtk/packages/std/bbs/appli/exampleSetElementVector.bbs +# ---------------------------------- + +# BBTK GEditor Script +# ---------------------- + +include std +include itkvtk +include std +include wx + +author "Author ??" +description "Description ??" +category "" + +new std:GetVectorStringPointer Box01 + set Box01.In "A B C D E" + +new std:SetElementVectorVectorString Box02 + set Box02.I "2" + set Box02.Value "2" + +new wx:OutputText Box03 + +new wx:LayoutSplit Box04 + +new wx:Slider Box05 + set Box05.ReactiveOnTrack "true" + + +connect Box05.Widget Box04.Widget1 + +connect Box05.BoxChange Box03.BoxExecute + +connect Box05.BoxChange Box02.BoxExecute + +connect Box05.Out Box02.Value + +connect Box03.Widget Box04.Widget2 + +connect Box01.PVec Box02.PVec + +connect Box02.Vec Box03.In + + + +# Complex input ports +exec Box04 diff --git a/packages/std/src/bbstdGetVectorPointer.cxx b/packages/std/src/bbstdGetVectorPointer.cxx new file mode 100644 index 0000000..a4f4abd --- /dev/null +++ b/packages/std/src/bbstdGetVectorPointer.cxx @@ -0,0 +1,65 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdGetVectorElement.cxx,v $ + Language: C++ + Date: $Date: 2012/11/16 08:51:32 $ + Version: $Revision: 1.4 $ +=========================================================================*/ + + +#include "bbstdGetVectorPointer.h" +#include "bbstdPackage.h" + + +namespace bbstd +{ + //==================================================================== + BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(GetVectorPointer, + bbtk::AtomicBlackBox); + //==================================================================== + +//==================================================================== +// Add the specialized boxes to the package + +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,int8_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,uint8_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,int16_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,uint16_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,int32_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,uint32_t); +///\todo : diff between uint32_t and long? +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,long); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,float); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,double); +typedef std::string string; +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,GetVectorPointer,string); +//==================================================================== + +} // namespace bbstd diff --git a/packages/std/src/bbstdGetVectorPointer.h b/packages/std/src/bbstdGetVectorPointer.h new file mode 100644 index 0000000..931dc66 --- /dev/null +++ b/packages/std/src/bbstdGetVectorPointer.h @@ -0,0 +1,109 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdGetVectorElement.h,v $ + Language: C++ + Date: $Date: 2012/11/16 08:51:32 $ + Version: $Revision: 1.9 $ +=========================================================================*/ + + +#ifndef __bbstdGetVectorPointer_INCLUDED_h__ +#define __bbstdGetVectorPointer_INCLUDED_h__ + +#include "bbtkAtomicBlackBox.h" +#include "bbstd_EXPORT.h" + +namespace bbstd +{ + //================================================================= + // BlackBox declaration + template + class bbstd_EXPORT GetVectorPointer : public bbtk::AtomicBlackBox + { + BBTK_TEMPLATE_BLACK_BOX_INTERFACE(GetVectorPointer,bbtk::AtomicBlackBox,T); + BBTK_DECLARE_INPUT(In,std::vector); + BBTK_DECLARE_OUTPUT(PVec,std::vector*); + BBTK_PROCESS(DoIt); + void DoIt(); + std::vector vec; + }; + //================================================================= + + //================================================================= + // BlackBox description + BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorPointer,bbtk::AtomicBlackBox); + BBTK_NAME("Get"+bbtk::HumanTypeName >()+"Pointer"); + BBTK_AUTHOR("info-dev@creatis.insa-lyon.fr"); + // BBTK_DEFAULT_ADAPTOR(); + BBTK_DESCRIPTION("Gets the the pointer of the input vector ("+bbtk::TypeName >()); + typedef std::vector Tvector; + BBTK_TEMPLATE_INPUT(GetVectorPointer, In,"Input",Tvector); +// BBTK_TEMPLATE_INPUT(GetVectorPointer, I, "Input",int); +// BBTK_TEMPLATE_INPUT(GetVectorPointer, ErrorValue, "ErrorValue",T); +// BBTK_TEMPLATE_OUTPUT(GetVectorPointer,Out,"Output",T); + BBTK_TEMPLATE_OUTPUT(GetVectorPointer,PVec,"Output Pointer Vector",std::vector*); + BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(GetVectorPointer); + //================================================================= + + //================================================================= + template + void GetVectorPointer::DoIt() + { + vec = bbGetInputIn(); + bbSetOutputPVec( &vec ); + } + //================================================================= + + //================================================================= + template + void GetVectorPointer::bbUserSetDefaultValues() + { + + } + //================================================================= + //================================================================= + template + void GetVectorPointer::bbUserInitializeProcessing() + { + + } + //================================================================= + //================================================================= + template + void GetVectorPointer::bbUserFinalizeProcessing() + { + + } + //================================================================= + +} // namespace bbstd + +#endif //__bbstdGetVectorPointer_INCLUDED_h__ + diff --git a/packages/std/src/bbstdMixingVectors.cxx b/packages/std/src/bbstdMixingVectors.cxx index f042724..6386db5 100644 --- a/packages/std/src/bbstdMixingVectors.cxx +++ b/packages/std/src/bbstdMixingVectors.cxx @@ -36,41 +36,30 @@ BBTK_BLACK_BOX_IMPLEMENTATION(MixingVectors,bbtk::AtomicBlackBox); void MixingVectors::Process() { // THE MAIN PROCESSING METHOD BODY - int size1 = bbGetInputIn1().size(); - int size2 = bbGetInputIn2().size(); - int size3 = bbGetInputIn3().size(); - int size4 = bbGetInputIn4().size(); - int size5 = bbGetInputIn5().size(); - int size6 = bbGetInputIn6().size(); - int size7 = bbGetInputIn7().size(); - int size8 = bbGetInputIn8().size(); - int size9 = bbGetInputIn9().size(); - int size10 = bbGetInputIn10().size(); - std::vector outputVector; - - for (int i = 0; i < size1; i++) - { + int size1 = bbGetInputIn1().size(); + int size2 = bbGetInputIn2().size(); + int size3 = bbGetInputIn3().size(); + int size4 = bbGetInputIn4().size(); + int size5 = bbGetInputIn5().size(); + int size6 = bbGetInputIn6().size(); + int size7 = bbGetInputIn7().size(); + int size8 = bbGetInputIn8().size(); + int size9 = bbGetInputIn9().size(); + int size10 = bbGetInputIn10().size(); + std::vector outputVector; + for (int i = 0; i < size1; i++) + { outputVector.push_back( bbGetInputIn1()[i] ); - if (i < size2) - outputVector.push_back( bbGetInputIn2()[i] ); - if (i < size3) - outputVector.push_back( bbGetInputIn3()[i] ); - if (i < size4) - outputVector.push_back( bbGetInputIn4()[i] ); - if (i < size5) - outputVector.push_back( bbGetInputIn5()[i] ); - if (i < size6) - outputVector.push_back( bbGetInputIn6()[i] ); - if (i < size7) - outputVector.push_back( bbGetInputIn7()[i] ); - if (i < size8) - outputVector.push_back( bbGetInputIn8()[i] ); - if (i < size9) - outputVector.push_back( bbGetInputIn9()[i] ); - if (i < size10) - outputVector.push_back( bbGetInputIn10()[i] ); + if (i < size2) { outputVector.push_back( bbGetInputIn2()[i] ); } + if (i < size3) { outputVector.push_back( bbGetInputIn3()[i] ); } + if (i < size4) { outputVector.push_back( bbGetInputIn4()[i] ); } + if (i < size5) { outputVector.push_back( bbGetInputIn5()[i] ); } + if (i < size6) { outputVector.push_back( bbGetInputIn6()[i] ); } + if (i < size7) { outputVector.push_back( bbGetInputIn7()[i] ); } + if (i < size8) { outputVector.push_back( bbGetInputIn8()[i] ); } + if (i < size9) { outputVector.push_back( bbGetInputIn9()[i] ); } + if (i < size10) { outputVector.push_back( bbGetInputIn10()[i] ); } } - bbSetOutputOut(outputVector); } @@ -88,5 +77,5 @@ void MixingVectors::bbUserFinalizeProcessing() { } -} -// EO namespace bbstd + +} // EO namespace bbstd diff --git a/packages/std/src/bbstdSetElementVector.cxx b/packages/std/src/bbstdSetElementVector.cxx new file mode 100644 index 0000000..cbd79b4 --- /dev/null +++ b/packages/std/src/bbstdSetElementVector.cxx @@ -0,0 +1,65 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdGetVectorElement.cxx,v $ + Language: C++ + Date: $Date: 2012/11/16 08:51:32 $ + Version: $Revision: 1.4 $ +=========================================================================*/ + + +#include "bbstdSetElementVector.h" +#include "bbstdPackage.h" + + +namespace bbstd +{ + //==================================================================== + BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(SetElementVector, + bbtk::AtomicBlackBox); + //==================================================================== + +//==================================================================== +// Add the specialized boxes to the package + +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,int8_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,uint8_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,int16_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,uint16_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,int32_t); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,uint32_t); +///\todo : diff between uint32_t and long? +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,long); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,float); +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,double); +typedef std::string string; +BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(std,SetElementVector,string); +//==================================================================== + +} // namespace bbstd diff --git a/packages/std/src/bbstdSetElementVector.h b/packages/std/src/bbstdSetElementVector.h new file mode 100644 index 0000000..5f3286e --- /dev/null +++ b/packages/std/src/bbstdSetElementVector.h @@ -0,0 +1,113 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdGetVectorElement.h,v $ + Language: C++ + Date: $Date: 2012/11/16 08:51:32 $ + Version: $Revision: 1.9 $ +=========================================================================*/ + + +#ifndef __bbstdSetElementVector_INCLUDED_h__ +#define __bbstdSetElementVector_INCLUDED_h__ + +#include "bbtkAtomicBlackBox.h" +#include "bbstd_EXPORT.h" + +namespace bbstd +{ + //================================================================= + // BlackBox declaration + template + class bbstd_EXPORT SetElementVector : public bbtk::AtomicBlackBox + { + BBTK_TEMPLATE_BLACK_BOX_INTERFACE(SetElementVector,bbtk::AtomicBlackBox,T); + BBTK_DECLARE_INPUT(PVec,std::vector*); + BBTK_DECLARE_INPUT(I,int); + BBTK_DECLARE_INPUT(Value,T); + BBTK_DECLARE_OUTPUT(Vec,std::vector); + BBTK_PROCESS(DoIt); + void DoIt(); + }; + //================================================================= + + //================================================================= + // BlackBox description + BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(SetElementVector,bbtk::AtomicBlackBox); + BBTK_NAME("SetElementVector"+bbtk::HumanTypeName >()); + BBTK_AUTHOR("info-dev@creatis.insa-lyon.fr"); + // BBTK_DEFAULT_ADAPTOR(); + BBTK_DESCRIPTION("Sets the value of the i-element ("+bbtk::TypeName >()); + typedef std::vector* pTvector; + BBTK_TEMPLATE_INPUT(SetElementVector, PVec,"Pointer to Vector",pTvector); + BBTK_TEMPLATE_INPUT(SetElementVector, I, "id-element",int); + BBTK_TEMPLATE_INPUT(SetElementVector, Value, "Input Value",T); + BBTK_TEMPLATE_OUTPUT(SetElementVector,Vec,"Output Vector",std::vector); + BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(SetElementVector); + //================================================================= + + //================================================================= + template + void SetElementVector::DoIt() + { + if ( (bbGetInputI()>=0) && (bbGetInputI()size()) ) + { + (*( bbGetInputPVec() ))[ bbGetInputI() ] = bbGetInputValue(); + } + bbSetOutputVec( *( bbGetInputPVec() ) ); + bbSignalOutputModification(std::string("Vec")); + } + //================================================================= + + //================================================================= + template + void SetElementVector::bbUserSetDefaultValues() + { + + } + //================================================================= + //================================================================= + template + void SetElementVector::bbUserInitializeProcessing() + { + + } + //================================================================= + //================================================================= + template + void SetElementVector::bbUserFinalizeProcessing() + { + + } + //================================================================= + +} // namespace bbstd + +#endif //__bbstdSetElementVector_INCLUDED_h__ + diff --git a/packages/std/src/bbstdStringVectorToNumericalVector.h b/packages/std/src/bbstdStringVectorToNumericalVector.h index e292bd2..c7bee76 100644 --- a/packages/std/src/bbstdStringVectorToNumericalVector.h +++ b/packages/std/src/bbstdStringVectorToNumericalVector.h @@ -79,13 +79,13 @@ namespace bbstd template void StringVectorToNumericalVector::DoIt() { - std::cout << "StringVectorToNumericalVector<"<()<<">::DoIt() start "< // recopie? // JPR //std::vector vect (bbGetInputIn() ); + bbmOutputOut.clear(); + // get a std::string, add it to the > int lgt=bbGetInputIn().size(); for (int i=0; i()<<">::DoIt() end "<