From 4f57a70fb89b217cd91c847f1bdd7838dcfc422c Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Mon, 13 Nov 2023 13:57:13 -0800 Subject: [PATCH 1/2] fix(obj): Only write the mtllib reference when requested --- ladybug_geometry/interop/obj.py | 3 ++- tests/obj/two_material_cubes_edit.obj | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ladybug_geometry/interop/obj.py b/ladybug_geometry/interop/obj.py index 65f8e06b..72e1cfb5 100644 --- a/ladybug_geometry/interop/obj.py +++ b/ladybug_geometry/interop/obj.py @@ -372,7 +372,8 @@ def to_file(self, folder, name, triangulate_quads=False, include_mtl=False): # add material file name if include_mtl is true if self._material_structure is not None or include_mtl: - outfile.write('mtllib ' + mtl_file + '\n') + if include_mtl: + outfile.write('mtllib ' + mtl_file + '\n') if self._material_structure is None: outfile.write('usemtl diffuse_0\n') diff --git a/tests/obj/two_material_cubes_edit.obj b/tests/obj/two_material_cubes_edit.obj index 3286e0d5..0719aede 100644 --- a/tests/obj/two_material_cubes_edit.obj +++ b/tests/obj/two_material_cubes_edit.obj @@ -1,6 +1,5 @@ # Rhino -mtllib two_material_cubes.mtl v 10 0 -20 v 10 10 -20 v 10 0 -10 From 0fa4cafafea1c97b31209c767c4a65f181ea4fe4 Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Fri, 12 Jan 2024 11:43:34 -0800 Subject: [PATCH 2/2] fix(face): Snap hole polygons together before intersection --- ladybug_geometry/geometry3d/face.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ladybug_geometry/geometry3d/face.py b/ladybug_geometry/geometry3d/face.py index 7e473e41..31bb2a55 100644 --- a/ladybug_geometry/geometry3d/face.py +++ b/ladybug_geometry/geometry3d/face.py @@ -2037,10 +2037,22 @@ def coplanar_split(face1, face2, tolerance, angle_tolerance): # get BooleanPolygons of the two faces f1_polys = [(pb.BooleanPoint(pt.x, pt.y) for pt in f1_poly.vertices)] f2_polys = [(pb.BooleanPoint(pt.x, pt.y) for pt in s2_poly.vertices)] - if face1.has_holes: + if face1.has_holes and face2.has_holes: # snap corresponding holes together + f1h_polys = face1.hole_polygon2d + f2h_polys = [Polygon2D(tuple(prim_pl.xyz_to_xy(pt) for pt in h_pts)) + for h_pts in face2.holes] + for f1hp in f1h_polys: + for hi, f2hp in enumerate(f2h_polys): + if f1hp.center.distance_to_point(f2hp.center) < tolerance: + f2h_polys[hi] = f1hp.snap_to_polygon(f2hp, tolerance) + for hole in f1h_polys: + f1_polys.append((pb.BooleanPoint(pt.x, pt.y) for pt in hole.vertices)) + for hole in f2h_polys: + f2_polys.append((pb.BooleanPoint(pt.x, pt.y) for pt in hole.vertices)) + elif face1.has_holes: for hole in face1.hole_polygon2d: f1_polys.append((pb.BooleanPoint(pt.x, pt.y) for pt in hole.vertices)) - if face2.has_holes: + elif face2.has_holes: for hole in face2.holes: h_pt2d = (prim_pl.xyz_to_xy(pt) for pt in hole) f2_polys.append((pb.BooleanPoint(pt.x, pt.y) for pt in h_pt2d))