From 86c3482ce714b8d4201c8d819a10b59e4e4440c4 Mon Sep 17 00:00:00 2001 From: trillos Date: Mon, 2 Nov 2009 08:53:35 +0000 Subject: [PATCH] *** empty log message *** --- PackRecalage/bbs/appli/ExampleRecalage.bbs | 64 ++- PackRecalage/bbs/appli/Recalage2D.bbs | 57 ++- .../ViewerMerge2DInteractiveDemoFabianADC.bbs | 397 ------------------ ...iewerMerge2DInteractiveDemoFabianADCV2.bbs | 48 --- ...ViewerMerge2DInteractiveDemoFabianPeak.bbs | 391 ----------------- .../ViewerMerge2DInteractiveDemoFabianT2.bbs | 393 ----------------- .../src/bbPackRecalageCalculateVectorBox.cxx | 22 +- .../src/bbPackRecalageCalculateVectorBox.h | 43 +- .../src/bbPackRecalageImageSwitcherBox.cxx | 69 ++- .../src/bbPackRecalageImageSwitcherBox.h | 7 +- .../src/bbPackRecalageReSlicerBox.cxx | 2 +- .../src/bbPackRecalageTransform2DBox.cxx | 14 +- .../src/bbPackRecalageTransform2DBox.h | 13 +- lib/Transformer.cxx | 20 +- lib/Transformer.h | 5 +- lib/VectorMath.cxx | 93 +++- lib/VectorMath.h | 26 +- 17 files changed, 347 insertions(+), 1317 deletions(-) delete mode 100644 PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs delete mode 100644 PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs delete mode 100644 PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs delete mode 100644 PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs diff --git a/PackRecalage/bbs/appli/ExampleRecalage.bbs b/PackRecalage/bbs/appli/ExampleRecalage.bbs index da8b614..8b91bb2 100644 --- a/PackRecalage/bbs/appli/ExampleRecalage.bbs +++ b/PackRecalage/bbs/appli/ExampleRecalage.bbs @@ -10,6 +10,7 @@ include vtk include wx load itkvtk load creaMaracasVisu +load PackRecalage //File selection and file reader for the first image @@ -38,16 +39,6 @@ new ShowNPoints showNpoints connect viewer.BoxChange showNpoints.BoxExecute set showNpoints.Radio 10 -///////////////////////////////////////////////////// -#Calculate Vector Box -///////////////////////////////////////////////////// -/* -new CalculateVectorBox vector1 - connect showNpoints.lstPointsX vector1.PointsX1 - connect showNpoints.BoxChange vector1.BoxExecute -*/ -//////////////////////////////////////////////////// - //Viewer NV and ShowPoints for the second image new ViewerNV viewer2 @@ -61,6 +52,48 @@ new ShowNPoints showNpoints2 connect viewer2.BoxChange showNpoints2.BoxExecute set showNpoints2.Radio 10 +///////////////////////////////////////////////////// +#Calculate Vector Box +///////////////////////////////////////////////////// + +new CalculateVectorBox vector1 + connect showNpoints.lstPointsX vector1.PointsX1 + connect showNpoints2.lstPointsX vector1.PointsX2 + connect showNpoints.lstPointsY vector1.PointsY1 + connect showNpoints2.lstPointsY vector1.PointsY2 + connect showNpoints.lstPointsZ vector1.PointsZ1 + connect showNpoints2.lstPointsZ vector1.PointsZ2 + +//////////////////////////////////////////////////// + +/////////////////////////////////////////////////// +#Transformation Boxes +////////////////////////////////////////////////// + +new Transform2DBox transform + connect vector1.Origin transform.CenterPoint + connect vector1.OutAngle transform.Angle + connect vector1.OutScaleX transform.ScaleX + connect vector1.OutScaleY transform.ScaleY + connect vector1.OutScaleZ transform.ScaleZ + connect vector1.TransformAxis transform.Axis + set transform.3D true + +new ReSlicerBox reslice1 + connect vector1.OriginReslicer reslice1.Origin + connect transform.Out reslice1.Transform + connect reader2.Out reslice1.In + +//ViewerNV and ComandButton for the result image + +new ViewerNV viewer3 + set viewer3.nTypeView "5 1 2 0" + connect reslice1.Out viewer3.In + +new CommandButton butExec + set butExec.Label "Execute" + connect butExec.BoxChange viewer3.BoxExecute + //Tab for the first image new LayoutSplit tab1 @@ -75,12 +108,19 @@ new LayoutSplit tab2 connect showNpoints2.Widget tab2.Widget1 connect viewer2.Widget tab2.Widget2 +//Tab for the result image + +new LayoutSplit result + set result.Orientation H + connect butExec.Widget result.Widget1 + connect viewer3.Widget result.Widget2 + //Main window new LayoutTab main set main.Orientation H connect tab1.Widget main.Widget1 connect tab2.Widget main.Widget2 +connect result.Widget main.Widget3 -exec main - +exec main \ No newline at end of file diff --git a/PackRecalage/bbs/appli/Recalage2D.bbs b/PackRecalage/bbs/appli/Recalage2D.bbs index e9ffb0e..28ef695 100644 --- a/PackRecalage/bbs/appli/Recalage2D.bbs +++ b/PackRecalage/bbs/appli/Recalage2D.bbs @@ -6,6 +6,8 @@ load creaMaracasVisu load PackRecalage +//include PackRecalage/boxes/checkerView + new FileSelector imageSelector1 set imageSelector1.Wildcard "*.mhd" new FileSelector imageSelector2 @@ -103,11 +105,18 @@ new ImageConvolution convol1 new ImageConvolution convol2 connect reslice1.Out convol2.In +#Image Properties + +new ImageRecalageProperties properties + connect image.Out properties.In + connect image.BoxChange properties.BoxExecute + # Create the ZSlider for the slices new Slider sdrZ set sdrZ.ReactiveOnTrack 1 - set sdrZ.Max 50 + set sdrZ.Min 0 + connect properties.LengthZ sdrZ.Max set sdrZ.Title "Z for slice" connect sdrZ.Out imgslice1.Z @@ -141,21 +150,20 @@ new MultipleInputs multF connect multF.BoxChange convol1.BoxExecute connect multF.BoxChange convol2.BoxExecute - #Create Sliders for WinLevel and ColorLevel new Slider colorLevel set colorLevel.Min "0" - set colorLevel.Max "99" - set colorLevel.In "50" + connect properties.ColorLevel colorLevel.Max + connect properties.MidColorLevel colorLevel.In set colorLevel.ReactiveOnTrack true set colorLevel.Title "Color Level" new Slider windowLevel set windowLevel.Min "0" - set windowLevel.Max "99" - set windowLevel.In "50" + connect properties.ColorLevel windowLevel.Max + connect properties.MidColorLevel windowLevel.In set windowLevel.ReactiveOnTrack true set windowLevel.Title "Window Level" @@ -232,7 +240,15 @@ new ViewerNV viewerCH connect ly.Widget checkerBoard.Widget2 /////////////end of Checkboard//////////////////// +/* +new checkerView checkerboard + + connect convol1.Out checkerboard.In1 + connect convol2.Out checkerboard.In2 + connect colorLevel.Out checkerboard.ColorLevel + connect windowLevel.Out checkerboard.WindowLevel +*/ //////////////Transparency/////////////////////////// #Image Transparency view @@ -266,8 +282,12 @@ new LayoutSplit transparency new ImageSwitcherBox switch connect convol1.Out switch.In1 - connect convol2.Out switch.In2 - set switch.On "True" + connect convol2.Out switch.In2 + +new CheckBox checkS + connect checkS.Out switch.On + set checkS.Title "On" + set checkS.In "true" new Slider sdrT set sdrT.Max "1000" @@ -283,10 +303,23 @@ new Viewer2D viewerSwitch connect sdrT.BoxChange switch.BoxExecute connect switch.BoxChange viewerSwitch.BoxExecute -new LayoutLine switcher - connect viewerSwitch.Widget switcher.Widget1 - connect switch.Widget switcher.Widget2 - connect sdrT.Widget switcher.Widget3 +new LayoutSplit switcher + set switcher.Proportion "70" + +new LayoutSplit switchWindow + set switchWindow.Proportion "80" + connect viewerSwitch.Widget switchWindow.Widget1 + +new LayoutSplit switchTool + set switchTool.Orientation H + set switchTool.Proportion "50" + connect switch.Widget switchTool.Widget1 + connect checkS.Widget switchTool.Widget2 + + connect switchTool.Widget switchWindow.Widget2 + + connect switchWindow.Widget switcher.Widget1 + connect sdrT.Widget switcher.Widget2 //////////////end of Image Switch/////////////////// diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs deleted file mode 100644 index 0cd8d77..0000000 --- a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADC.bbs +++ /dev/null @@ -1,397 +0,0 @@ -load wx -load std -load vtk -load wxvtk -load creaMaracasVisu -load PackVisuImages -//load creaImageIO - -load PackRecalage - -//include vtk/boxes/bbLoadHola -//new LoadHola image - -new FileSelector imageSelector1 -new FileSelector imageSelector2 - -new MetaImageReader image - connect imageSelector1.Out image.In - -new MetaImageReader image2 - connect imageSelector2.Out image2.In - - -#new Gimmick image -#new Gimmick image2 - -#Viewer containing image 1 - -new LayoutLine v1Layout -new ViewerNV viewer1 -connect image.Out viewer1.In -set viewer1.nTypeView "0" -connect viewer1.Widget v1Layout.Widget1 - - -#Viewer containing image 2 - -new LayoutLine v2Layout -new ViewerNV viewer2 -connect image2.Out viewer2.In -set viewer2.nTypeView "0" -connect viewer2.Widget v2Layout.Widget1 - -#LayoutSplit were the images will be - -new LayoutSplit initialImages -set initialImages.Proportion "50" -set initialImages.Orientation H -connect v1Layout.Widget initialImages.Widget1 -connect v2Layout.Widget initialImages.Widget2 - -#Layout line that will contain the buttons - -new LayoutLine buttonsLayout - set buttonsLayout.Orientation V - -#Slider were the angle will be entered - -new Slider slider - set slider.Title "Angle" - set slider.In 0 - set slider.Min 0 - set slider.Max 360 - set slider.ReactiveOnTrack "1" - connect slider.Widget buttonsLayout.Widget1 - - - -#Slider were the xScale will be entered - -new Slider sliderX - set sliderX.Title "% Scale in X" - set sliderX.In 100 - set sliderX.Min 10 - set sliderX.Max 500 - set sliderX.ReactiveOnTrack "1" - connect sliderX.Widget buttonsLayout.Widget2 - - - -#Slider were the yScale will be entered - -new Slider sliderY - set sliderY.Title "% Scale in Y" - set sliderY.In 100 - set sliderY.Min 10 - set sliderY.Max 500 - set sliderY.ReactiveOnTrack "1" - connect sliderY.Widget buttonsLayout.Widget3 - - -#Box were the transformation will be made - -new Transform2DBox transform - connect viewer2.Point transform.CenterPoint - connect slider.Out transform.Angle - connect sliderX.Out transform.ScaleX - connect sliderY.Out transform.ScaleY - - - -new ReSlicerBox reslice1 - connect viewer1.Point reslice1.Origin - connect transform.Out reslice1.Transform - connect image2.Out reslice1.In - -new SliceImage slice1 - connect reslice1.Out slice1.In - set slice1.Z "1" - -new Viewer2D viewer2d - connect reslice1.Out viewer2d.In - set viewer2d.Slice "1" - -#new ViewerNV viewer3 - #connect reslice1.Out viewer3.In - #set viewer3.nTypeView "5" - #set viewer3.WinWidth "600" - -# Create the reslicers - -new SliceImage imgslice1 -new SliceImage imgslice2 - connect image.Out imgslice1.In - connect reslice1.Out imgslice2.In - -# Create the visulization box -new CheckBoardBox cbb - connect imgslice1.Out cbb.In1 - connect imgslice2.Out cbb.In2 - -# Create the slider1 -new Slider sdr - set sdr.ReactiveOnTrack 1 - set sdr.Max 50 - set sdr.In 14 - -# Create the slider2 -new Slider sdr2 - set sdr2.ReactiveOnTrack 1 - set sdr2.Max 50 - set sdr2.In 14 - -# Create the ZSlider for the slices - -new Slider sdrZ - set sdrZ.ReactiveOnTrack 1 - set sdrZ.Max 50 - set sdrZ.Title "Z for slice" - -connect sdrZ.Out imgslice1.Z -connect sdrZ.Out imgslice2.Z -connect sdrZ.BoxChange imgslice1.BoxExecute -connect sdrZ.BoxChange imgslice2.BoxExecute - -# Create viewer & layout -new LayoutSplit checkerBoard -new LayoutLine ly -new ViewerNV viewerCH - set viewerCH.nTypeView "0" - set checkerBoard.Proportion 80 - -# Graphical pipeline - connect sdr.Out cbb.Cols - connect sdr2.Out cbb.Rows - connect cbb.Out viewerCH.In - - #connect sdrZ.Widget ly.Widget1 - connect sdr.Widget ly.Widget2 - connect sdr2.Widget ly.Widget3 - - connect viewerCH.Widget checkerBoard.Widget1 - connect ly.Widget checkerBoard.Widget2 - -# Create Surface View - -new SurfaceCreator surf - set surf.Color1 RED - set surf.Color2 BLUE - - connect imgslice1.Out surf.Image1 - connect imgslice2.Out surf.Image2 - -new Slider sdrSurf1 - set sdrSurf1.Min -500 - set sdrSurf1.Max 500 - set sdrSurf1.In 100 - -new Slider sdrSurf2 - set sdrSurf2.Min -500 - set sdrSurf2.Max 500 - set sdrSurf2.In 300 - - connect sdrSurf1.Out surf.Height1 - connect sdrSurf2.Out surf.Height2 - -# Create Surface Layouts - -new LayoutSplit surface -new LayoutLine lySurf -new Viewer3D viewerSurf - set surface.Proportion 80 - connect sdrSurf1.Widget lySurf.Widget1 - connect sdrSurf2.Widget lySurf.Widget2 - connect viewerSurf.Renderer surf.Renderer - #connect lySurf.BoxChange viewerSurf.BoxExecute - - connect surf.Out1 viewerSurf.In1 - connect surf.Out2 viewerSurf.In2 - - connect viewerSurf.Widget surface.Widget1 - connect lySurf.Widget surface.Widget2 - -#Create Substraction View - -new ImageSubstraction imageSub - connect imgslice1.Out imageSub.In1 - connect imgslice2.Out imageSub.In2 - -new Slider sdrSub1 - set sdrSub1.In 51 - set sdrSub1.Max 255 - set sdrSub1.Min 0 - set sdrSub1.Title "Upper Zero Level" - -new Slider sdrSub2 - set sdrSub2.In 49 - set sdrSub2.Max 255 - set sdrSub2.Min 0 - set sdrSub2.Title "Lower Zero Level" - - connect sdrSub1.Out imageSub.In3 - connect sdrSub2.Out imageSub.In4 - -new ColourSelectorButton colorU -new ColourSelectorButton colorM -new ColourSelectorButton colorL - - set colorU.WinTitle "Upper Level Colour" - set colorM.WinTitle "Middle Level Colour" - set colorL.WinTitle "Lower Level Colour" - - set colorU.In "0" - set colorM.In "50,50,50" - set colorL.In "1" - - connect colorU.Out imageSub.InU - connect colorM.Out imageSub.InM - connect colorL.Out imageSub.InL - -#Create substraction layout - -new Viewer2D subView - connect imageSub.Out subView.In - -new LayoutSplit substraction -new LayoutLine lySub - - connect sdrSub1.Widget lySub.Widget1 - connect sdrSub2.Widget lySub.Widget2 - -new LayoutLine lySubColor - - set lySubColor.Orientation H - connect colorU.Widget lySubColor.Widget1 - connect colorM.Widget lySubColor.Widget2 - connect colorL.Widget lySubColor.Widget3 - - connect lySubColor.Widget lySub.Widget3 - - set substraction.Proportion "70" - - connect subView.Widget substraction.Widget1 - connect lySub.Widget substraction.Widget2 -/* -# Create the transparency box -new Transparency tb - connect imgslice1.Out tb.Image1 - connect imgslice2.Out tb.Image2 - -# Create viewer and add actors -new Viewer3D transparency - connect tb.Actor1 transparency.In1 - connect tb.Actor2 transparency.In2 - -*/ -#Multiple inputs for managing the interaction - -new MultipleInputs mult - connect slider.BoxChange mult.In1 - connect sliderX.BoxChange mult.In2 - connect sliderY.BoxChange mult.In3 - connect viewer1.BoxChange mult.In4 - connect viewer2.BoxChange mult.In5 - #connect mult.BoxChange viewer3.BoxExecute - #connect mult.BoxChange viewer2d.BoxExecute - - -# Execution pipeline for checkboard - -new MultipleInputs mult2 - connect ly.BoxChange mult2.In1 - connect mult.BoxChange mult2.In2 - connect imgslice1.BoxChange mult2.In3 - connect imgslice2.BoxChange mult2.In4 - -connect mult2.BoxChange cbb.BoxExecute -connect cbb.BoxChange viewerCH.BoxExecute - -# Execution pipeline for Surface - -new MultipleInputs mult3 - connect mult2.BoxChange mult3.In1 - connect sdrSurf1.BoxChange mult3.In2 - connect sdrSurf2.BoxChange mult3.In3 - - connect mult3.BoxChange surf.BoxExecute - connect surf.BoxChange viewerSurf.BoxExecute - -#Execution pipeline for Substraction - -new MultipleInputs mult4 - connect sdrSub1.BoxChange mult4.In1 - connect sdrSub2.BoxChange mult4.In2 - connect mult2.BoxChange mult4.In3 - -new MultipleInputs mult5 - connect mult4.BoxChange mult5.In1 - connect colorU.BoxChange mult5.In2 - connect colorM.BoxChange mult5.In3 - connect colorL.BoxChange mult5.In4 - - connect mult5.BoxChange imageSub.BoxExecute - connect imageSub.BoxChange substraction.BoxExecute - -#Execution pipeline for Transparency -/* -connect mult2.BoxChange tb.BoxExecute -connect tb.BoxChange transparency.BoxExecute -*/ -# Button for saving - -new CommandButton saveBut - set saveBut.Label "Save Image" - -new FileSelector fileSave - set fileSave.OpenSave "Save" - set fileSave.Wildcard "*.mhd" - -new MetaImageWriter writSave - connect reslice1.Out writSave.In - connect fileSave.Out writSave.Filename - - connect saveBut.BoxChange fileSave.BoxExecute - connect fileSave.BoxChange writSave.BoxExecute - -#Layout were the images and the buttones will be displayed - -new LayoutSplit window1 - set window1.WinWidth "600" - set window1.Proportion "80" - set window1.Orientation V - connect initialImages.Widget window1.Widget1 - connect buttonsLayout.Widget window1.Widget2 - -#new LayoutSplit checkBoard - #set window1.WinWidth "600" - #set window1.Proportion "80" - #set window1.Orientation V - #connect viewer3.Widget checkBoard.Widget1 - #connect checkView.Widget checkBoard.Widget1 - -new LayoutTab tabs - connect checkerBoard.Widget tabs.Widget1 - connect surface.Widget tabs.Widget2 - connect substraction.Widget tabs.Widget3 - //connect transparency.Widget tabs.Widget4 - -new LayoutLine tools - connect sdrZ.Widget tools.Widget1 - connect saveBut.Widget tools.Widget2 - -new LayoutSplit window2 - connect tabs.Widget window2.Widget1 - connect tools.Widget window2.Widget2 - set window2.Proportion "90" - -new LayoutSplit main - set main.WinWidth "1200" - set main.Proportion "50" - set main.Orientation H - connect window1.Widget main.Widget1 - connect window2.Widget main.Widget2 - -#exec image -#exec image2 -exec main \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs deleted file mode 100644 index 5e529bf..0000000 --- a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianADCV2.bbs +++ /dev/null @@ -1,48 +0,0 @@ -load wx -load std -load vtk -load wxvtk -load creaMaracasVisu -load PackVisuImages -//load creaImageIO - -load PackRecalage - -//include vtk/boxes/bbLoadHola -//new LoadHola image - -new MetaImageReader image - set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\adc-j0.mhd" -//new MetaImageReader image2 - //set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\adc-j1.mhd" - - -#new Gimmick image -#new Gimmick image2 - -#Viewer containing image 1 - -new LayoutLine v1Layout -new ViewerNV viewer1 -connect image.Out viewer1.In -set viewer1.nTypeView "0" -connect viewer1.Widget v1Layout.Widget1 - - -#Viewer containing image 2 - -new LayoutLine v2Layout -new ViewerNV viewer2 -connect image.Out viewer2.In -set viewer2.nTypeView "0" -connect viewer2.Widget v2Layout.Widget1 - -#LayoutSplit were the images will be - -new LayoutSplit initialImages -set initialImages.Proportion "50" -set initialImages.Orientation H -connect v1Layout.Widget initialImages.Widget1 -connect v2Layout.Widget initialImages.Widget2 - -exec initialImages \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs deleted file mode 100644 index 3c0587d..0000000 --- a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianPeak.bbs +++ /dev/null @@ -1,391 +0,0 @@ -load wx -load std -load vtk -load wxvtk -load creaMaracasVisu -load PackVisuImages -//load creaImageIO - -load PackRecalage - -//include vtk/boxes/bbLoadHola -//new LoadHola image - -new MetaImageReader image - set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\peak-j0.mhd" -new MetaImageReader image2 - set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\peak-j1.mhd" - - -#new Gimmick image -#new Gimmick image2 - -#Viewer containing image 1 - -new LayoutLine v1Layout -new ViewerNV viewer1 -connect image.Out viewer1.In -set viewer1.nTypeView "0" -connect viewer1.Widget v1Layout.Widget1 - - -#Viewer containing image 2 - -new LayoutLine v2Layout -new ViewerNV viewer2 -connect image2.Out viewer2.In -set viewer2.nTypeView "0" -connect viewer2.Widget v2Layout.Widget1 - -#LayoutSplit were the images will be - -new LayoutSplit initialImages -set initialImages.Proportion "50" -set initialImages.Orientation H -connect v1Layout.Widget initialImages.Widget1 -connect v2Layout.Widget initialImages.Widget2 - -#Layout line that will contain the buttons - -new LayoutLine buttonsLayout - set buttonsLayout.Orientation V - -#Slider were the angle will be entered - -new Slider slider - set slider.Title "Angle" - set slider.In 0 - set slider.Min 0 - set slider.Max 360 - set slider.ReactiveOnTrack "1" - connect slider.Widget buttonsLayout.Widget1 - - - -#Slider were the xScale will be entered - -new Slider sliderX - set sliderX.Title "% Scale in X" - set sliderX.In 100 - set sliderX.Min 10 - set sliderX.Max 500 - set sliderX.ReactiveOnTrack "1" - connect sliderX.Widget buttonsLayout.Widget2 - - - -#Slider were the yScale will be entered - -new Slider sliderY - set sliderY.Title "% Scale in Y" - set sliderY.In 100 - set sliderY.Min 10 - set sliderY.Max 500 - set sliderY.ReactiveOnTrack "1" - connect sliderY.Widget buttonsLayout.Widget3 - - -#Box were the transformation will be made - -new Transform2DBox transform - connect viewer2.Point transform.CenterPoint - connect slider.Out transform.Angle - connect sliderX.Out transform.ScaleX - connect sliderY.Out transform.ScaleY - - - -new ReSlicerBox reslice1 - connect viewer1.Point reslice1.Origin - connect transform.Out reslice1.Transform - connect image2.Out reslice1.In - -new SliceImage slice1 - connect reslice1.Out slice1.In - set slice1.Z "1" - -new Viewer2D viewer2d - connect reslice1.Out viewer2d.In - set viewer2d.Slice "1" - -#new ViewerNV viewer3 - #connect reslice1.Out viewer3.In - #set viewer3.nTypeView "5" - #set viewer3.WinWidth "600" - -# Create the reslicers - -new SliceImage imgslice1 -new SliceImage imgslice2 - connect image.Out imgslice1.In - connect reslice1.Out imgslice2.In - -# Create the visulization box -new CheckBoardBox cbb - connect imgslice1.Out cbb.In1 - connect imgslice2.Out cbb.In2 - -# Create the slider1 -new Slider sdr - set sdr.ReactiveOnTrack 1 - set sdr.Max 50 - set sdr.In 14 - -# Create the slider2 -new Slider sdr2 - set sdr2.ReactiveOnTrack 1 - set sdr2.Max 50 - set sdr2.In 14 - -# Create the ZSlider for the slices - -new Slider sdrZ - set sdrZ.ReactiveOnTrack 1 - set sdrZ.Max 50 - set sdrZ.Title "Z for slice" - -connect sdrZ.Out imgslice1.Z -connect sdrZ.Out imgslice2.Z -connect sdrZ.BoxChange imgslice1.BoxExecute -connect sdrZ.BoxChange imgslice2.BoxExecute - -# Create viewer & layout -new LayoutSplit checkerBoard -new LayoutLine ly -new Viewer2D viewerCH - set checkerBoard.Proportion 80 - -# Graphical pipeline - connect sdr.Out cbb.Cols - connect sdr2.Out cbb.Rows - connect cbb.Out viewerCH.In - - #connect sdrZ.Widget ly.Widget1 - connect sdr.Widget ly.Widget2 - connect sdr2.Widget ly.Widget3 - - connect viewerCH.Widget checkerBoard.Widget1 - connect ly.Widget checkerBoard.Widget2 - -# Create Surface View - -new SurfaceCreator surf - set surf.Color1 RED - set surf.Color2 BLUE - - connect imgslice1.Out surf.Image1 - connect imgslice2.Out surf.Image2 - -new Slider sdrSurf1 - set sdrSurf1.Min -500 - set sdrSurf1.Max 500 - set sdrSurf1.In 100 - -new Slider sdrSurf2 - set sdrSurf2.Min -500 - set sdrSurf2.Max 500 - set sdrSurf2.In 300 - - connect sdrSurf1.Out surf.Height1 - connect sdrSurf2.Out surf.Height2 - -# Create Surface Layouts - -new LayoutSplit surface -new LayoutLine lySurf -new Viewer3D viewerSurf - set surface.Proportion 80 - connect sdrSurf1.Widget lySurf.Widget1 - connect sdrSurf2.Widget lySurf.Widget2 - connect viewerSurf.Renderer surf.Renderer - #connect lySurf.BoxChange viewerSurf.BoxExecute - - connect surf.Out1 viewerSurf.In1 - connect surf.Out2 viewerSurf.In2 - - connect viewerSurf.Widget surface.Widget1 - connect lySurf.Widget surface.Widget2 - -#Create Substraction View - -new ImageSubstraction imageSub - connect imgslice1.Out imageSub.In1 - connect imgslice2.Out imageSub.In2 - -new Slider sdrSub1 - set sdrSub1.In 51 - set sdrSub1.Max 255 - set sdrSub1.Min 0 - set sdrSub1.Title "Upper Zero Level" - -new Slider sdrSub2 - set sdrSub2.In 49 - set sdrSub2.Max 255 - set sdrSub2.Min 0 - set sdrSub2.Title "Lower Zero Level" - - connect sdrSub1.Out imageSub.In3 - connect sdrSub2.Out imageSub.In4 - -new ColourSelectorButton colorU -new ColourSelectorButton colorM -new ColourSelectorButton colorL - - set colorU.WinTitle "Upper Level Colour" - set colorM.WinTitle "Middle Level Colour" - set colorL.WinTitle "Lower Level Colour" - - set colorU.In "0" - set colorM.In "50,50,50" - set colorL.In "1" - - connect colorU.Out imageSub.InU - connect colorM.Out imageSub.InM - connect colorL.Out imageSub.InL - -#Create substraction layout - -new Viewer2D subView - connect imageSub.Out subView.In - -new LayoutSplit substraction -new LayoutLine lySub - - connect sdrSub1.Widget lySub.Widget1 - connect sdrSub2.Widget lySub.Widget2 - -new LayoutLine lySubColor - - set lySubColor.Orientation H - connect colorU.Widget lySubColor.Widget1 - connect colorM.Widget lySubColor.Widget2 - connect colorL.Widget lySubColor.Widget3 - - connect lySubColor.Widget lySub.Widget3 - - set substraction.Proportion "70" - - connect subView.Widget substraction.Widget1 - connect lySub.Widget substraction.Widget2 - -# Create the transparency box -new Transparency tb - connect imgslice1.Out tb.Image1 - connect imgslice2.Out tb.Image2 - -# Create viewer and add actors -new Viewer3D transparency - connect tb.Actor1 transparency.In1 - connect tb.Actor2 transparency.In2 - -#Multiple inputs for managing the interaction - -new MultipleInputs mult - connect slider.BoxChange mult.In1 - connect sliderX.BoxChange mult.In2 - connect sliderY.BoxChange mult.In3 - connect viewer1.BoxChange mult.In4 - connect viewer2.BoxChange mult.In5 - #connect mult.BoxChange viewer3.BoxExecute - #connect mult.BoxChange viewer2d.BoxExecute - - -# Execution pipeline for checkboard - -new MultipleInputs mult2 - connect ly.BoxChange mult2.In1 - connect mult.BoxChange mult2.In2 - connect imgslice1.BoxChange mult2.In3 - connect imgslice2.BoxChange mult2.In4 - -connect mult2.BoxChange cbb.BoxExecute -connect cbb.BoxChange viewerCH.BoxExecute - -# Execution pipeline for Surface - -new MultipleInputs mult3 - connect mult2.BoxChange mult3.In1 - connect sdrSurf1.BoxChange mult3.In2 - connect sdrSurf2.BoxChange mult3.In3 - - connect mult3.BoxChange surf.BoxExecute - connect surf.BoxChange viewerSurf.BoxExecute - -#Execution pipeline for Substraction - -new MultipleInputs mult4 - connect sdrSub1.BoxChange mult4.In1 - connect sdrSub2.BoxChange mult4.In2 - connect mult2.BoxChange mult4.In3 - -new MultipleInputs mult5 - connect mult4.BoxChange mult5.In1 - connect colorU.BoxChange mult5.In2 - connect colorM.BoxChange mult5.In3 - connect colorL.BoxChange mult5.In4 - - connect mult5.BoxChange imageSub.BoxExecute - connect imageSub.BoxChange substraction.BoxExecute - -#Execution pipeline for Transparency - -connect mult2.BoxChange tb.BoxExecute -connect tb.BoxChange transparency.BoxExecute - -# Button for saving - -new CommandButton saveBut - set saveBut.Label "Save Image" - -new FileSelector fileSave - set fileSave.OpenSave "Save" - set fileSave.Wildcard "*.mhd" - -new MetaImageWriter writSave - connect reslice1.Out writSave.In - connect fileSave.Out writSave.Filename - - connect saveBut.BoxChange fileSave.BoxExecute - connect fileSave.BoxChange writSave.BoxExecute - -#Layout were the images and the buttones will be displayed - -new LayoutSplit window1 - set window1.WinWidth "600" - set window1.Proportion "80" - set window1.Orientation V - connect initialImages.Widget window1.Widget1 - connect buttonsLayout.Widget window1.Widget2 - -#new LayoutSplit checkBoard - #set window1.WinWidth "600" - #set window1.Proportion "80" - #set window1.Orientation V - #connect viewer3.Widget checkBoard.Widget1 - #connect checkView.Widget checkBoard.Widget1 - -new LayoutTab tabs - connect checkerBoard.Widget tabs.Widget1 - connect surface.Widget tabs.Widget2 - connect substraction.Widget tabs.Widget3 - connect transparency.Widget tabs.Widget4 - -new LayoutLine tools - connect sdrZ.Widget tools.Widget1 - connect saveBut.Widget tools.Widget2 - -new LayoutSplit window2 - connect tabs.Widget window2.Widget1 - connect tools.Widget window2.Widget2 - set window2.Proportion "90" - -new LayoutSplit main - set main.WinWidth "1200" - set main.Proportion "50" - set main.Orientation H - connect window1.Widget main.Widget1 - connect window2.Widget main.Widget2 - -#exec image -#exec image2 -exec main \ No newline at end of file diff --git a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs b/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs deleted file mode 100644 index 4e3664e..0000000 --- a/PackRecalage/bbs/appli/ViewerMerge2DInteractiveDemoFabianT2.bbs +++ /dev/null @@ -1,393 +0,0 @@ -load wx -load std -load vtk -load wxvtk -load creaMaracasVisu -load PackVisuImages -//load creaImageIO - -load PackRecalage - -//include vtk/boxes/bbLoadHola -//new LoadHola image - -new MetaImageReader image - set image.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\t2-j0.mhd" -new MetaImageReader image2 - set image2.In "C:\Documents and Settings\trillos\Bureau\Nicolas\Stage\CreaRecalage\PackRecalage\data\ImagesFabienRecalage\t2-j1.mhd" - - -#new Gimmick image -#new Gimmick image2 - -#Viewer containing image 1 - -new LayoutLine v1Layout -new ViewerNV viewer1 -connect image.Out viewer1.In -set viewer1.nTypeView "0" -connect viewer1.Widget v1Layout.Widget1 - - -#Viewer containing image 2 - -new LayoutLine v2Layout -new ViewerNV viewer2 -connect image2.Out viewer2.In -set viewer2.nTypeView "0" -connect viewer2.Widget v2Layout.Widget1 - -#LayoutSplit were the images will be - -new LayoutSplit initialImages -set initialImages.Proportion "50" -set initialImages.Orientation H -connect v1Layout.Widget initialImages.Widget1 -connect v2Layout.Widget initialImages.Widget2 - -#Layout line that will contain the buttons - -new LayoutLine buttonsLayout - set buttonsLayout.Orientation V - -#Slider were the angle will be entered - -new Slider slider - set slider.Title "Angle" - set slider.In 0 - set slider.Min 0 - set slider.Max 360 - set slider.ReactiveOnTrack "1" - connect slider.Widget buttonsLayout.Widget1 - - - -#Slider were the xScale will be entered - -new Slider sliderX - set sliderX.Title "% Scale in X" - set sliderX.In 100 - set sliderX.Min 10 - set sliderX.Max 500 - set sliderX.ReactiveOnTrack "1" - connect sliderX.Widget buttonsLayout.Widget2 - - - -#Slider were the yScale will be entered - -new Slider sliderY - set sliderY.Title "% Scale in Y" - set sliderY.In 100 - set sliderY.Min 10 - set sliderY.Max 500 - set sliderY.ReactiveOnTrack "1" - connect sliderY.Widget buttonsLayout.Widget3 - - -#Box were the transformation will be made - -new Transform2DBox transform - connect viewer2.Point transform.CenterPoint - connect slider.Out transform.Angle - connect sliderX.Out transform.ScaleX - connect sliderY.Out transform.ScaleY - - - -new ReSlicerBox reslice1 - connect viewer1.Point reslice1.Origin - connect transform.Out reslice1.Transform - connect image2.Out reslice1.In - -new SliceImage slice1 - connect reslice1.Out slice1.In - set slice1.Z "1" - -new Viewer2D viewer2d - connect reslice1.Out viewer2d.In - set viewer2d.Slice "1" - -#new ViewerNV viewer3 - #connect reslice1.Out viewer3.In - #set viewer3.nTypeView "5" - #set viewer3.WinWidth "600" - -# Create the reslicers - -new SliceImage imgslice1 -new SliceImage imgslice2 - connect image.Out imgslice1.In - connect reslice1.Out imgslice2.In - -# Create the visulization box -new CheckBoardBox cbb - connect imgslice1.Out cbb.In1 - connect imgslice2.Out cbb.In2 - -# Create the slider1 -new Slider sdr - set sdr.ReactiveOnTrack 1 - set sdr.Max 50 - set sdr.In 14 - -# Create the slider2 -new Slider sdr2 - set sdr2.ReactiveOnTrack 1 - set sdr2.Max 50 - set sdr2.In 14 - -# Create the ZSlider for the slices - -new Slider sdrZ - set sdrZ.ReactiveOnTrack 1 - set sdrZ.Max 50 - set sdrZ.Title "Z for slice" - -connect sdrZ.Out imgslice1.Z -connect sdrZ.Out imgslice2.Z -connect sdrZ.BoxChange imgslice1.BoxExecute -connect sdrZ.BoxChange imgslice2.BoxExecute - -# Create viewer & layout -new LayoutSplit checkerBoard -new LayoutLine ly -new ViewerNV viewerCH - set viewerCH.nTypeView "0" - set checkerBoard.Proportion 80 - -# Graphical pipeline - connect sdr.Out cbb.Cols - connect sdr2.Out cbb.Rows - connect cbb.Out viewerCH.In - - #connect sdrZ.Widget ly.Widget1 - connect sdr.Widget ly.Widget2 - connect sdr2.Widget ly.Widget3 - - connect viewerCH.Widget checkerBoard.Widget1 - connect ly.Widget checkerBoard.Widget2 - -# Create Surface View - -new SurfaceCreator surf - set surf.Color1 RED - set surf.Color2 BLUE - - connect imgslice1.Out surf.Image1 - connect imgslice2.Out surf.Image2 - -new Slider sdrSurf1 - set sdrSurf1.Min -500 - set sdrSurf1.Max 500 - set sdrSurf1.In 100 - -new Slider sdrSurf2 - set sdrSurf2.Min -500 - set sdrSurf2.Max 500 - set sdrSurf2.In 300 - - connect sdrSurf1.Out surf.Height1 - connect sdrSurf2.Out surf.Height2 - -# Create Surface Layouts - -new LayoutSplit surface -new LayoutLine lySurf -new Viewer3D viewerSurf - set surface.Proportion 80 - connect sdrSurf1.Widget lySurf.Widget1 - connect sdrSurf2.Widget lySurf.Widget2 - connect viewerSurf.Renderer surf.Renderer - #connect lySurf.BoxChange viewerSurf.BoxExecute - - connect surf.Out1 viewerSurf.In1 - connect surf.Out2 viewerSurf.In2 - - connect viewerSurf.Widget surface.Widget1 - connect lySurf.Widget surface.Widget2 - -#Create Substraction View - -new ImageSubstraction imageSub - connect imgslice1.Out imageSub.In1 - connect imgslice2.Out imageSub.In2 - -new Slider sdrSub1 - set sdrSub1.In 51 - set sdrSub1.Max 255 - set sdrSub1.Min 0 - set sdrSub1.Title "Upper Zero Level" - -new Slider sdrSub2 - set sdrSub2.In 49 - set sdrSub2.Max 255 - set sdrSub2.Min 0 - set sdrSub2.Title "Lower Zero Level" - - connect sdrSub1.Out imageSub.In3 - connect sdrSub2.Out imageSub.In4 - -new ColourSelectorButton colorU -new ColourSelectorButton colorM -new ColourSelectorButton colorL - - set colorU.WinTitle "Upper Level Colour" - set colorM.WinTitle "Middle Level Colour" - set colorL.WinTitle "Lower Level Colour" - - set colorU.In "0" - set colorM.In "50,50,50" - set colorL.In "1" - - connect colorU.Out imageSub.InU - connect colorM.Out imageSub.InM - connect colorL.Out imageSub.InL - -#Create substraction layout - -new Viewer2D subView - connect imageSub.Out subView.In - -new LayoutSplit substraction -new LayoutLine lySub - - connect sdrSub1.Widget lySub.Widget1 - connect sdrSub2.Widget lySub.Widget2 - -new LayoutLine lySubColor - - set lySubColor.Orientation H - connect colorU.Widget lySubColor.Widget1 - connect colorM.Widget lySubColor.Widget2 - connect colorL.Widget lySubColor.Widget3 - - connect lySubColor.Widget lySub.Widget3 - - set substraction.Proportion "70" - - connect subView.Widget substraction.Widget1 - connect lySub.Widget substraction.Widget2 -/* -# Create the transparency box -new Transparency tb - connect imgslice1.Out tb.Image1 - connect imgslice2.Out tb.Image2 - -# Create viewer and add actors -new Viewer3D transparency - connect tb.Actor1 transparency.In1 - connect tb.Actor2 transparency.In2 - -*/ -#Multiple inputs for managing the interaction - -new MultipleInputs mult - connect slider.BoxChange mult.In1 - connect sliderX.BoxChange mult.In2 - connect sliderY.BoxChange mult.In3 - connect viewer1.BoxChange mult.In4 - connect viewer2.BoxChange mult.In5 - #connect mult.BoxChange viewer3.BoxExecute - #connect mult.BoxChange viewer2d.BoxExecute - - -# Execution pipeline for checkboard - -new MultipleInputs mult2 - connect ly.BoxChange mult2.In1 - connect mult.BoxChange mult2.In2 - connect imgslice1.BoxChange mult2.In3 - connect imgslice2.BoxChange mult2.In4 - -connect mult2.BoxChange cbb.BoxExecute -connect cbb.BoxChange viewerCH.BoxExecute - -# Execution pipeline for Surface - -new MultipleInputs mult3 - connect mult2.BoxChange mult3.In1 - connect sdrSurf1.BoxChange mult3.In2 - connect sdrSurf2.BoxChange mult3.In3 - - connect mult3.BoxChange surf.BoxExecute - connect surf.BoxChange viewerSurf.BoxExecute - -#Execution pipeline for Substraction - -new MultipleInputs mult4 - connect sdrSub1.BoxChange mult4.In1 - connect sdrSub2.BoxChange mult4.In2 - connect mult2.BoxChange mult4.In3 - -new MultipleInputs mult5 - connect mult4.BoxChange mult5.In1 - connect colorU.BoxChange mult5.In2 - connect colorM.BoxChange mult5.In3 - connect colorL.BoxChange mult5.In4 - - connect mult5.BoxChange imageSub.BoxExecute - connect imageSub.BoxChange substraction.BoxExecute - -#Execution pipeline for Transparency -/* -connect mult2.BoxChange tb.BoxExecute -connect tb.BoxChange transparency.BoxExecute -*/ -# Button for saving - -new CommandButton saveBut - set saveBut.Label "Save Image" - -new FileSelector fileSave - set fileSave.OpenSave "Save" - set fileSave.Wildcard "*.mhd" - -new MetaImageWriter writSave - connect reslice1.Out writSave.In - connect fileSave.Out writSave.Filename - - connect saveBut.BoxChange fileSave.BoxExecute - connect fileSave.BoxChange writSave.BoxExecute - -#Layout were the images and the buttones will be displayed - -new LayoutSplit window1 - set window1.WinWidth "600" - set window1.Proportion "80" - set window1.Orientation V - connect initialImages.Widget window1.Widget1 - connect buttonsLayout.Widget window1.Widget2 - -#new LayoutSplit checkBoard - #set window1.WinWidth "600" - #set window1.Proportion "80" - #set window1.Orientation V - #connect viewer3.Widget checkBoard.Widget1 - #connect checkView.Widget checkBoard.Widget1 - -new LayoutTab tabs - connect checkerBoard.Widget tabs.Widget1 - connect surface.Widget tabs.Widget2 - connect substraction.Widget tabs.Widget3 - //connect transparency.Widget tabs.Widget4 - -new LayoutLine tools - connect sdrZ.Widget tools.Widget1 - connect saveBut.Widget tools.Widget2 - -new LayoutSplit window2 - connect tabs.Widget window2.Widget1 - connect tools.Widget window2.Widget2 - set window2.Proportion "90" - -new LayoutSplit main - set main.WinWidth "1200" - set main.Proportion "50" - set main.Orientation H - connect window1.Widget main.Widget1 - connect window2.Widget main.Widget2 - -#exec image -#exec image2 -exec main \ No newline at end of file diff --git a/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx b/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx index 0290fce..675e176 100644 --- a/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx +++ b/PackRecalage/src/bbPackRecalageCalculateVectorBox.cxx @@ -11,23 +11,21 @@ BBTK_BLACK_BOX_IMPLEMENTATION(CalculateVectorBox,bbtk::AtomicBlackBox); void CalculateVectorBox::Process() { - if(bbGetInputLabels1()[0].compare("") != 0) + if(!bbGetInputPointsX1().empty() && !bbGetInputPointsX2().empty()) { - //std::vector newX1; - //newX1.push_back((float)bbGetInputPointsX1()[0]); - std::cout << "Points for first vector: " << bbGetInputPointsX1()[0] << " " << bbGetInputPointsX1()[1] << std::endl; - //std::vector newX2; - //newX2.push_back((float)bbGetInputPointsX2()[0]); + _vector->SetData(bbGetInputPointsX1(), bbGetInputPointsX2(), bbGetInputPointsY1(), bbGetInputPointsY2(), bbGetInputPointsZ1(), bbGetInputPointsZ2()); + _vector->Run(); + + bbSetOutputOrigin(_vector->GetOrigin()); + bbSetOutputOriginReslicer(_vector->GetOriginReslicer()); } } void CalculateVectorBox::bbUserSetDefaultValues() { - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 - /* - std::vector nuevo("",""); - bbSetInputLabels1(nuevo);*/ + _vector = new VectorMath(); + std::vector nullVector; + bbSetInputPointsX1(nullVector); + bbSetInputPointsX2(nullVector); } void CalculateVectorBox::bbUserInitializeProcessing() { diff --git a/PackRecalage/src/bbPackRecalageCalculateVectorBox.h b/PackRecalage/src/bbPackRecalageCalculateVectorBox.h index cf0922e..ed04a39 100644 --- a/PackRecalage/src/bbPackRecalageCalculateVectorBox.h +++ b/PackRecalage/src/bbPackRecalageCalculateVectorBox.h @@ -4,6 +4,8 @@ #include "bbtkAtomicBlackBox.h" #include "iostream" +#include "VectorMath.h" + namespace bbPackRecalage { @@ -12,23 +14,46 @@ class bbPackRecalage_EXPORT CalculateVectorBox public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(CalculateVectorBox,bbtk::AtomicBlackBox); + + /*Points in X for the first vector (the vector in the first image), this array should have the structure (a,b), "a" being the position in X for the starting point of the vector + and "b" the position in X for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsX1,std::vector); + + /*Points in X for the second vector (the vector in the second image), this array should have the structure (a,b), "a" being the position in X for the starting point of the vector + and "b" the position in X for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsX2,std::vector); + + /*Points in Y for the first vector (the vector in the first image), this array should have the structure (a,b), "a" being the position in Y for the starting point of the vector + and "b" the position in Y for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsY1,std::vector); + + /*Points in Y for the second vector (the vector in the second image), this array should have the structure (a,b), "a" being the position in Y for the starting point of the vector + and "b" the position in Y for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsY2,std::vector); + + /*Points in Z for the first vector (the vector in the first image), this array should have the structure (a,b), "a" being the position in Z for the starting point of the vector + and "b" the position in Z for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsZ1,std::vector); + + /*Points in Z for the second vector (the vector in the second image), this array should have the structure (a,b), "a" being the position in Z for the starting point of the vector + and "b" the position in Z for the ending point of the vector */ BBTK_DECLARE_INPUT(PointsZ2,std::vector); - BBTK_DECLARE_INPUT(Labels1,std::vector); - BBTK_DECLARE_INPUT(Labels2,std::vector); - BBTK_DECLARE_OUTPUT(OutX,int); - BBTK_DECLARE_OUTPUT(OutY,int); - BBTK_DECLARE_OUTPUT(OutZ,int); + + /*Origin (starting point of the vector) of the second image, this is necesary for the translation matrix of a transform filter*/ + BBTK_DECLARE_OUTPUT(Origin, std::vector); + + /**/ + BBTK_DECLARE_OUTPUT(OriginReslicer, std::vector); + BBTK_DECLARE_OUTPUT(TransformAxis, std::vector); BBTK_DECLARE_OUTPUT(OutScaleX,int); BBTK_DECLARE_OUTPUT(OutScaleY,int); BBTK_DECLARE_OUTPUT(OutScaleZ,int); BBTK_DECLARE_OUTPUT(OutAngle,double); BBTK_PROCESS(Process); void Process(); + + private: + VectorMath *_vector; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(CalculateVectorBox,bbtk::AtomicBlackBox); @@ -42,11 +67,9 @@ BBTK_INPUT(CalculateVectorBox,PointsY1,"List of points in Y for the first vector BBTK_INPUT(CalculateVectorBox,PointsY2,"List of points in Y for the second vector",std::vector,""); BBTK_INPUT(CalculateVectorBox,PointsZ1,"List of points in Z for the first vector",std::vector,""); BBTK_INPUT(CalculateVectorBox,PointsZ2,"List of points in Z for the second vector",std::vector,""); -BBTK_INPUT(CalculateVectorBox,Labels1,"Labels of the points for the first vector",std::vector,""); -BBTK_INPUT(CalculateVectorBox,Labels2,"Labels of the points for the second vector",std::vector,""); -BBTK_OUTPUT(CalculateVectorBox,OutX,"Point in X for the cross multiplication",int,""); -BBTK_OUTPUT(CalculateVectorBox,OutY,"Point in Y for the cross multiplication",int,""); -BBTK_OUTPUT(CalculateVectorBox,OutZ,"Point in Z for the cross multiplication",int,""); +BBTK_OUTPUT(CalculateVectorBox,Origin,"Points of Origin for the transformation",std::vector,""); +BBTK_OUTPUT(CalculateVectorBox,OriginReslicer,"Points of Origin for the transformation for the Reslicer",std::vector,""); +BBTK_OUTPUT(CalculateVectorBox,TransformAxis,"Axis used for the transformation (Result of Cross multiplication)",std::vector,""); BBTK_OUTPUT(CalculateVectorBox,OutScaleX,"Difference in scale for X for the cross multiplication",int,""); BBTK_OUTPUT(CalculateVectorBox,OutScaleY,"Difference in scale for Y for the cross multiplication",int,""); BBTK_OUTPUT(CalculateVectorBox,OutScaleZ,"Difference in scale for Z for the cross multiplication",int,""); diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx index 1c603f6..99c0a64 100644 --- a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx @@ -4,28 +4,55 @@ namespace bbPackRecalage { MyTimer::MyTimer(ImageSwitcherBox *box): wxTimer() { - _box = box; + _box = box; } MyTimer::~MyTimer() { + delete this; } void MyTimer::Notify() { - _box->Process(); + _box->Change(); _box->bbSignalOutputModification(std::string("Out")); - } - - - + } BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSwitcherBox) BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox); + +void ImageSwitcherBox::Change() +{ + if(change == false) + { + bbSetOutputOut(bbGetInputIn2()); + change = true; + } + else + { + bbSetOutputOut(bbGetInputIn1()); + change = false; + } +} + void ImageSwitcherBox::Process() { time = bbGetInputTime(); - _on = bbGetInputOn(); + _on = bbGetInputOn(); + + if(firstTime == true) + { + if(bbGetInputIn1() != NULL) + { + bbSetOutputOut(bbGetInputIn1()); + firstTime = false; + } + else if(bbGetInputIn2() != NULL) + { + bbSetOutputOut(bbGetInputIn2()); + firstTime = false; + } + } if(myTimer == NULL) { @@ -33,28 +60,33 @@ void ImageSwitcherBox::Process() myTimer->Start(time); oldTime = time; } - + /* if(oldTime != time && myTimer !=NULL) { myTimer->Stop(); myTimer->Start(time); oldTime = time; + }*/ + + if(!_on) + { + myTimer->Stop(); } - - if(change == false) + else if(!myTimer->IsRunning()) { - bbSetOutputOut(bbGetInputIn1()); - change = true; + myTimer->Start(time); + oldTime = time; } - else + else if(oldTime != time) { - bbSetOutputOut(bbGetInputIn2()); - change = false; - } + myTimer->Stop(); + myTimer->Start(time); + oldTime=time; + } } void ImageSwitcherBox::CreateWidget(wxWindow* parent) { - bbSetOutputWidget( new wxButton ( parent , -1 , _T("Start/Stop Image Change") ) ); + bbSetOutputWidget( new wxStaticText(parent, -1, _T("Image Switcher")) ); } void ImageSwitcherBox::bbUserSetDefaultValues() { @@ -62,7 +94,8 @@ void ImageSwitcherBox::bbUserSetDefaultValues() change = false; time = 500; oldTime = 500; - _on = false; + firstTime = true; + _on=false; } void ImageSwitcherBox::bbUserInitializeProcessing() { diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.h b/PackRecalage/src/bbPackRecalageImageSwitcherBox.h index 7bb5cdf..0d3c18f 100644 --- a/PackRecalage/src/bbPackRecalageImageSwitcherBox.h +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.h @@ -7,6 +7,7 @@ #include "vtkImageData.h" #include +#include namespace bbPackRecalage { @@ -38,12 +39,16 @@ class bbPackRecalage_EXPORT ImageSwitcherBox BBTK_CREATE_WIDGET(CreateWidget); void CreateWidget(wxWindow*); + public: + void Change(); + private: bool change; MyTimer *myTimer; int time; int oldTime; bool _on; + bool firstTime; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageSwitcherBox,bbtk::WxBlackBox); @@ -55,7 +60,7 @@ BBTK_INPUT(ImageSwitcherBox,Title,"Title prepended to the Widget",std::string,"" BBTK_INPUT(ImageSwitcherBox,In1,"First Image",vtkImageData*,""); BBTK_INPUT(ImageSwitcherBox,In2,"Second Image",vtkImageData*,""); BBTK_INPUT(ImageSwitcherBox,Time,"Time between image change",int,""); -BBTK_INPUT(ImageSwitcherBox,On,"Timer status. True = On.",bool,""); +BBTK_INPUT(ImageSwitcherBox,On,"Defines if the switcher is turned on. ON = True.",bool,""); BBTK_OUTPUT(ImageSwitcherBox,Out,"Image to be placed",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(ImageSwitcherBox); } diff --git a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx index 28a1d91..7fcd742 100644 --- a/PackRecalage/src/bbPackRecalageReSlicerBox.cxx +++ b/PackRecalage/src/bbPackRecalageReSlicerBox.cxx @@ -9,7 +9,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ReSlicerBox,bbtk::AtomicBlackBox); void ReSlicerBox::Process() { - if(bbGetInputOrigin()[0]) + if(!bbGetInputOrigin().empty()) { image = vtkImageChangeInformation::New(); image->SetInput( bbGetInputIn() ); diff --git a/PackRecalage/src/bbPackRecalageTransform2DBox.cxx b/PackRecalage/src/bbPackRecalageTransform2DBox.cxx index 6a7bd1b..ce988d9 100644 --- a/PackRecalage/src/bbPackRecalageTransform2DBox.cxx +++ b/PackRecalage/src/bbPackRecalageTransform2DBox.cxx @@ -7,7 +7,7 @@ BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,Transform2DBox) BBTK_BLACK_BOX_IMPLEMENTATION(Transform2DBox,bbtk::AtomicBlackBox); void Transform2DBox::Process() { - if(bbGetInputCenterPoint()[0]) + if(!bbGetInputCenterPoint().empty()) { // The inputs are set in the library transformer transformer->SetCenterPoint( bbGetInputCenterPoint() ); @@ -15,8 +15,15 @@ void Transform2DBox::Process() transformer->SetScaleX( bbGetInputScaleX() ); transformer->SetScaleY( bbGetInputScaleY() ); transformer->SetScaleZ( bbGetInputScaleZ() ); + + //If 3D, make extra preparations + if(_3D) + { + transformer->SetAxis(bbGetInputAxis()); + } + // The calculation of the transformations are made - transformer->Run(); + transformer->Run(_3D); // We get the results of transformer and set it as result of this box bbSetOutputOut( transformer->GetResult() ); } @@ -36,7 +43,8 @@ void Transform2DBox::bbUserSetDefaultValues() bbSetInputScaleX(100); bbSetInputScaleY(100); bbSetInputScaleZ(100); - bbSetOutputOut(NULL); + bbSetOutputOut(NULL); + _3D = false; } void Transform2DBox::bbUserInitializeProcessing() diff --git a/PackRecalage/src/bbPackRecalageTransform2DBox.h b/PackRecalage/src/bbPackRecalageTransform2DBox.h index 6a4ea9d..52288f8 100644 --- a/PackRecalage/src/bbPackRecalageTransform2DBox.h +++ b/PackRecalage/src/bbPackRecalageTransform2DBox.h @@ -18,6 +18,9 @@ class bbPackRecalage_EXPORT Transform2DBox /*Point(x,y) -> Rotation Center*/ BBTK_DECLARE_INPUT(CenterPoint,std::vector); + /*Vector(x,y) -> Axis Rotation Vector*/ + BBTK_DECLARE_INPUT(Axis,std::vector); + /*Rotation angle*/ BBTK_DECLARE_INPUT(Angle,double); @@ -32,6 +35,9 @@ class bbPackRecalage_EXPORT Transform2DBox /*Scalation to be done int the z axis*/ BBTK_DECLARE_INPUT(ScaleZ,double); + + /*3D transformation on or off option*/ + BBTK_DECLARE_INPUT(3D,bool); /*Resultant vtkTransform*/ BBTK_DECLARE_OUTPUT(Out, vtkLinearTransform*); @@ -41,6 +47,9 @@ class bbPackRecalage_EXPORT Transform2DBox /*Class in charge of making the transformations*/ Transformer *transformer; + + /*Boolean that defines if the transformation is in 3D or not. True = Transfomation is in 3D*/ + bool _3D; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform2DBox,bbtk::AtomicBlackBox); @@ -49,11 +58,13 @@ BBTK_AUTHOR("va-perez@uniandes.edu.co"); BBTK_DESCRIPTION("Given 2 points and an angle, it calculates the vtkTransform result after aplying the transformations, using the first point as base of the transformation"); BBTK_CATEGORY("filter"); BBTK_INPUT(Transform2DBox,CenterPoint,"Point (x,y,z) -> Rotation Center",std::vector,""); +BBTK_INPUT(Transform2DBox,Axis,"Vector (x,y,z) -> Axis Rotation Vector. Used only on 3D transformations.",std::vector,""); BBTK_INPUT(Transform2DBox,Angle,"Rotation Angle",double,""); BBTK_INPUT(Transform2DBox,ScaleX,"Scale in X",double,""); BBTK_INPUT(Transform2DBox,ScaleY,"Scale in Y",double,""); BBTK_INPUT(Transform2DBox,ScaleZ,"Scale in Z",double,""); -BBTK_OUTPUT(Transform2DBox,Out,"vtk Transform filter ",vtkLinearTransform*,""); +BBTK_INPUT(Transform2DBox,3D,"Boolean that defines if the transformation is in 3D or not. True = Transfomation is in 3D ",bool,""); +BBTK_OUTPUT(Transform2DBox,Out,"Linear Transform filter",vtkLinearTransform*,""); BBTK_END_DESCRIBE_BLACK_BOX(Transform2DBox); } // EO namespace bbPackRecalage diff --git a/lib/Transformer.cxx b/lib/Transformer.cxx index de53958..ed1b25b 100644 --- a/lib/Transformer.cxx +++ b/lib/Transformer.cxx @@ -46,6 +46,14 @@ void Transformer::SetCenterPoint(std::vector point) _centerPoint=point; } +/* + SETS AXIS POINT +*/ +void Transformer::SetAxis(std::vector axis) +{ + _transformAxis=axis; +} + /* SETS THE ANGLE */ @@ -91,11 +99,19 @@ vtkTransform *Transformer::GetResult() /* MAKES THE TRANSFORMATIONS */ -void Transformer::Run() +void Transformer::Run(bool _3D) { _transform->Identity(); _transform->Translate(_centerPoint[0], _centerPoint[1], _centerPoint[2]); _transform->Scale(_scaleX, _scaleY,_scaleZ); - _transform->RotateWXYZ(_angle, 0, 0, 1); + if(_3D) + { + _transform->RotateWXYZ(_angle, _transformAxis[0], _transformAxis[1], _transformAxis[2]); + } + else + { + _transform->RotateWXYZ(_angle, 0, 0, 1); + } + _transform->Update(); } diff --git a/lib/Transformer.h b/lib/Transformer.h index 1bf6f06..54fdbfe 100644 --- a/lib/Transformer.h +++ b/lib/Transformer.h @@ -11,14 +11,17 @@ public: ~Transformer(); void SetTransform(vtkTransform *transform); void SetCenterPoint(std::vector point); + void SetAxis(std::vector axis); void SetAngle(double angle); void SetScaleX(double scaleX); void SetScaleY(double scaleY); void SetScaleZ(double scaleZ); - void Run(); + void Run(bool _3D); + vtkTransform *GetResult(); private: std::vector _centerPoint; + std::vector _transformAxis; double _angle; double _scaleX; double _scaleY; diff --git a/lib/VectorMath.cxx b/lib/VectorMath.cxx index 9fc0a75..56f4b1b 100644 --- a/lib/VectorMath.cxx +++ b/lib/VectorMath.cxx @@ -2,12 +2,12 @@ VectorMath::VectorMath() { - //_math = vtkMath::new(); + } VectorMath::~VectorMath() { - if (_math != NULL ) { _math->Delete(); } + } void VectorMath::SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2) @@ -30,20 +30,99 @@ void VectorMath::SetData(std::vector pointsX1, std::vector pointsX2, s _pointz2a = pointsZ2[0]; _pointz2b = pointsZ2[1]; } -/* -int[3]* VectorMath::GetPoints() +void VectorMath::Run() { + _origin.clear(); + _origin.push_back(_pointx2a); + _origin.push_back(_pointy2a); + _origin.push_back(_pointz2a); + _originReslicer.clear(); + _originReslicer.push_back(_pointx1a); + _originReslicer.push_back(_pointy1a); + _originReslicer.push_back(_pointz1a); + + double _vectorA[3]; + _vectorA[0] =(double)(_pointx1b - _pointx1a); + _vectorA[1] =(double)(_pointy1b - _pointy1a); + _vectorA[2] =(double)(_pointz1b - _pointz1a); + + double normA = vtkMath::Norm(_vectorA); + + _vectorA[0] = _vectorA[0]/normA; + _vectorA[1] = _vectorA[1]/normA; + _vectorA[2] = _vectorA[2]/normA; + + double _vectorB[3]; + _vectorB[0] =(double)(_pointx2b - _pointx2a - _pointx1a); + _vectorB[1] =(double)(_pointy2b - _pointy2a - _pointy1a); + _vectorB[2] =(double)(_pointz2b - _pointz2a - _pointz1a); + + double normB = vtkMath::Norm(_vectorB); + + _vectorB[0] = _vectorB[0]/normB; + _vectorB[1] = _vectorB[1]/normB; + _vectorB[2] = _vectorB[2]/normB; + + vtkMath::Cross(_vectorA, _vectorB, _result); + + std::cout << "Data from vector A: X: " << _vectorA[0] << " Y: " << _vectorA[1] << " Z: " << _vectorA[2] << std::endl; + std::cout << "Data from vector B: X: " << _vectorB[0] << " Y: " << _vectorB[1] << " Z: " << _vectorB[2] << std::endl; + std::cout << "Data from result: X: " << _result[0] << " Y: " << _result[1] << " Z: " << _result[2] << std::endl; + + double _vectorOrigin[3] = {0,0,0}; + + double distanceA = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA); + double distanceB = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA); + + double proportion = distanceA/distanceB; + + _scaleX = proportion; + _scaleY = proportion; + _scaleZ = proportion; + + _angle = acos(vtkMath::Dot(_vectorA, _vectorB)); + + _angle = vtkMath::DegreesFromRadians(_angle); + + std::cout << "Dot " << vtkMath::Dot(_vectorA, _vectorB) << std::endl; + std::cout << "Angle " << (double)_angle << std::endl; +} + + +std::vector VectorMath::GetOrigin() +{ + return _origin; } -double[3]* VectorMath::GetScales() +std::vector VectorMath::GetOriginReslicer() { + return _originReslicer; +} +void VectorMath::GetResult(double result[3]) +{ + result = _result; } -double VectorMath::GetAngle() +double VectorMath::GetScaleX() +{ + return _scaleX; +} + +double VectorMath::GetScaleY() +{ + return _scaleY; +} + +double VectorMath::GetScaleZ() { + return _scaleZ; +} -}*/ +double VectorMath::GetAngle() +{ + return _angle; +} diff --git a/lib/VectorMath.h b/lib/VectorMath.h index 386a564..9eafe8b 100644 --- a/lib/VectorMath.h +++ b/lib/VectorMath.h @@ -10,13 +10,15 @@ public: ~VectorMath(); void SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2); void Run(); - /* - int[3]* GetPoints(); - double[3]* GetScales(); - double GetAngle();*/ + std::vector GetOrigin(); + std::vector GetOriginReslicer(); + void GetResult(double result[3]); + double GetAngle(); + double GetScaleX(); + double GetScaleY(); + double GetScaleZ(); + private: - //float[3] _points; - int _pointx1a; int _pointx1b; int _pointx2a; @@ -31,8 +33,16 @@ private: int _pointz1b; int _pointz2a; int _pointz2b; - - vtkMath *_math; + + std::vector _origin; + std::vector _originReslicer; + double _result[3]; + + double _scaleX; + double _scaleY; + double _scaleZ; + + double _angle; }; #endif -- 2.47.1