https://medium.com/@jsdbroughton/not-as-recursive-as-id-hoped-2f0fc2a30cc7
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
<header id="speckle-header"> | |
<div class="header-content active" data-banner-id="1"> | |
<a href="https://speckle.community/t/august-24-community-standup/12731?u=jonathon" class="link-container"> | |
<img src="https://speckle.community/uploads/default/original/2X/a/a6e2e76d1a8c6556c5bbaa1af9635dc628504fe7.gif" | |
alt="Signup for Augusts Community Standup" | |
class="link-image" /> | |
</a> | |
</div> | |
<div class="header-content" data-banner-id="2"> | |
<a href="https://speckle.community/t/speak-at-specklecon-2024-call-for-proposals-now-open/12550" class="link-container"> |
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
using System; | |
using System.Diagnostics; | |
namespace CASE.Navis2BCF | |
{ | |
/// <summary> | |
/// Conversion methods between an IFC | |
/// encoded GUID string and a .NET GUID. | |
/// This is a translation of the C code |
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
import { | |
ActionContext, | |
ActionTree, | |
GetterTree, | |
MutationTree, | |
Module, | |
Store as VuexStore, | |
CommitOptions, | |
DispatchOptions, | |
} from 'vuex' |
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
// tree is what is returned post shenanigans. | |
let tree:TreeItem[] = []; | |
// keyMap keeps track of the indexes where parentKeys are found in the keyed but flat array. | |
const keyMap:Map<string, number> = new Map(); | |
treeItemsWithBranches.forEach( ( node ):void => { | |
// nodes with no parents are at root level. | |
// this is not a binary tree, there can be several root level nodes. |
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
const parentItems:TreeItem[] = []; | |
parentKeys.forEach( ( v:string ):void=>{ | |
let parts = v.split( `-` ); | |
while ( uniqueIds.has( lastId ) ) { | |
lastId += 1; | |
} | |
uniqueIds.add( lastId ); | |
let name = parts.pop() || ``; | |
parentItems.push( { | |
id: lastId, |
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
const keyedItems = treeItems.map( ( item ): TreeItem => { | |
const fieldValues = fieldNames.map( ( field ): string => item.data && item.data[field] ); | |
let parentKey = fieldValues.slice( 0, -1 ).reduce( ( id, field ):string=>{ | |
if ( id && field ) { | |
id += `-` + field; | |
} | |
if ( !id && field ) { | |
id = field; | |
} | |
parentKeys.add( id ); |
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
const fieldNames = fieldTokens.map( ( field ): string => field.name ); | |
const parentKeys: Set<string> = new Set(); |
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
const fieldNames = fieldTokens.map( ( field ): string => field.name ); | |
const parentKeys: Set<string> = new Set(); |
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
const uniqueIds: Set<number> = new Set(); | |
let lastId = 1; | |
// All treeviewItems | |
treeItems.forEach( ( item ): void => { | |
if ( item && item.data ) { | |
uniqueIds.add( item.data.uniqueId ); | |
lastId += 1; | |
} | |
}); |
NewerOlder