File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @thatopen/fragments" ,
3
3
"description" : " Simple geometric system built on top of Three.js to display 3D BIM data efficiently." ,
4
- "version" : " 2.3.0-alpha.5 " ,
4
+ "version" : " 2.3.0-alpha.6 " ,
5
5
"author" : " That Open Company" ,
6
6
"contributors" : [
7
7
" Antonio Gonzalez Viegas (https://github.com/agviegas)" ,
Original file line number Diff line number Diff line change
1
+ import { FragmentIdMap } from "./base-types" ;
2
+
3
+ export class FragmentUtils {
4
+ static combine ( maps : Iterable < FragmentIdMap > ) {
5
+ const result : FragmentIdMap = { } ;
6
+ for ( const map of maps ) {
7
+ for ( const fragID in map ) {
8
+ if ( ! result [ fragID ] ) {
9
+ result [ fragID ] = new Set < number > ( ) ;
10
+ }
11
+ for ( const expressID of map [ fragID ] ) {
12
+ result [ fragID ] . add ( expressID ) ;
13
+ }
14
+ }
15
+ }
16
+ return result ;
17
+ }
18
+
19
+ static export ( map : FragmentIdMap ) {
20
+ const serialized : { [ fragID : string ] : number [ ] } = { } ;
21
+ for ( const fragID in map ) {
22
+ serialized [ fragID ] = Array . from ( map [ fragID ] ) ;
23
+ }
24
+ return JSON . stringify ( serialized ) ;
25
+ }
26
+
27
+ static import ( serializedMap : string ) {
28
+ const serialized = JSON . parse ( serializedMap ) as {
29
+ [ fragID : string ] : number [ ] ;
30
+ } ;
31
+ const map : FragmentIdMap = { } ;
32
+ for ( const fragID in serialized ) {
33
+ map [ fragID ] = new Set ( serialized [ fragID ] ) ;
34
+ }
35
+ return map ;
36
+ }
37
+ }
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ export * from "./fragment-mesh";
6
6
export * from "./streamer-file-db" ;
7
7
export * from "./civil" ;
8
8
export * from "./stream-serializer" ;
9
+ export * from "./fragment-utils" ;
You can’t perform that action at this time.
0 commit comments