Skip to content

Commit

Permalink
feat: rename families folder
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Mar 3, 2024
1 parent b9f3d56 commit 7554159
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 710 deletions.
167 changes: 6 additions & 161 deletions resources/openbim-clay.js
Original file line number Diff line number Diff line change
Expand Up @@ -4400,161 +4400,6 @@ class Walls extends Primitive {
}
}

// import { Vector3 } from "three";
class Slabs extends Primitive {
constructor() {
super();
this.extrusions = new Extrusions();
this.lines = new Lines();
this._nextIndex = 0;
this._nextPolylineIndex = 0;
this._extrusionSlabMap = new Map();
this.list = {};
this.polylines = {};
this.mesh = this.extrusions.mesh;
}
/**
* Given a face index, returns the slab ID that contains it.
* @param faceIndex The index of the face whose slab ID to get.
*/
getFromIndex(faceIndex) {
const faceID = this.extrusions.faces.getFromIndex(faceIndex);
if (faceID === undefined)
return undefined;
const extrusionID = this.extrusions.getFromFace(faceID);
if (extrusionID === undefined)
return undefined;
return this._extrusionSlabMap.get(extrusionID);
}
addPolyline(lines) {
const id = this._nextPolylineIndex++;
this.polylines[id] = {
id,
lines: new Set(lines),
};
return id;
}
setPolylines(id, lines) {
this.list[id].polylines = new Set(lines);
}
add(polylines, height) {
const id = this._nextIndex++;
const directionID = this.getDirection(height);
this.list[id] = {
id,
direction: directionID,
polylines: new Set(polylines),
extrusion: null,
};
this.regenerate([id]);
}
remove(ids) {
const pointsToDelete = new Set();
for (const id of ids) {
const slab = this.list[id];
this.removeExtrusion(id);
for (const line of slab.polylines) {
const { start, end } = this.lines.list[line];
pointsToDelete.add(start);
pointsToDelete.add(end);
}
}
this.lines.removePoints(pointsToDelete);
}
regenerate(ids) {
for (const id of ids) {
this.removeExtrusion(id);
const slab = this.list[id];
let outline = [];
const holes = [];
const outlineID = this.getOutline(id);
for (const polyID of slab.polylines) {
const pointIDs = this.createPoints(polyID);
if (polyID === outlineID) {
outline = pointIDs;
}
else {
holes.push(pointIDs);
}
}
const face = this.extrusions.faces.add(outline, holes);
const extrusion = this.extrusions.add(face, slab.direction);
slab.extrusion = extrusion;
this._extrusionSlabMap.set(extrusion, id);
}
}
removeExtrusion(id) {
const slab = this.list[id];
const extrusion = slab.extrusion;
if (extrusion === null)
return;
this.extrusions.remove([extrusion]);
this.list[id].extrusion = null;
}
getOutline(id) {
const slab = this.list[id];
let biggestSize = 0;
let biggestPolyline = 0;
for (const polyID of slab.polylines) {
const size = this.getPolylineSize(polyID);
if (size > biggestSize) {
biggestSize = size;
biggestPolyline = polyID;
}
}
return biggestPolyline;
}
getPolylineSize(id) {
const polyline = this.polylines[id];
const max = Number.MAX_VALUE;
const biggest = [-max, -max, -max];
const smallest = [max, max, max];
for (const lineID of polyline.lines) {
const line = this.lines.list[lineID];
const end = this.lines.vertices.get(line.end);
if (!end)
continue;
if (end[0] > biggest[0])
biggest[0] = end[0];
if (end[1] > biggest[1])
biggest[1] = end[1];
if (end[2] > biggest[2])
biggest[2] = end[2];
if (end[0] < smallest[0])
smallest[0] = end[0];
if (end[1] < smallest[1])
smallest[1] = end[1];
if (end[2] < smallest[2])
smallest[2] = end[2];
}
const x = Math.abs(biggest[0] - smallest[0]);
const y = Math.abs(biggest[1] - smallest[1]);
const z = Math.abs(biggest[2] - smallest[2]);
return x + y + z;
}
createPoints(id) {
const polyline = this.polylines[id];
const points = [];
for (const lineID of polyline.lines) {
const line = this.lines.list[lineID];
const end = this.lines.vertices.get(line.end);
if (!end)
continue;
points.push(end);
}
return this.extrusions.faces.addPoints(points);
}
getDirection(height) {
// TODO: Make direction normal to face
const directionPointsIDs = this.extrusions.lines.addPoints([
[0, 0, 0],
[0, height, 0],
]);
const [directionID] = this.extrusions.lines.add(directionPointsIDs);
return directionID;
}
}

var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
Expand Down Expand Up @@ -78025,7 +77870,7 @@ class RectangleProfile extends Profile {
}
}

class Family extends ClayObject {
class Element extends ClayObject {
constructor(model) {
super(model);
this.position = new THREE.Vector3();
Expand Down Expand Up @@ -78057,7 +77902,7 @@ class Family extends ClayObject {
}
}

class Opening extends Family {
class Opening extends Element {
get baseDimension() {
return this.geometries.body.profile.dimension;
}
Expand Down Expand Up @@ -78100,7 +77945,7 @@ class Opening extends Family {
}
}

class SimpleSlab extends Family {
class SimpleSlab extends Element {
get thickness() {
return this.geometries.body.depth;
}
Expand Down Expand Up @@ -78133,7 +77978,7 @@ class SimpleSlab extends Family {
}
}

class SimpleWall extends Family {
class SimpleWall extends Element {
get length() {
return this.startPoint.distanceTo(this.endPoint);
}
Expand Down Expand Up @@ -78221,7 +78066,7 @@ class SimpleWall extends Family {
}
}

class Furniture extends Family {
class Furniture extends Element {
constructor(model, geometry) {
super(model);
this.geometries = { body: new Brep(model, geometry) };
Expand All @@ -78243,4 +78088,4 @@ class Furniture extends Family {
}
}

export { Brep, BufferManager, ClayObject, Control, Extrusion, Extrusions, Faces, Furniture, IdIndexMap, Lines, Model, OffsetFaces, Opening, Primitive, Raycaster, RectangleProfile, Selector, SimpleSlab, SimpleWall, Slabs, Vector, Vertices, Walls };
export { Brep, BufferManager, ClayObject, Control, Extrusion, Extrusions, Faces, Furniture, IdIndexMap, Lines, Model, OffsetFaces, Opening, Primitive, Raycaster, RectangleProfile, Selector, SimpleSlab, SimpleWall, Vector, Vertices, Walls };
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ClayObject, Model } from "../../base";
import { Opening } from "../Opening";
import { IfcUtils } from "../../utils/ifc-utils";

export abstract class Family extends ClayObject {
export abstract class Element extends ClayObject {
abstract ifcData: IFC.IfcElement;
abstract geometries: { [name: string]: ClayObject };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { IFC4X3 as IFC } from "web-ifc";
import * as THREE from "three";
import { v4 as uuidv4 } from "uuid";
import { Model } from "../../../base";
import { Family } from "../../Family";
import { Element } from "../../Element";
import { Brep } from "../../../geometries";
import { IfcUtils } from "../../../utils/ifc-utils";

export class Furniture extends Family {
export class Furniture extends Element {
ifcData: IFC.IfcFurnishingElement;

geometries: { body: Brep };
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as THREE from "three";
import { v4 as uuidv4 } from "uuid";
import { Model } from "../../base";
import { Extrusion, RectangleProfile } from "../../geometries";
import { Family } from "../Family";
import { Element } from "../Element";
import { IfcUtils } from "../../utils/ifc-utils";

export class Opening extends Family {
export class Opening extends Element {
ifcData: IFC.IfcOpeningElement;

geometries: { body: Extrusion<RectangleProfile> };
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { v4 as uuidv4 } from "uuid";
import { IFC4X3 as IFC } from "web-ifc";
import { Model } from "../../../base";
import { Family } from "../../Family";
import { Element } from "../../Element";
import { Extrusion, RectangleProfile } from "../../../geometries";
import { IfcUtils } from "../../../utils/ifc-utils";

export class SimpleSlab extends Family {
export class SimpleSlab extends Element {
ifcData: IFC.IfcSlab;

geometries: { body: Extrusion<RectangleProfile> };
Expand Down
Loading

0 comments on commit 7554159

Please sign in to comment.