@@ -20,11 +20,14 @@ export function getChildByName(root: ComposedObject, childName, skip=0) {
20
20
fragments . shift ( ) ;
21
21
}
22
22
let start : ComposedObject | undefined = root ;
23
- while ( fragments . length && start ) {
23
+ while ( fragments . length && start && start . children ) {
24
+ console . log ( start , fragments [ 0 ] ) ;
24
25
let f = fragments . shift ( ) ;
25
- start = root . children ! . find ( i => i . name . split ( '/' ) . reverse ( ) [ 0 ] === f ) ;
26
+ start = start . children ! . find ( i => i . name . split ( '/' ) . reverse ( ) [ 0 ] === f ) ;
27
+ }
28
+ if ( fragments . length == 0 ) {
29
+ return start ;
26
30
}
27
- return start ;
28
31
}
29
32
30
33
export function compose ( datas : Ifc5FileJson [ ] ) {
@@ -220,15 +223,13 @@ export function compose(datas: Ifc5FileJson[]) {
220
223
}
221
224
} ;
222
225
223
- console . log ( compositionEdgesUnique ) ;
224
-
225
226
// Essentially we do an 'interactive' topological sort. Where we process the composition edges for
226
227
// those prims that do not have any dependencies left. However, as a consequence of composition,
227
228
// novel prim paths can also be formed which can resolve the dependencies for other prims.
228
229
let maxIterations = 100 ;
229
230
while ( maxIterations -- ) {
230
231
const bottomRankNodes = Object . entries ( compositionEdgesUnique ) . filter ( ( [ _ , dep ] ) => dep . size === 0 && ( composed [ _ ] || built . has ( _ ) || _ . endsWith ( ' complete' ) ) ) . map ( ( [ k , v ] ) => k ) ;
231
- console . log ( 'Bottom rank prims to resolve:' , ...bottomRankNodes ) ;
232
+ // console.log('Bottom rank prims to resolve:', ...bottomRankNodes);
232
233
233
234
if ( bottomRankNodes . length === 0 ) {
234
235
break ;
@@ -243,7 +244,7 @@ export function compose(datas: Ifc5FileJson[]) {
243
244
// (An array does not really function as a tuple). So we need to reverse engineer
244
245
// the type of the edge (and therefore what composition action to apply) based on
245
246
// the names of the vertices.
246
- console . log ( 'Processing edge:' , k , ' --- ' , v ) ;
247
+ // console.log('Processing edge:', k, ' --- ', v);
247
248
if ( k . endsWith ( ' complete' ) && v . endsWith ( ' over' ) ) {
248
249
// Only for life cycle dependency management, no action associated
249
250
} else if ( v . startsWith ( k + '/' ) ) {
@@ -307,7 +308,7 @@ export function compose(datas: Ifc5FileJson[]) {
307
308
} ) ;
308
309
} ) ;
309
310
310
- console . log ( 'Constructed prims:' , ...definedPrims ) ;
311
+ // console.log('Constructed prims:', ...definedPrims);
311
312
312
313
Array . from ( definedPrims ) . forEach ( a => built . add ( a ) ) ;
313
314
@@ -323,6 +324,6 @@ export function compose(datas: Ifc5FileJson[]) {
323
324
console . error ( "Unresolved nodes:" , ...Object . keys ( compositionEdgesUnique ) ) ;
324
325
}
325
326
326
- console . log ( composed [ '' ] ) ;
327
+ // console.log(composed['']);
327
328
return composed [ '' ] ;
328
329
}
0 commit comments