-
Notifications
You must be signed in to change notification settings - Fork 1
/
20220125_IFCjs_vs_LBD.html
464 lines (358 loc) · 13.6 KB
/
20220125_IFCjs_vs_LBD.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>LBD meetis IFC.js</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/white.css">
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<!-- Custom styles -->
<style>
.two-col{
display: flex;
height: 100vh;
}
.col{
flex: 1;
padding: 50px;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>Linked Building Data meets IFC.js</h2>
</section>
<section>
<h2>About us</h2>
<div style="display: flex; height: 40vh">
<div class="col">
<p>Antonio González Viegas</p>
</div>
<div class="col">
<img src="static/images/ansoni.jpeg">
</div>
</div>
<div style="display: flex;; height: 40vh">
<div class="col">
<p>Mads Holten Rasmussen</p>
</div>
<div class="col">
<img src="static/images/mhra.jpeg">
</div>
</div>
</section>
<!-- Intro to IFC.js -->
<section>
<section>
<h2>IFC.js</h2>
<p>An open source library for IFC on the web</p>
</section>
<section>
<h2>Why?</h2>
<p class="fragment fade-out">BIM is hard, thus only the big players can compete in equal terms.</p>
<p class="fragment fade-in" style="margin-top: -8rem" > 👨💼👨💼👨💼 Consequences of an oligopoly: expensive software that does not meet many of the needs of users and businesses.</p>
</section>
<section>
<h2>Concept</h2>
<p>Anyone can create a videogame for free in some hours.</p>
<p>🌱 What if we could make a BIM tool in an afternoon and completely free?</p>
</section>
<!-- Example 1: web ifc viewer -->
<section>
<p>How it works</p>
<pre><code class="hljs javascript" data-line-numbers="|1|3-5|7-9|11-21">import { IfcViewerAPI } from 'web-ifc-viewer';
// Initialize IFC.js
const container = document.getElementById('viewer-container');
const viewer = new IfcViewerAPI({ container });
// Add scene elements
viewer.addAxes();
viewer.addGrid();
// Set up input element
const input = document.getElementById("file-input");
input.addEventListener("change",
async (changed) => {
const file = changed.target.files[0];
const ifcURL = URL.createObjectURL(file);
viewer.IFC.loadIfcUrl(ifcURL);
},
false
);
</code></pre>
</section>
<section data-background-iframe="https://github1s.com/agviegas/BIMrras-IFCjs-course/tree/main/Module%205%20-%20IFCjs/exercise%202" data-background-interactive>
</section>
<section data-background-iframe="https://ifcjs.github.io/web-ifc-viewer/example/index" data-background-interactive>
<div style="height: 80vh; display: flex; justify-content: center; align-items: flex-start">
<p>Example 1: How it works</p>
</div>
</section>
<!-- Documentation -->
<section data-background-iframe="https://ifcjs.github.io/info/" data-background-interactive>
</section>
<!-- Example 2: twitter -->
<section>
<p>Example 2: Making a BIM tool inside Twitter</p>
<div style="display: flex; justify-content: center">
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Everyone is prejudiced, including me. For example, if you talk to me about how your BIM processes implement Big data or AI, I'm not likely to take you very seriously anymore.</p>— ansoni (@agviegasBIM) <a href="https://twitter.com/agviegasBIM/status/1441548986028986377?ref_src=twsrc%5Etfw">September 24, 2021</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</section>
<!-- Example 3: city lite -->
<section data-background-iframe="https://github1s.com/Parametricos/CityLite" data-background-interactive>
<div style="color: white; height: 80vh; display: flex; justify-content: center; align-items: flex-start">
<div style=" padding: 1rem; background: rgba(80,80,80,0.7)">
<p>Example 3: BIM + GIS in 48 hours</p>
</div>
</div>
</section>
<section data-background-iframe="https://parametricos-cassini-hackathon.vercel.app/" data-background-interactive>
</section>
<!-- Example 4: desktop app -->
<section>
<h4>Example 4: desktop application</h4>
</section>
<!-- Open collective -->
<section>
<div style="margin-top: 3rem">
<h4>Sustainability</h4>
<script src="https://opencollective.com/ifcjs/banner.js"></script>
</div>
</section>
</section>
<!-- Intro to IFC-LBD -->
<section>
<section>
<h2>IFC-LBD</h2>
<p>An open source converter built in IFC.js</p>
</section>
<section>
<ul>
<li>Includes a CLI tool</li>
<li>Works with web-ifc-three <pre><code class="hljs javascript"> const rdf = await lbdParser.parseBOTTriples(ifcApi, modelID);</code></pre></li>
<li>Currently supports BOT, Products and FSO</li>
<li>Modular and easy to extend</li>
<li>Written in TypeScript</li>
</ul>
</section>
<section>
<h2>Use as a cli tool</h2>
<pre><code class="hljs bash">
npm install -g ifc-lbd
</code></pre>
</section>
<section>
<!-- Install from npm -->
<script id="asciicast-LBOJ5ttHS0QhMgbeHpPWpWfWS" src="https://asciinema.org/a/LBOJ5ttHS0QhMgbeHpPWpWfWS.js" async></script>
</section>
<section>
<!-- IFC-BOT with CLI tool -->
<script id="asciicast-UXK5g315KVl8UjVcvU0MSc71U" src="https://asciinema.org/a/UXK5g315KVl8UjVcvU0MSc71U.js" async></script>
</section>
<section>
<h2>Use it in an app</h2>
<pre><code class="hljs javascript" data-line-numbers="|12-14|16-19|21-24">
import * as WebIFC from "web-ifc/web-ifc-api.js";
import { LBDParser } from "ifc-lbd";
import * as path from 'path';
import { readFile } from "fs";
import * as util from "util";
const readFileAsync = util.promisify(readFile);
async function main(){
// Read file
const modelPath = path.join(__dirname, './Duplex.ifc');
const modelData = readFileAsync(modelPath);
// Init API and load model
const ifcApi = new WebIFC.IfcAPI();
await ifcApi.Init();
const modelID = ifcApi.OpenModel(ifcModelData);
// Init LBD Parser and parse BOT
const lbdParser = new LBDParser();
const botTriples = await lbdParser.parseBOTTriples(ifcApi, modelID);
console.log(botTriples);
// Close the model, all memory is freed
ifcApi.CloseModel(modelID);
}
main();
</code></pre>
</section>
</section>
<section>
<section>
<h2>Deeper look into the code</h2>
<h4>Path search helpers</h4>
<ul>
<li>buildRelOneToOne()</li>
<li>buildRelOneToMany()</li>
</ul>
</section>
<section>
<h2>buildRelOneToOne()</h2>
<p>For example: IFCRELSPACEBOUNDARY</p>
<pre><code class="hljs typescript" data-line-numbers>function buildRelOneToOne(
ifcAPI: WebIFC.IfcAPI, modelID: number = 0,
relationshipType: number, subjectRef: string,
targetRef: string, rdfRelationship: string,
includeInterface: boolean = false,
biderectional: boolean = false)</code></pre>
</section>
<section>
<h2>buildRelOneToOne()</h2>
<h4>space/element adjacency</h4>
<pre><code class="hljs typescript" data-line-numbers>private async buildSpaceAdjacentElementRelationships(){
const subjectRef = "RelatingSpace";
const targetRef = "RelatedBuildingElement";
const rdfRelationship = "bot:adjacentElement";
return await buildRelOneToOne(
this.ifcAPI, // API
this.modelID, // modelID
IFCRELSPACEBOUNDARY, // relationship type
subjectRef, // what rel is used to find subject of triple?
targetRef, // what rel is used to find object of triple?
rdfRelationship, // what's the predicate of the new triple?
true // Add triple in both directions?
);
}</code></pre>
</section>
<section>
<h2>buildRelOneToMany()</h2>
<p>For example: IFCRELCONTAINEDINSPATIALSTRUCTURE</p>
<pre><code class="hljs typescript" data-line-numbers>function buildRelOneToMany(
ifcAPI: WebIFC.IfcAPI, modelID: number = 0,
relationshipType: number, subjectRef: string,
targetRef: string, rdfRelationship: string,
subjectClassConstraint?: number,
targetClassConstraint?: number)</code></pre>
</section>
<section>
<h2>buildRelOneToOne()</h2>
<h4>space/element adjacency</h4>
<pre><code class="hljs typescript" data-line-numbers>private async buildSpaceContainedElementRelationships(){
const subjectRef = "RelatingStructure";
const targetRef = "RelatedElements";
const rdfRelationship = "bot:containsElement";
const subjectClass = IFCSPACE;
return await buildRelOneToMany(
this.ifcAPI, // API
this.modelID, // modelID
IFCRELCONTAINEDINSPATIALSTRUCTURE, // relationship type
subjectRef, // what rel is used to find subject of triples?
targetRef, // what rel is used to find objects of triples?
rdfRelationship, // what's the predicate of the new triple?
subjectClass // subjects must be of this type
);
}</code></pre>
</section>
</section>
<section>
<section>
<h2>Post-processing with N3 + Comunica</h2>
</section>
<section>
<p>FSO uses some pattern matches that require post-processing with SPARQL update queries</p>
</section>
<section>
<!-- IFC-FSO with CLI tool -->
<script id="asciicast-F6FcgJEDhqhT7xjZNVfMNkyyH" src="https://asciinema.org/a/F6FcgJEDhqhT7xjZNVfMNkyyH.js" async></script>
</section>
<section>
<ol>
<li>Load data into N3 store</li>
<li>Use Comunica to query the store</li>
<li>Serialize store content to file with N3 stream writer</li>
</ol>
</section>
<section>
<pre><code class="hljs typescript" data-line-numbers="|3-16|17">async function componentConections(): Promise<void>{
const query = `
PREFIX fso: <https://w3id.org/fso#>
INSERT{
?e1 fso:connectedWith ?e2 .
?e2 fso:connectedWith ?e1 .
?e1 fso:feedsFluidTo ?e2 .
?e2 fso:hasFluidFedBy ?e1
}
WHERE{
?e1 fso:connectedPort ?p1 .
?p1 fso:connectedPort ?p2 .
?p2 fso:connectedComponent ?e2 .
?p1 a fso:OutPort .
?p2 a fso:InPort .
}`;
await this.executeUpdateQuery(query);
}</code></pre>
</section>
<section>
<h4>Some queries use Extension Functions</h4>
<pre><code class="hljs typescript" data-line-numbers="|3,11">async function segmentLengths(): Promise<void>{
const query = `INSERT{
?seg ex:length ?d
}
WHERE{
?seg a fso:Segment ;
fso:connectedPort ?port1 , ?port2 .
FILTER(?port1 != ?port2)
?port1 omg:hasGeometry/fog::asSfa_v2-wkt ?p1 .
?port2 omg:hasGeometry/fog::asSfa_v2-wkt ?p2 .
BIND(geosf:distance(?p1, ?p2, 3) AS ?d)
}`;
await this.executeUpdateQuery(query);
}</code></pre>
</section>
<section>
<h4>Some queries use Extension Functions</h4>
<pre><code class="hljs typescript" data-line-numbers="|5-6|11-18|20|24-25">// GEOJSON
// geosf:distance(p1, p2, decimals)
'http://www.opengis.net/def/function/geosparql/distance'(args: RDF.Term[]) {
// Number of decimals? (default = 8)
const decimals = args[2] != undefined ? parseFloat(args[2].value) : 8;
// Make sure both args are literal values
if (args[0].termType === 'Literal' && args[1].termType === 'Literal') {
const p1 = parseWKT(args[0].value);
const p2 = parseWKT(args[1].value);
const a = p1[0] - p2[0];
const b = p1[1] - p2[1];
const c = p1[2] - p2[2];
const d: number = round(Math.sqrt(a * a + b * b + c * c), decimals);
return DF.literal(d.toString(), DF.namedNode('http://www.w3.org/2001/XMLSchema#decimal'));
}
// Just return literal "ERROR" if something fails
return DF.literal("ERROR");
}</code></pre>
</section>
</section>
<section>
<section data-background-iframe="https://ld-bim.web.app/viewer" data-background-interactive>
</section>
</section>
<section>
<section>
<h4>Please join the effort in further developing these open source projects!</h4>
<ul>
<li><a href="https://github.com/LBD-Hackers/IFC-LBD">IFC-LBD</a></li>
<li><a href="https://github.com/LBD-Hackers/comunica-geosparql">Comunica geoSPARQL</a></li>
</ul>
</section>
</section>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/4.1.2/reveal.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/4.1.2/plugin/notes/notes.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/4.1.2/plugin/markdown/markdown.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/4.1.2/plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
</script>
</body>
</html>