diff --git a/docs/_images/example_brep_split.png b/docs/_images/example_brep_split.png new file mode 100644 index 000000000..4427665e0 Binary files /dev/null and b/docs/_images/example_brep_split.png differ diff --git a/docs/examples/brep_from_booleans.rst b/docs/examples/brep_from_booleans.rst index 8a443606f..67a0dd7c3 100644 --- a/docs/examples/brep_from_booleans.rst +++ b/docs/examples/brep_from_booleans.rst @@ -1,5 +1,5 @@ ******************************************************************************** -BRep Shape From Booleans +Brep Shape From Booleans ******************************************************************************** .. figure:: /_images/example_brep_from_booleans.png diff --git a/docs/examples/brep_from_mesh.rst b/docs/examples/brep_from_mesh.rst index 333db7374..38c83f055 100644 --- a/docs/examples/brep_from_mesh.rst +++ b/docs/examples/brep_from_mesh.rst @@ -1,5 +1,5 @@ ******************************************************************************** -BRep From Mesh +Brep From Mesh ******************************************************************************** .. figure:: /_images/example_brep_from_mesh.png diff --git a/docs/examples/brep_slice.py b/docs/examples/brep_slice.py new file mode 100644 index 000000000..a53559efe --- /dev/null +++ b/docs/examples/brep_slice.py @@ -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() diff --git a/docs/examples/brep_split.py b/docs/examples/brep_split.py new file mode 100644 index 000000000..84a59fbb1 --- /dev/null +++ b/docs/examples/brep_split.py @@ -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() diff --git a/docs/examples/brep_split.rst b/docs/examples/brep_split.rst new file mode 100644 index 000000000..dfb3a7a66 --- /dev/null +++ b/docs/examples/brep_split.rst @@ -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 diff --git a/docs/examples/brep_trim.py b/docs/examples/brep_trim.py new file mode 100644 index 000000000..a97827ffd --- /dev/null +++ b/docs/examples/brep_trim.py @@ -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() diff --git a/docs/examples/brepface_with_hole.rst b/docs/examples/brepface_with_hole.rst index e48657763..f591e1b96 100644 --- a/docs/examples/brepface_with_hole.rst +++ b/docs/examples/brepface_with_hole.rst @@ -1,5 +1,5 @@ ******************************************************************************** -BRepFace with Hole +BrepFace with Hole ******************************************************************************** .. figure:: /_images/example_brepface_with_hole.png diff --git a/docs/examples/brepface_with_holes.rst b/docs/examples/brepface_with_holes.rst index f54e69c84..8a8a7edfc 100644 --- a/docs/examples/brepface_with_holes.rst +++ b/docs/examples/brepface_with_holes.rst @@ -1,5 +1,5 @@ ******************************************************************************** -BRepFace with Holes +BrepFace with Holes ******************************************************************************** .. figure:: /_images/example_brepface_with_holes.png