]> Creatis software - bbtk.git/commitdiff
#3524 DeepCoppy in vtkBinaryOperation box
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 21 Oct 2024 09:29:10 +0000 (11:29 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 21 Oct 2024 09:29:10 +0000 (11:29 +0200)
packages/vtk/src/bbvtkBinaryOperations.cxx
packages/vtk/src/bbvtkBinaryOperations.h

index d6812aee9de8c3cbcb29190a902e23185784c106..480534dd2014617dca2a4c44a377767bedd9b227 100644 (file)
@@ -49,43 +49,47 @@ void BinaryOperations::Process()
     
     if (bbGetInputIn1() == NULL)
     {
-        printf( "EED Warning!!!  (%s)  BinaryOperations::Process  Set In1 at least", bbGetFullName().c_str() );
+        printf( "EED Warning!!!  (%s)  BinaryOperations::Process  Set In1 at least \n", bbGetFullName().c_str() );
         bbSetOutputOut(NULL);
         return;
     }
     
-    if (ope!=NULL)
-    {
-        ope->Delete();
-        ope = NULL;
-    } // if
-    ope = vtkImageMathematics::New();
-    
-    //EED 2017-01-01 Migration VTK7
-#if (VTK_MAJOR_VERSION <= 5) 
-    ope->SetInput1((vtkDataObject*)bbGetInputIn1());
-#endif
-#if (VTK_MAJOR_VERSION >= 6) 
-    ope->SetInput1Data((vtkDataObject*)bbGetInputIn1());
-#endif
-    
-    if (bbGetInputIn2() != NULL)
-    {
-        //EED 2017-01-01 Migration VTK7
-#if (VTK_MAJOR_VERSION <= 5) 
-        ope->SetInput2((vtkDataObject*)bbGetInputIn2());
-#endif
-#if (VTK_MAJOR_VERSION >= 6) 
-        ope->SetInput2Data((vtkDataObject*)bbGetInputIn2());
-#endif
-    } else {
-        printf( "EED Warning!!!  (%s)  BinaryOperations::Process  Set In2 at least", bbGetFullName().c_str() );
-        bbSetOutputOut(NULL);
-        return;
-    }
     
     if ( (bbGetInputOperation()>=0) &&  (bbGetInputOperation()<=5) )
     {
+        
+        if (ope!=NULL)
+        {
+            ope->Delete();
+            ope = NULL;
+        } // if
+        ope = vtkImageMathematics::New();
+        
+        //EED 2017-01-01 Migration VTK7
+    #if (VTK_MAJOR_VERSION <= 5)
+        ope->SetInput1((vtkDataObject*)bbGetInputIn1());
+    #endif
+    #if (VTK_MAJOR_VERSION >= 6)
+        ope->SetInput1Data((vtkDataObject*)bbGetInputIn1());
+    #endif
+        
+     
+        if (bbGetInputIn2() != NULL)
+        {
+            //EED 2017-01-01 Migration VTK7
+    #if (VTK_MAJOR_VERSION <= 5)
+            ope->SetInput2((vtkDataObject*)bbGetInputIn2());
+    #endif
+    #if (VTK_MAJOR_VERSION >= 6)
+            ope->SetInput2Data((vtkDataObject*)bbGetInputIn2());
+    #endif
+        } else {
+            printf( "EED Warning!!!  (%s)  BinaryOperations::Process  Set In2 at least \n", bbGetFullName().c_str() );
+            bbSetOutputOut(NULL);
+            return;
+        }
+
         switch ( bbGetInputOperation() )
         {
             case 0:
@@ -124,6 +128,44 @@ void BinaryOperations::Process()
     {
         bbSetOutputOut( bbGetInputIn2() );
     }
+    if ( bbGetInputOperation()==8 )
+    {
+        if (bbGetInputIn1()!=NULL)
+        {
+            if (bbGetInputIn2()==NULL)
+            {
+                int ext[6];
+                bbGetInputIn1()->GetExtent(ext);
+                int dimX        = ext[1]-ext[0] + 1;
+                int dimY        = ext[3]-ext[2] + 1;
+                int dimZ        = ext[5]-ext[4] + 1;
+                int scalarSize  = bbGetInputIn1()->GetScalarSize();
+                long int size   = dimX * dimY * dimZ *scalarSize;
+                memset ( bbGetInputIn1()->GetScalarPointer(), 0 , size );
+            } else {
+                /*
+                int ext[6];
+                bbGetInputIn1()->GetExtent(ext);
+                int dimX1       = ext[1]-ext[0] + 1;
+                int dimY1       = ext[3]-ext[2] + 1;
+                int dimZ1       = ext[5]-ext[4] + 1;
+                int scalarSize1 = bbGetInputIn1()->GetScalarSize();
+                bbGetInputIn2()->GetExtent(ext);
+                int dimX2       = ext[1]-ext[0] + 1;
+                int dimY2       = ext[3]-ext[2] + 1;
+                int dimZ2       = ext[5]-ext[4] + 1;
+                int scalarSize2  = bbGetInputIn1()->GetScalarSize();
+                long int size   = dimX1 * dimY1 * dimZ1 * scalarSize1;
+                if ((dimX1==dimX2) && (dimY1==dimY2) && (dimZ1==dimZ2) && (scalarSize1==scalarSize2))
+                {
+                    memcpy( bbGetInputIn1()->GetScalarPointer(), bbGetInputIn2()->GetScalarPointer() , size );
+                } // if dim size
+                */
+                bbGetInputIn1()->DeepCopy( bbGetInputIn2() );
+            } // if In2
+        } // if In1
+        bbSetOutputOut( bbGetInputIn1() );
+    } // Operation 8
     // bbSignalOutputModification();
 }
 
index 49db6b15d79e308f211d7491167e1b094a2aeeac..ca684be0d7de3cb35aa30ac391119148df265f30 100644 (file)
@@ -73,7 +73,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryOperations,bbtk::AtomicBlackBox);
   BBTK_CATEGORY("filter");
   BBTK_INPUT(BinaryOperations,In1,"first image to be operated",vtkImageData*,"NULL default");
   BBTK_INPUT(BinaryOperations,In2,"second image to be operated",vtkImageData*,"NULL default");
-  BBTK_INPUT(BinaryOperations,Operation,"0:Add (default) , 1:subtract, 2:multiply, 3:divide, 4=Max, 5=Min, 6=Replace with In1, 7=Replace with In2",int,"");
+  BBTK_INPUT(BinaryOperations,Operation,"0:Add (default) , 1:subtract, 2:multiply, 3:divide, 4=Max, 5=Min, 6=Replace with In1, 7=Replace with In2, 8=DeepCopy de In2 to In1 (output In1)",int,"");
   BBTK_OUTPUT(BinaryOperations,Out,"",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(BinaryOperations);
 }