]> Creatis software - creaVtk.git/commitdiff
#3513 CleanMeshWithPatch
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 12 Jul 2023 17:55:35 +0000 (19:55 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 12 Jul 2023 17:55:35 +0000 (19:55 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkCleanMeshWithPatch.cxx

index 222c00eeb9f467e237590e8ee09718ae368d9684..9fd42dc41b49edcf8abb3b3ee8e97d078b251a50 100644 (file)
@@ -215,7 +215,7 @@ void CleanMeshWithPatch::Process()
         connectivity->Update();
 //        bbSetOutputOut( connectivity->GetOutput() );
 
-        printf("EED CleanMeshWithPatch::Process   connectivity GetNumberOfPoints  %ld \n   ", connectivity->GetOutput()->GetNumberOfPoints() );
+//        printf("EED CleanMeshWithPatch::Process   connectivity GetNumberOfPoints  %ld \n   ", connectivity->GetOutput()->GetNumberOfPoints() );
 
 /*
         vtkAppendPolyData* append3 = vtkAppendPolyData::New();
@@ -269,10 +269,10 @@ void CleanMeshWithPatch::Process()
         connectivityClean->SetInputData( connectivity->GetOutput() );
         connectivityClean->Update();
         
-        //step 6.1.  -- connect both meshes     Patch->ConnectivityClean    --
-        Stretch( connectivityClean->GetOutput() , bbGetInputPatch() );
         //step 6.2.  -- connect both meshes     ConnectivityClean->Patch    --
         Stretch(  bbGetInputPatch(), connectivityClean->GetOutput()  );
+        //step 6.1.  -- connect both meshes     Patch->ConnectivityClean    --
+        Stretch( connectivityClean->GetOutput() , bbGetInputPatch() );
 
      /*
         //step 6.1.  -- connect both meshes     Patch->ConnectivityClean    --
@@ -369,27 +369,26 @@ printf("\n EED CleanMeshWithPatch::Process  sizeArrayIds2=%ld \n", sizeArrayIds2
         append2Clean->SetInputData( append2->GetOutput() );
         append2Clean->Update();
         
-//        vtkTriangleFilter *triangles = vtkTriangleFilter::New();
-//        triangles->SetInputData( append2Clean->GetOutput() );
-//        triangles->Update();
+        vtkTriangleFilter *triangles = vtkTriangleFilter::New();
+        triangles->SetInputData( append2Clean->GetOutput() );
+        triangles->Update();
 //        bbSetOutputOut( triangles->GetOutput() );
-
         
         //step 8.  -- Clean  --
 
         vtkPolyDataNormals *normals =vtkPolyDataNormals::New();
-  //      normals->SetInputConnection( triangles->GetOutputPort() );
+        normals->SetInputConnection( triangles->GetOutputPort() );
        normals->SetInputConnection( append2Clean->GetOutputPort() );
         normals->ConsistencyOn();
         normals->SplittingOff();
         normals->Update();
-       bbSetOutputOut( normals->GetOutput() );
+//       bbSetOutputOut( normals->GetOutput() );
 
-//        vtkFillHolesFilter *fillHoles = vtkFillHolesFilter::New();
-//        fillHoles->SetInputData( normals->GetOutput() );
-//        fillHoles->SetHoleSize(1000);
-//        fillHoles->Update();
-//        bbSetOutputOut( fillHoles->GetOutput() );
+        vtkFillHolesFilter *fillHoles = vtkFillHolesFilter::New();
+        fillHoles->SetInputData( normals->GetOutput() );
+        fillHoles->SetHoleSize(1000);
+        fillHoles->Update();
+        bbSetOutputOut( fillHoles->GetOutput() );
         
         
         /*
@@ -451,9 +450,35 @@ void CleanMeshWithPatch::Stretch(vtkPolyData *newMesh, vtkPolyData *patchMesh)
     long int iIds,sizeArrayIds    = edges->GetOutput()->GetNumberOfPoints();
     
     
-//    vtkPolyData             *newMesh        = connectivityClean->GetOutput();
+//EED2
+    vtkIdFilter *idFilter2 = vtkIdFilter::New();
+    idFilter2->SetInputData( newMesh );
+    //idFilter2->SetIdsArrayName("ids");
+    //idFilter2->SetCellIdsArrayName("ids");
+    idFilter2->SetPointIdsArrayName("ids");
+    idFilter2->SetPointIds(true);
+    idFilter2->SetCellIds(false);
+//# Available for vtk>=8.3:
+//           #idFilter2.SetPointIdsArrayName(arrayName)
+//           #idFilter2.SetCellIdsArrayName(arrayName)
+    idFilter2->Update();
+    vtkFeatureEdges *edges2 = vtkFeatureEdges::New();
+    edges2->SetInputData( idFilter2->GetOutput() );
+    edges2->BoundaryEdgesOn();
+    edges2->ManifoldEdgesOff();
+    edges2->NonManifoldEdgesOff();
+    edges2->FeatureEdgesOff();
+    edges2->Update();
+    vtkIdTypeArray* arrayIds2       = vtkIdTypeArray::SafeDownCast(edges2->GetOutput()->GetPointData()->GetArray("ids"));
+    long int iIds2,sizeArrayIds2    = edges2->GetOutput()->GetNumberOfPoints();
+    
+
+    
+    
     vtkStaticPointLocator   *pointLocator2  = vtkStaticPointLocator::New();
-    pointLocator2->SetDataSet( newMesh );
+//EED2    pointLocator2->SetDataSet( newMesh );
+    pointLocator2->SetDataSet( edges2->GetOutput() );
+
     pointLocator2->BuildLocator();
     vtkPoints *pointsPatch    = patchMesh->GetPoints();
     vtkPoints *pointsNewMesh  = newMesh->GetPoints();
@@ -462,7 +487,11 @@ void CleanMeshWithPatch::Stretch(vtkPolyData *newMesh, vtkPolyData *patchMesh)
     for (iIds=0; iIds<sizeArrayIds ; iIds++ )
     {
         pointsPatch->GetPoint( arrayIds->GetValue(iIds) , pP );
-        idNewMesh = pointLocator2->FindClosestPoint(pP);
+        
+//EED2        idNewMesh =   pointLocator2->FindClosestPoint(pP);
+        iIds2 =    pointLocator2->FindClosestPoint(pP);
+        idNewMesh = arrayIds2->GetValue(iIds2);
+        
         pointsNewMesh->GetPoint( idNewMesh , pPP );
         pointsPatch->SetPoint( arrayIds->GetValue(iIds) , pPP );
     } // for iIds