--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBG BlackBox Diagram file
+# - /Users/davila/Creatis/C24/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleGetPropertiesBySlice.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+EXPORTFORMAT:0
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:25
+BOX
+vtk:LoadHola:Box00
+ISEXEC:FALSE
+14.552971:46.386074:-900.000000
+36.102971:43.886074:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box01
+ISEXEC:FALSE
+-28.546753:12.988187:-900.000000
+15.333247:10.488187:-900.000000
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+creaVtk:GetPropertiesBySlice:Box02
+ISEXEC:FALSE
+43.247486:-49.748132:-900.000000
+65.887486:-52.248132:-900.000000
+PORT
+Type:"1"
+FIN_BOX
+BOX
+creaMaracasVisu:wxVtkBaseView_Info:Box03
+ISEXEC:FALSE
+33.054919:-38.651597:-900.000000
+63.854919:-41.151597:-900.000000
+PORT
+InteractionType:"6"
+PORT
+WithEventPropagation:"true"
+FIN_BOX
+BOX
+vtk:vtkImageDataPointerRelay:Box04
+ISEXEC:FALSE
+52.384212:13.404796:-900.000000
+75.594212:10.904796:-900.000000
+FIN_BOX
+BOX
+creaVtk:ImageThreshold:Box09
+ISEXEC:FALSE
+53.073656:31.995238:-900.000000
+75.253656:29.495238:-900.000000
+PORT
+InValue:"255"
+PORT
+Lower:"1200"
+PORT
+OutValue:"0"
+PORT
+Upper:"5000"
+FIN_BOX
+BOX
+creaVtk:ImageContinuousErode3D:Box10
+ISEXEC:FALSE
+52.668350:24.105883:-900.000000
+75.833350:21.605883:-900.000000
+PORT
+Repetitions:"3"
+PORT
+X:"3"
+PORT
+Y:"3"
+PORT
+Z:"3"
+FIN_BOX
+BOX
+creaMaracasVisu:SetPosition:Box23
+ISEXEC:FALSE
+24.095115:-72.159801:-900.000000
+45.755115:-74.659801:-900.000000
+FIN_BOX
+BOX
+wx:LayoutLine:Box24
+ISEXEC:FALSE
+-108.089144:-87.910634:-900.000000
+-73.009144:-90.410634:-900.000000
+FIN_BOX
+BOX
+std:MagicBox:Box28
+ISEXEC:FALSE
+24.770247:-29.506304:-900.000000
+46.370247:-32.006304:-900.000000
+FIN_BOX
+BOX
+creaVtk:GetPropertiesBySlice:Box30
+ISEXEC:FALSE
+84.973904:-58.862414:-900.000000
+107.613904:-61.362414:-900.000000
+PORT
+Type:"1"
+FIN_BOX
+BOX
+creaMaracasVisu:wxVtkBaseView_Info:Box31
+ISEXEC:FALSE
+84.671306:-41.949121:-900.000000
+115.471306:-44.449121:-900.000000
+PORT
+InteractionType:"6"
+PORT
+WithEventPropagation:"true"
+FIN_BOX
+BOX
+creaMaracasVisu:SetPosition:Box32
+ISEXEC:FALSE
+88.587146:-70.986849:-900.000000
+110.247146:-73.486849:-900.000000
+FIN_BOX
+BOX
+creaVtk:GetPropertiesBySlice:Box35
+ISEXEC:FALSE
+138.411698:-59.185774:-900.000000
+161.051698:-61.685774:-900.000000
+PORT
+Type:"1"
+FIN_BOX
+BOX
+creaMaracasVisu:wxVtkBaseView_Info:Box36
+ISEXEC:FALSE
+138.109101:-42.272480:-900.000000
+168.909101:-44.772480:-900.000000
+PORT
+InteractionType:"6"
+PORT
+WithEventPropagation:"true"
+FIN_BOX
+BOX
+creaMaracasVisu:SetPosition:Box37
+ISEXEC:FALSE
+140.917521:-70.645756:-900.000000
+162.577521:-73.145756:-900.000000
+FIN_BOX
+BOX
+std:MagicBox:Box38
+ISEXEC:FALSE
+138.844785:-30.957716:-900.000000
+160.444785:-33.457716:-900.000000
+FIN_BOX
+BOX
+std:MagicBox:Box22
+ISEXEC:FALSE
+83.479028:-30.961889:-900.000000
+105.079028:-33.461889:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ColorLayerImageView:Box25
+ISEXEC:FALSE
+-84.875769:-29.615543:-900.000000
+-42.755769:-32.115543:-900.000000
+PORT
+ColorBarPosition:"-1000 -1000"
+PORT
+Opacity:"25"
+PORT
+TypeControlsInterface:"2"
+PORT
+lstTransparenceBoundaries:"0"
+FIN_BOX
+BOX
+wx:LayoutSplit:Box26
+ISEXEC:TRUE
+-48.719943:-126.366145:-900.000000
+-24.199943:-128.866145:-900.000000
+PORT
+Orientation:"H"
+PORT
+Proportion:"15"
+FIN_BOX
+BOX
+std:MultipleInputs:Box27
+ISEXEC:TRUE
+74.448938:-127.635999:-900.000000
+96.418938:-130.135999:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box29
+ISEXEC:FALSE
+-91.320446:-50.830232:-900.000000
+-47.440446:-53.330232:-900.000000
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+creaMaracasVisu:PolyDataToActor_Widget:Box33
+ISEXEC:FALSE
+-92.879351:-62.603329:-900.000000
+-69.859351:-65.103329:-900.000000
+FIN_BOX
+BOX
+wx:LayoutSplit:Box34
+ISEXEC:FALSE
+-65.917063:-96.797370:-900.000000
+-41.397063:-99.297370:-900.000000
+PORT
+Orientation:"H"
+PORT
+Proportion:"15"
+FIN_BOX
+BOX
+creaMaracasVisu:ImageChangeInformation:Box43
+ISEXEC:FALSE
+-76.844038:-40.237093:-900.000000
+-53.694038:-42.737093:-900.000000
+FIN_BOX
+CONNECTIONS:45
+CONNECTION
+Box03:Direction:Box02:Orientation
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box02:Image
+NumberOfControlPoints:0
+CONNECTION
+Box00:Out:Box09:In
+NumberOfControlPoints:0
+CONNECTION
+Box09:Out:Box10:Image
+NumberOfControlPoints:0
+CONNECTION
+Box10:Out:Box04:In
+NumberOfControlPoints:0
+CONNECTION
+Box03:Point:Box02:InPoint_pixel
+NumberOfControlPoints:0
+CONNECTION
+Box02:OutPoint_pixel:Box23:Point
+NumberOfControlPoints:0
+CONNECTION
+Box28:Out:Box23:wxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView4:Box28:In
+NumberOfControlPoints:0
+CONNECTION
+Box28:Out:Box03:wxVtkBaseView3
+NumberOfControlPoints:0
+CONNECTION
+Box03:BoxChange:Box23:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box31:Direction:Box30:Orientation
+NumberOfControlPoints:0
+CONNECTION
+Box31:Point:Box30:InPoint_pixel
+NumberOfControlPoints:0
+CONNECTION
+Box30:OutPoint_pixel:Box32:Point
+NumberOfControlPoints:0
+CONNECTION
+Box31:BoxChange:Box32:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box30:Image
+NumberOfControlPoints:0
+CONNECTION
+Box36:Direction:Box35:Orientation
+NumberOfControlPoints:0
+CONNECTION
+Box36:Point:Box35:InPoint_pixel
+NumberOfControlPoints:0
+CONNECTION
+Box35:OutPoint_pixel:Box37:Point
+NumberOfControlPoints:0
+CONNECTION
+Box38:Out:Box37:wxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box36:BoxChange:Box37:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView3:Box38:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box35:Image
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView2:Box22:In
+NumberOfControlPoints:0
+CONNECTION
+Box22:Out:Box32:wxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box22:Out:Box31:wxVtkBaseView3
+NumberOfControlPoints:0
+CONNECTION
+Box38:Out:Box36:wxVtkBaseView3
+NumberOfControlPoints:0
+CONNECTION
+Box00:Out:Box01:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:Box25:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView2:Box25:WxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView3:Box25:WxVtkBaseView1
+NumberOfControlPoints:0
+CONNECTION
+Box01:wxVtkBaseView4:Box25:WxVtkBaseView2
+NumberOfControlPoints:0
+CONNECTION
+Box25:Widget:Box24:Widget3
+NumberOfControlPoints:0
+CONNECTION
+Box01:Widget:Box26:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box03:BoxChange:Box27:In2
+NumberOfControlPoints:0
+CONNECTION
+Box31:BoxChange:Box27:In4
+NumberOfControlPoints:0
+CONNECTION
+Box36:BoxChange:Box27:In6
+NumberOfControlPoints:0
+CONNECTION
+Box33:widget:Box24:Widget4
+NumberOfControlPoints:0
+CONNECTION
+Box29:Renderer1:Box33:render
+NumberOfControlPoints:0
+CONNECTION
+Box24:Widget:Box34:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box34:Widget:Box26:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box02:PolyDataDiscreteflyingedges2D:Box33:polydata
+NumberOfControlPoints:0
+CONNECTION
+Box29:Widget:Box34:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box02:ImageConnected2D:Box43:In
+NumberOfControlPoints:0
+CONNECTION
+Box43:Out:Box29:In
+NumberOfControlPoints:0
+APP_END
--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBS BlackBox Script
+# - /Users/davila/Creatis/C24/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleGetPropertiesBySlice.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include vtk
+include creaMaracasVisu
+include creaVtk
+include wx
+include std
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new vtk:LoadHola Box00
+
+new creaMaracasVisu:ViewerNV Box01
+ set Box01.nTypeView "6 1 2 0"
+
+new creaVtk:GetPropertiesBySlice Box02
+ set Box02.Type "1"
+
+new creaMaracasVisu:wxVtkBaseView_Info Box03
+ set Box03.InteractionType "6"
+ set Box03.WithEventPropagation "true"
+
+new vtk:vtkImageDataPointerRelay Box04
+
+new creaVtk:ImageThreshold Box09
+ set Box09.InValue "255"
+ set Box09.Lower "1200"
+ set Box09.OutValue "0"
+ set Box09.Upper "5000"
+
+new creaVtk:ImageContinuousErode3D Box10
+ set Box10.Repetitions "3"
+ set Box10.X "3"
+ set Box10.Y "3"
+ set Box10.Z "3"
+
+new creaMaracasVisu:SetPosition Box23
+
+new wx:LayoutLine Box24
+
+new std:MagicBox Box28
+
+new creaVtk:GetPropertiesBySlice Box30
+ set Box30.Type "1"
+
+new creaMaracasVisu:wxVtkBaseView_Info Box31
+ set Box31.InteractionType "6"
+ set Box31.WithEventPropagation "true"
+
+new creaMaracasVisu:SetPosition Box32
+
+new creaVtk:GetPropertiesBySlice Box35
+ set Box35.Type "1"
+
+new creaMaracasVisu:wxVtkBaseView_Info Box36
+ set Box36.InteractionType "6"
+ set Box36.WithEventPropagation "true"
+
+new creaMaracasVisu:SetPosition Box37
+
+new std:MagicBox Box38
+
+new std:MagicBox Box22
+
+new creaMaracasVisu:ColorLayerImageView Box25
+ set Box25.ColorBarPosition "-1000 -1000"
+ set Box25.Opacity "25"
+ set Box25.TypeControlsInterface "2"
+ set Box25.lstTransparenceBoundaries "0"
+
+new wx:LayoutSplit Box26
+ set Box26.Orientation "H"
+ set Box26.Proportion "15"
+
+new std:MultipleInputs Box27
+
+new creaMaracasVisu:ViewerNV Box29
+ set Box29.nTypeView "6 1 2 0"
+
+new creaMaracasVisu:PolyDataToActor_Widget Box33
+
+new wx:LayoutSplit Box34
+ set Box34.Orientation "H"
+ set Box34.Proportion "15"
+
+new creaMaracasVisu:ImageChangeInformation Box43
+
+
+connect Box03.Direction Box02.Orientation
+
+connect Box04.Out Box02.Image
+
+connect Box00.Out Box09.In
+
+connect Box09.Out Box10.Image
+
+connect Box10.Out Box04.In
+
+connect Box03.Point Box02.InPoint_pixel
+
+connect Box02.OutPoint_pixel Box23.Point
+
+connect Box28.Out Box23.wxVtkBaseView
+
+connect Box01.wxVtkBaseView4 Box28.In
+
+connect Box28.Out Box03.wxVtkBaseView3
+
+connect Box03.BoxChange Box23.BoxExecute
+
+connect Box31.Direction Box30.Orientation
+
+connect Box31.Point Box30.InPoint_pixel
+
+connect Box30.OutPoint_pixel Box32.Point
+
+connect Box31.BoxChange Box32.BoxExecute
+
+connect Box04.Out Box30.Image
+
+connect Box36.Direction Box35.Orientation
+
+connect Box36.Point Box35.InPoint_pixel
+
+connect Box35.OutPoint_pixel Box37.Point
+
+connect Box38.Out Box37.wxVtkBaseView
+
+connect Box36.BoxChange Box37.BoxExecute
+
+connect Box01.wxVtkBaseView3 Box38.In
+
+connect Box04.Out Box35.Image
+
+connect Box01.wxVtkBaseView2 Box22.In
+
+connect Box22.Out Box32.wxVtkBaseView
+
+connect Box22.Out Box31.wxVtkBaseView3
+
+connect Box38.Out Box36.wxVtkBaseView3
+
+connect Box00.Out Box01.In
+
+connect Box04.Out Box25.In
+
+connect Box01.wxVtkBaseView2 Box25.WxVtkBaseView
+
+connect Box01.wxVtkBaseView3 Box25.WxVtkBaseView1
+
+connect Box01.wxVtkBaseView4 Box25.WxVtkBaseView2
+
+connect Box25.Widget Box24.Widget3
+
+connect Box01.Widget Box26.Widget2
+
+connect Box03.BoxChange Box27.In2
+
+connect Box31.BoxChange Box27.In4
+
+connect Box36.BoxChange Box27.In6
+
+connect Box33.widget Box24.Widget4
+
+connect Box29.Renderer1 Box33.render
+
+connect Box24.Widget Box34.Widget1
+
+connect Box34.Widget Box26.Widget1
+
+connect Box02.PolyDataDiscreteflyingedges2D Box33.polydata
+
+connect Box29.Widget Box34.Widget2
+
+connect Box02.ImageConnected2D Box43.In
+
+connect Box43.Out Box29.In
+
+
+
+# Complex input ports
+exec Box26
+exec Box27
BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,DistanceMap)
BBTK_BLACK_BOX_IMPLEMENTATION(DistanceMap,bbtk::AtomicBlackBox);
-//=====
+//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
+//=====
void DistanceMap::Process()
{
-
-// THE MAIN PROCESSING METHOD BODY
-// Here we simply set the input 'In' value to the output 'Out'
-// And print out the output value
-// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
-// void bbSet{Input|Output}NAME(const TYPE&)
-// const TYPE& bbGet{Input|Output}NAME() const
-// Where :
-// * NAME is the name of the input/output
-// (the one provided in the attribute 'name' of the tag 'input')
-// * TYPE is the C++ type of the input/output
-// (the one provided in the attribute 'type' of the tag 'input')
-
- if ( (bbGetInputIn()!=NULL) && (bbGetInputPoint1().size()==3) )
- {
-
- int ext[6];
- int dim[3];
- long int dimX,dimXY;
- double spc[3];
- bbGetInputIn()->GetSpacing(spc);
- bbGetInputIn()->GetExtent(ext);
- dim[0] = ext[1]-ext[0]+1;
- dim[1] = ext[3]-ext[2]+1;
- dim[2] = ext[5]-ext[4]+1;
- dimX = dim[0];
- dimXY = dim[0]*dim[1];
- if (imageoutput!=NULL)
- {
- imageoutput->Delete();
- }
- imageoutput = vtkImageData::New();
- imageoutput->Initialize();
- imageoutput->SetSpacing( spc );
- imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
-
- //EED 2017-01-01 Migration VTK7
- #if (VTK_MAJOR_VERSION <= 5)
- imageoutput->SetScalarType( VTK_DOUBLE );
- imageoutput->AllocateScalars();
- #endif
- #if (VTK_MAJOR_VERSION >= 6)
- imageoutput->AllocateScalars( VTK_DOUBLE,1 );
- #endif
- imageoutput->Modified();
-
- memset( imageoutput->GetScalarPointer() ,0, sizeof(double)*dim[0]*dim[1]*dim[2] );
- std::vector<int> lst1X;
- std::vector<int> lst1Y;
- std::vector<int> lst1Z;
-
- std::vector<int> lst2X;
- std::vector<int> lst2Y;
- std::vector<int> lst2Z;
-
- lst1X.push_back( bbGetInputPoint1()[0] );
- lst1Y.push_back( bbGetInputPoint1()[1]);
- lst1Z.push_back( bbGetInputPoint1()[2]);
-
- long int i,size;
- double glIn,glOut;
- double depth=0;
- int px,py,pz;
- int pxOut,pyOut,pzOut;
- double tmpValue;
-
-
- DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())
- DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput)
-
- while (lst1X.size()>0)
- {
- depth=depth+bbGetInputSlope();
- size=lst1X.size();
- for (i=0;i<size;i++)
- {
- GETVALUE2_VTK_CREA(glIn,pIn,stIn, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
-
-// glIn=bbGetInputIn()->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
- if (glIn!=0)
- {
- GETVALUE2_VTK_CREA(glOut,pOut,stOut, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
-// glOut=imageoutput->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
- if (glOut==0)
- {
- tmpValue = depth + (255-glIn)*bbGetInputAverageRadius()*2;
- SETVALUE2_VTK_CREA(tmpValue,pOut,stOut, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
-// imageoutput->SetScalarComponentFromDouble( lst1X[i], lst1Y[i], lst1Z[i], 0, depth+(255-glIn)*bbGetInputAverageRadius()*2);
- pxOut=lst1X[i]; pyOut=lst1Y[i]; pzOut=lst1Z[i];
-
-
- for (px=lst1X[i]-1;px<=lst1X[i]+1;px++)
- {
- for (py=lst1Y[i]-1;py<=lst1Y[i]+1;py++)
- {
- for (pz=lst1Z[i]-1;pz<=lst1Z[i]+1;pz++)
- {
- if (!( (px==lst1X[i]) && (py==lst1Y[i]) && (pz==lst1Z[i]) ))
- {
- if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) && (pz>=0) && (pz<dim[2]) )
- {
- GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
-// glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0);
- } else {
- glOut=-1;
- } // if px py pz inside the image
- if (glOut==0) { lst2X.push_back(px); lst2Y.push_back( py ); lst2Z.push_back( pz ); }
- } // if
- } // for kk
- } // fo jj
- } // for ii
-
- if ( bbGetInputPoint2().size()==3)
- {
- if ( (bbGetInputPoint2()[0]==lst1X[i]) && (bbGetInputPoint2()[1]==lst1Y[i]) && (bbGetInputPoint2()[2]==lst1Z[i]) )
- {
- i=size; // out of for lst1
- lst2X.clear();
- lst2Y.clear();
- lst2Z.clear();
- } // if Arrive to Point2
- } // Point size 3
-
- }
-
- }// If glIn
-
- } // for lst1
-
- lst1X.clear();
- lst1Y.clear();
- lst1Z.clear();
-
- size=lst2X.size();
- for (i=0;i<size;i++)
- {
- lst1X.push_back( lst2X[i] );
- lst1Y.push_back( lst2Y[i] );
- lst1Z.push_back( lst2Z[i] );
- } // for lst2
-
- lst2X.clear();
- lst2Y.clear();
- lst2Z.clear();
-
- } // while lstX
-
-
- std::vector<int> lstPointOut;
- lstPointOut.push_back( pxOut );
- lstPointOut.push_back( pyOut );
- lstPointOut.push_back( pzOut );
-
- std::vector<int> lstPathXOut;
- std::vector<int> lstPathYOut;
- std::vector<int> lstPathZOut;
-
- lstPathXOut.push_back( pxOut );
- lstPathYOut.push_back( pyOut );
- lstPathZOut.push_back( pzOut );
-
- // find Path
- bool ok2;
- bool ok = true;
- double min = imageoutput->GetScalarComponentAsDouble( pxOut,pyOut,pzOut , 0);
- int pxOutBack;
- int pyOutBack;
- int pzOutBack;
- while (ok==true)
- {
- ok2=false;
- for (px=pxOut-1;px<=pxOut+1;px++)
- {
- for (py=pyOut-1;py<=pyOut+1;py++)
- {
- for (pz=pzOut-1;pz<=pzOut+1;pz++)
- {
- if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) && (pz>=0) && (pz<dim[2]) )
- {
- GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
-// glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0);
- if ( (glOut<min) && (glOut!=0) )
- {
- min = glOut;
- pxOutBack = px;
- pyOutBack = py;
- pzOutBack = pz;
- ok2 = true;
- } // if min
- } // if
- } // for pz
- } // fo py
- } // for px
-
- if (ok2==true)
- {
- pxOut=pxOutBack;
- pyOut=pyOutBack;
- pzOut=pzOutBack;
- lstPathXOut.push_back( pxOut );
- lstPathYOut.push_back( pyOut );
- lstPathZOut.push_back( pzOut );
- } else {
- ok=false;
- }
- } // while
-
- bbSetOutputOut( imageoutput );
- bbSetOutputFinalPoint( lstPointOut );
- bbSetOutputLengthPixels( lstPathXOut.size() );
-
- // invert list of points
- size=lstPathXOut.size();
- long int size2=size/2;
- int tmp;
- for (i=0; i<size2;i++)
- {
- tmp= lstPathXOut[i]; lstPathXOut[i]=lstPathXOut[size-1-i]; lstPathXOut[size-1-i]=tmp;
- tmp= lstPathYOut[i]; lstPathYOut[i]=lstPathYOut[size-1-i]; lstPathYOut[size-1-i]=tmp;
- tmp= lstPathZOut[i]; lstPathZOut[i]=lstPathZOut[size-1-i]; lstPathZOut[size-1-i]=tmp;
- } // for invert list
-
- bbSetOutputLstPathXOut( lstPathXOut );
- bbSetOutputLstPathYOut( lstPathYOut );
- bbSetOutputLstPathZOut( lstPathZOut );
- } else {
- printf("EED Warnning! DistanceMap::Process In or Point1 is EMPTY\n");
- } // if In Point1
-
+
+ // THE MAIN PROCESSING METHOD BODY
+ // Here we simply set the input 'In' value to the output 'Out'
+ // And print out the output value
+ // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+ // void bbSet{Input|Output}NAME(const TYPE&)
+ // const TYPE& bbGet{Input|Output}NAME() const
+ // Where :
+ // * NAME is the name of the input/output
+ // (the one provided in the attribute 'name' of the tag 'input')
+ // * TYPE is the C++ type of the input/output
+ // (the one provided in the attribute 'type' of the tag 'input')
+
+ if ( (bbGetInputIn()!=NULL) && (bbGetInputPoint1().size()==3) )
+ {
+
+ int ext[6];
+ int dim[3];
+ long int dimX,dimXY;
+ double spc[3];
+ bbGetInputIn()->GetSpacing(spc);
+ bbGetInputIn()->GetExtent(ext);
+ dim[0] = ext[1]-ext[0]+1;
+ dim[1] = ext[3]-ext[2]+1;
+ dim[2] = ext[5]-ext[4]+1;
+ dimX = dim[0];
+ dimXY = dim[0]*dim[1];
+ if (imageoutput!=NULL)
+ {
+ imageoutput->Delete();
+ }
+ imageoutput = vtkImageData::New();
+ imageoutput->Initialize();
+ imageoutput->SetSpacing( spc );
+ imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
+
+ //EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5)
+ imageoutput->SetScalarType( VTK_DOUBLE );
+ imageoutput->AllocateScalars();
+#endif
+#if (VTK_MAJOR_VERSION >= 6)
+ imageoutput->AllocateScalars( VTK_DOUBLE,1 );
+#endif
+ imageoutput->Modified();
+
+ memset( imageoutput->GetScalarPointer() ,0, sizeof(double)*dim[0]*dim[1]*dim[2] );
+ std::vector<int> lst1X;
+ std::vector<int> lst1Y;
+ std::vector<int> lst1Z;
+
+ std::vector<int> lst2X;
+ std::vector<int> lst2Y;
+ std::vector<int> lst2Z;
+
+ lst1X.push_back( bbGetInputPoint1()[0] );
+ lst1Y.push_back( bbGetInputPoint1()[1]);
+ lst1Z.push_back( bbGetInputPoint1()[2]);
+
+ long int i,size;
+ double glIn,glOut;
+ double depth=0;
+ int px,py,pz;
+ int pxOut,pyOut,pzOut;
+ double tmpValue;
+
+
+ DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())
+ DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput)
+
+ while (lst1X.size()>0)
+ {
+ depth=depth+bbGetInputSlope();
+ size=lst1X.size();
+ for (i=0;i<size;i++)
+ {
+ GETVALUE2_VTK_CREA(glIn,pIn,stIn, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+
+ // glIn=bbGetInputIn()->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
+ if (glIn!=0)
+ {
+ GETVALUE2_VTK_CREA(glOut,pOut,stOut, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+ // glOut=imageoutput->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
+ if (glOut==0)
+ {
+ tmpValue = depth + (255-glIn)*bbGetInputAverageRadius()*2;
+ SETVALUE2_VTK_CREA(tmpValue,pOut,stOut, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+ // imageoutput->SetScalarComponentFromDouble( lst1X[i], lst1Y[i], lst1Z[i], 0, depth+(255-glIn)*bbGetInputAverageRadius()*2);
+ pxOut=lst1X[i]; pyOut=lst1Y[i]; pzOut=lst1Z[i];
+
+
+ for (px=lst1X[i]-1;px<=lst1X[i]+1;px++)
+ {
+ for (py=lst1Y[i]-1;py<=lst1Y[i]+1;py++)
+ {
+ for (pz=lst1Z[i]-1;pz<=lst1Z[i]+1;pz++)
+ {
+ if (!( (px==lst1X[i]) && (py==lst1Y[i]) && (pz==lst1Z[i]) ))
+ {
+ if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) && (pz>=0) && (pz<dim[2]) )
+ {
+ GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
+ // glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0);
+ } else {
+ glOut=-1;
+ } // if px py pz inside the image
+ if (glOut==0) { lst2X.push_back(px); lst2Y.push_back( py ); lst2Z.push_back( pz ); }
+ } // if
+ } // for kk
+ } // fo jj
+ } // for ii
+
+ if ( bbGetInputPoint2().size()==3)
+ {
+ if ( (bbGetInputPoint2()[0]==lst1X[i]) && (bbGetInputPoint2()[1]==lst1Y[i]) && (bbGetInputPoint2()[2]==lst1Z[i]) )
+ {
+ i=size; // out of for lst1
+ lst2X.clear();
+ lst2Y.clear();
+ lst2Z.clear();
+ } // if Arrive to Point2
+ } // Point size 3
+
+ }
+
+ }// If glIn
+
+ } // for lst1
+
+ lst1X.clear();
+ lst1Y.clear();
+ lst1Z.clear();
+
+ size=lst2X.size();
+ for (i=0;i<size;i++)
+ {
+ lst1X.push_back( lst2X[i] );
+ lst1Y.push_back( lst2Y[i] );
+ lst1Z.push_back( lst2Z[i] );
+ } // for lst2
+
+ lst2X.clear();
+ lst2Y.clear();
+ lst2Z.clear();
+
+ } // while lstX
+
+
+ std::vector<int> lstPointOut;
+ lstPointOut.push_back( pxOut );
+ lstPointOut.push_back( pyOut );
+ lstPointOut.push_back( pzOut );
+
+ std::vector<int> lstPathXOut;
+ std::vector<int> lstPathYOut;
+ std::vector<int> lstPathZOut;
+
+ lstPathXOut.push_back( pxOut );
+ lstPathYOut.push_back( pyOut );
+ lstPathZOut.push_back( pzOut );
+
+ // find Path
+ bool ok2;
+ bool ok = true;
+ double min = imageoutput->GetScalarComponentAsDouble( pxOut,pyOut,pzOut , 0);
+ int pxOutBack;
+ int pyOutBack;
+ int pzOutBack;
+ while (ok==true)
+ {
+ ok2=false;
+ for (px=pxOut-1;px<=pxOut+1;px++)
+ {
+ for (py=pyOut-1;py<=pyOut+1;py++)
+ {
+ for (pz=pzOut-1;pz<=pzOut+1;pz++)
+ {
+ if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) && (pz>=0) && (pz<dim[2]) )
+ {
+ GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
+ // glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0);
+ if ( (glOut<min) && (glOut!=0) )
+ {
+ min = glOut;
+ pxOutBack = px;
+ pyOutBack = py;
+ pzOutBack = pz;
+ ok2 = true;
+ } // if min
+ } // if
+ } // for pz
+ } // fo py
+ } // for px
+
+ if (ok2==true)
+ {
+ pxOut=pxOutBack;
+ pyOut=pyOutBack;
+ pzOut=pzOutBack;
+ lstPathXOut.push_back( pxOut );
+ lstPathYOut.push_back( pyOut );
+ lstPathZOut.push_back( pzOut );
+ } else {
+ ok=false;
+ }
+ } // while
+ bbSetOutputOut( imageoutput );
+ bbSetOutputFinalPoint( lstPointOut );
+ bbSetOutputLengthPixels( lstPathXOut.size() );
+ // invert list of points
+ size=lstPathXOut.size();
+ long int size2=size/2;
+ int tmp;
+ for (i=0; i<size2;i++)
+ {
+ tmp= lstPathXOut[i]; lstPathXOut[i]=lstPathXOut[size-1-i]; lstPathXOut[size-1-i]=tmp;
+ tmp= lstPathYOut[i]; lstPathYOut[i]=lstPathYOut[size-1-i]; lstPathYOut[size-1-i]=tmp;
+ tmp= lstPathZOut[i]; lstPathZOut[i]=lstPathZOut[size-1-i]; lstPathZOut[size-1-i]=tmp;
+ } // for invert list
+ bbSetOutputLstPathXOut( lstPathXOut );
+ bbSetOutputLstPathYOut( lstPathYOut );
+ bbSetOutputLstPathZOut( lstPathZOut );
+ } else {
+ printf("EED Warnning! DistanceMap::Process In or Point1 is EMPTY\n");
+ } // if In Point1
}
-//=====
+
+//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
+//=====
void DistanceMap::bbUserSetDefaultValues()
{
-
-// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
-// Here we initialize the input 'In' to 0
- bbSetInputIn(NULL);
- bbSetInputAverageRadius(10);
- bbSetInputSlope(10);
- imageoutput=NULL;
-
+ // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+ // Here we initialize the input 'In' to 0
+ bbSetInputIn(NULL);
+ bbSetInputAverageRadius(10);
+ bbSetInputSlope(10);
+ imageoutput=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)
-//=====
+//=====
void DistanceMap::bbUserInitializeProcessing()
{
-
-// THE INITIALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should allocate the internal/output pointers
-// if any
-
-
+ // THE INITIALIZATION METHOD BODY :
+ // Here does nothing
+ // but this is where you should allocate the internal/output pointers
+ // if any
}
-//=====
+
+//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
+//=====
void DistanceMap::bbUserFinalizeProcessing()
{
-
-// THE FINALIZATION METHOD BODY :
-// Here does nothing
-// but this is where you should desallocate the internal/output pointers
-// if any
-
-}
+ // THE FINALIZATION METHOD BODY :
+ // Here does nothing
+ // but this is where you should desallocate the internal/output pointers
+ // if any
}
-// EO namespace bbcreaVtk
+
+}// EO namespace bbcreaVtk