-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9eb4e07
commit 90122ff
Showing
9 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters