From 2e3f0513d8ed53019196f83a71e3baa7bebf55e8 Mon Sep 17 00:00:00 2001 From: Claire Mouton Date: Wed, 7 Nov 2012 13:31:30 +0000 Subject: [PATCH] Feature #1743 Add a box building a vector ot arithmetic suite values. --- .../exampleCreateArithmeticSuiteVector.bbg | 35 ++++++++++++++++ .../exampleCreateArithmeticSuiteVector.bbs | 31 ++++++++++++++ .../src/bbstdCreateArithmeticSuiteVector.cxx | 42 +++++++++++++++++++ .../src/bbstdCreateArithmeticSuiteVector.h | 37 ++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbg create mode 100644 packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbs create mode 100644 packages/std/src/bbstdCreateArithmeticSuiteVector.cxx create mode 100644 packages/std/src/bbstdCreateArithmeticSuiteVector.h diff --git a/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbg b/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbg new file mode 100644 index 0000000..639192e --- /dev/null +++ b/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbg @@ -0,0 +1,35 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBG BlackBox Diagram file +# - /home/mouton/Creatis/all/creatools_source/bbtk/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbg +# ---------------------------------- + +APP_START +CATEGORY: +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:FALSE +COMPLEXINPUTS:0 +BOXES:2 +BOX +std:CreateArithmeticSuiteVector:Box00 +ISEXEC:FALSE +-26.352728:60.824945:-900.000000 +44.822272:50.824945:-900.000000 +PORT +Delta:"2" +PORT +FirstValue:"5" +PORT +Size:"10" +FIN_BOX +BOX +wx:OutputText:Box01 +ISEXEC:TRUE +-28.062094:29.201672:-900.000000 +17.512906:19.201672:-900.000000 +FIN_BOX +CONNECTIONS:1 +CONNECTION +Box00:ArithmeticSuiteVector:Box01:In +NumberOfControlPoints:0 +APP_END diff --git a/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbs b/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbs new file mode 100644 index 0000000..f864f99 --- /dev/null +++ b/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbs @@ -0,0 +1,31 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBS BlackBox Script +# - /home/mouton/Creatis/all/creatools_source/bbtk/packages/std/bbs/appli/exampleCreateArithmeticSuiteVector.bbs +# ---------------------------------- + +# BBTK GEditor Script +# ---------------------- + +include std +include itkvtk +include std +include wx + +author "Author ??" +description "Description ??" +category "" + +new CreateArithmeticSuiteVector Box00 + set Box00.Delta "2" + set Box00.FirstValue "5" + set Box00.Size "10" + +new OutputText Box01 + + +connect Box00.ArithmeticSuiteVector Box01.In + + + +# Complex input ports +exec Box01 diff --git a/packages/std/src/bbstdCreateArithmeticSuiteVector.cxx b/packages/std/src/bbstdCreateArithmeticSuiteVector.cxx new file mode 100644 index 0000000..caa2c07 --- /dev/null +++ b/packages/std/src/bbstdCreateArithmeticSuiteVector.cxx @@ -0,0 +1,42 @@ +#include "bbstdCreateArithmeticSuiteVector.h" +#include "bbstdPackage.h" +namespace bbstd +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,CreateArithmeticSuiteVector) +BBTK_BLACK_BOX_IMPLEMENTATION(CreateArithmeticSuiteVector,bbtk::AtomicBlackBox); + +void CreateArithmeticSuiteVector::Process() +{ +// THE MAIN PROCESSING METHOD BODY + std::vector outputVector; + + double value = bbGetInputFirstValue(); + double delta = bbGetInputDelta(); + for (int i = 0; i < bbGetInputSize(); i++) + { + outputVector.push_back(value + i*delta); + } + + bbSetOutputArithmeticSuiteVector(outputVector); +} + +void CreateArithmeticSuiteVector::bbUserSetDefaultValues() +{ + // THE DEFAULT INPUT/OUTPUT VALUES + bbSetInputFirstValue(0); + bbSetInputDelta(0); + bbSetInputSize(0); +} + +void CreateArithmeticSuiteVector::bbUserInitializeProcessing() +{ + +} + +void CreateArithmeticSuiteVector::bbUserFinalizeProcessing() +{ + +} +} +// EO namespace bbstd diff --git a/packages/std/src/bbstdCreateArithmeticSuiteVector.h b/packages/std/src/bbstdCreateArithmeticSuiteVector.h new file mode 100644 index 0000000..426eaa3 --- /dev/null +++ b/packages/std/src/bbstdCreateArithmeticSuiteVector.h @@ -0,0 +1,37 @@ +#ifndef __bbstdCreateArithmeticSuiteVector_h_INCLUDED__ +#define __bbstdCreateArithmeticSuiteVector_h_INCLUDED__ +#include "bbstd_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +namespace bbstd +{ + +class bbstd_EXPORT CreateArithmeticSuiteVector + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(CreateArithmeticSuiteVector,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(FirstValue,double); + BBTK_DECLARE_INPUT(Delta,double); + BBTK_DECLARE_INPUT(Size,int); + BBTK_DECLARE_OUTPUT(ArithmeticSuiteVector,std::vector); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(CreateArithmeticSuiteVector,bbtk::AtomicBlackBox); +BBTK_NAME("CreateArithmeticSuiteVector"); +BBTK_AUTHOR("Claire Mouton"); +BBTK_DESCRIPTION("Creates a vector with the values of an arithmetic suite, given the first value, the difference between two consecutive elements (delta) and its size."); +BBTK_CATEGORY("std"); +BBTK_INPUT(CreateArithmeticSuiteVector,FirstValue,"The first value of the vector.",double,""); +BBTK_INPUT(CreateArithmeticSuiteVector,Delta,"The difference between two consecutive elements (Put 0 to get a constatn vector).",double,""); +BBTK_INPUT(CreateArithmeticSuiteVector,Size,"Size of the vector to create.",int,""); +BBTK_OUTPUT(CreateArithmeticSuiteVector,ArithmeticSuiteVector,"The created vector.",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(CreateArithmeticSuiteVector); +} +// EO namespace bbstd + +#endif // __bbstdCreateArithmeticSuiteVector_h_INCLUDED__ + -- 2.47.1