//===== // 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) //===== #include "bbcreaVtkDistanceMap.h" #include "bbcreaVtkPackage.h" namespace bbcreaVtk { 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]; 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; 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 lst1X; std::vector lst1Y; std::vector lst1Z; std::vector lst2X; std::vector lst2Y; std::vector 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; printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); printf("EED Warnning! DistanceMap::Process Clean Ponter Image......\n"); while (lst1X.size()>0) { depth=depth+bbGetInputSlope(); size=lst1X.size(); for (i=0;iGetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0); if (glIn!=0) { glOut=imageoutput->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0); if (glOut==0) { imageoutput->SetScalarComponentFromDouble( lst1X[i], lst1Y[i], lst1Z[i], 0, depth+(255-glIn)); 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=0) && (py=0) && (pzGetScalarComponentAsDouble( px,py,pz , 0); } else { glOut=-1; } 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 lstPointOut; lstPointOut.push_back( pxOut ); lstPointOut.push_back( pyOut ); lstPointOut.push_back( pzOut ); std::vector lstPathXOut; std::vector lstPathYOut; std::vector 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; int length=0; 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=0) && (py=0) && (pzGetScalarComponentAsDouble( px,py,pz , 0); if ( (glOut