Repository: pyvista/pyvista

Issue:
Boolean Operation freezes/crashes 
### Describe the bug, what's wrong, and what you expected.

Apparently, if two polyData have the exact same shape, their boolean operation freezes/crashes the application!


### Steps to reproduce the bug.

```python
p1 = pv.Sphere().triangulate()
p2 = pv.Sphere().triangulate()

p1.boolean_intersection(p2)
``````

### System Information

```shell
--------------------------------------------------------------------------------
  Date: Tue Aug 22 12:17:01 2023 EEST

                OS : Darwin
            CPU(s) : 12
           Machine : x86_64
      Architecture : 64bit
               RAM : 16.0 GiB
       Environment : Jupyter
       File system : apfs
        GPU Vendor : ATI Technologies Inc.
      GPU Renderer : AMD Radeon Pro 5300M OpenGL Engine
       GPU Version : 4.1 ATI-4.14.1
  MathText Support : False

  Python 3.10.11 (v3.10.11:7d4cc5aa85, Apr  4 2023, 19:05:19) [Clang 13.0.0
  (clang-1300.0.29.30)]

           pyvista : 0.41.1
               vtk : 9.2.6
             numpy : 1.24.2
        matplotlib : 3.7.1
            scooby : 0.7.2
             pooch : v1.7.0
           IPython : 8.14.0
             scipy : 1.10.1
        jupyterlab : 4.0.5
      nest_asyncio : 1.5.7
--------------------------------------------------------------------------------
```


### Screenshots

_No response_


Discussion:

Patch:
diff --git a/pyvista/core/filters/poly_data.py b/pyvista/core/filters/poly_data.py
--- a/pyvista/core/filters/poly_data.py
+++ b/pyvista/core/filters/poly_data.py
@@ -81,6 +81,11 @@ def edge_mask(self, angle, progress_bar=False):
 
     def _boolean(self, btype, other_mesh, tolerance, progress_bar=False):
         """Perform boolean operation."""
+        if self.n_points == other_mesh.n_points:
+            if np.allclose(self.points, other_mesh.points):
+                raise ValueError(
+                    "The input mesh contains identical points to the surface being operated on. Unable to perform boolean operations on an identical surface."
+                )
         if not isinstance(other_mesh, pyvista.PolyData):
             raise TypeError("Input mesh must be PolyData.")
         if not self.is_all_triangles or not other_mesh.is_all_triangles:


Test patch:
diff --git a/tests/core/test_polydata.py b/tests/core/test_polydata.py
--- a/tests/core/test_polydata.py
+++ b/tests/core/test_polydata.py
@@ -280,9 +280,9 @@ def test_boolean_difference(sphere, sphere_shifted):
     assert np.isclose(difference.volume, expected_volume, atol=1e-3)
 
 
-def test_boolean_difference_fail(plane):
+def test_boolean_difference_fail(plane, sphere):
     with pytest.raises(NotAllTrianglesError):
-        plane - plane
+        plane - sphere
 
 
 def test_subtract(sphere, sphere_shifted):
diff --git a/tests/core/test_polydata_filters.py b/tests/core/test_polydata_filters.py
--- a/tests/core/test_polydata_filters.py
+++ b/tests/core/test_polydata_filters.py
@@ -45,3 +45,8 @@ def test_boolean_intersect_edge_case():
 
     with pytest.warns(UserWarning, match='contained within another'):
         a.boolean_intersection(b)
+
+
+def test_identical_boolean(sphere):
+    with pytest.raises(ValueError, match='identical points'):
+        sphere.boolean_intersection(sphere.copy())