From 4362ad7240226019cf06a2215d114d1440a169d5 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 12 Jun 2014 11:22:12 +0200 Subject: [PATCH] 2391 BBTK Feature New Normal box castVector in std package --- packages/std/src/bbstdCast.cxx | 1 + packages/std/src/bbstdCast.h | 32 +-- .../vtk/bbs/appli/exampleMeasureLength.bbg | 200 +++++++++++++++--- .../vtk/bbs/appli/exampleMeasureLength.bbs | 94 ++++++-- packages/vtk/src/bbvtkMeasureLength.cxx | 4 +- .../vtk/src/bbvtkPointsXYZtoVTKPoints.cxx | 22 +- packages/vtk/src/bbvtkText2D.cxx | 15 ++ 7 files changed, 295 insertions(+), 73 deletions(-) diff --git a/packages/std/src/bbstdCast.cxx b/packages/std/src/bbstdCast.cxx index 7cbb632..5d8367d 100644 --- a/packages/std/src/bbstdCast.cxx +++ b/packages/std/src/bbstdCast.cxx @@ -127,6 +127,7 @@ namespace bbstd BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(std,Cast,uint8_t,int8_t); BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(std,Cast,int8_t,uint8_t); + //==================================================================== diff --git a/packages/std/src/bbstdCast.h b/packages/std/src/bbstdCast.h index f14cd05..f42024a 100644 --- a/packages/std/src/bbstdCast.h +++ b/packages/std/src/bbstdCast.h @@ -46,20 +46,20 @@ namespace bbstd //================================================================= // BlackBox declaration - template + template < class T, class U > class bbstd_EXPORT Cast : public bbtk::AtomicBlackBox { - BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox,T,U); - BBTK_DECLARE_INPUT(In,T); - BBTK_DECLARE_OUTPUT(Out,U); + BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox , T , U ); + BBTK_DECLARE_INPUT(In , T ); + BBTK_DECLARE_OUTPUT(Out , U ); BBTK_PROCESS(DoIt); void DoIt() { bbtkDebugMessage("Data",5,"bbstd::Cast In = " - <() + << bbGetInputIn() <<" <"<() <<">"<(bbGetInputIn()) ); + bbSetOutputOut( static_cast< U >(bbGetInputIn()) ); bbtkDebugMessage("Data",5,"bbstd::Cast Out = " - <<(U)bbGetInputIn()<<" <"<() + <<( U )bbGetInputIn()<<" <"<() <<">"<()+"To"+bbtk::HumanTypeName()); + BBTK_NAME("Cast"+bbtk::HumanTypeName< T1 >()+"To"+bbtk::HumanTypeName< T2 >()); BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); - BBTK_DESCRIPTION("Static cast from "+bbtk::HumanTypeName()+" (" - +bbtk::TypeName()+") to "+bbtk::HumanTypeName() - +" ("+bbtk::TypeName()+")"); + BBTK_DESCRIPTION("Static cast from "+bbtk::HumanTypeName< T1 >()+" (" + +bbtk::TypeName< T1 >()+") to "+bbtk::HumanTypeName< T2 >() + +" ("+bbtk::TypeName< T2 >()+")"); BBTK_DEFAULT_ADAPTOR(); - BBTK_TEMPLATE2_INPUT(Cast,In,"Input",T1); - BBTK_TEMPLATE2_OUTPUT(Cast,Out,"Output",T2); + BBTK_TEMPLATE2_INPUT(Cast,In,"Input", T1 ); + BBTK_TEMPLATE2_OUTPUT(Cast,Out,"Output", T2 ); BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast); //================================================================= - template void Cast::bbUserSetDefaultValues() {} - template void Cast::bbUserInitializeProcessing() {} - template void Cast::bbUserFinalizeProcessing() {} + template void Cast< T , U >::bbUserSetDefaultValues() {} + template void Cast< T , U >::bbUserInitializeProcessing() {} + template void Cast< T , U >::bbUserFinalizeProcessing() {} } // namespace bbstd diff --git a/packages/vtk/bbs/appli/exampleMeasureLength.bbg b/packages/vtk/bbs/appli/exampleMeasureLength.bbg index f1ac03b..6a7e5f2 100644 --- a/packages/vtk/bbs/appli/exampleMeasureLength.bbg +++ b/packages/vtk/bbs/appli/exampleMeasureLength.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBG BlackBox Diagram file -# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbg +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbg # ---------------------------------- APP_START @@ -9,12 +9,12 @@ DESCRIPTION:Evaluates the sum of the Euclidean distances among the points in the AUTHOR:Ricardo A Corredor COMPLEXBOX:FALSE COMPLEXINPUTS:0 -BOXES:8 +BOXES:20 BOX creaMaracasVisu:ShowNPoints:Box00 -ISEXEC:TRUE --51.309471:11.810349:-900.000000 --2.989471:1.810349:-900.000000 +ISEXEC:FALSE +-20.575067:-1.900823:-900.000000 +27.744933:-11.900823:-900.000000 PORT WinTitle:"Points Widget" PORT @@ -22,17 +22,17 @@ WinWidth:"200" FIN_BOX BOX creaMaracasVisu:ViewerNV:Box02 -ISEXEC:TRUE --26.721828:47.483487:-900.000000 -33.918172:37.483487:-900.000000 +ISEXEC:FALSE +32.451487:18.015162:-900.000000 +93.091487:8.015162:-900.000000 PORT WinTitle:"Image Viewer" FIN_BOX BOX wx:CommandButton:Box03 -ISEXEC:TRUE --128.980270:47.281481:-900.000000 --83.405270:37.281481:-900.000000 +ISEXEC:FALSE +-124.217922:-25.806219:-900.000000 +-78.642922:-35.806219:-900.000000 PORT Label:"Evaluate length..." PORT @@ -45,38 +45,114 @@ FIN_BOX BOX vtk:MeasureLength:Box04 ISEXEC:FALSE --112.956474:-50.441103:-900.000000 --67.381474:-60.441103:-900.000000 +-83.249723:-44.698142:-900.000000 +-37.674723:-54.698142:-900.000000 FIN_BOX BOX vtk:PointsXYZtoVTKPoints:Box05 ISEXEC:FALSE --54.277786:-36.674180:-900.000000 -16.897214:-46.674180:-900.000000 +-68.713790:-27.331519:-900.000000 +2.461210:-37.331519:-900.000000 FIN_BOX BOX wx:OutputText:Box06 ISEXEC:FALSE --113.407849:-80.683196:-900.000000 --67.832849:-90.683196:-900.000000 +-106.948982:-66.573864:-900.000000 +-61.373982:-76.573864:-900.000000 +FIN_BOX +BOX +creaMaracasVisu:DrawAxe3D:Box09 +ISEXEC:FALSE +-6.044096:-121.459131:-900.000000 +39.530904:-131.459131:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box10 +ISEXEC:FALSE +82.578614:-47.313269:-900.000000 +128.153614:-57.313269:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box11 +ISEXEC:FALSE +100.248722:-68.607816:-900.000000 +145.823722:-78.607816:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box12 +ISEXEC:FALSE +89.242836:-94.110903:-900.000000 +134.817836:-104.110903:-900.000000 +FIN_BOX +BOX +vtk:ImageVtkProperties:Box13 +ISEXEC:FALSE +-27.999351:-41.893546:-900.000000 +17.575649:-51.893546:-900.000000 +FIN_BOX +BOX +vtk:LoadHola:Box14 +ISEXEC:FALSE +-86.746462:92.889408:-900.000000 +-41.171462:82.889408:-900.000000 +FIN_BOX +BOX +vtk:Transform:Box15 +ISEXEC:FALSE +-29.422707:-79.221243:-900.000000 +16.152293:-89.221243:-900.000000 +FIN_BOX +BOX +std:ConcatStrings:Box16 +ISEXEC:FALSE +-17.642995:-61.028922:-900.000000 +27.932005:-71.028922:-900.000000 +FIN_BOX +BOX +vtk:vtkImageDataPointerRelay:Box17 +ISEXEC:FALSE +-73.510553:44.615154:-900.000000 +-2.335553:34.615154:-900.000000 FIN_BOX BOX -vtk:MetaImageReader:Box07 +creaImageIO:ImagesChooserDialogBox:Box18 ISEXEC:FALSE --58.531222:83.907503:-900.000000 --12.956222:73.907503:-900.000000 +-34.396302:72.707317:-900.000000 +36.778698:62.707317:-900.000000 FIN_BOX BOX -wx:FileSelector:Box08 +wx:LayoutSplit:Box19 +ISEXEC:TRUE +29.399279:-160.598681:-900.000000 +74.974279:-170.598681:-900.000000 +PORT +Orientation:"H" +PORT +Proportion:"30" +FIN_BOX +BOX +vtk:UpdateRender:Box20 ISEXEC:FALSE --57.766108:111.196570:-900.000000 --12.191108:101.196570:-900.000000 +-55.505058:-104.393331:-900.000000 +-9.930058:-114.393331:-900.000000 PORT -Message:"Select an image ..." +Active:"true" +FIN_BOX +BOX +wx:LayoutSplit:Box21 +ISEXEC:FALSE +-102.220830:-112.698357:-900.000000 +-56.645830:-122.698357:-900.000000 PORT -Title:"Select an image ..." +Proportion:"25" +FIN_BOX +BOX +wx:LayoutLine:Box22 +ISEXEC:FALSE +-121.648659:-82.889246:-900.000000 +-64.088659:-92.889246:-900.000000 FIN_BOX -CONNECTIONS:13 +CONNECTIONS:33 CONNECTION Box02:Renderer1:Box00:Renderer NumberOfControlPoints:0 @@ -99,21 +175,81 @@ CONNECTION Box05:Points:Box04:Points NumberOfControlPoints:0 CONNECTION -Box03:BoxChange:Box06:BoxExecute +Box04:Length:Box06:In NumberOfControlPoints:0 CONNECTION -Box04:Length:Box06:In +Box02:Renderer1:Box09:Renderer +NumberOfControlPoints:0 +CONNECTION +Box00:lstPointsX:Box10:In1 +NumberOfControlPoints:0 +CONNECTION +Box00:lstPointsY:Box11:In1 +NumberOfControlPoints:0 +CONNECTION +Box11:Out:Box09:lstPointY +NumberOfControlPoints:0 +CONNECTION +Box10:Out:Box09:lstPointX +NumberOfControlPoints:0 +CONNECTION +Box00:lstPointsZ:Box12:In1 +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box09:lstPointZ +NumberOfControlPoints:0 +CONNECTION +Box15:Out:Box09:Transform +NumberOfControlPoints:0 +CONNECTION +Box13:Spacing:Box16:In1 +NumberOfControlPoints:0 +CONNECTION +Box17:Out:Box02:In +NumberOfControlPoints:0 +CONNECTION +Box17:Out:Box00:Image +NumberOfControlPoints:0 +CONNECTION +Box17:Out:Box04:ImageData +NumberOfControlPoints:0 +CONNECTION +Box17:Out:Box13:In +NumberOfControlPoints:0 +CONNECTION +Box02:Widget:Box19:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box16:Out:Box15:Scale +NumberOfControlPoints:0 +CONNECTION +Box00:BoxChange:Box09:BoxExecute NumberOfControlPoints:0 CONNECTION -Box07:Out:Box02:In +Box02:Renderer1:Box20:Renderer +NumberOfControlPoints:0 +CONNECTION +Box00:BoxChange:Box20:BoxExecute +NumberOfControlPoints:0 +CONNECTION +Box03:Widget:Box22:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box06:Widget:Box22:Widget2 +NumberOfControlPoints:0 +CONNECTION +Box21:Widget:Box19:Widget1 +NumberOfControlPoints:0 +CONNECTION +Box03:BoxChange:Box06:BoxExecute NumberOfControlPoints:0 CONNECTION -Box07:Out:Box04:ImageData +Box22:Widget:Box21:Widget1 NumberOfControlPoints:0 CONNECTION -Box07:Out:Box00:Image +Box00:Widget:Box21:Widget2 NumberOfControlPoints:0 CONNECTION -Box08:Out:Box07:In +Box18:Out:Box17:In NumberOfControlPoints:0 APP_END diff --git a/packages/vtk/bbs/appli/exampleMeasureLength.bbs b/packages/vtk/bbs/appli/exampleMeasureLength.bbs index 4ffc5a7..fe9bdc0 100644 --- a/packages/vtk/bbs/appli/exampleMeasureLength.bbs +++ b/packages/vtk/bbs/appli/exampleMeasureLength.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.4 BBS BlackBox Script -# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbs +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbs # ---------------------------------- # BBTK GEditor Script @@ -11,6 +11,8 @@ include itkvtk include creaMaracasVisu include wx include vtk +include std +include creaImageIO author "Ricardo A Corredor" description "Evaluates the sum of the Euclidean distances among the points in the list following their order. Put some points in the image using the Points Widget and the click on Evaluate Length button. " @@ -35,11 +37,37 @@ new PointsXYZtoVTKPoints Box05 new OutputText Box06 -new MetaImageReader Box07 +new DrawAxe3D Box09 + +new ConcatStrings Box10 + +new ConcatStrings Box11 + +new ConcatStrings Box12 + +new ImageVtkProperties Box13 + +new LoadHola Box14 + +new Transform Box15 + +new ConcatStrings Box16 + +new vtkImageDataPointerRelay Box17 + +new ImagesChooserDialogBox Box18 -new FileSelector Box08 - set Box08.Message "Select an image ..." - set Box08.Title "Select an image ..." +new LayoutSplit Box19 + set Box19.Orientation "H" + set Box19.Proportion "30" + +new UpdateRender Box20 + set Box20.Active "true" + +new LayoutSplit Box21 + set Box21.Proportion "25" + +new LayoutLine Box22 connect Box02.Renderer1 Box00.Renderer @@ -56,21 +84,59 @@ connect Box00.lstPointsZ Box05.LstPointsZ connect Box05.Points Box04.Points -connect Box03.BoxChange Box06.BoxExecute - connect Box04.Length Box06.In -connect Box07.Out Box02.In +connect Box02.Renderer1 Box09.Renderer + +connect Box00.lstPointsX Box10.In1 + +connect Box00.lstPointsY Box11.In1 + +connect Box11.Out Box09.lstPointY + +connect Box10.Out Box09.lstPointX + +connect Box00.lstPointsZ Box12.In1 + +connect Box12.Out Box09.lstPointZ + +connect Box15.Out Box09.Transform + +connect Box13.Spacing Box16.In1 + +connect Box17.Out Box02.In + +connect Box17.Out Box00.Image + +connect Box17.Out Box04.ImageData + +connect Box17.Out Box13.In + +connect Box02.Widget Box19.Widget2 + +connect Box16.Out Box15.Scale + +connect Box00.BoxChange Box09.BoxExecute + +connect Box02.Renderer1 Box20.Renderer + +connect Box00.BoxChange Box20.BoxExecute + +connect Box03.Widget Box22.Widget1 + +connect Box06.Widget Box22.Widget2 + +connect Box21.Widget Box19.Widget1 + +connect Box03.BoxChange Box06.BoxExecute -connect Box07.Out Box04.ImageData +connect Box22.Widget Box21.Widget1 -connect Box07.Out Box00.Image +connect Box00.Widget Box21.Widget2 -connect Box08.Out Box07.In +connect Box18.Out Box17.In # Complex input ports -exec Box00 -exec Box02 -exec Box03 +exec Box19 diff --git a/packages/vtk/src/bbvtkMeasureLength.cxx b/packages/vtk/src/bbvtkMeasureLength.cxx index 1b2a645..4dfc3d7 100644 --- a/packages/vtk/src/bbvtkMeasureLength.cxx +++ b/packages/vtk/src/bbvtkMeasureLength.cxx @@ -13,7 +13,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(MeasureLength,bbtk::AtomicBlackBox); //===== void MeasureLength::Process() { - //std::cout << "RaC MeasureLength::Process START"<< std::endl; + std::cout << "RaC MeasureLength::Process START"<< std::endl; _points = bbGetInputPoints(); _image = bbGetInputImageData(); @@ -61,7 +61,7 @@ void MeasureLength::Process() bbSetOutputLength(sumLength); - //std::cout << "RaC MeasureLength::Process END"<< std::endl; + std::cout << "RaC MeasureLength::Process END"<< std::endl; } //===== // 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/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx index 0a825a2..f2a8495 100644 --- a/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx +++ b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx @@ -14,27 +14,33 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox); void PointsXYZtoVTKPoints::Process() { - //std::cout << "RaC PointsXYZtoVTKPoints::Process START"<< std::endl; +//std::cout << "RaC PointsXYZtoVTKPoints::Process START"<< std::endl; std::vector lstPointsX = bbGetInputLstPointsX(); std::vector lstPointsY = bbGetInputLstPointsY(); std::vector lstPointsZ = bbGetInputLstPointsZ(); + if(_points==NULL) + { _points=vtkPoints::New(); - else + } else { _points->Reset();//CLEAR + } + double point[3]; + point[0]=0; + point[1]=0; + point[2]=0; for (int i =0; i < lstPointsX.size(); ++i) { - double point[3]; point[0]=lstPointsX[i]; - point[1]=lstPointsY[i]; - point[2]=lstPointsZ[i]; + if (lstPointsY.size()>i) { point[1]=lstPointsY[i]; } + if (lstPointsZ.size()>i) { point[2]=lstPointsZ[i]; } _points->InsertPoint(i,point); } bbSetOutputPoints(_points); - //std::cout << "RaC PointsXYZtoVTKPoints::Process END"<< std::endl; +std::cout << "RaC PointsXYZtoVTKPoints::Process END"<< std::endl; } //===== @@ -42,9 +48,7 @@ void PointsXYZtoVTKPoints::Process() //===== void PointsXYZtoVTKPoints::bbUserSetDefaultValues() { - - - + _points=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/packages/vtk/src/bbvtkText2D.cxx b/packages/vtk/src/bbvtkText2D.cxx index c5d9d73..5eaa9c2 100644 --- a/packages/vtk/src/bbvtkText2D.cxx +++ b/packages/vtk/src/bbvtkText2D.cxx @@ -38,6 +38,14 @@ void Text2D::Process() _textActor = vtkTextActor::New(); _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld(); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToDisplay (); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay (); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToViewport (); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport (); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToView (); +// _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld (); + + if (bbGetInputRenderer()!=NULL) { bbGetInputRenderer()->AddActor2D(_textActor); @@ -66,7 +74,14 @@ void Text2D::Process() } } +// _textActor->SetTextScaleModeToProp(); _textActor->SetPosition( px*spx , py*spy ); + +printf("EED Text2D::Process px=%f py=%f\n",px,py); + +// _textActor->SetPosition( 150,150 ); +// _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); +// _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 ); // textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1); vtkTextProperty *tprop = _textActor->GetTextProperty(); -- 2.45.0