Skip to content

Commit

Permalink
fix intersection runtime warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed Aug 29, 2023
1 parent 5482119 commit ee25caf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from helpers.geometry import plane_params, project_mesh, to_3d
from scipy.spatial import distance_matrix
from sklearn.cluster import AgglomerativeClustering
from shapely import intersects, Polygon

def get_points_of_type(mesh, surface_type):
"""Returns the points that belong to the given surface type"""
Expand Down Expand Up @@ -219,7 +220,7 @@ def groupby(a, clusterids):
return labels, n_clusters

def intersect_surfaces(meshes, onlywalls=True):
"""Return the intersection between the surfaces of multiple meshes"""
"""Return the intersection between the surfaces of multiple meshes. Note first mesh is the one we are computing the surfaces for, following ones are neighbors"""

def get_area_from_ring(areas, area, geom, normal, origin, subtract=False):
pts = to_3d(geom.coords, normal, origin)
Expand Down Expand Up @@ -274,11 +275,13 @@ def get_area_from_polygon(areas, geom, normal, origin):
polys = [project_mesh(msurface, normal, origin) for msurface in msurfaces]

# Intersect the 2D polygons
inter = polys[0]
inter = Polygon()
poly_0 = polys[0]
for i in range(1, len(polys)):
inter = inter.intersection(polys[i])
if intersects(poly_0, polys[i]):
inter = inter.union(poly_0.intersection(polys[i]))

if len(polys) > 2:
if len(polys) != 2:
print(len(polys))

if inter.area > 0.001:
Expand Down

0 comments on commit ee25caf

Please sign in to comment.