From 12cabdcf1b2b599425e2aaf752fb49de71149c54 Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Mon, 15 Apr 2024 23:42:24 -0700 Subject: [PATCH 1/7] Enabled creation of plates --- src/elements/Plates/SimplePlate/index.html | 106 +++++++++++++++++++ src/elements/Plates/SimplePlate/index.ts | 34 ++++++ src/elements/Plates/SimplePlate/src/index.ts | 49 +++++++++ src/elements/Plates/index.ts | 1 + src/elements/index.ts | 1 + 5 files changed, 191 insertions(+) create mode 100644 src/elements/Plates/SimplePlate/index.html create mode 100644 src/elements/Plates/SimplePlate/index.ts create mode 100644 src/elements/Plates/SimplePlate/src/index.ts create mode 100644 src/elements/Plates/index.ts diff --git a/src/elements/Plates/SimplePlate/index.html b/src/elements/Plates/SimplePlate/index.html new file mode 100644 index 0000000..db25820 --- /dev/null +++ b/src/elements/Plates/SimplePlate/index.html @@ -0,0 +1,106 @@ + + + + + + + + + + Tools Component + + + +
+ + + + diff --git a/src/elements/Plates/SimplePlate/index.ts b/src/elements/Plates/SimplePlate/index.ts new file mode 100644 index 0000000..3eff71a --- /dev/null +++ b/src/elements/Plates/SimplePlate/index.ts @@ -0,0 +1,34 @@ +import { v4 as uuidv4 } from "uuid"; +import { IFC4X3 as IFC } from "web-ifc"; +import { Model } from "../../../base"; +import { DynamicElementType } from "../../Elements"; +import { SimplePlate } from "./src"; + +export class SimplePlateType extends DynamicElementType { + attributes: IFC.IfcPlateType; + + plateType: IFC.IfcPlateTypeEnum + + constructor(model: Model) { + super(model); + + this.plateType = IFC.IfcPlateTypeEnum.CURTAIN_PANEL + + this.attributes = new IFC.IfcPlateType( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + null, + null, + null, + null, + this.plateType, + ); + } + + protected createElement() { + return new SimplePlate(this.model, this); + } +} diff --git a/src/elements/Plates/SimplePlate/src/index.ts b/src/elements/Plates/SimplePlate/src/index.ts new file mode 100644 index 0000000..82919df --- /dev/null +++ b/src/elements/Plates/SimplePlate/src/index.ts @@ -0,0 +1,49 @@ +import { IFC4X3 as IFC } from "web-ifc"; +import { Element } from "../../../Elements"; +import { Model } from "../../../../base"; +import { SimplePlateType } from ".."; +import { v4 as uuidv4 } from "uuid"; +import { IfcUtils } from "../../../../utils/ifc-utils"; +import { Extrusion, RectangleProfile } from "../../../../geometries"; + + +export class SimplePlate extends Element { + attributes: IFC.IfcPlate; + + body: Extrusion; + + type: SimplePlateType + + constructor(model: Model, type: SimplePlateType) { + super(model, type) + this.type = type + + const placement = IfcUtils.localPlacement(); + + const profile = new RectangleProfile(model); + profile.dimension.x = 0.127 //2.6 inches in meters + profile.dimension.y = 0.0635 //5 inches in meters + profile.update(); + + this.body = new Extrusion(model, profile); + const id = this.body.attributes.expressID; + this.type.geometries.set(id, this.body); + this.geometries.add(id); + + + this.attributes = new IFC.IfcPlate( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + placement, + IfcUtils.productDefinitionShape(model, [this.body.attributes]), + null, + type.plateType, + ) + + this.model.set(this.attributes); + } + +} diff --git a/src/elements/Plates/index.ts b/src/elements/Plates/index.ts new file mode 100644 index 0000000..201ae88 --- /dev/null +++ b/src/elements/Plates/index.ts @@ -0,0 +1 @@ +export * from "./SimplePlate"; diff --git a/src/elements/index.ts b/src/elements/index.ts index 4ee9c41..b9dd2cb 100644 --- a/src/elements/index.ts +++ b/src/elements/index.ts @@ -3,3 +3,4 @@ export * from "./Slabs"; export * from "./Walls"; export * from "./Furniture"; export * from "./Windows"; +export * from "./Plates" From da319cce79e053e2923660a1c31692a0568da0f5 Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Tue, 16 Apr 2024 17:23:56 -0700 Subject: [PATCH 2/7] Enabled creation of members and began curtain wall feature --- .../CurtainWalls/SimpleCurtainWall/index.html | 137 ++++++++ .../CurtainWalls/SimpleCurtainWall/index.ts | 315 ++++++++++++++++++ .../SimpleCurtainWall/src/index.ts | 41 +++ src/elements/CurtainWalls/index.ts | 1 + src/elements/Members/SimpleMember/index.html | 106 ++++++ src/elements/Members/SimpleMember/index.ts | 34 ++ .../Members/SimpleMember/src/index.ts | 51 +++ src/elements/Members/index.ts | 1 + src/elements/Plates/SimplePlate/src/index.ts | 9 +- src/elements/index.ts | 2 + .../Profiles/RectangleProfile/index.ts | 5 + 11 files changed, 698 insertions(+), 4 deletions(-) create mode 100644 src/elements/CurtainWalls/SimpleCurtainWall/index.html create mode 100644 src/elements/CurtainWalls/SimpleCurtainWall/index.ts create mode 100644 src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts create mode 100644 src/elements/CurtainWalls/index.ts create mode 100644 src/elements/Members/SimpleMember/index.html create mode 100644 src/elements/Members/SimpleMember/index.ts create mode 100644 src/elements/Members/SimpleMember/src/index.ts create mode 100644 src/elements/Members/index.ts diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.html b/src/elements/CurtainWalls/SimpleCurtainWall/index.html new file mode 100644 index 0000000..d2b8675 --- /dev/null +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.html @@ -0,0 +1,137 @@ + + + + + + + + + + Tools Component + + + +
+ + + + diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts new file mode 100644 index 0000000..fc70fd3 --- /dev/null +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -0,0 +1,315 @@ +import { IFC4X3, IFC4X3 as IFC } from "web-ifc"; +import { v4 as uuidv4 } from "uuid"; +import { Model } from "../../../base"; +// import { Extrusion, RectangleProfile } from "../../../geometries"; +import { IfcUtils } from "../../../utils/ifc-utils"; +import { StaticElementType } from "../../Elements"; +import { SimpleCurtainWall } from "./src"; +import { SimpleMemberType } from "../../Members"; +import { SimplePlateType } from "../../Plates"; +// import * as THREE from "three"; +import { SimpleMember } from "../../Members/SimpleMember/src"; +import { SimplePlate } from "../../Plates/SimplePlate/src"; + + +export * from "./src"; + +export class SimpleCurtainWallType extends StaticElementType { + attributes: IFC4X3.IfcCurtainWallType; + + shape: IFC4X3.IfcProductDefinitionShape; + + frameWidth = 0.1; + + length = 1; + + width = 0.2; + + height = 1; + +// private bottomFrame: Extrusion; + +// private topFrame: Extrusion; + +// private leftFrame: Extrusion; + +// private rightFrame: Extrusion; + + constructor(model: Model) { + super(model); + + // const horizontalProfile = new RectangleProfile(model); + // const body1 = new Extrusion(model, horizontalProfile); + // const id1 = body1.attributes.expressID; + // const fragment = this.newFragment(); + // this.fragments.set(id1, fragment); + // this.geometries.set(id1, body1); + // this.bottomFrame = body1; + + // const body2 = new Extrusion(model, horizontalProfile); + // const id2 = body2.attributes.expressID; + // this.geometries.set(id2, body2); + // this.topFrame = body2; + // const fragment2 = this.newFragment(); + // this.fragments.set(id2, fragment2); + + // const verticalProfile = new RectangleProfile(model); + // const body3 = new Extrusion(model, verticalProfile); + // const id3 = body3.attributes.expressID; + // this.geometries.set(id3, body3); + // this.leftFrame = body3; + // const fragment3 = this.newFragment(); + // this.fragments.set(id3, fragment3); + // body3.rotation.y = Math.PI / 2; + // body3.update(); + + // const body4 = new Extrusion(model, verticalProfile); + // const id4 = body4.attributes.expressID; + // this.geometries.set(id4, body4); + // this.rightFrame = body4; + // const fragment4 = this.newFragment(); + // this.fragments.set(id4, fragment4); + // body4.rotation.y = Math.PI / 2; + // body4.update(); + + + + // this.shape = IfcUtils.productDefinitionShape(model, [ + // body1.attributes, + // body2.attributes, + // body3.attributes, + // body4.attributes, + // ]); + + const numberOfColumns = 2; + const numberOfRows = 6 + + const sideAMembers: SimpleMember[] = []; + const sideBMembers: SimpleMember[] = []; + const bottomMembers: SimpleMember[] = []; + const topMembers: SimpleMember[] = []; + const middleMembers: SimpleMember[] = []; + const plates: SimplePlate[] = []; + + + // const sideBMember = new Array(numberOfRows); + + // const topMembers = new Array(numberOfColumns); + // const bottomMembers = new Array(numberOfColumns) + + for (let i = 0; i < numberOfColumns; i++ ) { + + // generate horizontal member in middle + const topMember = new SimpleMemberType(model).addInstance(); + const topMemberBody = topMember.body + const topMemberId = topMemberBody.attributes.expressID; + const topMemberFragment = this.newFragment(); + + // bottomMember.body.position.y = numberOfColumns + + // if (i > 0) { + // sideBMember.body.position.z = i + // } + + topMember.body.rotation.x = Math.PI / -2; + topMember.body.position.z = numberOfRows + topMember.body.update(); + + + this.fragments.set(topMemberId, topMemberFragment) + this.geometries.set(topMemberId, topMemberBody) + + topMembers.push(topMember); + + + // generate horizontal member in middle + const bottomMember = new SimpleMemberType(model).addInstance(); + const bottomMemberBody = bottomMember.body + const bottomMemberId = bottomMemberBody.attributes.expressID; + const bottomMemberFragment = this.newFragment(); + + // bottomMember.body.position.y = numberOfColumns + + // if (i > 0) { + // sideBMember.body.position.z = i + // } + bottomMember.body.rotation.x = Math.PI / -2; + bottomMember.body.update(); + + + this.fragments.set(bottomMemberId, bottomMemberFragment) + this.geometries.set(bottomMemberId, bottomMemberBody) + + bottomMembers.push(bottomMember); + + + for (let j = 0; j < numberOfRows; j++ ) { + + // generate plates + const plate = new SimplePlateType(model).addInstance(); + const plateBody = plate.body + const plateId = plateBody.attributes.expressID; + const plateFragment = this.newFragment(); + + if (j > 0) { + plate.body.position.z = j + plate.body.update(); + } + + this.fragments.set(plateId, plateFragment) + this.geometries.set(plateId, plateBody) + + plates.push(plate); + + + // generate middle members + const middleMember = new SimpleMemberType(model).addInstance(); + const middleMemberBody = middleMember.body + const middleMemberId = middleMemberBody.attributes.expressID; + const middleMemberFragment = this.newFragment(); + + if (j > 0 ) { + middleMember.body.position.z = j + } + + middleMember.body.rotation.x = Math.PI / -2; + middleMember.body.update(); + + this.fragments.set(middleMemberId, middleMemberFragment) + this.geometries.set(middleMemberId, middleMemberBody) + + middleMembers.push(middleMember); + + // generate members on origing side + const sideAMember = new SimpleMemberType(model).addInstance(); + const sideAMemberBody = sideAMember.body + const sideAMemberId = sideAMemberBody.attributes.expressID; + const sideAMemberFragment = this.newFragment(); + + console.log(sideAMemberId) + + if (j > 0) { + sideAMember.body.position.z = j + sideAMember.body.update(); + } + + this.fragments.set(sideAMemberId, sideAMemberFragment) + this.geometries.set(sideAMemberId, sideAMemberBody) + + sideAMembers.push(sideAMember); + + + // generate members on end side + const sideBMember = new SimpleMemberType(model).addInstance(); + const sideBMemberBody = sideBMember.body + const sideBMemberId = sideBMemberBody.attributes.expressID; + const sideBMemberFragment = this.newFragment(); + + console.log(sideAMemberId) + + sideBMember.body.position.y = numberOfColumns + + if (j > 0) { + sideBMember.body.position.z = j + } + + sideBMember.body.update(); + + + this.fragments.set(sideBMemberId, sideBMemberFragment) + this.geometries.set(sideBMemberId, sideBMemberBody) + + sideBMembers.push(sideBMember); + } + } + + + // // const member = new SimpleMemberType(model).addInstance(); + + // const plate = new SimplePlateType(model).addInstance(); + + // // const memberBody = member.body + // const plateBody = plate.body + + // // const memberId = memberBody.attributes.expressID; + // const plateId = plateBody.attributes.expressID; + // // console.log(plateId) + + // // const memberFragment = this.newFragment(); + // const plateFragment = this.newFragment(); + + // // this.fragments.set(memberId, memberFragment) + // this.fragments.set(plateId, plateFragment) + + // // this.geometries.set(memberId, memberBody) + // this.geometries.set(plateId, plateBody) + + console.log(sideAMembers) + + const sideAMembersAttributes = sideAMembers.map(member => member.body.attributes) + const sideBMembersAttributes = sideBMembers.map(member => member.body.attributes) + const bottomMembersAttributes = bottomMembers.map(member => member.body.attributes) + const topMembersAttributes = topMembers.map(member => member.body.attributes) + const platesAttributes = plates.map(member => member.body.attributes) + const middleMembersAttributes = middleMembers.map(member => member.body.attributes) + // const items = [plateBody.attributes] + + const concatItems = sideAMembersAttributes.concat(sideBMembersAttributes).concat(bottomMembersAttributes).concat(topMembersAttributes).concat(platesAttributes).concat(middleMembersAttributes) + + console.log(concatItems) + + this.shape = IfcUtils.productDefinitionShape(model, concatItems); + + this.attributes = new IFC.IfcCurtainWallType( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + null, + null, + null, + null, + IFC.IfcCurtainWallTypeEnum.NOTDEFINED + ); + + this.updateGeometry(); + this.model.set(this.attributes); + } + + update(updateGeometry: boolean = false) { + this.updateGeometry(); + super.update(updateGeometry); + } + + private updateGeometry() { + // this.bottomFrame.profile.dimension.y = this.width; + // this.bottomFrame.profile.dimension.x = this.length; + // this.bottomFrame.profile.update(); + + // this.bottomFrame.depth = this.frameWidth; + // this.bottomFrame.update(); + + // this.topFrame.position.z = this.height; + // this.topFrame.depth = this.frameWidth; + // this.topFrame.update(); + + // this.rightFrame.profile.dimension.y = this.width; + // this.rightFrame.profile.dimension.x = this.height; + // this.rightFrame.profile.update(); + + // this.rightFrame.position.x = -this.length / 2; + // this.rightFrame.position.z = this.height / 2; + // this.rightFrame.depth = this.frameWidth; + // this.rightFrame.update(); + + // this.leftFrame.position.x = this.length / 2 - this.frameWidth; + // this.leftFrame.position.z = this.height / 2; + // this.leftFrame.depth = this.frameWidth; + // this.leftFrame.update(); + } + + protected createElement() { + return new SimpleCurtainWall(this.model, this); + } +} diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts new file mode 100644 index 0000000..c180b68 --- /dev/null +++ b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts @@ -0,0 +1,41 @@ +import { IFC4X3 as IFC } from "web-ifc"; +import { v4 as uuidv4 } from "uuid"; +import { Model } from "../../../../base"; +import { IfcUtils } from "../../../../utils/ifc-utils"; +import { Element } from "../../../Elements/Element"; +import { SimpleCurtainWallType } from "../index"; + +export class SimpleCurtainWall extends Element { + attributes: IFC.IfcCurtainWall; + + type: SimpleCurtainWallType; + + constructor(model: Model, type: SimpleCurtainWallType) { + super(model, type); + this.type = type; + + const placement = IfcUtils.localPlacement(); + + for(const [id] of type.geometries) { + this.geometries.add(id); + } + + this.attributes = new IFC.IfcWindow( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + placement, + type.shape, + null, + null, + null, + null, + null, + null + ); + + this.model.set(this.attributes); + } +} diff --git a/src/elements/CurtainWalls/index.ts b/src/elements/CurtainWalls/index.ts new file mode 100644 index 0000000..c4c1f4b --- /dev/null +++ b/src/elements/CurtainWalls/index.ts @@ -0,0 +1 @@ +export * from "./SimpleCurtainWall" \ No newline at end of file diff --git a/src/elements/Members/SimpleMember/index.html b/src/elements/Members/SimpleMember/index.html new file mode 100644 index 0000000..81f2aef --- /dev/null +++ b/src/elements/Members/SimpleMember/index.html @@ -0,0 +1,106 @@ + + + + + + + + + + Tools Component + + + +
+ + + + diff --git a/src/elements/Members/SimpleMember/index.ts b/src/elements/Members/SimpleMember/index.ts new file mode 100644 index 0000000..bd63d33 --- /dev/null +++ b/src/elements/Members/SimpleMember/index.ts @@ -0,0 +1,34 @@ +import { v4 as uuidv4 } from "uuid"; +import { IFC4X3 as IFC } from "web-ifc"; +import { Model } from "../../../base"; +import { DynamicElementType } from "../../Elements"; +import { SimpleMember } from "./src"; + +export class SimpleMemberType extends DynamicElementType { + attributes: IFC.IfcMemberType; + + memberType: IFC.IfcMemberTypeEnum + + constructor(model: Model) { + super(model); + + this.memberType = IFC.IfcMemberTypeEnum.MULLION + + this.attributes = new IFC.IfcMemberType( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + null, + null, + null, + null, + this.memberType, + ); + } + + protected createElement() { + return new SimpleMember(this.model, this); + } +} diff --git a/src/elements/Members/SimpleMember/src/index.ts b/src/elements/Members/SimpleMember/src/index.ts new file mode 100644 index 0000000..a148f6e --- /dev/null +++ b/src/elements/Members/SimpleMember/src/index.ts @@ -0,0 +1,51 @@ +import { IFC4X3 as IFC } from "web-ifc"; +import { Element } from "../../../Elements"; +import { Model } from "../../../../base"; +import { SimpleMemberType } from ".."; +import { v4 as uuidv4 } from "uuid"; +import { IfcUtils } from "../../../../utils/ifc-utils"; +import { Extrusion, RectangleProfile } from "../../../../geometries"; +import * as THREE from "three"; + + +export class SimpleMember extends Element { + attributes: IFC.IfcMember; + + body: Extrusion; + + type: SimpleMemberType + + constructor(model: Model, type: SimpleMemberType) { + super(model, type) + this.type = type + const location = new THREE.Vector3(0,0,1) + const placement = IfcUtils.localPlacement(location); + + const profile = new RectangleProfile(model); + profile.dimension.x = 0.127 //2.6 inches in meters + profile.dimension.y = 0.0635 //5 inches in meters + profile.position = new THREE.Vector3(0,0,5) + profile.update(); + + this.body = new Extrusion(model, profile); + const id = this.body.attributes.expressID; + this.type.geometries.set(id, this.body); + this.geometries.add(id); + + + this.attributes = new IFC.IfcPlate( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + placement, + IfcUtils.productDefinitionShape(model, [this.body.attributes]), + null, + type.memberType, + ) + + this.model.set(this.attributes); + } + +} diff --git a/src/elements/Members/index.ts b/src/elements/Members/index.ts new file mode 100644 index 0000000..816f875 --- /dev/null +++ b/src/elements/Members/index.ts @@ -0,0 +1 @@ +export * from "./SimpleMember" \ No newline at end of file diff --git a/src/elements/Plates/SimplePlate/src/index.ts b/src/elements/Plates/SimplePlate/src/index.ts index 82919df..0923f48 100644 --- a/src/elements/Plates/SimplePlate/src/index.ts +++ b/src/elements/Plates/SimplePlate/src/index.ts @@ -5,7 +5,7 @@ import { SimplePlateType } from ".."; import { v4 as uuidv4 } from "uuid"; import { IfcUtils } from "../../../../utils/ifc-utils"; import { Extrusion, RectangleProfile } from "../../../../geometries"; - +import * as THREE from "three"; export class SimplePlate extends Element { attributes: IFC.IfcPlate; @@ -18,11 +18,12 @@ export class SimplePlate extends Element { super(model, type) this.type = type - const placement = IfcUtils.localPlacement(); + const placement = IfcUtils.localPlacement(new THREE.Vector3(1,1,1),new THREE.Vector3(1,1,1),new THREE.Vector3(1,1,1)); const profile = new RectangleProfile(model); - profile.dimension.x = 0.127 //2.6 inches in meters - profile.dimension.y = 0.0635 //5 inches in meters + profile.dimension.x = 0.0833333333333333 + profile.dimension.y = 1 + profile.position = new THREE.Vector3(0,0.5,0) profile.update(); this.body = new Extrusion(model, profile); diff --git a/src/elements/index.ts b/src/elements/index.ts index b9dd2cb..1220c68 100644 --- a/src/elements/index.ts +++ b/src/elements/index.ts @@ -4,3 +4,5 @@ export * from "./Walls"; export * from "./Furniture"; export * from "./Windows"; export * from "./Plates" +export * from "./Members" +export * from "./CurtainWalls" diff --git a/src/geometries/Profiles/RectangleProfile/index.ts b/src/geometries/Profiles/RectangleProfile/index.ts index 360c5cd..2032b6f 100644 --- a/src/geometries/Profiles/RectangleProfile/index.ts +++ b/src/geometries/Profiles/RectangleProfile/index.ts @@ -36,6 +36,11 @@ export class RectangleProfile extends Profile { this.attributes.XDim.value = this.dimension.x; this.attributes.YDim.value = this.dimension.y; + this.attributes.Position = new IFC.IfcAxis2Placement2D( + IfcUtils.point(this.position), + IfcUtils.direction(new THREE.Vector3(1, 0, 0)) + ); + const placement = this.model.get(this.attributes.Position); IfcUtils.setAxis2Placement( From 8512b37cacbd53cf89a69e49d2d82dd0410e608e Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Tue, 16 Apr 2024 20:44:34 -0700 Subject: [PATCH 3/7] Enable basic functionality for generation of curtain wall elements --- .../CurtainWalls/SimpleCurtainWall/index.ts | 102 ++++-------------- 1 file changed, 18 insertions(+), 84 deletions(-) diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts index fc70fd3..1c44ff7 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -1,7 +1,6 @@ import { IFC4X3, IFC4X3 as IFC } from "web-ifc"; import { v4 as uuidv4 } from "uuid"; import { Model } from "../../../base"; -// import { Extrusion, RectangleProfile } from "../../../geometries"; import { IfcUtils } from "../../../utils/ifc-utils"; import { StaticElementType } from "../../Elements"; import { SimpleCurtainWall } from "./src"; @@ -38,51 +37,8 @@ export class SimpleCurtainWallType extends StaticElementType constructor(model: Model) { super(model); - // const horizontalProfile = new RectangleProfile(model); - // const body1 = new Extrusion(model, horizontalProfile); - // const id1 = body1.attributes.expressID; - // const fragment = this.newFragment(); - // this.fragments.set(id1, fragment); - // this.geometries.set(id1, body1); - // this.bottomFrame = body1; - - // const body2 = new Extrusion(model, horizontalProfile); - // const id2 = body2.attributes.expressID; - // this.geometries.set(id2, body2); - // this.topFrame = body2; - // const fragment2 = this.newFragment(); - // this.fragments.set(id2, fragment2); - - // const verticalProfile = new RectangleProfile(model); - // const body3 = new Extrusion(model, verticalProfile); - // const id3 = body3.attributes.expressID; - // this.geometries.set(id3, body3); - // this.leftFrame = body3; - // const fragment3 = this.newFragment(); - // this.fragments.set(id3, fragment3); - // body3.rotation.y = Math.PI / 2; - // body3.update(); - - // const body4 = new Extrusion(model, verticalProfile); - // const id4 = body4.attributes.expressID; - // this.geometries.set(id4, body4); - // this.rightFrame = body4; - // const fragment4 = this.newFragment(); - // this.fragments.set(id4, fragment4); - // body4.rotation.y = Math.PI / 2; - // body4.update(); - - - - // this.shape = IfcUtils.productDefinitionShape(model, [ - // body1.attributes, - // body2.attributes, - // body3.attributes, - // body4.attributes, - // ]); - - const numberOfColumns = 2; - const numberOfRows = 6 + const numberOfColumns = 10; + const numberOfRows = 3 const sideAMembers: SimpleMember[] = []; const sideBMembers: SimpleMember[] = []; @@ -91,15 +47,9 @@ export class SimpleCurtainWallType extends StaticElementType const middleMembers: SimpleMember[] = []; const plates: SimplePlate[] = []; - - // const sideBMember = new Array(numberOfRows); - - // const topMembers = new Array(numberOfColumns); - // const bottomMembers = new Array(numberOfColumns) - for (let i = 0; i < numberOfColumns; i++ ) { - // generate horizontal member in middle + const topMember = new SimpleMemberType(model).addInstance(); const topMemberBody = topMember.body const topMemberId = topMemberBody.attributes.expressID; @@ -113,9 +63,9 @@ export class SimpleCurtainWallType extends StaticElementType topMember.body.rotation.x = Math.PI / -2; topMember.body.position.z = numberOfRows + topMember.body.position.y = i; topMember.body.update(); - this.fragments.set(topMemberId, topMemberFragment) this.geometries.set(topMemberId, topMemberBody) @@ -123,6 +73,7 @@ export class SimpleCurtainWallType extends StaticElementType // generate horizontal member in middle + const bottomMember = new SimpleMemberType(model).addInstance(); const bottomMemberBody = bottomMember.body const bottomMemberId = bottomMemberBody.attributes.expressID; @@ -133,28 +84,32 @@ export class SimpleCurtainWallType extends StaticElementType // if (i > 0) { // sideBMember.body.position.z = i // } + bottomMember.body.rotation.x = Math.PI / -2; - bottomMember.body.update(); + bottomMember.body.position.y = i; + bottomMember.body.update(); this.fragments.set(bottomMemberId, bottomMemberFragment) this.geometries.set(bottomMemberId, bottomMemberBody) bottomMembers.push(bottomMember); - for (let j = 0; j < numberOfRows; j++ ) { // generate plates + const plate = new SimplePlateType(model).addInstance(); const plateBody = plate.body const plateId = plateBody.attributes.expressID; const plateFragment = this.newFragment(); + plate.body.position.y = i if (j > 0) { plate.body.position.z = j - plate.body.update(); } + + plate.body.update(); this.fragments.set(plateId, plateFragment) this.geometries.set(plateId, plateBody) @@ -168,6 +123,8 @@ export class SimpleCurtainWallType extends StaticElementType const middleMemberId = middleMemberBody.attributes.expressID; const middleMemberFragment = this.newFragment(); + middleMember.body.position.y = i + if (j > 0 ) { middleMember.body.position.z = j } @@ -187,12 +144,15 @@ export class SimpleCurtainWallType extends StaticElementType const sideAMemberFragment = this.newFragment(); console.log(sideAMemberId) + sideAMember.body.position.y = i if (j > 0) { sideAMember.body.position.z = j - sideAMember.body.update(); } + sideAMember.body.update(); + + this.fragments.set(sideAMemberId, sideAMemberFragment) this.geometries.set(sideAMemberId, sideAMemberBody) @@ -205,8 +165,6 @@ export class SimpleCurtainWallType extends StaticElementType const sideBMemberId = sideBMemberBody.attributes.expressID; const sideBMemberFragment = this.newFragment(); - console.log(sideAMemberId) - sideBMember.body.position.y = numberOfColumns if (j > 0) { @@ -223,36 +181,12 @@ export class SimpleCurtainWallType extends StaticElementType } } - - // // const member = new SimpleMemberType(model).addInstance(); - - // const plate = new SimplePlateType(model).addInstance(); - - // // const memberBody = member.body - // const plateBody = plate.body - - // // const memberId = memberBody.attributes.expressID; - // const plateId = plateBody.attributes.expressID; - // // console.log(plateId) - - // // const memberFragment = this.newFragment(); - // const plateFragment = this.newFragment(); - - // // this.fragments.set(memberId, memberFragment) - // this.fragments.set(plateId, plateFragment) - - // // this.geometries.set(memberId, memberBody) - // this.geometries.set(plateId, plateBody) - - console.log(sideAMembers) - const sideAMembersAttributes = sideAMembers.map(member => member.body.attributes) const sideBMembersAttributes = sideBMembers.map(member => member.body.attributes) const bottomMembersAttributes = bottomMembers.map(member => member.body.attributes) const topMembersAttributes = topMembers.map(member => member.body.attributes) const platesAttributes = plates.map(member => member.body.attributes) const middleMembersAttributes = middleMembers.map(member => member.body.attributes) - // const items = [plateBody.attributes] const concatItems = sideAMembersAttributes.concat(sideBMembersAttributes).concat(bottomMembersAttributes).concat(topMembersAttributes).concat(platesAttributes).concat(middleMembersAttributes) From 84c61824cf6192ea1caa35e32dcf6df2fd9adb48 Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Sat, 20 Apr 2024 18:53:20 -0700 Subject: [PATCH 4/7] Fixed bug in curtain wall generation algorithm --- .../CurtainWalls/SimpleCurtainWall/index.ts | 224 ++++++++++++------ .../Members/SimpleMember/src/index.ts | 1 + src/elements/Plates/SimplePlate/src/index.ts | 7 +- .../Profiles/RectangleProfile/index.ts | 2 + 4 files changed, 163 insertions(+), 71 deletions(-) diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts index 1c44ff7..dc631f0 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -37,40 +37,66 @@ export class SimpleCurtainWallType extends StaticElementType constructor(model: Model) { super(model); - const numberOfColumns = 10; - const numberOfRows = 3 + + // const plateWidth = 1.9238 //plate.body.profile.dimension.y + // const plateHeight = 1 + const memberWidth = 0.0635 //topMembtopMemberer.body.profile.dimension.y + + const length = 5; + const height = 3 + + const numberOfColumns = 2 + const numberOfRows = 10; + + const numberOfVerticalMembers = numberOfColumns + 1 + const numberOfHorizontalMembers = numberOfRows + 1 + + + const plateWidth = (length - (numberOfVerticalMembers * memberWidth)) / numberOfColumns //plate.body.profile.dimension.y + const plateHeight = (height - (numberOfHorizontalMembers * memberWidth)) / numberOfRows const sideAMembers: SimpleMember[] = []; const sideBMembers: SimpleMember[] = []; const bottomMembers: SimpleMember[] = []; const topMembers: SimpleMember[] = []; - const middleMembers: SimpleMember[] = []; + const middleHorizontalMembers: SimpleMember[] = []; + const middleVerticalMembers: SimpleMember[] = []; + const plates: SimplePlate[] = []; for (let i = 0; i < numberOfColumns; i++ ) { + + const totalDistance = plateWidth * numberOfColumns + memberWidth * (numberOfColumns - 1) + const distanceToCenter = totalDistance / numberOfColumns + // generate horizontal member in middle const topMember = new SimpleMemberType(model).addInstance(); const topMemberBody = topMember.body const topMemberId = topMemberBody.attributes.expressID; - const topMemberFragment = this.newFragment(); - - // bottomMember.body.position.y = numberOfColumns - - // if (i > 0) { - // sideBMember.body.position.z = i - // } + const topMemberFragment = this.newFragment();totalDistance topMember.body.rotation.x = Math.PI / -2; - topMember.body.position.z = numberOfRows - topMember.body.position.y = i; + topMember.body.position.z = height - memberWidth/2 //numberOfRows * (memberWidth + plateHeight) + memberWidth/2 + topMember.body.position.y = i * distanceToCenter; + topMember.body.depth = plateWidth + memberWidth + memberWidth/2 + + if (i > 0) { + topMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) + topMember.body.depth = plateWidth + memberWidth + } + + if (i == numberOfColumns - 1) { + topMember.body.depth = plateWidth + memberWidth + memberWidth/2 + } + + topMember.body.profile.update() topMember.body.update(); this.fragments.set(topMemberId, topMemberFragment) this.geometries.set(topMemberId, topMemberBody) topMembers.push(topMember); - // generate horizontal member in middle @@ -79,14 +105,20 @@ export class SimpleCurtainWallType extends StaticElementType const bottomMemberId = bottomMemberBody.attributes.expressID; const bottomMemberFragment = this.newFragment(); - // bottomMember.body.position.y = numberOfColumns + bottomMember.body.rotation.x = Math.PI / -2; + bottomMember.body.position.z = memberWidth / 2; - // if (i > 0) { - // sideBMember.body.position.z = i - // } + bottomMember.body.position.y = i * distanceToCenter ; + bottomMember.body.depth = plateWidth + memberWidth + memberWidth/2 - bottomMember.body.rotation.x = Math.PI / -2; - bottomMember.body.position.y = i; + if (i>0) { + bottomMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) + bottomMember.body.depth = plateWidth + memberWidth + } + + if (i == numberOfColumns - 1) { + bottomMember.body.depth = plateWidth + memberWidth + memberWidth/2 + } bottomMember.body.update(); @@ -96,19 +128,32 @@ export class SimpleCurtainWallType extends StaticElementType bottomMembers.push(bottomMember); for (let j = 0; j < numberOfRows; j++ ) { - + // generate plates const plate = new SimplePlateType(model).addInstance(); const plateBody = plate.body const plateId = plateBody.attributes.expressID; const plateFragment = this.newFragment(); - plate.body.position.y = i - if (j > 0) { - plate.body.position.z = j + plate.body.position.y = plateWidth/2 + memberWidth + + if (i > 0) { + plate.body.position.y = i * (plateWidth+ memberWidth ) + memberWidth + plateWidth/2 } + plate.body.position.z = memberWidth + + if (j > 0 ) { + plate.body.position.z = j * (plateHeight + memberWidth) + memberWidth + } + + plate.body.profile.dimension.y = plateWidth + console.log(plateHeight) + plate.body.depth = plateHeight + + plate.body.profile.update() + plate.body.update(); this.fragments.set(plateId, plateFragment) @@ -116,47 +161,82 @@ export class SimpleCurtainWallType extends StaticElementType plates.push(plate); - // generate middle members - const middleMember = new SimpleMemberType(model).addInstance(); - const middleMemberBody = middleMember.body - const middleMemberId = middleMemberBody.attributes.expressID; - const middleMemberFragment = this.newFragment(); - - middleMember.body.position.y = i - if (j > 0 ) { - middleMember.body.position.z = j - } - - middleMember.body.rotation.x = Math.PI / -2; - middleMember.body.update(); - - this.fragments.set(middleMemberId, middleMemberFragment) - this.geometries.set(middleMemberId, middleMemberBody) - - middleMembers.push(middleMember); + const middleHorizontalMember = new SimpleMemberType(model).addInstance(); + const middleHorizontalMemberBody = middleHorizontalMember.body + const middleHorizontalMemberId = middleHorizontalMemberBody.attributes.expressID; + const middleHorizontalMemberFragment = this.newFragment(); + + middleHorizontalMember.body.depth = plateWidth + memberWidth + memberWidth / 2 + middleHorizontalMember.body.position.z = memberWidth/2 + j * (plateHeight + memberWidth) + middleHorizontalMember.body.position.y = i * distanceToCenter ; + middleHorizontalMember.body.rotation.x = Math.PI / -2; + + if (i > 0) { + middleHorizontalMember.body.depth = memberWidth + plateWidth + middleHorizontalMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) + } + + if (i == numberOfColumns - 1) { + middleHorizontalMember.body.depth = plateWidth + memberWidth + memberWidth/2 + } + + middleHorizontalMember.body.update(); + + this.fragments.set(middleHorizontalMemberId, middleHorizontalMemberFragment) + this.geometries.set(middleHorizontalMemberId, middleHorizontalMemberBody) + + middleHorizontalMembers.push(middleHorizontalMember); + } + if (i > 0 ) { // generate members on origing side - const sideAMember = new SimpleMemberType(model).addInstance(); - const sideAMemberBody = sideAMember.body - const sideAMemberId = sideAMemberBody.attributes.expressID; - const sideAMemberFragment = this.newFragment(); + const middleVerticalMember = new SimpleMemberType(model).addInstance(); + const middleVerticalMemberBody = middleVerticalMember.body + const middleVerticalMemberId = middleVerticalMemberBody.attributes.expressID; + const middleVerticalMemberFragment = this.newFragment(); + + middleVerticalMember.body.position.y = i * (plateWidth + memberWidth) + memberWidth/2 + middleVerticalMember.body.depth = plateHeight + middleVerticalMember.body.position.z = memberWidth + + if (j > 0 ) { + middleVerticalMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth + } + + middleVerticalMember.body.update(); + + this.fragments.set(middleVerticalMemberId, middleVerticalMemberFragment) + this.geometries.set(middleVerticalMemberId, middleVerticalMemberBody) + + middleVerticalMembers.push(middleVerticalMember); + + } - console.log(sideAMemberId) - sideAMember.body.position.y = i + if (i == 0 ) { + // generate members on origing side + const sideAMember = new SimpleMemberType(model).addInstance(); + const sideAMemberBody = sideAMember.body + const sideAMemberId = sideAMemberBody.attributes.expressID; + const sideAMemberFragment = this.newFragment(); - if (j > 0) { - sideAMember.body.position.z = j - } + sideAMember.body.position.y = i * distanceToCenter + memberWidth/2 + sideAMember.body.depth = plateHeight + sideAMember.body.position.z = memberWidth + + if (j > 0 ) { + sideAMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth + } - sideAMember.body.update(); + sideAMember.body.update(); + this.fragments.set(sideAMemberId, sideAMemberFragment) + this.geometries.set(sideAMemberId, sideAMemberBody) - this.fragments.set(sideAMemberId, sideAMemberFragment) - this.geometries.set(sideAMemberId, sideAMemberBody) + sideAMembers.push(sideAMember); - sideAMembers.push(sideAMember); + } // generate members on end side @@ -165,15 +245,16 @@ export class SimpleCurtainWallType extends StaticElementType const sideBMemberId = sideBMemberBody.attributes.expressID; const sideBMemberFragment = this.newFragment(); - sideBMember.body.position.y = numberOfColumns - - if (j > 0) { - sideBMember.body.position.z = j + sideBMember.body.position.y = length - memberWidth / 2 // + 2 * memberWidth - memberWidth / 2 + sideBMember.body.depth = plateHeight + sideBMember.body.position.z = memberWidth + + if (j > 0 ) { + sideBMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth } sideBMember.body.update(); - this.fragments.set(sideBMemberId, sideBMemberFragment) this.geometries.set(sideBMemberId, sideBMemberBody) @@ -181,15 +262,22 @@ export class SimpleCurtainWallType extends StaticElementType } } - const sideAMembersAttributes = sideAMembers.map(member => member.body.attributes) - const sideBMembersAttributes = sideBMembers.map(member => member.body.attributes) - const bottomMembersAttributes = bottomMembers.map(member => member.body.attributes) - const topMembersAttributes = topMembers.map(member => member.body.attributes) - const platesAttributes = plates.map(member => member.body.attributes) - const middleMembersAttributes = middleMembers.map(member => member.body.attributes) - - const concatItems = sideAMembersAttributes.concat(sideBMembersAttributes).concat(bottomMembersAttributes).concat(topMembersAttributes).concat(platesAttributes).concat(middleMembersAttributes) - + var sideAMembersAttributes = sideAMembers.map(member => member.body.attributes) + // sideAMembersAttributes = []; + var sideBMembersAttributes = sideBMembers.map(member => member.body.attributes) + // sideBMembersAttributes = []; + var bottomMembersAttributes = bottomMembers.map(member => member.body.attributes) + // bottomMembersAttributes = []; + var topMembersAttributes = topMembers.map(member => member.body.attributes) + // topMembersAttributes = []; + var platesAttributes = plates.map(member => member.body.attributes) + // platesAttributes = []; + var middleHorizontalMembersAttributes = middleHorizontalMembers.map(member => member.body.attributes) + // middleHorizontalMembersAttributes = []; + var middleVerticalMembersAttributes = middleVerticalMembers.map(member => member.body.attributes) + // middleVerticalMembersAttributes = []; + const concatItems = sideAMembersAttributes.concat(sideBMembersAttributes).concat(bottomMembersAttributes).concat(topMembersAttributes).concat(platesAttributes).concat(middleHorizontalMembersAttributes).concat(middleVerticalMembersAttributes) + console.log(sideBMembers) console.log(concatItems) this.shape = IfcUtils.productDefinitionShape(model, concatItems); diff --git a/src/elements/Members/SimpleMember/src/index.ts b/src/elements/Members/SimpleMember/src/index.ts index a148f6e..7621d32 100644 --- a/src/elements/Members/SimpleMember/src/index.ts +++ b/src/elements/Members/SimpleMember/src/index.ts @@ -1,3 +1,4 @@ + import { IFC4X3 as IFC } from "web-ifc"; import { Element } from "../../../Elements"; import { Model } from "../../../../base"; diff --git a/src/elements/Plates/SimplePlate/src/index.ts b/src/elements/Plates/SimplePlate/src/index.ts index 0923f48..c28ccfc 100644 --- a/src/elements/Plates/SimplePlate/src/index.ts +++ b/src/elements/Plates/SimplePlate/src/index.ts @@ -18,12 +18,13 @@ export class SimplePlate extends Element { super(model, type) this.type = type - const placement = IfcUtils.localPlacement(new THREE.Vector3(1,1,1),new THREE.Vector3(1,1,1),new THREE.Vector3(1,1,1)); + const placement = IfcUtils.localPlacement(); const profile = new RectangleProfile(model); profile.dimension.x = 0.0833333333333333 - profile.dimension.y = 1 - profile.position = new THREE.Vector3(0,0.5,0) + profile.dimension.y = 1.9238 + profile.dimension.z = 1 + profile.position = new THREE.Vector3(0,0,0) profile.update(); this.body = new Extrusion(model, profile); diff --git a/src/geometries/Profiles/RectangleProfile/index.ts b/src/geometries/Profiles/RectangleProfile/index.ts index 2032b6f..e6be4b3 100644 --- a/src/geometries/Profiles/RectangleProfile/index.ts +++ b/src/geometries/Profiles/RectangleProfile/index.ts @@ -12,6 +12,8 @@ export class RectangleProfile extends Profile { rotation = new THREE.Euler(0, 0, 0); position = new THREE.Vector3(0, 0, 0); + + depth = 1; constructor(model: Model) { super(model); From 327efeca7b8c8a380fd3ac9f56908710046d0e22 Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Mon, 22 Apr 2024 16:32:30 -0700 Subject: [PATCH 5/7] Cleaned algorithm and fixed other bugs --- .../CurtainWalls/SimpleCurtainWall/index.html | 63 +-- .../CurtainWalls/SimpleCurtainWall/index.ts | 480 ++++++++---------- .../SimpleCurtainWall/src/index.ts | 12 +- .../Members/SimpleMember/src/index.ts | 8 +- 4 files changed, 257 insertions(+), 306 deletions(-) diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.html b/src/elements/CurtainWalls/SimpleCurtainWall/index.html index d2b8675..e55a2fc 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.html +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.html @@ -1,4 +1,4 @@ - + @@ -92,46 +92,23 @@ model.ifcAPI.SetWasmPath("https://unpkg.com/web-ifc@0.0.50/", true); await model.init(); - const curtainWall = new CLAY.SimpleCurtainWallType(model).addInstance(); - - curtainWall.update(true) - - scene.add(...curtainWall.meshes) - - -// const windowType = new CLAY.SimpleWindowType(model); -// const windowInstance = windowType.addInstance(); -// windowInstance.update(true); - -// scene.add(...windowInstance.meshes); - -// const gui = new dat.GUI(); - -// gui.add(windowType, "frameWidth").name("Frame width").min(0.01).max(0.1).step(0.01).onChange(() => { -// windowType.update(true); -// }); - -// gui.add(windowType, "length").name("Length").min(0.2).max(1).step(0.01).onChange(() => { -// windowType.update(true); -// }); - -// gui.add(windowType, "width").name("Width").min(0.2).max(1).step(0.01).onChange(() => { -// windowType.update(true); -// }); - -// gui.add(windowType, "height").name("Height").min(0.2).max(1).step(0.01).onChange(() => { -// windowType.update(true); -// }); - - -// window.addEventListener("keydown", () => { -// const exported = model.ifcAPI.SaveModel(model.modelID); -// const file = new File([new Blob([exported])], "a"); -// const a = document.createElement("a"); -// a.href = URL.createObjectURL(file); -// a.download = "example.ifc"; -// a.click(); -// }) - - + const curtainWallType = new CLAY.SimpleCurtainWallType(model); + // curtainWallType.length = 2; + // curtainWallType.height = 6; + // curtainWallType.numberOfColumns = 2; + // curtainWallType.numberOfRows = 2; + // curtainWallType.update(true) + + const curtainWall = curtainWallType.addInstance(); + + scene.add(...curtainWall.meshes); + + window.addEventListener("keydown", () => { + const exported = model.ifcAPI.SaveModel(model.modelID); + const file = new File([new Blob([exported])], "a"); + const a = document.createElement("a"); + a.href = URL.createObjectURL(file); + a.download = "example.ifc"; + a.click(); + }); diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts index dc631f0..0d276c7 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -6,11 +6,9 @@ import { StaticElementType } from "../../Elements"; import { SimpleCurtainWall } from "./src"; import { SimpleMemberType } from "../../Members"; import { SimplePlateType } from "../../Plates"; -// import * as THREE from "three"; import { SimpleMember } from "../../Members/SimpleMember/src"; import { SimplePlate } from "../../Plates/SimplePlate/src"; - export * from "./src"; export class SimpleCurtainWallType extends StaticElementType { @@ -18,317 +16,289 @@ export class SimpleCurtainWallType extends StaticElementType shape: IFC4X3.IfcProductDefinitionShape; - frameWidth = 0.1; + length = 6; + + height = 3; + + numberOfColumns = 8; + + numberOfRows = 5; + + //Glazing - length = 1; + private plates: SimplePlate[] = []; - width = 0.2; + //Outer square frame - height = 1; + private sideAMembers: SimpleMember[] = []; -// private bottomFrame: Extrusion; + private sideBMembers: SimpleMember[] = []; -// private topFrame: Extrusion; + private bottomMembers: SimpleMember[] = []; -// private leftFrame: Extrusion; + private topMembers: SimpleMember[] = []; -// private rightFrame: Extrusion; + //Interior grid frame + + private middleHorizontalMembers: SimpleMember[] = []; + + private middleVerticalMembers: SimpleMember[] = []; constructor(model: Model) { super(model); + const componentAttributes = this.composeCurtainWall(model); + + this.shape = IfcUtils.productDefinitionShape(model, componentAttributes); + + this.attributes = new IFC.IfcCurtainWallType( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + null, + null, + null, + null, + IFC.IfcCurtainWallTypeEnum.NOTDEFINED + ); + } + + update(updateGeometry: boolean = false) { + const componentAttributes = this.composeCurtainWall(); - // const plateWidth = 1.9238 //plate.body.profile.dimension.y - // const plateHeight = 1 - const memberWidth = 0.0635 //topMembtopMemberer.body.profile.dimension.y - - const length = 5; - const height = 3 + this.shape = IfcUtils.productDefinitionShape( + this.model, + componentAttributes + ); - const numberOfColumns = 2 - const numberOfRows = 10; + super.update(updateGeometry); + } - const numberOfVerticalMembers = numberOfColumns + 1 - const numberOfHorizontalMembers = numberOfRows + 1 + composeCurtainWall(model?: Model) { + if (!model) { + model = this.model; + } + const memberWidth = new SimpleMemberType(model).addInstance().width; - const plateWidth = (length - (numberOfVerticalMembers * memberWidth)) / numberOfColumns //plate.body.profile.dimension.y - const plateHeight = (height - (numberOfHorizontalMembers * memberWidth)) / numberOfRows + const plateWidth = + (this.length - (this.numberOfColumns + 1) * memberWidth) / + this.numberOfColumns; + const plateHeight = + (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; - const sideAMembers: SimpleMember[] = []; - const sideBMembers: SimpleMember[] = []; - const bottomMembers: SimpleMember[] = []; - const topMembers: SimpleMember[] = []; - const middleHorizontalMembers: SimpleMember[] = []; - const middleVerticalMembers: SimpleMember[] = []; + const horizontalMemberLength = plateWidth + memberWidth + memberWidth / 2; - const plates: SimplePlate[] = []; + for (let i = 0; i < this.numberOfColumns; i++) { + const initialHorizontalColumnLocation = 0; + const nonInitialHorizontalColumnLocation = + i * (plateWidth + memberWidth) + memberWidth / 2; - for (let i = 0; i < numberOfColumns; i++ ) { + // generate top horizontal members of outer frame------------------------- + const topMember = new SimpleMemberType(model).addInstance(); + const topMemberId = topMember.body.attributes.expressID; - const totalDistance = plateWidth * numberOfColumns + memberWidth * (numberOfColumns - 1) - const distanceToCenter = totalDistance / numberOfColumns + topMember.body.depth = horizontalMemberLength; - // generate horizontal member in middle + topMember.body.position.y = initialHorizontalColumnLocation; + topMember.body.position.z = this.height - memberWidth / 2; - const topMember = new SimpleMemberType(model).addInstance(); - const topMemberBody = topMember.body - const topMemberId = topMemberBody.attributes.expressID; - const topMemberFragment = this.newFragment();totalDistance + topMember.body.rotation.x = Math.PI / -2; - topMember.body.rotation.x = Math.PI / -2; - topMember.body.position.z = height - memberWidth/2 //numberOfRows * (memberWidth + plateHeight) + memberWidth/2 - topMember.body.position.y = i * distanceToCenter; - topMember.body.depth = plateWidth + memberWidth + memberWidth/2 - - if (i > 0) { - topMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) - topMember.body.depth = plateWidth + memberWidth - } + if (i > 0) { + topMember.body.depth = plateWidth + memberWidth; + topMember.body.position.y = nonInitialHorizontalColumnLocation; + } - if (i == numberOfColumns - 1) { - topMember.body.depth = plateWidth + memberWidth + memberWidth/2 - } - - topMember.body.profile.update() - topMember.body.update(); + if (i == this.numberOfColumns - 1) { + topMember.body.depth = horizontalMemberLength; + } + + topMember.body.profile.update(); + topMember.body.update(); + + this.fragments.set(topMemberId, this.newFragment()); + this.geometries.set(topMemberId, topMember.body); + this.topMembers.push(topMember); + + // generate bottom horizontal members of outer frame------------------------- + const bottomMember = new SimpleMemberType(model).addInstance(); + const bottomMemberId = bottomMember.body.attributes.expressID; + + bottomMember.body.depth = horizontalMemberLength; + + bottomMember.body.position.y = initialHorizontalColumnLocation; + bottomMember.body.position.z = memberWidth / 2; + + bottomMember.body.rotation.x = Math.PI / -2; + + if (i > 0) { + bottomMember.body.depth = plateWidth + memberWidth; + bottomMember.body.position.y = nonInitialHorizontalColumnLocation; + } + + if (i == this.numberOfColumns - 1) { + bottomMember.body.depth = horizontalMemberLength; + } - this.fragments.set(topMemberId, topMemberFragment) - this.geometries.set(topMemberId, topMemberBody) + bottomMember.body.update(); - topMembers.push(topMember); - - // generate horizontal member in middle + this.fragments.set(bottomMemberId, this.newFragment()); + this.geometries.set(bottomMemberId, bottomMember.body); + this.bottomMembers.push(bottomMember); - const bottomMember = new SimpleMemberType(model).addInstance(); - const bottomMemberBody = bottomMember.body - const bottomMemberId = bottomMemberBody.attributes.expressID; - const bottomMemberFragment = this.newFragment(); + for (let j = 0; j < this.numberOfRows; j++) { + const nonInitialVerticalRowLocation = + memberWidth + j * (plateHeight + memberWidth); - bottomMember.body.rotation.x = Math.PI / -2; - bottomMember.body.position.z = memberWidth / 2; + // generate glazing plates------------------------------------ + const plate = new SimplePlateType(model).addInstance(); + const plateId = plate.body.attributes.expressID; - bottomMember.body.position.y = i * distanceToCenter ; - bottomMember.body.depth = plateWidth + memberWidth + memberWidth/2 + plate.body.profile.dimension.y = plateWidth; + plate.body.depth = plateHeight; - if (i>0) { - bottomMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) - bottomMember.body.depth = plateWidth + memberWidth + plate.body.position.y = plateWidth / 2 + memberWidth; + plate.body.position.z = memberWidth; + + if (i > 0) { + plate.body.position.y = + memberWidth + i * (plateWidth + memberWidth) + plateWidth / 2; } - if (i == numberOfColumns - 1) { - bottomMember.body.depth = plateWidth + memberWidth + memberWidth/2 + if (j > 0) { + plate.body.position.z = nonInitialVerticalRowLocation; } - bottomMember.body.update(); - - this.fragments.set(bottomMemberId, bottomMemberFragment) - this.geometries.set(bottomMemberId, bottomMemberBody) - - bottomMembers.push(bottomMember); - - for (let j = 0; j < numberOfRows; j++ ) { - - // generate plates - - const plate = new SimplePlateType(model).addInstance(); - const plateBody = plate.body - const plateId = plateBody.attributes.expressID; - const plateFragment = this.newFragment(); - - plate.body.position.y = plateWidth/2 + memberWidth - - if (i > 0) { - plate.body.position.y = i * (plateWidth+ memberWidth ) + memberWidth + plateWidth/2 - } - - plate.body.position.z = memberWidth - - if (j > 0 ) { - plate.body.position.z = j * (plateHeight + memberWidth) + memberWidth - } - - plate.body.profile.dimension.y = plateWidth - console.log(plateHeight) - plate.body.depth = plateHeight - - plate.body.profile.update() - - plate.body.update(); - - this.fragments.set(plateId, plateFragment) - this.geometries.set(plateId, plateBody) - - plates.push(plate); - - // generate middle members - if (j > 0 ) { - const middleHorizontalMember = new SimpleMemberType(model).addInstance(); - const middleHorizontalMemberBody = middleHorizontalMember.body - const middleHorizontalMemberId = middleHorizontalMemberBody.attributes.expressID; - const middleHorizontalMemberFragment = this.newFragment(); - - middleHorizontalMember.body.depth = plateWidth + memberWidth + memberWidth / 2 - middleHorizontalMember.body.position.z = memberWidth/2 + j * (plateHeight + memberWidth) - middleHorizontalMember.body.position.y = i * distanceToCenter ; - middleHorizontalMember.body.rotation.x = Math.PI / -2; - - if (i > 0) { - middleHorizontalMember.body.depth = memberWidth + plateWidth - middleHorizontalMember.body.position.y = memberWidth/2 + i * (plateWidth + memberWidth) - } - - if (i == numberOfColumns - 1) { - middleHorizontalMember.body.depth = plateWidth + memberWidth + memberWidth/2 - } - - middleHorizontalMember.body.update(); - - this.fragments.set(middleHorizontalMemberId, middleHorizontalMemberFragment) - this.geometries.set(middleHorizontalMemberId, middleHorizontalMemberBody) - - middleHorizontalMembers.push(middleHorizontalMember); - } - - if (i > 0 ) { - // generate members on origing side - const middleVerticalMember = new SimpleMemberType(model).addInstance(); - const middleVerticalMemberBody = middleVerticalMember.body - const middleVerticalMemberId = middleVerticalMemberBody.attributes.expressID; - const middleVerticalMemberFragment = this.newFragment(); - - middleVerticalMember.body.position.y = i * (plateWidth + memberWidth) + memberWidth/2 - middleVerticalMember.body.depth = plateHeight - middleVerticalMember.body.position.z = memberWidth - - if (j > 0 ) { - middleVerticalMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth - } - - middleVerticalMember.body.update(); - - this.fragments.set(middleVerticalMemberId, middleVerticalMemberFragment) - this.geometries.set(middleVerticalMemberId, middleVerticalMemberBody) - - middleVerticalMembers.push(middleVerticalMember); - - } - - if (i == 0 ) { - // generate members on origing side - const sideAMember = new SimpleMemberType(model).addInstance(); - const sideAMemberBody = sideAMember.body - const sideAMemberId = sideAMemberBody.attributes.expressID; - const sideAMemberFragment = this.newFragment(); + plate.body.profile.update(); + plate.body.update(); - sideAMember.body.position.y = i * distanceToCenter + memberWidth/2 - sideAMember.body.depth = plateHeight - sideAMember.body.position.z = memberWidth + this.fragments.set(plateId, this.newFragment()); + this.geometries.set(plateId, plate.body); + this.plates.push(plate); - if (j > 0 ) { - sideAMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth - } + // generate middle horizontal grid members----------------------------------- + if (j > 0) { + const middleHorizontalMember = new SimpleMemberType( + model + ).addInstance(); + const middleHorizontalMemberId = + middleHorizontalMember.body.attributes.expressID; - sideAMember.body.update(); + middleHorizontalMember.body.depth = horizontalMemberLength; + + middleHorizontalMember.body.position.y = + initialHorizontalColumnLocation; + middleHorizontalMember.body.position.z = + nonInitialVerticalRowLocation - memberWidth / 2; - this.fragments.set(sideAMemberId, sideAMemberFragment) - this.geometries.set(sideAMemberId, sideAMemberBody) + middleHorizontalMember.body.rotation.x = Math.PI / -2; - sideAMembers.push(sideAMember); + if (i > 0) { + middleHorizontalMember.body.depth = memberWidth + plateWidth; + middleHorizontalMember.body.position.y = + nonInitialHorizontalColumnLocation; + } + if (i == this.numberOfColumns - 1) { + middleHorizontalMember.body.depth = horizontalMemberLength; } + middleHorizontalMember.body.update(); + + this.fragments.set(middleHorizontalMemberId, this.newFragment()); + this.geometries.set( + middleHorizontalMemberId, + middleHorizontalMember.body + ); + this.middleHorizontalMembers.push(middleHorizontalMember); + } - // generate members on end side - const sideBMember = new SimpleMemberType(model).addInstance(); - const sideBMemberBody = sideBMember.body - const sideBMemberId = sideBMemberBody.attributes.expressID; - const sideBMemberFragment = this.newFragment(); + if (i > 0) { + // generate middle vertical grid members------------------------- + const middleVerticalMember = new SimpleMemberType( + model + ).addInstance(); + const middleVerticalMemberId = + middleVerticalMember.body.attributes.expressID; - sideBMember.body.position.y = length - memberWidth / 2 // + 2 * memberWidth - memberWidth / 2 - sideBMember.body.depth = plateHeight - sideBMember.body.position.z = memberWidth - - if (j > 0 ) { - sideBMember.body.position.z = j * (plateHeight + memberWidth) + memberWidth - } + middleVerticalMember.body.depth = plateHeight; - sideBMember.body.update(); + middleVerticalMember.body.position.y = + nonInitialHorizontalColumnLocation; + middleVerticalMember.body.position.z = memberWidth; + + if (j > 0) { + middleVerticalMember.body.position.z = + nonInitialVerticalRowLocation; + } - this.fragments.set(sideBMemberId, sideBMemberFragment) - this.geometries.set(sideBMemberId, sideBMemberBody) + middleVerticalMember.body.update(); - sideBMembers.push(sideBMember); + this.fragments.set(middleVerticalMemberId, this.newFragment()); + this.geometries.set( + middleVerticalMemberId, + middleVerticalMember.body + ); + this.middleVerticalMembers.push(middleVerticalMember); } - } - var sideAMembersAttributes = sideAMembers.map(member => member.body.attributes) - // sideAMembersAttributes = []; - var sideBMembersAttributes = sideBMembers.map(member => member.body.attributes) - // sideBMembersAttributes = []; - var bottomMembersAttributes = bottomMembers.map(member => member.body.attributes) - // bottomMembersAttributes = []; - var topMembersAttributes = topMembers.map(member => member.body.attributes) - // topMembersAttributes = []; - var platesAttributes = plates.map(member => member.body.attributes) - // platesAttributes = []; - var middleHorizontalMembersAttributes = middleHorizontalMembers.map(member => member.body.attributes) - // middleHorizontalMembersAttributes = []; - var middleVerticalMembersAttributes = middleVerticalMembers.map(member => member.body.attributes) - // middleVerticalMembersAttributes = []; - const concatItems = sideAMembersAttributes.concat(sideBMembersAttributes).concat(bottomMembersAttributes).concat(topMembersAttributes).concat(platesAttributes).concat(middleHorizontalMembersAttributes).concat(middleVerticalMembersAttributes) - console.log(sideBMembers) - console.log(concatItems) - - this.shape = IfcUtils.productDefinitionShape(model, concatItems); + if (i == 0) { + // generate vertical outer frame members on origing side-------------------------------- + const sideAMember = new SimpleMemberType(model).addInstance(); + const sideAMemberId = sideAMember.body.attributes.expressID; - this.attributes = new IFC.IfcCurtainWallType( - new IFC.IfcGloballyUniqueId(uuidv4()), - null, - null, - null, - null, - null, - null, - null, - null, - IFC.IfcCurtainWallTypeEnum.NOTDEFINED - ); + sideAMember.body.depth = plateHeight; - this.updateGeometry(); - this.model.set(this.attributes); - } + sideAMember.body.position.y = + initialHorizontalColumnLocation + memberWidth / 2; + sideAMember.body.position.z = memberWidth; - update(updateGeometry: boolean = false) { - this.updateGeometry(); - super.update(updateGeometry); - } + if (j > 0) { + sideAMember.body.position.z = nonInitialVerticalRowLocation; + } - private updateGeometry() { - // this.bottomFrame.profile.dimension.y = this.width; - // this.bottomFrame.profile.dimension.x = this.length; - // this.bottomFrame.profile.update(); + sideAMember.body.update(); + + this.fragments.set(sideAMemberId, this.newFragment()); + this.geometries.set(sideAMemberId, sideAMember.body); + this.sideAMembers.push(sideAMember); + } - // this.bottomFrame.depth = this.frameWidth; - // this.bottomFrame.update(); + // generate vertical outer frame members on end side-------------------------------------- + const sideBMember = new SimpleMemberType(model).addInstance(); + const sideBMemberId = sideBMember.body.attributes.expressID; - // this.topFrame.position.z = this.height; - // this.topFrame.depth = this.frameWidth; - // this.topFrame.update(); + sideBMember.body.depth = plateHeight; - // this.rightFrame.profile.dimension.y = this.width; - // this.rightFrame.profile.dimension.x = this.height; - // this.rightFrame.profile.update(); + sideBMember.body.position.y = this.length - memberWidth / 2; + sideBMember.body.position.z = memberWidth; + + if (j > 0) { + sideBMember.body.position.z = nonInitialVerticalRowLocation; + } - // this.rightFrame.position.x = -this.length / 2; - // this.rightFrame.position.z = this.height / 2; - // this.rightFrame.depth = this.frameWidth; - // this.rightFrame.update(); + sideBMember.body.update(); + + this.fragments.set(sideBMemberId, this.newFragment()); + this.geometries.set(sideBMemberId, sideBMember.body); + this.sideBMembers.push(sideBMember); + } + } + + const components = new Array().concat( + this.plates, + this.sideAMembers, + this.sideBMembers, + this.bottomMembers, + this.topMembers, + this.middleHorizontalMembers, + this.middleVerticalMembers + ); - // this.leftFrame.position.x = this.length / 2 - this.frameWidth; - // this.leftFrame.position.z = this.height / 2; - // this.leftFrame.depth = this.frameWidth; - // this.leftFrame.update(); + return components.map((component) => component.body.attributes); } protected createElement() { diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts index c180b68..57770d0 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts @@ -20,7 +20,10 @@ export class SimpleCurtainWall extends Element { this.geometries.add(id); } - this.attributes = new IFC.IfcWindow( + console.log('creating simplecurtainwall instance') + console.log(type.shape.Representations) + + this.attributes = new IFC.IfcCurtainWall( new IFC.IfcGloballyUniqueId(uuidv4()), null, null, @@ -30,12 +33,9 @@ export class SimpleCurtainWall extends Element { type.shape, null, null, - null, - null, - null, - null ); this.model.set(this.attributes); - } + + } } diff --git a/src/elements/Members/SimpleMember/src/index.ts b/src/elements/Members/SimpleMember/src/index.ts index 7621d32..82007d4 100644 --- a/src/elements/Members/SimpleMember/src/index.ts +++ b/src/elements/Members/SimpleMember/src/index.ts @@ -16,6 +16,10 @@ export class SimpleMember extends Element { type: SimpleMemberType + width = 0.0635; + + depth = 0.127; + constructor(model: Model, type: SimpleMemberType) { super(model, type) this.type = type @@ -23,8 +27,8 @@ export class SimpleMember extends Element { const placement = IfcUtils.localPlacement(location); const profile = new RectangleProfile(model); - profile.dimension.x = 0.127 //2.6 inches in meters - profile.dimension.y = 0.0635 //5 inches in meters + profile.dimension.x = this.depth; + profile.dimension.y = this.width; profile.position = new THREE.Vector3(0,0,5) profile.update(); From e4e49f2a96009b8c36605732960364e8e5716757 Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Fri, 10 May 2024 14:54:10 -0700 Subject: [PATCH 6/7] separated algorithm into instantiation and updates --- .../CurtainWalls/SimpleCurtainWall/index.html | 83 +++- .../CurtainWalls/SimpleCurtainWall/index.ts | 355 ++++++++---------- .../SimpleCurtainWall/src/index.ts | 10 +- .../Members/SimpleMember/src/index.ts | 85 ++--- 4 files changed, 263 insertions(+), 270 deletions(-) diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.html b/src/elements/CurtainWalls/SimpleCurtainWall/index.html index e55a2fc..17d1609 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.html +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.html @@ -93,22 +93,81 @@ await model.init(); const curtainWallType = new CLAY.SimpleCurtainWallType(model); - // curtainWallType.length = 2; - // curtainWallType.height = 6; - // curtainWallType.numberOfColumns = 2; - // curtainWallType.numberOfRows = 2; - // curtainWallType.update(true) + + // curtainWallType.height = 5; + + // curtainWallType.numberOfColumns = 3; + // curtainWallType.numberOfRows = 3; + + curtainWallType.startPoint.x = -10; + curtainWallType.startPoint.y = 0; + + curtainWallType.endPoint.x = 0; + curtainWallType.endPoint.y = 10; + + curtainWallType.update(true); const curtainWall = curtainWallType.addInstance(); scene.add(...curtainWall.meshes); - window.addEventListener("keydown", () => { - const exported = model.ifcAPI.SaveModel(model.modelID); - const file = new File([new Blob([exported])], "a"); - const a = document.createElement("a"); - a.href = URL.createObjectURL(file); - a.download = "example.ifc"; - a.click(); + const gui = new dat.GUI(); + + + + gui + .add(curtainWallType.startPoint, "x") + .name("Start X") + .min(-10) + .max(10) + .step(1) + .onChange(() => { + curtainWallType.update(true); + }); + + gui + .add(curtainWallType.startPoint, "y") + .name("Start Y") + .min(-10) + .max(10) + .step(1) + .onChange(() => { + curtainWallType.update(true); + }); + + + gui + .add(curtainWallType.endPoint, "x") + .name("End X") + .min(-10) + .max(10) + .step(1) + .onChange(() => { + curtainWallType.update(true); + }); + + gui + .add(curtainWallType.endPoint, "y") + .name("End Y") + .min(-10) + .max(10) + .step(1) + .onChange(() => { + curtainWallType.update(true); + }); + + gui + .add(curtainWallType, "height") + .name("Height") + .min(1) + .max(10) + .step(1) + .onChange(() => { + curtainWallType.update(true); + }); + + gui.add(curtainWallType, "frameWidth").name("Frame Width").min(0.127).max(1).step(0.01).onChange(() => { + curtainWallType.update(true); }); + diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts index 0d276c7..4440d85 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -8,6 +8,7 @@ import { SimpleMemberType } from "../../Members"; import { SimplePlateType } from "../../Plates"; import { SimpleMember } from "../../Members/SimpleMember/src"; import { SimplePlate } from "../../Plates/SimplePlate/src"; +import * as THREE from "three"; export * from "./src"; @@ -16,19 +17,19 @@ export class SimpleCurtainWallType extends StaticElementType shape: IFC4X3.IfcProductDefinitionShape; - length = 6; - height = 3; - numberOfColumns = 8; + frameWidth = 0.127; - numberOfRows = 5; + startPoint = new THREE.Vector3(0,0,0) + + endPoint = new THREE.Vector3(1,0,0) - //Glazing + numberOfColumns = 2; - private plates: SimplePlate[] = []; + numberOfRows = 2; - //Outer square frame + private plates: SimplePlate[] = []; private sideAMembers: SimpleMember[] = []; @@ -38,16 +39,33 @@ export class SimpleCurtainWallType extends StaticElementType private topMembers: SimpleMember[] = []; - //Interior grid frame - private middleHorizontalMembers: SimpleMember[] = []; private middleVerticalMembers: SimpleMember[] = []; + get length() { + return this.startPoint.distanceTo(this.endPoint); + } + + get midPoint() { + return new THREE.Vector3( + (this.startPoint.x + this.endPoint.x) / 2, + (this.startPoint.y + this.endPoint.y) / 2, + (this.startPoint.z + this.endPoint.z) / 2 + ); + } + + get direction() { + const vector = new THREE.Vector3(); + vector.subVectors(this.endPoint, this.startPoint); + vector.normalize(); + return vector; + } + constructor(model: Model) { super(model); - const componentAttributes = this.composeCurtainWall(model); + const componentAttributes = this.instantiateComponents(model); this.shape = IfcUtils.productDefinitionShape(model, componentAttributes); @@ -63,229 +81,70 @@ export class SimpleCurtainWallType extends StaticElementType null, IFC.IfcCurtainWallTypeEnum.NOTDEFINED ); + this.updateComponentGeometries(); + this.model.set(this.attributes); } update(updateGeometry: boolean = false) { - const componentAttributes = this.composeCurtainWall(); - - this.shape = IfcUtils.productDefinitionShape( - this.model, - componentAttributes - ); - + this.updateComponentGeometries(); super.update(updateGeometry); } - composeCurtainWall(model?: Model) { - if (!model) { - model = this.model; - } - - const memberWidth = new SimpleMemberType(model).addInstance().width; - - const plateWidth = - (this.length - (this.numberOfColumns + 1) * memberWidth) / - this.numberOfColumns; - const plateHeight = - (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; + instantiateComponents(model: Model = this.model) { - const horizontalMemberLength = plateWidth + memberWidth + memberWidth / 2; - - for (let i = 0; i < this.numberOfColumns; i++) { - const initialHorizontalColumnLocation = 0; - const nonInitialHorizontalColumnLocation = - i * (plateWidth + memberWidth) + memberWidth / 2; - - // generate top horizontal members of outer frame------------------------- - const topMember = new SimpleMemberType(model).addInstance(); - const topMemberId = topMember.body.attributes.expressID; - - topMember.body.depth = horizontalMemberLength; - - topMember.body.position.y = initialHorizontalColumnLocation; - topMember.body.position.z = this.height - memberWidth / 2; - - topMember.body.rotation.x = Math.PI / -2; - - if (i > 0) { - topMember.body.depth = plateWidth + memberWidth; - topMember.body.position.y = nonInitialHorizontalColumnLocation; - } - - if (i == this.numberOfColumns - 1) { - topMember.body.depth = horizontalMemberLength; - } - - topMember.body.profile.update(); - topMember.body.update(); - - this.fragments.set(topMemberId, this.newFragment()); - this.geometries.set(topMemberId, topMember.body); - this.topMembers.push(topMember); - - // generate bottom horizontal members of outer frame------------------------- + for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { + const bottomMember = new SimpleMemberType(model).addInstance(); const bottomMemberId = bottomMember.body.attributes.expressID; - - bottomMember.body.depth = horizontalMemberLength; - - bottomMember.body.position.y = initialHorizontalColumnLocation; - bottomMember.body.position.z = memberWidth / 2; - - bottomMember.body.rotation.x = Math.PI / -2; - - if (i > 0) { - bottomMember.body.depth = plateWidth + memberWidth; - bottomMember.body.position.y = nonInitialHorizontalColumnLocation; - } - - if (i == this.numberOfColumns - 1) { - bottomMember.body.depth = horizontalMemberLength; - } - - bottomMember.body.update(); - this.fragments.set(bottomMemberId, this.newFragment()); this.geometries.set(bottomMemberId, bottomMember.body); this.bottomMembers.push(bottomMember); - for (let j = 0; j < this.numberOfRows; j++) { - const nonInitialVerticalRowLocation = - memberWidth + j * (plateHeight + memberWidth); - - // generate glazing plates------------------------------------ - const plate = new SimplePlateType(model).addInstance(); - const plateId = plate.body.attributes.expressID; + for (let currentRow = 0; currentRow < this.numberOfRows; currentRow++) { - plate.body.profile.dimension.y = plateWidth; - plate.body.depth = plateHeight; - - plate.body.position.y = plateWidth / 2 + memberWidth; - plate.body.position.z = memberWidth; - - if (i > 0) { - plate.body.position.y = - memberWidth + i * (plateWidth + memberWidth) + plateWidth / 2; - } - - if (j > 0) { - plate.body.position.z = nonInitialVerticalRowLocation; + if (currentColumn == 0) { + const sideAMember = new SimpleMemberType(model).addInstance(); + const sideAMemberId = sideAMember.body.attributes.expressID; + this.fragments.set(sideAMemberId, this.newFragment()); + this.geometries.set(sideAMemberId, sideAMember.body); + this.sideAMembers.push(sideAMember); } - plate.body.profile.update(); - plate.body.update(); - - this.fragments.set(plateId, this.newFragment()); - this.geometries.set(plateId, plate.body); - this.plates.push(plate); - - // generate middle horizontal grid members----------------------------------- - if (j > 0) { - const middleHorizontalMember = new SimpleMemberType( - model - ).addInstance(); - const middleHorizontalMemberId = - middleHorizontalMember.body.attributes.expressID; - - middleHorizontalMember.body.depth = horizontalMemberLength; - - middleHorizontalMember.body.position.y = - initialHorizontalColumnLocation; - middleHorizontalMember.body.position.z = - nonInitialVerticalRowLocation - memberWidth / 2; - - middleHorizontalMember.body.rotation.x = Math.PI / -2; - - if (i > 0) { - middleHorizontalMember.body.depth = memberWidth + plateWidth; - middleHorizontalMember.body.position.y = - nonInitialHorizontalColumnLocation; - } - - if (i == this.numberOfColumns - 1) { - middleHorizontalMember.body.depth = horizontalMemberLength; - } - - middleHorizontalMember.body.update(); - + if (currentRow > 0) { + const middleHorizontalMember = new SimpleMemberType(model).addInstance(); + const middleHorizontalMemberId = middleHorizontalMember.body.attributes.expressID; this.fragments.set(middleHorizontalMemberId, this.newFragment()); - this.geometries.set( - middleHorizontalMemberId, - middleHorizontalMember.body - ); + this.geometries.set(middleHorizontalMemberId, middleHorizontalMember.body); this.middleHorizontalMembers.push(middleHorizontalMember); } - if (i > 0) { - // generate middle vertical grid members------------------------- - const middleVerticalMember = new SimpleMemberType( - model - ).addInstance(); - const middleVerticalMemberId = - middleVerticalMember.body.attributes.expressID; - - middleVerticalMember.body.depth = plateHeight; - - middleVerticalMember.body.position.y = - nonInitialHorizontalColumnLocation; - middleVerticalMember.body.position.z = memberWidth; - - if (j > 0) { - middleVerticalMember.body.position.z = - nonInitialVerticalRowLocation; - } - - middleVerticalMember.body.update(); - + if (currentColumn > 0) { + const middleVerticalMember = new SimpleMemberType(model).addInstance(); + const middleVerticalMemberId = middleVerticalMember.body.attributes.expressID; this.fragments.set(middleVerticalMemberId, this.newFragment()); - this.geometries.set( - middleVerticalMemberId, - middleVerticalMember.body - ); + this.geometries.set(middleVerticalMemberId, middleVerticalMember.body); this.middleVerticalMembers.push(middleVerticalMember); } - if (i == 0) { - // generate vertical outer frame members on origing side-------------------------------- - const sideAMember = new SimpleMemberType(model).addInstance(); - const sideAMemberId = sideAMember.body.attributes.expressID; - - sideAMember.body.depth = plateHeight; - - sideAMember.body.position.y = - initialHorizontalColumnLocation + memberWidth / 2; - sideAMember.body.position.z = memberWidth; - - if (j > 0) { - sideAMember.body.position.z = nonInitialVerticalRowLocation; - } - - sideAMember.body.update(); - - this.fragments.set(sideAMemberId, this.newFragment()); - this.geometries.set(sideAMemberId, sideAMember.body); - this.sideAMembers.push(sideAMember); - } - - // generate vertical outer frame members on end side-------------------------------------- - const sideBMember = new SimpleMemberType(model).addInstance(); - const sideBMemberId = sideBMember.body.attributes.expressID; - - sideBMember.body.depth = plateHeight; - - sideBMember.body.position.y = this.length - memberWidth / 2; - sideBMember.body.position.z = memberWidth; - - if (j > 0) { - sideBMember.body.position.z = nonInitialVerticalRowLocation; + if (currentColumn == this.numberOfColumns - 1) { + const sideBMember = new SimpleMemberType(model).addInstance(); + const sideBMemberId = sideBMember.body.attributes.expressID; + this.fragments.set(sideBMemberId, this.newFragment()); + this.geometries.set(sideBMemberId, sideBMember.body); + this.sideBMembers.push(sideBMember); } - sideBMember.body.update(); - - this.fragments.set(sideBMemberId, this.newFragment()); - this.geometries.set(sideBMemberId, sideBMember.body); - this.sideBMembers.push(sideBMember); + const plate = new SimplePlateType(model).addInstance(); + const plateId = plate.body.attributes.expressID; + this.fragments.set(plateId, this.newFragment()); + this.geometries.set(plateId, plate.body); + this.plates.push(plate); } + const topMember = new SimpleMemberType(model).addInstance(); + const topMemberId = topMember.body.attributes.expressID; + this.fragments.set(topMemberId, this.newFragment()); + this.geometries.set(topMemberId, topMember.body); + this.topMembers.push(topMember); } const components = new Array().concat( @@ -301,6 +160,90 @@ export class SimpleCurtainWallType extends StaticElementType return components.map((component) => component.body.attributes); } + updateComponentGeometries(model: Model = this.model) { + const memberWidth = new SimpleMemberType(model).addInstance().width; + const plateWidth = this.length / this.numberOfColumns - memberWidth; + const plateHeight = (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; + const deltaX = (this.endPoint.x - this.startPoint.x) / this.numberOfColumns; + const deltaY = (this.endPoint.y - this.startPoint.y) / this.numberOfColumns; + const rotationY = Math.atan2(this.endPoint.x - this.startPoint.x, this.endPoint.y - this.startPoint.y); + + for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { + const posX = this.startPoint.x + currentColumn * deltaX; + const posY = this.startPoint.y + currentColumn * deltaY; + + const bottomMember = this.bottomMembers[currentColumn]; + bottomMember.body.profile.dimension.x = this.frameWidth; + bottomMember.body.depth = this.length / this.numberOfColumns; + bottomMember.body.position.set(posX, posY, memberWidth / 2); + bottomMember.body.rotation.set(Math.PI / -2, rotationY, 0); + bottomMember.body.profile.update(); + bottomMember.body.update(); + + for (let currentRow = 0; currentRow < this.numberOfRows; currentRow++) { + const nonInitialVerticalRowLocation = memberWidth + currentRow * (plateHeight + memberWidth); + + if (currentColumn == 0) { + const sideAMember = this.sideAMembers[currentRow]; + sideAMember.body.profile.dimension.x = this.frameWidth; + sideAMember.body.profile.position.y = memberWidth/2 + sideAMember.body.depth = plateHeight; + sideAMember.body.position.set(this.startPoint.x, this.startPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); + sideAMember.body.rotation.set(0, 0, -rotationY); + sideAMember.body.profile.update(); + sideAMember.body.update(); + } + + if (currentColumn == this.numberOfColumns - 1) { + const sideBMember = this.sideBMembers[currentRow]; + sideBMember.body.profile.dimension.x = this.frameWidth; + sideBMember.body.profile.position.y = -1 * (memberWidth/2) + sideBMember.body.depth = plateHeight; + sideBMember.body.position.set(this.endPoint.x, this.endPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); + sideBMember.body.rotation.set(0, 0, -rotationY); + sideBMember.body.profile.update(); + sideBMember.body.update(); + } + + if (currentRow > 0) { + const middleHorizontalMember = this.middleHorizontalMembers[currentColumn * (this.numberOfRows - 1) + (currentRow - 1)]; + middleHorizontalMember.body.profile.dimension.x = this.frameWidth; + middleHorizontalMember.body.depth = this.length / this.numberOfColumns; + middleHorizontalMember.body.position.set(posX, posY, nonInitialVerticalRowLocation - memberWidth / 2); + middleHorizontalMember.body.rotation.set(Math.PI / -2, rotationY, 0); + middleHorizontalMember.body.profile.update(); + middleHorizontalMember.body.update(); + } + + if (currentColumn > 0 && currentRow < this.numberOfRows) { + const middleVerticalMember = this.middleVerticalMembers[(currentColumn - 1) * this.numberOfRows + currentRow]; + middleVerticalMember.body.profile.dimension.x = this.frameWidth; + middleVerticalMember.body.depth = plateHeight; + middleVerticalMember.body.position.set(posX, posY, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); + middleVerticalMember.body.rotation.set(0, 0, -rotationY); + middleVerticalMember.body.profile.update(); + middleVerticalMember.body.update(); + } + + const plate = this.plates[currentColumn * this.numberOfRows + currentRow]; + plate.body.profile.dimension.y = plateWidth; + plate.body.depth = plateHeight; + plate.body.position.set(posX + deltaX / 2, posY + deltaY / 2, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); + plate.body.rotation.z = -rotationY; + plate.body.profile.update(); + plate.body.update(); + } + + const topMember = this.topMembers[currentColumn]; + topMember.body.profile.dimension.x = this.frameWidth; + topMember.body.depth = this.length / this.numberOfColumns; + topMember.body.position.set(posX, posY, this.height - memberWidth / 2); + topMember.body.rotation.set(Math.PI / -2, rotationY, 0); + topMember.body.profile.update(); + topMember.body.update(); + } +} + protected createElement() { return new SimpleCurtainWall(this.model, this); } diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts index 57770d0..e6a9db2 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/src/index.ts @@ -16,13 +16,10 @@ export class SimpleCurtainWall extends Element { const placement = IfcUtils.localPlacement(); - for(const [id] of type.geometries) { + for (const [id] of type.geometries) { this.geometries.add(id); } - console.log('creating simplecurtainwall instance') - console.log(type.shape.Representations) - this.attributes = new IFC.IfcCurtainWall( new IFC.IfcGloballyUniqueId(uuidv4()), null, @@ -32,10 +29,9 @@ export class SimpleCurtainWall extends Element { placement, type.shape, null, - null, + null ); this.model.set(this.attributes); - - } + } } diff --git a/src/elements/Members/SimpleMember/src/index.ts b/src/elements/Members/SimpleMember/src/index.ts index 82007d4..16fec2f 100644 --- a/src/elements/Members/SimpleMember/src/index.ts +++ b/src/elements/Members/SimpleMember/src/index.ts @@ -1,4 +1,3 @@ - import { IFC4X3 as IFC } from "web-ifc"; import { Element } from "../../../Elements"; import { Model } from "../../../../base"; @@ -8,49 +7,45 @@ import { IfcUtils } from "../../../../utils/ifc-utils"; import { Extrusion, RectangleProfile } from "../../../../geometries"; import * as THREE from "three"; - export class SimpleMember extends Element { - attributes: IFC.IfcMember; - - body: Extrusion; - - type: SimpleMemberType - - width = 0.0635; - - depth = 0.127; - - constructor(model: Model, type: SimpleMemberType) { - super(model, type) - this.type = type - const location = new THREE.Vector3(0,0,1) - const placement = IfcUtils.localPlacement(location); - - const profile = new RectangleProfile(model); - profile.dimension.x = this.depth; - profile.dimension.y = this.width; - profile.position = new THREE.Vector3(0,0,5) - profile.update(); - - this.body = new Extrusion(model, profile); - const id = this.body.attributes.expressID; - this.type.geometries.set(id, this.body); - this.geometries.add(id); - - - this.attributes = new IFC.IfcPlate( - new IFC.IfcGloballyUniqueId(uuidv4()), - null, - null, - null, - null, - placement, - IfcUtils.productDefinitionShape(model, [this.body.attributes]), - null, - type.memberType, - ) - - this.model.set(this.attributes); - } - + attributes: IFC.IfcMember; + + body: Extrusion; + + type: SimpleMemberType; + + width = 0.0635; + + depth = 0.127; + + constructor(model: Model, type: SimpleMemberType) { + super(model, type); + this.type = type; + const location = new THREE.Vector3(0, 0, 1); + const placement = IfcUtils.localPlacement(location); + + const profile = new RectangleProfile(model); + profile.dimension.x = this.depth; + profile.dimension.y = this.width; + profile.position = new THREE.Vector3(0, 0, 5); + profile.update(); + + this.body = new Extrusion(model, profile); + const id = this.body.attributes.expressID; + this.type.geometries.set(id, this.body); + this.geometries.add(id); + + this.attributes = new IFC.IfcPlate( + new IFC.IfcGloballyUniqueId(uuidv4()), + null, + null, + null, + null, + placement, + IfcUtils.productDefinitionShape(model, [this.body.attributes]), + null, + type.memberType + ); + this.model.set(this.attributes); + } } From 14498dbd303fd0289daff8cadb5895879f864ede Mon Sep 17 00:00:00 2001 From: cristian sotomayor Date: Fri, 10 May 2024 16:42:15 -0700 Subject: [PATCH 7/7] fixed bug when instantiating geomtry --- .../CurtainWalls/SimpleCurtainWall/index.html | 13 +- .../CurtainWalls/SimpleCurtainWall/index.ts | 310 +++++++++++++----- 2 files changed, 232 insertions(+), 91 deletions(-) diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.html b/src/elements/CurtainWalls/SimpleCurtainWall/index.html index 17d1609..96380be 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.html +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.html @@ -92,16 +92,11 @@ model.ifcAPI.SetWasmPath("https://unpkg.com/web-ifc@0.0.50/", true); await model.init(); - const curtainWallType = new CLAY.SimpleCurtainWallType(model); - - // curtainWallType.height = 5; - - // curtainWallType.numberOfColumns = 3; - // curtainWallType.numberOfRows = 3; - + const curtainWallType = new CLAY.SimpleCurtainWallType(model, 5, 5); + + curtainWallType.height = 5 curtainWallType.startPoint.x = -10; curtainWallType.startPoint.y = 0; - curtainWallType.endPoint.x = 0; curtainWallType.endPoint.y = 10; @@ -113,8 +108,6 @@ const gui = new dat.GUI(); - - gui .add(curtainWallType.startPoint, "x") .name("Start X") diff --git a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts index 4440d85..c3f135e 100644 --- a/src/elements/CurtainWalls/SimpleCurtainWall/index.ts +++ b/src/elements/CurtainWalls/SimpleCurtainWall/index.ts @@ -62,8 +62,14 @@ export class SimpleCurtainWallType extends StaticElementType return vector; } - constructor(model: Model) { + constructor(model: Model, numberOfColumns?: number, numberOfRows?: number) { super(model); + + if (numberOfColumns) + this.numberOfColumns = numberOfColumns; + + if (numberOfRows) + this.numberOfRows = numberOfRows; const componentAttributes = this.instantiateComponents(model); @@ -81,6 +87,7 @@ export class SimpleCurtainWallType extends StaticElementType null, IFC.IfcCurtainWallTypeEnum.NOTDEFINED ); + this.updateComponentGeometries(); this.model.set(this.attributes); } @@ -91,7 +98,7 @@ export class SimpleCurtainWallType extends StaticElementType } instantiateComponents(model: Model = this.model) { - + console.log('intantiating...') for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { const bottomMember = new SimpleMemberType(model).addInstance(); @@ -160,90 +167,231 @@ export class SimpleCurtainWallType extends StaticElementType return components.map((component) => component.body.attributes); } - updateComponentGeometries(model: Model = this.model) { - const memberWidth = new SimpleMemberType(model).addInstance().width; - const plateWidth = this.length / this.numberOfColumns - memberWidth; - const plateHeight = (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; - const deltaX = (this.endPoint.x - this.startPoint.x) / this.numberOfColumns; - const deltaY = (this.endPoint.y - this.startPoint.y) / this.numberOfColumns; - const rotationY = Math.atan2(this.endPoint.x - this.startPoint.x, this.endPoint.y - this.startPoint.y); +// updateComponentGeometries(model: Model = this.model) { +// const memberWidth = new SimpleMemberType(model).addInstance().width; +// const plateWidth = this.length / this.numberOfColumns - memberWidth; +// const plateHeight = (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; +// const deltaX = (this.endPoint.x - this.startPoint.x) / this.numberOfColumns; +// const deltaY = (this.endPoint.y - this.startPoint.y) / this.numberOfColumns; +// const rotationY = Math.atan2(this.endPoint.x - this.startPoint.x, this.endPoint.y - this.startPoint.y); + +// for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { +// const posX = this.startPoint.x + currentColumn * deltaX; +// const posY = this.startPoint.y + currentColumn * deltaY; + +// const bottomMember = this.bottomMembers[currentColumn]; +// bottomMember.body.profile.dimension.x = this.frameWidth; +// bottomMember.body.depth = this.length / this.numberOfColumns; +// bottomMember.body.position.set(posX, posY, memberWidth / 2); +// bottomMember.body.rotation.set(Math.PI / -2, rotationY, 0); +// bottomMember.body.profile.update(); +// bottomMember.body.update(); + +// for (let currentRow = 0; currentRow < this.numberOfRows; currentRow++) { +// const nonInitialVerticalRowLocation = memberWidth + currentRow * (plateHeight + memberWidth); + +// if (currentColumn == 0) { +// const sideAMember = this.sideAMembers[currentRow]; +// console.log(currentRow) +// console.log(this.sideAMembers) +// console.log('here!!!!!!!!!!!!!!!!!!!') +// sideAMember.body.profile.dimension.x = this.frameWidth; +// sideAMember.body.profile.position.y = memberWidth/2 +// sideAMember.body.depth = plateHeight; +// sideAMember.body.position.set(this.startPoint.x, this.startPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); +// sideAMember.body.rotation.set(0, 0, -rotationY); +// sideAMember.body.profile.update(); +// sideAMember.body.update(); +// } + +// if (currentColumn == this.numberOfColumns - 1) { +// const sideBMember = this.sideBMembers[currentRow]; +// sideBMember.body.profile.dimension.x = this.frameWidth; +// sideBMember.body.profile.position.y = -1 * (memberWidth/2) +// sideBMember.body.depth = plateHeight; +// sideBMember.body.position.set(this.endPoint.x, this.endPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); +// sideBMember.body.rotation.set(0, 0, -rotationY); +// sideBMember.body.profile.update(); +// sideBMember.body.update(); +// } + +// if (currentRow > 0) { +// const middleHorizontalMember = this.middleHorizontalMembers[currentColumn * (this.numberOfRows - 1) + (currentRow - 1)]; +// middleHorizontalMember.body.profile.dimension.x = this.frameWidth; +// middleHorizontalMember.body.depth = this.length / this.numberOfColumns; +// middleHorizontalMember.body.position.set(posX, posY, nonInitialVerticalRowLocation - memberWidth / 2); +// middleHorizontalMember.body.rotation.set(Math.PI / -2, rotationY, 0); +// middleHorizontalMember.body.profile.update(); +// middleHorizontalMember.body.update(); +// } + +// if (currentColumn > 0 && currentRow < this.numberOfRows) { +// const middleVerticalMember = this.middleVerticalMembers[(currentColumn - 1) * this.numberOfRows + currentRow]; +// middleVerticalMember.body.profile.dimension.x = this.frameWidth; +// middleVerticalMember.body.depth = plateHeight; +// middleVerticalMember.body.position.set(posX, posY, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); +// middleVerticalMember.body.rotation.set(0, 0, -rotationY); +// middleVerticalMember.body.profile.update(); +// middleVerticalMember.body.update(); +// } + +// const plate = this.plates[currentColumn * this.numberOfRows + currentRow]; +// plate.body.profile.dimension.y = plateWidth; +// plate.body.depth = plateHeight; +// plate.body.position.set(posX + deltaX / 2, posY + deltaY / 2, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); +// plate.body.rotation.z = -rotationY; +// plate.body.profile.update(); +// plate.body.update(); +// } + +// const topMember = this.topMembers[currentColumn]; +// topMember.body.profile.dimension.x = this.frameWidth; +// topMember.body.depth = this.length / this.numberOfColumns; +// topMember.body.position.set(posX, posY, this.height - memberWidth / 2); +// topMember.body.rotation.set(Math.PI / -2, rotationY, 0); +// topMember.body.profile.update(); +// topMember.body.update(); +// } +// } + +updateComponentGeometries(model: Model = this.model) { + + const memberWidth = new SimpleMemberType(model).addInstance().width; + const plateWidth = this.length/this.numberOfColumns - memberWidth; + const plateHeight = (this.height - (this.numberOfRows + 1) * memberWidth) / this.numberOfRows; + + for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { + + const bottomMember = this.bottomMembers[currentColumn]; + bottomMember.body.profile.dimension.x = this.frameWidth; + bottomMember.body.depth = this.length / this.numberOfColumns; + bottomMember.body.position.x = this.startPoint.x​ + (currentColumn/this.numberOfColumns) * (this.endPoint.x ​- this.startPoint.x​); + bottomMember.body.position.y = this.startPoint.y​ + (currentColumn/this.numberOfColumns) * (this.endPoint.y ​- this.startPoint.y​); + bottomMember.body.position.z = memberWidth / 2; + bottomMember.body.rotation.x = Math.PI / -2; + bottomMember.body.rotation.y = Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + if (currentColumn == this.numberOfColumns - 1) { + bottomMember.body.depth = this.length / this.numberOfColumns; + } - for (let currentColumn = 0; currentColumn < this.numberOfColumns; currentColumn++) { - const posX = this.startPoint.x + currentColumn * deltaX; - const posY = this.startPoint.y + currentColumn * deltaY; - - const bottomMember = this.bottomMembers[currentColumn]; - bottomMember.body.profile.dimension.x = this.frameWidth; - bottomMember.body.depth = this.length / this.numberOfColumns; - bottomMember.body.position.set(posX, posY, memberWidth / 2); - bottomMember.body.rotation.set(Math.PI / -2, rotationY, 0); - bottomMember.body.profile.update(); - bottomMember.body.update(); - - for (let currentRow = 0; currentRow < this.numberOfRows; currentRow++) { - const nonInitialVerticalRowLocation = memberWidth + currentRow * (plateHeight + memberWidth); - - if (currentColumn == 0) { - const sideAMember = this.sideAMembers[currentRow]; - sideAMember.body.profile.dimension.x = this.frameWidth; - sideAMember.body.profile.position.y = memberWidth/2 - sideAMember.body.depth = plateHeight; - sideAMember.body.position.set(this.startPoint.x, this.startPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); - sideAMember.body.rotation.set(0, 0, -rotationY); - sideAMember.body.profile.update(); - sideAMember.body.update(); - } - - if (currentColumn == this.numberOfColumns - 1) { - const sideBMember = this.sideBMembers[currentRow]; - sideBMember.body.profile.dimension.x = this.frameWidth; - sideBMember.body.profile.position.y = -1 * (memberWidth/2) - sideBMember.body.depth = plateHeight; - sideBMember.body.position.set(this.endPoint.x, this.endPoint.y, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); - sideBMember.body.rotation.set(0, 0, -rotationY); - sideBMember.body.profile.update(); - sideBMember.body.update(); - } - - if (currentRow > 0) { - const middleHorizontalMember = this.middleHorizontalMembers[currentColumn * (this.numberOfRows - 1) + (currentRow - 1)]; - middleHorizontalMember.body.profile.dimension.x = this.frameWidth; - middleHorizontalMember.body.depth = this.length / this.numberOfColumns; - middleHorizontalMember.body.position.set(posX, posY, nonInitialVerticalRowLocation - memberWidth / 2); - middleHorizontalMember.body.rotation.set(Math.PI / -2, rotationY, 0); - middleHorizontalMember.body.profile.update(); - middleHorizontalMember.body.update(); - } - - if (currentColumn > 0 && currentRow < this.numberOfRows) { - const middleVerticalMember = this.middleVerticalMembers[(currentColumn - 1) * this.numberOfRows + currentRow]; - middleVerticalMember.body.profile.dimension.x = this.frameWidth; - middleVerticalMember.body.depth = plateHeight; - middleVerticalMember.body.position.set(posX, posY, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); - middleVerticalMember.body.rotation.set(0, 0, -rotationY); - middleVerticalMember.body.profile.update(); - middleVerticalMember.body.update(); - } - - const plate = this.plates[currentColumn * this.numberOfRows + currentRow]; - plate.body.profile.dimension.y = plateWidth; - plate.body.depth = plateHeight; - plate.body.position.set(posX + deltaX / 2, posY + deltaY / 2, currentRow > 0 ? nonInitialVerticalRowLocation : memberWidth); - plate.body.rotation.z = -rotationY; - plate.body.profile.update(); - plate.body.update(); + bottomMember.body.profile.update(); + bottomMember.body.update(); + + for (let currentRow = 0; currentRow < this.numberOfRows; currentRow++) { + + const nonInitialVerticalRowLocation = memberWidth + currentRow * (plateHeight + memberWidth); + + if (currentColumn == 0) { + + const sideAMember = this.sideAMembers[currentRow] + sideAMember.body.profile.dimension.x = this.frameWidth; + sideAMember.body.profile.position.y = memberWidth/2 + sideAMember.body.depth = plateHeight; + sideAMember.body.position.x = this.startPoint.x; + sideAMember.body.position.y = this.startPoint.y; + sideAMember.body.position.z = memberWidth; + sideAMember.body.rotation.z = -1 * Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + if (currentRow > 0) { + sideAMember.body.position.z = nonInitialVerticalRowLocation; } + + sideAMember.body.profile.update(); + sideAMember.body.update(); + } + + if (currentRow > 0) { + + const middleHorizontalMember = this.middleHorizontalMembers[currentColumn * (this.numberOfRows - 1) + (currentRow - 1)] + middleHorizontalMember.body.profile.dimension.x = this.frameWidth; + middleHorizontalMember.body.depth = this.length / this.numberOfColumns; + middleHorizontalMember.body.position.x = this.startPoint.x​ + (currentColumn/this.numberOfColumns) * (this.endPoint.x ​- this.startPoint.x​); + middleHorizontalMember.body.position.y = this.startPoint.y​ + (currentColumn/this.numberOfColumns) * (this.endPoint.y ​- this.startPoint.y​); + middleHorizontalMember.body.position.z = nonInitialVerticalRowLocation - memberWidth / 2; + middleHorizontalMember.body.rotation.x = Math.PI / -2; + middleHorizontalMember.body.rotation.y = Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + middleHorizontalMember.body.profile.update(); + middleHorizontalMember.body.update(); + } + + if (currentColumn > 0) { + + const middleVerticalMember = this.middleVerticalMembers[(currentColumn - 1) * this.numberOfRows + currentRow] + middleVerticalMember.body.profile.dimension.x = this.frameWidth; + middleVerticalMember.body.depth = plateHeight; + middleVerticalMember.body.position.x = this.startPoint.x​ + (currentColumn/this.numberOfColumns) * (this.endPoint.x ​- this.startPoint.x​); + middleVerticalMember.body.position.y = this.startPoint.y​ + (currentColumn/this.numberOfColumns) * (this.endPoint.y ​- this.startPoint.y​); + middleVerticalMember.body.position.z = memberWidth; + middleVerticalMember.body.rotation.z = -1 * Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); - const topMember = this.topMembers[currentColumn]; - topMember.body.profile.dimension.x = this.frameWidth; - topMember.body.depth = this.length / this.numberOfColumns; - topMember.body.position.set(posX, posY, this.height - memberWidth / 2); - topMember.body.rotation.set(Math.PI / -2, rotationY, 0); - topMember.body.profile.update(); - topMember.body.update(); + if (currentRow > 0) { + middleVerticalMember.body.position.z = nonInitialVerticalRowLocation; + } + middleVerticalMember.body.profile.update(); + middleVerticalMember.body.update(); + } + + + if (currentColumn == this.numberOfColumns - 1) { + + const sideBMember = this.sideBMembers[currentRow] + sideBMember.body.profile.position.y = -1 * (memberWidth/2) + sideBMember.body.profile.dimension.x = this.frameWidth; + sideBMember.body.depth = plateHeight; + sideBMember.body.position.x = this.endPoint.x; + sideBMember.body.position.y = this.endPoint.y + sideBMember.body.position.z = memberWidth; + sideBMember.body.rotation.z = -1 * Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + if (currentRow > 0) { + sideBMember.body.position.z = nonInitialVerticalRowLocation; + } + + sideBMember.body.profile.update(); + sideBMember.body.update(); } -} + const plate = this.plates[currentColumn * this.numberOfRows + currentRow]; + plate.body.profile.dimension.y = plateWidth; + plate.body.depth = plateHeight; + plate.body.position.z = memberWidth; + plate.body.position.x = this.startPoint.x​ + (((this.endPoint.x - this.startPoint.x)/this.numberOfColumns) /2) + ((currentColumn/this.numberOfColumns) * (this.endPoint.x ​- this.startPoint.x​ )) ; + plate.body.position.y = this.startPoint.y​ + (((this.endPoint.y - this.startPoint.y)/this.numberOfColumns) /2) + ((currentColumn/this.numberOfColumns) * (this.endPoint.y ​- this.startPoint.y​ )) ; + plate.body.rotation.z = -1 * Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + if (currentRow > 0) { + plate.body.position.z = nonInitialVerticalRowLocation; + } + + if (currentColumn == 0 || currentColumn == this.numberOfColumns - 1) + { + plate.body.profile.dimension.y = plateWidth - memberWidth/2 + plate.body.profile.position.y = memberWidth/4 + } + + if (currentColumn == this.numberOfColumns - 1) { + plate.body.profile.position.y = -memberWidth/4 + } + + plate.body.profile.update(); + plate.body.update(); + } + + const topMember = this.topMembers[currentColumn] + topMember.body.profile.dimension.x = this.frameWidth; + topMember.body.depth = this.length / this.numberOfColumns; + topMember.body.position.x = this.startPoint.x​ + (currentColumn/this.numberOfColumns) * (this.endPoint.x ​- this.startPoint.x​); + topMember.body.position.y = this.startPoint.y​ + (currentColumn/this.numberOfColumns) * (this.endPoint.y ​- this.startPoint.y​); + topMember.body.position.z = this.height - memberWidth / 2; + topMember.body.rotation.x = Math.PI / -2; + topMember.body.rotation.y = Math.atan2(this.endPoint.x -this.startPoint.x, this.endPoint.y - this.startPoint.y); + + topMember.body.profile.update(); + topMember.body.update(); + } +} protected createElement() { return new SimpleCurtainWall(this.model, this); }