From: eduardo.davila@creatis.insa-lyon.fr Date: Thu, 17 Oct 2024 13:52:52 +0000 (+0200) Subject: #3523 openmp ImageBoundaries X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=72be953f863299543fe27d85628c1bc12fb384ae;p=bbtk.git #3523 openmp ImageBoundaries --- diff --git a/kernel/cmake/BBTKConfigurePackage.cmake b/kernel/cmake/BBTKConfigurePackage.cmake index cf1949e..7e627cd 100644 --- a/kernel/cmake/BBTKConfigurePackage.cmake +++ b/kernel/cmake/BBTKConfigurePackage.cmake @@ -142,6 +142,16 @@ ENDIF(NOT ${BBTK_PACKAGE_NAME}_IN_DEPS) #--------------------------------------------------------------------------- # Package dependencies + +IF(${BBTK_PACKAGE_NAME}_USE_OPENMP) + SET(USE_OPENMP ON CACHE BOOL "Use OPENMP" FORCE) + SET(${BBTK_PACKAGE_NAME}_LIBS + ${${BBTK_PACKAGE_NAME}_LIBS} + ${OpenMP_libomp_LIBRARY_crea} + ) + LINK_DIRECTORIES( /opt/local/lib/libomp ) +ENDIF(${BBTK_PACKAGE_NAME}_USE_VTK) + IF(${BBTK_PACKAGE_NAME}_USE_VTK) SET(USE_VTK ON CACHE BOOL "Use VTK" FORCE) SET(${BBTK_PACKAGE_NAME}_LIBS diff --git a/packages/itk/CMakeLists.txt b/packages/itk/CMakeLists.txt index c182117..c25db93 100644 --- a/packages/itk/CMakeLists.txt +++ b/packages/itk/CMakeLists.txt @@ -45,6 +45,8 @@ SET(${BBTK_PACKAGE_NAME}_USE_ITK ON) # SET(${BBTK_PACKAGE_NAME}_USE_GDCM2 ON) # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON) # SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON) +SET(${BBTK_PACKAGE_NAME}_USE_OPENMP ON) + #=========================================================================== #=========================================================================== @@ -140,6 +142,9 @@ SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS ../std/src # The path to the build tree folder is needed to find bbstd_EXPORT.h ${PROJECT_BINARY_DIR}/packages/std/src + + /opt/local/include/libomp + ) #=========================================================================== diff --git a/packages/itkvtk/CMakeLists.txt b/packages/itkvtk/CMakeLists.txt index 1b62a97..594830b 100644 --- a/packages/itkvtk/CMakeLists.txt +++ b/packages/itkvtk/CMakeLists.txt @@ -138,6 +138,8 @@ SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS # - automatically handled libraries or packages : wx, vtk... (see above) # - the dirs automatically set by other libraries found by FIND_PACKAGE ../itk/src + /opt/local/include/libomp + ) #=========================================================================== diff --git a/packages/std/src/bbstdVectorFilterDouble.cxx b/packages/std/src/bbstdVectorFilterDouble.cxx index 16c90e1..ff85b0b 100644 --- a/packages/std/src/bbstdVectorFilterDouble.cxx +++ b/packages/std/src/bbstdVectorFilterDouble.cxx @@ -492,6 +492,24 @@ void VectorFilterDouble::Process() } // if In0.size and k1.size } // Type 15 + if (bbGetInputType()==16) // 16 switch In0 and In1 (k1=1 nothing, k0 swhich) + { + if (bbGetInputk1().size()==1) + { + if (bbGetInputk1()[0] == 0) + { + Out0 = In0; + Out1 = In1; + } // if k1 == 0 + if (bbGetInputk1()[0] == 1) + { + Out0 = In1; + Out1 = In0; + } // if k1 == 1 + } // if size k1 == 1 + } // if Type 16 + + bbSetOutputOut0( Out0 ); bbSetOutputOut1( Out1 ); bbSetOutputOut2( Out2 ); diff --git a/packages/std/src/bbstdVectorFilterDouble.h b/packages/std/src/bbstdVectorFilterDouble.h index 08b525f..ee7976b 100644 --- a/packages/std/src/bbstdVectorFilterDouble.h +++ b/packages/std/src/bbstdVectorFilterDouble.h @@ -52,8 +52,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VectorFilterDouble,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(VectorFilterDouble,Type,"default (0) 0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors, 10=Nearest Point in the vector. In3PointXYZ In0LstX In1LstY In2LstZ (Out0-index Out1-PointXYZ), 11=Mul Spacing (K1[spcX,spcY,spcZ]=Spacing), 12=Div Spacing (K1[spcX,spcY,spcZ]=Spacing), 13=Distance pointIn0 and pontIn1, 14=Select specific segments [k1] in In0=lstPx In1=lstPy In2=lstPz In3=lstIndex (if k1 empty all segments are selected) , 15 swhitch element in a point k1=0 yz, k1=1 nothing k2=2 xz",int,""); - BBTK_INPUT(VectorFilterDouble,k1,"(default [0]) nothing (Type0), k1[0]=new size vectors (Type 1) , nothing (Type2), k1[0] = Addition const. (Type 3), k1[0] = Substraction const. (Type 4), k1[0] = Multiplication const. (Type 5) , k1[0] = Division const. (Type 6) , k1[spcX,spcY,spcZ] MulSpc In0_X,In1_Y,In2_Z (type 11), k1[spcX,spcY,spcZ] DivSpc In0_X,In1_Y,In2_Z (type 12) , k1[segment1, segment2,..] (type 14) , direction (type 15) ",std::vector,""); + BBTK_INPUT(VectorFilterDouble,Type,"default (0) 0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors, 10=Nearest Point in the vector. In3PointXYZ In0LstX In1LstY In2LstZ (Out0-index Out1-PointXYZ), 11=Mul Spacing (K1[spcX,spcY,spcZ]=Spacing), 12=Div Spacing (K1[spcX,spcY,spcZ]=Spacing), 13=Distance pointIn0 and pontIn1, 14=Select specific segments [k1] in In0=lstPx In1=lstPy In2=lstPz In3=lstIndex (if k1 empty all segments are selected) , 15 swhitch element in a point k1=0 yz, k1=1 nothing k2=2 xz , 16 switch In0 and In1 (k1=1 nothing k0 swhich)",int,""); + BBTK_INPUT(VectorFilterDouble,k1,"(default [0]) nothing (Type0), k1[0]=new size vectors (Type 1) , nothing (Type2), k1[0] = Addition const. (Type 3), k1[0] = Substraction const. (Type 4), k1[0] = Multiplication const. (Type 5) , k1[0] = Division const. (Type 6) , k1[spcX,spcY,spcZ] MulSpc In0_X,In1_Y,In2_Z (type 11), k1[spcX,spcY,spcZ] DivSpc In0_X,In1_Y,In2_Z (type 12) , k1[segment1, segment2,..] (type 14) , direction (type 15), direction (type 16) ",std::vector,""); BBTK_INPUT(VectorFilterDouble,In0,"Input vector",std::vector,""); BBTK_INPUT(VectorFilterDouble,In1,"Input vector",std::vector,""); BBTK_INPUT(VectorFilterDouble,In2,"Input vector",std::vector,""); diff --git a/packages/vtk/CMakeLists.txt b/packages/vtk/CMakeLists.txt index 6689a60..13ae68a 100644 --- a/packages/vtk/CMakeLists.txt +++ b/packages/vtk/CMakeLists.txt @@ -67,6 +67,7 @@ SET(${BBTK_PACKAGE_NAME}_BUILD_VERSION 0) # SET(${BBTK_PACKAGE_NAME}_USE_GDCM2 ON) # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON) # SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON) +SET(${BBTK_PACKAGE_NAME}_USE_OPENMP ON) #=========================================================================== #=========================================================================== diff --git a/packages/vtk/src/bbvtkImageBoundaries.cxx b/packages/vtk/src/bbvtkImageBoundaries.cxx index c477aad..ad8f1af 100644 --- a/packages/vtk/src/bbvtkImageBoundaries.cxx +++ b/packages/vtk/src/bbvtkImageBoundaries.cxx @@ -79,26 +79,41 @@ void ImageBoundaries::Process() DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI,bbGetInputIn()) long int index=0; - //int i,j; - int k; - -int k1omp=(double)(maxZ-1)*0.0; -int k2omp=(double)(maxZ-1)*0.2; -int k3omp=(double)(maxZ-1)*0.4; -int k4omp=(double)(maxZ-1)*0.6; -int k5omp=(double)(maxZ-1)*0.8; -int k6omp=(double)(maxZ-1)*1.0; - -//printf("EED ImageBoundaries::Process (with openmp)\n"); - + + int *vecXMin = (int*)malloc( maxZ*sizeof(int) ); + int *vecYMin = (int*)malloc( maxZ*sizeof(int) ); + int *vecZMin = (int*)malloc( maxZ*sizeof(int) ); + int *vecXMax = (int*)malloc( maxZ*sizeof(int) ); + int *vecYMax = (int*)malloc( maxZ*sizeof(int) ); + int *vecZMax = (int*)malloc( maxZ*sizeof(int) ); + + //int i,j; + int k; + + for ( k=0 ; k=lowervalue) && (vItmpOMP<=uppervalue) ) { + /* if (ibXMax) bXMax = i; if (j>bYMax) bYMax = j; if (k>bZMax) bZMax = k; + */ + if (ivecXMax[k]) vecXMax[k] = i; + if (j>vecYMax[k]) vecYMax[k] = j; + if (k>vecZMax[k]) vecZMax[k] = k; + } } // for k } // for j } // i -// } // #pragma - std::vector tmpIndex; + + for ( k=0 ; kbXMax) bXMax = vecXMax[k]; + if (vecYMax[k]>bYMax) bYMax = vecYMax[k]; + if (vecZMax[k]>bZMax) bZMax = vecZMax[k]; + } + + delete vecXMin; + delete vecYMin; + delete vecZMin; + delete vecXMax; + delete vecYMax; + delete vecZMax; + + std::vector tmpIndex; std::vector tmpSize; if (bXMin>bXMax){ tmpIndex.push_back(0);