# Intersection of 3D mesh with polydata (return only intersecting mesh region)

**URL:** https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747
**Category:** Support
**Created:** [November 27, 2020, 2:59pm UTC](https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747 "2020-11-27T14:59:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kradan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kradan/32/2663_2.png) [@kradan](https://discourse.vtk.org/u/kradan)
#### Post date: [November 27, 2020, 2:59pm UTC](https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747/1 "2020-11-27T14:59:38Z")

</div>

Hi, I would appreciate your help with a problem related to finding object intersections. I have a vtkMesh (.vtk, a brain edema), and vtkPolyData (.vtk, diffusion MRI tractography streamlines), and I want to obtain only that part of the mesh, where the streamlines intersect it. I used the vtkBooleanOperationPolyDataFilter to get the region, but an error message kept appearing:

ERROR: In …/Common/DataModel/vtkPointLocator.cxx, line 866  
vtkPointLocator (0x564069cc68a0): No points to subdivide

Generic Warning: In …/Filters/General/vtkIntersectionPolyDataFilter.cxx, line 2516  
No Intersection between objects

ERROR: In …/Filters/General/vtkDistancePolyDataFilter.cxx, line 78  
vtkDistancePolyDataFilter (0x56406ba04530): No points/cells to operate on

ERROR: In …/Filters/General/vtkDistancePolyDataFilter.cxx, line 78  
vtkDistancePolyDataFilter (0x56406ba04530): No points/cells to operate on

As the next step, I tried running the streamlines through vtkTriangleFilter, and vtkCleanPolyData filters, but now I have the following problem:

Warning: In …/Filters/General/vtkIntersectionPolyDataFilter.cxx, line 1675  
vtkIntersectionPolyDataFilter (0x56406ffffb90): No cell with correct orientation found

ERROR: In …/Common/ExecutionModel/vtkExecutive.cxx, line 782  
vtkCompositeDataPipeline (0x564085a0d780): Algorithm vtkIntersectionPolyDataFilter(0x56406ffffb90) returned failure for request: vtkInformation (0x56406ca76a70)  
Debug: Off  
Modified Time: 5953808  
Reference Count: 1  
Registered Events: (none)  
Request: REQUEST\_DATA  
FROM\_OUTPUT\_PORT: 0  
ALGORITHM\_AFTER\_FORWARD: 1  
FORWARD\_DIRECTION: 0

ERROR: In …/Common/ExecutionModel/vtkExecutive.cxx, line 782  
vtkCompositeDataPipeline (0x56406ba48770): Algorithm vtkBooleanOperationPolyDataFilter(0x56406b9fc530) returned failure for request: vtkInformation (0x56406ba47e90)  
Debug: Off  
Modified Time: 5953564  
Reference Count: 1  
Registered Events: (none)  
Request: REQUEST\_DATA  
FROM\_OUTPUT\_PORT: 0  
ALGORITHM\_AFTER\_FORWARD: 1  
FORWARD\_DIRECTION: 0

Does anyone know which approach should be taken here? Thanks in advance for your tips.

---

<div class="post-metadata">

### Author: ![Ron84](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ron84/32/630_2.png) [@Ron84](https://discourse.vtk.org/u/Ron84)
#### Post date: [November 27, 2020, 5:01pm UTC](https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747/2 "2020-11-27T17:01:31Z")

</div>

Please provide your polydatas first.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 1, 2020, 3:31am UTC](https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747/3 "2020-12-01T03:31:20Z")

</div>

Boolean filters in VTK are known to have issues. They can randomly fail on valid inputs. [Search on this forum for “Boolean” to learn more](https://discourse.vtk.org/search?q=boolean).

I would not even recommend to try perform Boolean operations using Roemer’s VTK classes (which seem to be more robust than the built-in VTK meshes) because meshes that you get by segmenting medical images often contains error, which confuse even the most robust algorithms.

Instead, since you get your segments from image segmentation, the most common solution is to perform all Boolean operations on the binary labelmaps (before you convert them to meshes). You can use [Logical operators effect](https://slicer.readthedocs.io/en/latest/user_guide/modules/segmenteditor.html#logical-operators) in 3D Slicer’s Segment Editor module if you want to perform this interactively, using a convenient GUI (and you can access all segmentation tools from Python scripting, console, or Jupyter notebooks, too).

---

<div class="post-metadata">

### Author: ![kradan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kradan/32/2663_2.png) [@kradan](https://discourse.vtk.org/u/kradan)
#### Post date: [December 1, 2020, 7:13am UTC](https://discourse.vtk.org/t/intersection-of-3d-mesh-with-polydata-return-only-intersecting-mesh-region/4747/4 "2020-12-01T07:13:02Z")

</div>

Thanks a lot for your tips, Andras. Meanwhile I figured out a rather simplistic solution that maps streamlines to binary masks according to a NIfTI template, and then calculates intersection regions in NIfTI space using common diffusion MR image processing tools.
