From bca4025d4fb375fbf07b431c16d1d3eb43301277 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Wed, 3 Jul 2024 13:33:32 +0200 Subject: [PATCH] small fixes --- CHANGELOG.md | 3 +++ src/compas_occ/brep/brep.py | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57dc7356..89c2aa68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Changed default precision of `compas_occ.brep.Brep.simplify`. +* Fixed bug due to import of `typing_extensions`. + ### Removed diff --git a/src/compas_occ/brep/brep.py b/src/compas_occ/brep/brep.py index 38465641..5e308914 100644 --- a/src/compas_occ/brep/brep.py +++ b/src/compas_occ/brep/brep.py @@ -14,6 +14,7 @@ from compas.geometry import Polyline from compas.geometry import Translation from compas.geometry import Vector +from compas.tolerance import TOL from OCC.Core import BOPAlgo from OCC.Core import BRep from OCC.Core import BRepAlgoAPI @@ -1261,7 +1262,7 @@ def heal(self): self.sew() self.fix() - def simplify(self, merge_edges=True, merge_faces=True, linear=0.001, angular=0.1): + def simplify(self, merge_edges=True, merge_faces=True, lineardeflection=None, angulardeflection=None): """Simplify the shape by merging colinear edges and coplanar faces. Parameters @@ -1270,6 +1271,10 @@ def simplify(self, merge_edges=True, merge_faces=True, linear=0.001, angular=0.1 Merge edges with the same underlying geometry. merge_faces : bool, optional Merge faces with the same underlying geometry. + lineardeflection : float, optional + Default is `compas.tolerance.Tolerance.lineardeflection`. + angulardeflection : float, optional + Default is `compas.tolerance.Tolerance.angulardeflection`. Returns ------- @@ -1278,9 +1283,13 @@ def simplify(self, merge_edges=True, merge_faces=True, linear=0.001, angular=0.1 """ if not merge_edges and not merge_faces: return + + lineardeflection = lineardeflection or TOL.lineardeflection + angulardeflection = angulardeflection or TOL.angulardeflection + simplifier = ShapeUpgrade.ShapeUpgrade_UnifySameDomain() - simplifier.SetLinearTolerance(linear) - simplifier.SetAngularTolerance(angular) + simplifier.SetLinearTolerance(lineardeflection) + simplifier.SetAngularTolerance(angulardeflection) simplifier.Initialize(self.native_brep, merge_edges, merge_faces) simplifier.Build() shape = simplifier.Shape()