diff --git a/vespa/Algorithm/vtkCGALPolyDataAlgorithm.cxx b/vespa/Algorithm/vtkCGALPolyDataAlgorithm.cxx index dec3f9b2e3f7f6f3aafccd9c30dbe621c09894fa..72da29460694b40326111443161bb9614aac790d 100644 --- a/vespa/Algorithm/vtkCGALPolyDataAlgorithm.cxx +++ b/vespa/Algorithm/vtkCGALPolyDataAlgorithm.cxx @@ -49,9 +49,7 @@ bool vtkCGALPolyDataAlgorithm::toCGAL(vtkPolyData* vtkMesh, Vespa_soup* cgalMesh vtkIdList* ids = cit->GetPointIds(); vtkIdType nbIds = cit->GetNumberOfPoints(); - cgalMesh->faces[cid].reserve(3); // mostly triangles - - std::vector cell(nbIds); + cgalMesh->faces[cid].reserve(ids->GetNumberOfIds()); for (vtkIdType i = 0; i < nbIds; i++) { cgalMesh->faces[cid].emplace_back(ids->GetId(i)); diff --git a/vespa/PolygonMeshProcessing/Testing/TestPMPAlphaWrapping.cxx b/vespa/PolygonMeshProcessing/Testing/TestPMPAlphaWrapping.cxx index 40a816b77ff43bcf99b074b3505a5df08863c661..a89c224d8fceaedc301fcc591361b5f8220eb851 100644 --- a/vespa/PolygonMeshProcessing/Testing/TestPMPAlphaWrapping.cxx +++ b/vespa/PolygonMeshProcessing/Testing/TestPMPAlphaWrapping.cxx @@ -1,5 +1,4 @@ -#include - +#include #include #include #include @@ -16,15 +15,24 @@ int TestPMPAlphaWrapping(int, char* argv[]) cfname += "/dragon.vtp"; reader->SetFileName(cfname.c_str()); - // Remesh + // Remesh surface + vtkNew aw1; + aw1->SetInputConnection(reader->GetOutputPort()); + + // Remesh point cloud + vtkNew toPC; + toPC->SetInputConnection(aw1->GetOutputPort()); + toPC->SetCellGenerationMode(vtkConvertToPointCloud::VERTEX_CELLS); - vtkNew aw; - aw->SetInputConnection(reader->GetOutputPort()); + // Remesh point cloud + vtkNew aw2; + aw2->SetInputConnection(toPC->GetOutputPort()); + aw2->SetAlpha(2); // Save result vtkNew writer; - writer->SetInputConnection(aw->GetOutputPort()); + writer->SetInputConnection(aw2->GetOutputPort()); writer->SetFileName("alpha_wrapping.vtp"); writer->Write(); diff --git a/vespa/PolygonMeshProcessing/vtk.module b/vespa/PolygonMeshProcessing/vtk.module index 84ab51499a32c17362adac829a3ee702d11a4ccf..b66b03218c2bbcd43f5c90161586514e64c62c01 100644 --- a/vespa/PolygonMeshProcessing/vtk.module +++ b/vespa/PolygonMeshProcessing/vtk.module @@ -9,6 +9,7 @@ DEPENDS TEST_DEPENDS VTK::CommonSystem VTK::FiltersSources + VTK::FiltersPoints VTK::IOInfovis VTK::IOXML VTK::TestingCore diff --git a/vespa/PolygonMeshProcessing/vtkCGALAlphaWrapping.cxx b/vespa/PolygonMeshProcessing/vtkCGALAlphaWrapping.cxx index 54048efa7b56929f41513949253c3932d7afb769..4fcb341f29571cb35319e4991d5ee04aafe9c2ed 100644 --- a/vespa/PolygonMeshProcessing/vtkCGALAlphaWrapping.cxx +++ b/vespa/PolygonMeshProcessing/vtkCGALAlphaWrapping.cxx @@ -57,7 +57,6 @@ int vtkCGALAlphaWrapping::RequestData( // Create the surface mesh for CGAL // -------------------------------- - // TODO switch to soup ? (or shrink 1) std::unique_ptr cgalMesh = std::make_unique(); this->toCGAL(input, cgalMesh.get()); @@ -68,7 +67,24 @@ int vtkCGALAlphaWrapping::RequestData( try { - CGAL::alpha_wrap_3(cgalMesh->points, cgalMesh->faces, alpha, offset, cgalOutput->surface); + bool isPointCloud = true; + for (auto& cell : cgalMesh->faces) + { + if (cell.size() > 1) + { + isPointCloud = false; + } + } + + if (isPointCloud) + { + // Specific version when we have only points + CGAL::alpha_wrap_3(cgalMesh->points, alpha, offset, cgalOutput->surface); + } + else + { + CGAL::alpha_wrap_3(cgalMesh->points, cgalMesh->faces, alpha, offset, cgalOutput->surface); + } } catch (std::exception& e) {