Skip to content

Commit

Permalink
small changes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Mar 15, 2024
1 parent 0eb8cfe commit 3ec3c6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/examples/breps/brep_from_booleans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from compas.geometry import Box, Cylinder
from compas_view2.app import App

from compas.tolerance import TOL

TOL.lineardeflection = 0.1

R = 1.4
YZ = Frame.worldYZ()
ZX = Frame.worldZX()
Expand Down
5 changes: 5 additions & 0 deletions src/compas_occ/brep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def from_native(*args, **kwargs):
return OCCBrep.from_native(*args, **kwargs)


@plugin(category="factories", requires=["compas_occ"])
def from_planes(*args, **kwargs):
return OCCBrep.from_planes(*args, **kwargs)


@plugin(category="factories", requires=["compas_occ"])
def from_polygons(*args, **kwargs):
return OCCBrep.from_polygons(*args, **kwargs)
Expand Down
8 changes: 6 additions & 2 deletions src/compas_occ/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ def from_extrusion(
cls,
profile: Union[OCCBrepEdge, OCCBrepFace],
vector: Vector,
cap_ends: bool = False,
) -> "OCCBrep":
"""
Construct a BRep by extruding a closed curve along a direction vector.
Expand All @@ -736,6 +737,9 @@ def from_extrusion(
"""
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism

if cap_ends:
raise NotImplementedError

brep = cls()
brep.native_brep = BRepPrimAPI_MakePrism(
profile.occ_shape,
Expand Down Expand Up @@ -1436,7 +1440,7 @@ def trim(self, plane: compas.geometry.Plane) -> None:
"""
from compas_occ.occ import split_shapes
from compas_occ.occ import compute_shape_centreofmass
from compas.geometry import is_point_infrontof_plane
from compas.geometry import is_point_behind_plane

if isinstance(plane, Frame):
plane = Plane.from_frame(plane)
Expand All @@ -1448,7 +1452,7 @@ def trim(self, plane: compas.geometry.Plane) -> None:
occ_shape = None
for test in results:
point = compute_shape_centreofmass(test)
if is_point_infrontof_plane(point, plane):
if is_point_behind_plane(point, plane):
occ_shape = test
break
if occ_shape:
Expand Down
10 changes: 5 additions & 5 deletions src/compas_occ/geometry/curves/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from .curve2d import OCCCurve2d # noqa : F401
from .curve import OCCCurve # noqa : F401
from .curve import OCCCurve
from .nurbs import OCCNurbsCurve

from compas.geometry import Curve
from compas.geometry import NurbsCurve
from compas.plugins import plugin


@plugin(category="factories", requires=["compas_occ"])
def new_curve(cls, *args, **kwargs):
return super(Curve, cls).__new__(cls)
curve = object.__new__(OCCCurve)
return curve


@plugin(category="factories", requires=["compas_occ"])
def new_nurbscurve(cls, *args, **kwargs):
return super(NurbsCurve, cls).__new__(cls)
curve = object.__new__(OCCNurbsCurve)
return curve


@plugin(category="factories", requires=["compas_occ"])
Expand Down

0 comments on commit 3ec3c6f

Please sign in to comment.