From 1ad352e42f40bc957c63cd82224ae319df33ca25 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 12 Jul 2023 19:55:35 +0200 Subject: [PATCH] #3513 CleanMeshWithPatch --- .../src/bbcreaVtkCleanMeshWithPatch.cxx | 63 ++++++++++++++----- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkCleanMeshWithPatch.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanMeshWithPatch.cxx index 222c00e..9fd42dc 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkCleanMeshWithPatch.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkCleanMeshWithPatch.cxx @@ -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; iIdsGetPoint( 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 -- 2.47.1