Skip to content

Commit 878010e

Browse files
committed
add subd to docs
1 parent c0ab928 commit 878010e

File tree

7 files changed

+66
-28
lines changed

7 files changed

+66
-28
lines changed

docs/_images/cgal_subd.png

1.13 MB
Loading

docs/examples/subd.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from compas.geometry import Box, Polyhedron
2+
from compas.geometry import Translation
3+
from compas_cgal.subdivision import catmull_clark
4+
from compas_view2.app import App
5+
6+
# ==============================================================================
7+
# Input
8+
# ==============================================================================
9+
10+
box = Box.from_diagonal(([0, 0, 0], [1, 1, 1]))
11+
12+
V, F = box.to_vertices_and_faces()
13+
14+
VF2 = catmull_clark((V, F), 2)
15+
VF4 = catmull_clark((V, F), 4)
16+
VF6 = catmull_clark((V, F), 6)
17+
VF8 = catmull_clark((V, F), 8)
18+
19+
S2 = Polyhedron(*VF2)
20+
S4 = Polyhedron(*VF4)
21+
S6 = Polyhedron(*VF6)
22+
S8 = Polyhedron(*VF8)
23+
24+
S2.transform(Translation.from_vector([1, 0, 0]))
25+
S4.transform(Translation.from_vector([2, 0, 0]))
26+
S6.transform(Translation.from_vector([3, 0, 0]))
27+
S8.transform(Translation.from_vector([4, 0, 0]))
28+
29+
# ==============================================================================
30+
# Viz
31+
# ==============================================================================
32+
33+
viewer = App(width=1200, height=750)
34+
viewer.view.camera.tx = -2.5
35+
viewer.view.camera.ty = -1
36+
viewer.view.camera.rz = 0
37+
viewer.view.camera.distance = 5
38+
39+
viewer.add(box)
40+
viewer.add(S2)
41+
viewer.add(S4)
42+
viewer.add(S6)
43+
viewer.add(S8)
44+
viewer.show()

docs/examples/subd.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
********************************************************************************
2+
Subdivision with Catmull Clark
3+
********************************************************************************
4+
5+
.. figure:: /_images/cgal_subd.png
6+
:figclass: figure
7+
:class: figure-img img-fluid
8+
9+
10+
.. literalinclude:: subd.py
11+
:language: python

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ m2r
1313
nbsphinx
1414
pydocstyle
1515
pytest >=3.2
16-
sphinx_compas_theme >=0.15
16+
sphinx_compas_theme >=0.15.11
1717
sphinx >=3.4
1818
twine
1919
wheel

scripts/subd.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/compas_cgal/booleans.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def _boolean(A, B, operation):
1717
1818
Returns
1919
-------
20-
NDArray[(Any, 3) np.float64]
20+
NDArray[(Any, 3), np.float64]
2121
The vertices of the boolean mesh.
22-
NDArray[(Any, 3) np.int32]
22+
NDArray[(Any, 3), np.int32]
2323
The faces of the boolean mesh.
2424
2525
Raises
@@ -62,9 +62,9 @@ def boolean_union(A, B):
6262
6363
Returns
6464
-------
65-
NDArray[(Any, 3) np.float64]
65+
NDArray[(Any, 3), np.float64]
6666
The vertices of the boolean mesh.
67-
NDArray[(Any, 3) np.int32]
67+
NDArray[(Any, 3), np.int32]
6868
The faces of the boolean mesh.
6969
7070
"""
@@ -86,9 +86,9 @@ def boolean_difference(A, B):
8686
8787
Returns
8888
-------
89-
NDArray[(Any, 3) np.float64]
89+
NDArray[(Any, 3), np.float64]
9090
The vertices of the boolean mesh.
91-
NDArray[(Any, 3) np.int32]
91+
NDArray[(Any, 3), np.int32]
9292
The faces of the boolean mesh.
9393
9494
"""
@@ -110,9 +110,9 @@ def boolean_intersection(A, B):
110110
111111
Returns
112112
-------
113-
NDArray[(Any, 3) np.float64]
113+
NDArray[(Any, 3), np.float64]
114114
The vertices of the boolean mesh.
115-
NDArray[(Any, 3) np.int32]
115+
NDArray[(Any, 3), np.int32]
116116
The faces of the boolean mesh.
117117
118118
"""

src/compas_cgal/subdivision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def catmull_clark(mesh, k=1):
1414
1515
Returns
1616
-------
17-
NDArray[(Any, 3) np.float64]
17+
NDArray[(Any, 3), np.float64]
1818
The vertices of the subdivided mesh.
19-
NDArray[(Any, 4) np.int32]
19+
NDArray[(Any, 4), np.int32]
2020
The faces of the subdivided mesh.
2121
2222
"""

0 commit comments

Comments
 (0)