Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read alignments #14

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8,513 changes: 8,513 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

390 changes: 328 additions & 62 deletions resources/openbim-components.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/alignment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IifcAlignmentData } from "./base-types";

export class IfcAlignmentData implements IifcAlignmentData {
Coordinates: Float32Array = new Float32Array(0);
CurveLenght: number[] = [];
SegmentLenght: number[] = [];

exportData() {
const coordinates = this.Coordinates;
const curveLenght = this.CurveLenght;
const segmentLenght = this.SegmentLenght;
return { coordinates, curveLenght, segmentLenght };
}
}
6 changes: 6 additions & 0 deletions src/base-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ export interface IfcMetadata {
export interface FragmentMap {
[fragmentID: string]: Set<number>;
}

export interface IifcAlignmentData {
Coordinates: Float32Array;
CurveLenght: number[];
SegmentLenght: number[];
}
12 changes: 12 additions & 0 deletions src/flatbuffers/fragment.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace Fragments.index;

table FragmentsGroup {
items: [Fragment];
civil: Civil;
coordination_matrix: [float];
ids: [uint];
items_keys: [uint];
Expand Down Expand Up @@ -32,4 +33,15 @@ table Fragment {
composites: string;
}

table Civil {
alignmentHorizontal: [Alignment];
alignmentVertical: [Alignment];
}

table Alignment {
position: [float];
curve: [int];
segment: [int];
}

root_type FragmentsGroup;
2 changes: 2 additions & 0 deletions src/flatbuffers/fragments/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { Alignment } from './index/alignment.js';
export { Civil } from './index/civil.js';
export { Fragment } from './index/fragment.js';
export { FragmentsGroup } from './index/fragments-group.js';
147 changes: 147 additions & 0 deletions src/flatbuffers/fragments/index/alignment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

export class Alignment {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Alignment {
this.bb_pos = i;
this.bb = bb;
return this;
}

static getRootAsAlignment(bb:flatbuffers.ByteBuffer, obj?:Alignment):Alignment {
return (obj || new Alignment()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsAlignment(bb:flatbuffers.ByteBuffer, obj?:Alignment):Alignment {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Alignment()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

position(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readFloat32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0;
}

positionLength():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

positionArray():Float32Array|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? new Float32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}

curve(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0;
}

curveLength():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

curveArray():Int32Array|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? new Int32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}

segment(index: number):number|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0;
}

segmentLength():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

segmentArray():Int32Array|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? new Int32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
}

static startAlignment(builder:flatbuffers.Builder) {
builder.startObject(3);
}

static addPosition(builder:flatbuffers.Builder, positionOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, positionOffset, 0);
}

static createPositionVector(builder:flatbuffers.Builder, data:number[]|Float32Array):flatbuffers.Offset;
/**
* @deprecated This Uint8Array overload will be removed in the future.
*/
static createPositionVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
static createPositionVector(builder:flatbuffers.Builder, data:number[]|Float32Array|Uint8Array):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addFloat32(data[i]!);
}
return builder.endVector();
}

static startPositionVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static addCurve(builder:flatbuffers.Builder, curveOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, curveOffset, 0);
}

static createCurveVector(builder:flatbuffers.Builder, data:number[]|Int32Array):flatbuffers.Offset;
/**
* @deprecated This Uint8Array overload will be removed in the future.
*/
static createCurveVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
static createCurveVector(builder:flatbuffers.Builder, data:number[]|Int32Array|Uint8Array):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt32(data[i]!);
}
return builder.endVector();
}

static startCurveVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static addSegment(builder:flatbuffers.Builder, segmentOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, segmentOffset, 0);
}

static createSegmentVector(builder:flatbuffers.Builder, data:number[]|Int32Array):flatbuffers.Offset;
/**
* @deprecated This Uint8Array overload will be removed in the future.
*/
static createSegmentVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
static createSegmentVector(builder:flatbuffers.Builder, data:number[]|Int32Array|Uint8Array):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt32(data[i]!);
}
return builder.endVector();
}

static startSegmentVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static endAlignment(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}

static createAlignment(builder:flatbuffers.Builder, positionOffset:flatbuffers.Offset, curveOffset:flatbuffers.Offset, segmentOffset:flatbuffers.Offset):flatbuffers.Offset {
Alignment.startAlignment(builder);
Alignment.addPosition(builder, positionOffset);
Alignment.addCurve(builder, curveOffset);
Alignment.addSegment(builder, segmentOffset);
return Alignment.endAlignment(builder);
}
}
93 changes: 93 additions & 0 deletions src/flatbuffers/fragments/index/civil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { Alignment } from '../../fragments/index/alignment.js';


export class Civil {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Civil {
this.bb_pos = i;
this.bb = bb;
return this;
}

static getRootAsCivil(bb:flatbuffers.ByteBuffer, obj?:Civil):Civil {
return (obj || new Civil()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsCivil(bb:flatbuffers.ByteBuffer, obj?:Civil):Civil {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Civil()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

alignmentHorizontal(index: number, obj?:Alignment):Alignment|null {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? (obj || new Alignment()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

alignmentHorizontalLength():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

alignmentVertical(index: number, obj?:Alignment):Alignment|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new Alignment()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

alignmentVerticalLength():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

static startCivil(builder:flatbuffers.Builder) {
builder.startObject(2);
}

static addAlignmentHorizontal(builder:flatbuffers.Builder, alignmentHorizontalOffset:flatbuffers.Offset) {
builder.addFieldOffset(0, alignmentHorizontalOffset, 0);
}

static createAlignmentHorizontalVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}

static startAlignmentHorizontalVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static addAlignmentVertical(builder:flatbuffers.Builder, alignmentVerticalOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, alignmentVerticalOffset, 0);
}

static createAlignmentVerticalVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
builder.startVector(4, data.length, 4);
for (let i = data.length - 1; i >= 0; i--) {
builder.addOffset(data[i]!);
}
return builder.endVector();
}

static startAlignmentVerticalVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}

static endCivil(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}

static createCivil(builder:flatbuffers.Builder, alignmentHorizontalOffset:flatbuffers.Offset, alignmentVerticalOffset:flatbuffers.Offset):flatbuffers.Offset {
Civil.startCivil(builder);
Civil.addAlignmentHorizontal(builder, alignmentHorizontalOffset);
Civil.addAlignmentVertical(builder, alignmentVerticalOffset);
return Civil.endCivil(builder);
}
}
Loading