Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jul 3, 2024
1 parent 36395e9 commit bca4025
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
15 changes: 12 additions & 3 deletions src/compas_occ/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
-------
Expand All @@ -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()
Expand Down

0 comments on commit bca4025

Please sign in to comment.