# how to make sure the result of vtkMarchCube or vtkFlyingEdge3D is closed one, which has no boundary edges and non-manifold edges

**URL:** https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334
**Category:** Support
**Created:** [April 20, 2022, 11:13am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334 "2022-04-20T11:13:14Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![xianger.qi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xianger.qi](https://discourse.vtk.org/u/xianger.qi)
#### Post date: [April 20, 2022, 11:13am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334/1 "2022-04-20T11:13:14Z")

</div>

Hi Gays:  
operations below, how could i make sure the result of these operations is a closed mesh, which has no boundary edges and non-manifold edges.  
OPERATIONS:  
step 1: create a closed surface A, which has no boundary edges and non-manifold edges.  
step 2: use vtkImplicitPolyDataDistance, and vtkSampleFunction to sample a vtkImageData for surface A  
step 3: modify the vtkImageData sampled(difference, intersection, union with another surfaces or planes, and so on)  
step 4: extract the isosurface from vtkImageData modified with vtkMarchCube or vtkFlyingEdge3D.  
REQUIREMENT: isosurface has no boundary and non-manifold egdes, vtkSelectEnclosedPoints::IsSurfaceClosed(isosurface) == true.  
Is there anyone can help me?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [April 20, 2022, 11:30am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334/2 "2022-04-20T11:30:51Z")

</div>

Here’s one approach: Create the isosurface. Then execute vtkFeatureEdges (using the isosurface as input) with BoundaryEdgesOn, and NonManifoldEdgesOn; all other edge types off. If the output of vtkFeatureEdges is empty, then you are good to go.

---

<div class="post-metadata">

### Author: ![xianger.qi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xianger.qi](https://discourse.vtk.org/u/xianger.qi)
#### Post date: [April 20, 2022, 11:37am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334/3 "2022-04-20T11:37:06Z")

</div>

Thanks! I know the method to check whether the isosurface is good one, i want to know how to make the bad one being closed. Is there any general methods can use?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [April 20, 2022, 11:47am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334/4 "2022-04-20T11:47:22Z")

</div>

In general, I don’t know of a foolproof way to repair a non-closed surface. You can try things like building closed loops and triangulating them. But in general, these loops may not be planar, so the triangulation will likely fail. Another approach I’ve seen used somewhat successfully is to “shrink wrap” objects (see this old reference for [GDM](https://www.researchgate.net/publication/220720384_Geometrically_deformed_models_a_method_for_extracting_closed_geometric_models_form_volume_data)s). However these are numerically sensitive and slow. There are probably other approaches that I’m forgetting - this is a difficult problem.

---

<div class="post-metadata">

### Author: ![xianger.qi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/x/f14d63/32.png) [@xianger.qi](https://discourse.vtk.org/u/xianger.qi)
#### Post date: [April 20, 2022, 11:53am UTC](https://discourse.vtk.org/t/how-to-make-sure-the-result-of-vtkmarchcube-or-vtkflyingedge3d-is-closed-one-which-has-no-boundary-edges-and-non-manifold-edges/8334/5 "2022-04-20T11:53:03Z")

</div>

Thanks for your replying !
