Skip to content

Commit 19bb2c5

Browse files
committed
try load data
1 parent 22f0d95 commit 19bb2c5

File tree

2 files changed

+3267
-0
lines changed

2 files changed

+3267
-0
lines changed

content/compas_dem_crossvault.ipynb

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"%%capture\n",
10+
"%pip install jsonschema networkx numpy scipy pythreejs\n",
11+
"%pip install compas>=2.8 --no-deps\n",
12+
"%pip install compas_notebook>=0.8.2 --no-deps\n",
13+
"%pip install compas_model --no-deps\n",
14+
"%pip install compas_dem --no-deps"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {},
20+
"source": [
21+
"# DEM of a Cross Vault"
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"metadata": {},
27+
"source": [
28+
"## Block Data"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 1,
34+
"metadata": {},
35+
"outputs": [],
36+
"source": [
37+
"import pathlib\n",
38+
"\n",
39+
"from compas.files import OBJ\n",
40+
"\n",
41+
"FILE = pathlib.Path.cwd() / \"data\" / \"crossvault.obj\"\n",
42+
"\n",
43+
"obj = OBJ(FILE)\n",
44+
"obj.read()"
45+
]
46+
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {},
50+
"source": [
51+
"## Block Meshes"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": 2,
57+
"metadata": {},
58+
"outputs": [],
59+
"source": [
60+
"from compas.datastructures import Mesh\n",
61+
"\n",
62+
"meshes = []\n",
63+
"for name in obj.objects:\n",
64+
" vertices, faces = obj.objects[name]\n",
65+
" mesh: Mesh = Mesh.from_vertices_and_faces(vertices, faces)\n",
66+
" mesh.scale(0.025, 0.025, 0.025)\n",
67+
" mesh.name = name\n",
68+
" meshes.append(mesh)"
69+
]
70+
},
71+
{
72+
"cell_type": "markdown",
73+
"metadata": {},
74+
"source": [
75+
"## Block Model"
76+
]
77+
},
78+
{
79+
"cell_type": "code",
80+
"execution_count": 3,
81+
"metadata": {},
82+
"outputs": [],
83+
"source": [
84+
"from compas_dem.models import BlockModel\n",
85+
"\n",
86+
"model = BlockModel.from_boxes(meshes)"
87+
]
88+
},
89+
{
90+
"cell_type": "markdown",
91+
"metadata": {},
92+
"source": [
93+
"## Contacts"
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": 4,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"# model.compute_contacts(tolerance=1e-3, minimum_area=1e-2)"
103+
]
104+
},
105+
{
106+
"cell_type": "markdown",
107+
"metadata": {},
108+
"source": [
109+
"## Supports"
110+
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": 5,
115+
"metadata": {},
116+
"outputs": [],
117+
"source": [
118+
"from compas_dem.elements import BlockElement\n",
119+
"\n",
120+
"element: BlockElement\n",
121+
"\n",
122+
"for element in model.elements():\n",
123+
" if model.graph.degree(element.graphnode) == 1:\n",
124+
" element.is_support = True"
125+
]
126+
},
127+
{
128+
"cell_type": "markdown",
129+
"metadata": {},
130+
"source": [
131+
"## Visualisation"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": 7,
137+
"metadata": {},
138+
"outputs": [
139+
{
140+
"data": {
141+
"application/vnd.jupyter.widget-view+json": {
142+
"model_id": "a3ed37df12a641b797702057f23d25db",
143+
"version_major": 2,
144+
"version_minor": 0
145+
},
146+
"text/plain": [
147+
"VBox(children=(HBox(children=(Button(icon='search-plus', layout=Layout(height='32px', width='48px'), style=But…"
148+
]
149+
},
150+
"metadata": {},
151+
"output_type": "display_data"
152+
}
153+
],
154+
"source": [
155+
"from compas_notebook import Viewer\n",
156+
"from compas_notebook.config import Config\n",
157+
"\n",
158+
"config = Config()\n",
159+
"config.view.camera.position = [0, -13, 3]\n",
160+
"config.view.camera.target = [0, 0, 3]\n",
161+
"\n",
162+
"viewer = Viewer(config=config)\n",
163+
"viewer.scene.add(model)\n",
164+
"viewer.show()"
165+
]
166+
}
167+
],
168+
"metadata": {
169+
"kernelspec": {
170+
"display_name": "masonry",
171+
"language": "python",
172+
"name": "python3"
173+
},
174+
"language_info": {
175+
"codemirror_mode": {
176+
"name": "ipython",
177+
"version": 3
178+
},
179+
"file_extension": ".py",
180+
"mimetype": "text/x-python",
181+
"name": "python",
182+
"nbconvert_exporter": "python",
183+
"pygments_lexer": "ipython3",
184+
"version": "3.10.14"
185+
}
186+
},
187+
"nbformat": 4,
188+
"nbformat_minor": 2
189+
}

0 commit comments

Comments
 (0)