@@ -21,7 +21,81 @@ export class Base {
2121 } ;
2222 }
2323
24- public guid ( value : string ) {
24+ calculateEndPoint (
25+ startPoint : number [ ] ,
26+ direction : number [ ] ,
27+ magnitude : number ,
28+ ) {
29+ const vectorMagnitude = Math . sqrt (
30+ direction [ 0 ] ** 2 + direction [ 1 ] ** 2 + direction [ 2 ] ** 2 ,
31+ ) ;
32+ const unitVector = direction . map (
33+ ( component ) => component / vectorMagnitude ,
34+ ) ;
35+ const displacementVector = unitVector . map (
36+ ( component ) => component * magnitude ,
37+ ) ;
38+ return [
39+ startPoint [ 0 ] + displacementVector [ 0 ] ,
40+ startPoint [ 1 ] + displacementVector [ 1 ] ,
41+ startPoint [ 2 ] + displacementVector [ 2 ] ,
42+ ] ;
43+ }
44+
45+ pointsDistance ( firstPoint : number [ ] , secondPoint : number [ ] ) {
46+ const dx = firstPoint [ 0 ] - secondPoint [ 0 ] ;
47+ const dy = firstPoint [ 1 ] - secondPoint [ 1 ] ;
48+ return Math . sqrt ( dx * dx + dy * dy ) ;
49+ }
50+
51+ representationContext ( ) {
52+ return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcRepresentationContext > (
53+ this . ifcAPI ,
54+ this . modelID ,
55+ WEBIFC . IFCREPRESENTATIONCONTEXT ,
56+ this . label ( "Body" ) ,
57+ this . label ( "Model" ) ,
58+ ) ;
59+ }
60+
61+ productDefinitionShape ( representations : WEBIFC . IFC4X3 . IfcRepresentation [ ] ) {
62+ return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcProductDefinitionShape > (
63+ this . ifcAPI ,
64+ this . modelID ,
65+ WEBIFC . IFCPRODUCTDEFINITIONSHAPE ,
66+ this . label ( "" ) ,
67+ this . label ( "" ) ,
68+ representations ,
69+ ) ;
70+ }
71+
72+ shapeRepresentation (
73+ identifier : string ,
74+ type : string ,
75+ representation : WEBIFC . IFC4X3 . IfcRepresentationItem ,
76+ ) {
77+ return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcShapeRepresentation > (
78+ this . ifcAPI ,
79+ this . modelID ,
80+ WEBIFC . IFCSHAPEREPRESENTATION ,
81+ this . representationContext ( ) ,
82+ this . label ( identifier ) ,
83+ this . label ( type ) ,
84+ [ representation ] ,
85+ ) ;
86+ }
87+
88+ polyline ( points : number [ ] [ ] ) {
89+ const listOfPoints = points . map ( ( point ) => this . cartesianPoint ( point ) ) ;
90+ return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcPolyline > (
91+ this . ifcAPI ,
92+ this . modelID ,
93+ WEBIFC . IFCPOLYLINE ,
94+ listOfPoints ,
95+ ) ;
96+ }
97+
98+ guid ( value : string ) {
2599 return createIfcType < typeof WEBIFC . IFC4X3 . IfcGloballyUniqueId > (
26100 this . ifcAPI ,
27101 this . modelID ,
@@ -30,7 +104,7 @@ export class Base {
30104 ) ;
31105 }
32106
33- public identifier ( value : string ) {
107+ identifier ( value : string ) {
34108 return createIfcType < typeof WEBIFC . IFC4X3 . IfcIdentifier > (
35109 this . ifcAPI ,
36110 this . modelID ,
@@ -39,7 +113,7 @@ export class Base {
39113 ) ;
40114 }
41115
42- public real ( value : number ) {
116+ real ( value : number ) {
43117 return createIfcType < typeof WEBIFC . IFC4X3 . IfcReal > (
44118 this . ifcAPI ,
45119 this . modelID ,
@@ -48,7 +122,7 @@ export class Base {
48122 ) ;
49123 }
50124
51- public label ( text : string ) {
125+ label ( text : string ) {
52126 return createIfcType < typeof WEBIFC . IFC4X3 . IfcLabel > (
53127 this . ifcAPI ,
54128 this . modelID ,
@@ -57,7 +131,7 @@ export class Base {
57131 ) ;
58132 }
59133
60- public length ( value : number ) {
134+ length ( value : number ) {
61135 return createIfcType < typeof WEBIFC . IFC4X3 . IfcLengthMeasure > (
62136 this . ifcAPI ,
63137 this . modelID ,
@@ -66,7 +140,7 @@ export class Base {
66140 ) ;
67141 }
68142
69- public positiveLength ( value : number ) {
143+ positiveLength ( value : number ) {
70144 return createIfcType < typeof WEBIFC . IFC4X3 . IfcPositiveLengthMeasure > (
71145 this . ifcAPI ,
72146 this . modelID ,
@@ -75,7 +149,7 @@ export class Base {
75149 ) ;
76150 }
77151
78- public objectPlacement (
152+ objectPlacement (
79153 placementRelTo : WEBIFC . IFC4X3 . IfcObjectPlacement | null = null ,
80154 ) {
81155 return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcObjectPlacement > (
@@ -86,28 +160,7 @@ export class Base {
86160 ) ;
87161 }
88162
89- public opening (
90- guid : string ,
91- placement : WEBIFC . IFC4X3 . IfcObjectPlacement ,
92- mesh : WEBIFC . IFC4X3 . IfcProductRepresentation ,
93- ) {
94- return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcOpeningElement > (
95- this . ifcAPI ,
96- this . modelID ,
97- WEBIFC . IFCOPENINGELEMENT ,
98- this . guid ( guid ) ,
99- null ,
100- this . label ( "name" ) ,
101- null ,
102- this . label ( "label" ) ,
103- placement ,
104- mesh ,
105- this . identifier ( "sadf" ) ,
106- null ,
107- ) ;
108- }
109-
110- public direction ( values : number [ ] ) {
163+ direction ( values : number [ ] ) {
111164 return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcDirection > (
112165 this . ifcAPI ,
113166 this . modelID ,
@@ -116,7 +169,7 @@ export class Base {
116169 ) ;
117170 }
118171
119- public cartesianPoint ( values : number [ ] ) {
172+ cartesianPoint ( values : number [ ] ) {
120173 return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcCartesianPoint > (
121174 this . ifcAPI ,
122175 this . modelID ,
@@ -125,15 +178,15 @@ export class Base {
125178 ) ;
126179 }
127180
128- public point ( ) {
181+ point ( ) {
129182 return createIfcEntity < typeof WEBIFC . IFC4X3 . IfcPoint > (
130183 this . ifcAPI ,
131184 this . modelID ,
132185 WEBIFC . IFCCARTESIANPOINT ,
133186 ) ;
134187 }
135188
136- public axis2Placement2D (
189+ axis2Placement2D (
137190 location : number [ ] | WEBIFC . IFC4X3 . IfcCartesianPoint ,
138191 direction : number [ ] | WEBIFC . IFC4X3 . IfcDirection | null = null ,
139192 ) {
@@ -148,13 +201,15 @@ export class Base {
148201 ) ;
149202 }
150203
151- public axis2Placement3D (
204+ axis2Placement3D (
205+ location : number [ ] | WEBIFC . IFC4X3 . IfcCartesianPoint ,
152206 axis : number [ ] | WEBIFC . IFC4X3 . IfcDirection | null = null ,
153207 direction : number [ ] | WEBIFC . IFC4X3 . IfcDirection | null = null ,
154208 ) {
155- const location = this . point ( ) ;
209+ if ( Array . isArray ( location ) ) location = this . cartesianPoint ( location ) ;
156210 if ( Array . isArray ( axis ) ) axis = this . direction ( axis ) ;
157211 if ( Array . isArray ( direction ) ) direction = this . direction ( direction ) ;
212+
158213 const placement = createIfcEntity < typeof WEBIFC . IFC4X3 . IfcAxis2Placement3D > (
159214 this . ifcAPI ,
160215 this . modelID ,
@@ -166,7 +221,7 @@ export class Base {
166221 return { placement, location } ;
167222 }
168223
169- public bool (
224+ bool (
170225 firstOperand : WEBIFC . IFC4X3 . IfcBooleanOperand ,
171226 secondOperand : WEBIFC . IFC4X3 . IfcBooleanOperand ,
172227 ) {
@@ -180,7 +235,7 @@ export class Base {
180235 ) ;
181236 }
182237
183- public vector ( values : number [ ] , type : keyof Types ) {
238+ vector ( values : number [ ] , type : keyof Types ) {
184239 if ( ! this . types [ type ] ) throw new Error ( `Type not found: ${ type } ` ) ;
185240 const action = this . types [ type ] ;
186241 return values . map ( ( value ) => action ( value ) ) ;
0 commit comments