Skip to content

Commit

Permalink
update brep examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Nov 7, 2023
1 parent 9eb4e07 commit 90122ff
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 4 deletions.
Binary file added docs/_images/example_brep_split.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/examples/brep_from_booleans.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
********************************************************************************
BRep Shape From Booleans
Brep Shape From Booleans
********************************************************************************

.. figure:: /_images/example_brep_from_booleans.png
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/brep_from_mesh.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
********************************************************************************
BRep From Mesh
Brep From Mesh
********************************************************************************

.. figure:: /_images/example_brep_from_mesh.png
Expand Down
20 changes: 20 additions & 0 deletions docs/examples/brep_slice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# type: ignore

from math import radians
from compas.geometry import Box
from compas.geometry import Plane
from compas.geometry import Rotation
from compas_view2.app import App

box = Box.from_width_height_depth(1, 1, 1).to_brep()

plane = Plane.worldXY()
R = Rotation.from_axis_and_angle([0, 1, 0], radians(30))

plane.transform(R)

slice = box.slice(plane)

viewer = App()
viewer.add(slice, linewidth=2)
viewer.show()
40 changes: 40 additions & 0 deletions docs/examples/brep_split.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# type: ignore

from math import radians
from compas.geometry import Box, Plane, Rotation
from compas.geometry import is_point_infront_plane
from compas.colors import Color
from compas_occ.brep import OCCBrep as Brep
from compas_view2.app import App

box = Box.from_width_height_depth(1, 1, 1).to_brep()

R = Rotation.from_axis_and_angle([0, 1, 0], radians(30))
plane = Plane.worldXY()
plane.transform(R)

result = box.split(Brep.from_planes([plane]))

viewer = App()
viewer.view.camera.position = [2, -4, 1]
viewer.view.camera.look_at([0, 0, 0])

viewer.add(plane, linewidth=2, opacity=0.3)

for brep in result:
if is_point_infront_plane(brep.centroid, plane):
viewer.add(
brep,
facecolor=Color.red().lightened(50),
linecolor=Color.red(),
linewidth=2,
)
else:
viewer.add(
brep,
facecolor=Color.blue().lightened(50),
linecolor=Color.blue(),
linewidth=2,
)

viewer.show()
11 changes: 11 additions & 0 deletions docs/examples/brep_split.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
********************************************************************************
Split a Brep Shape With a Plane
********************************************************************************

.. figure:: /_images/example_brep_split.png
:figclass: figure
:class: figure-img img-fluid


.. literalinclude:: brep_split.py
:language: python
19 changes: 19 additions & 0 deletions docs/examples/brep_trim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# type: ignore

from math import radians
from compas.geometry import Box
from compas.geometry import Plane
from compas.geometry import Rotation
from compas_view2.app import App

box = Box.from_width_height_depth(1, 1, 1).to_brep()

R = Rotation.from_axis_and_angle([0, 1, 0], radians(30))
plane = Plane.worldXY()
plane.transform(R)

box.trim(plane)

viewer = App()
viewer.add(box, linewidth=2)
viewer.show()
2 changes: 1 addition & 1 deletion docs/examples/brepface_with_hole.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
********************************************************************************
BRepFace with Hole
BrepFace with Hole
********************************************************************************

.. figure:: /_images/example_brepface_with_hole.png
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/brepface_with_holes.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
********************************************************************************
BRepFace with Holes
BrepFace with Holes
********************************************************************************

.. figure:: /_images/example_brepface_with_holes.png
Expand Down

0 comments on commit 90122ff

Please sign in to comment.