1
1
import { BitByBitBase , Base , BabylonScene , Draw } from "bitbybit-core" ;
2
- import { OCCT } from "bitbybit-core/lib/api/inputs/occ-inputs" ;
2
+ import { OCCT } from "bitbybit-core/lib/api/bitbybit/occt/occt" ;
3
+ import * as Inputs from "bitbybit-core/lib/api/inputs" ;
3
4
export class LaptopLogic {
4
5
5
6
private bitbybit : BitByBitBase ;
7
+ private occt : OCCT
6
8
7
9
private laptops : Laptop [ ] = [
8
10
{
@@ -34,6 +36,7 @@ export class LaptopLogic {
34
36
35
37
constructor ( bitbybit : BitByBitBase ) {
36
38
this . bitbybit = bitbybit ;
39
+ this . occt = bitbybit . occt as OCCT ;
37
40
}
38
41
async renderLaptops ( laptops ) {
39
42
@@ -49,45 +52,45 @@ export class LaptopLogic {
49
52
totalDistance += this . distanceBetweenLaptops + laptop . length / 2 + previousLaptopLength / 2 ;
50
53
previousLaptopLength = laptop . length ;
51
54
laptop . center [ 2 ] = totalDistance ;
52
- const laptopBaseModel = await this . bitbybit . occt . shapes . solid . createBox ( {
55
+ const laptopBaseModel = await this . occt . shapes . solid . createBox ( {
53
56
width : laptop . width ,
54
57
length : laptop . length ,
55
58
height : laptop . height ,
56
59
center : laptop . center
57
60
} ) ;
58
- const laptopFillet = await this . bitbybit . occt . fillets . filletEdges ( { shape : laptopBaseModel , radius : 0.2 } ) ;
61
+ const laptopFillet = await this . occt . fillets . filletEdges ( { shape : laptopBaseModel , radius : 0.2 } ) ;
59
62
laptopFillets . push ( laptopFillet ) ;
60
63
61
- const laptopVisModel = await this . bitbybit . occt . shapes . solid . createBox ( {
64
+ const laptopVisModel = await this . occt . shapes . solid . createBox ( {
62
65
width : laptop . width ,
63
66
length : laptop . length - 0.01 ,
64
67
height : laptop . height ,
65
68
center : laptop . center
66
69
} ) ;
67
- const laptopVisFillet = await this . bitbybit . occt . fillets . filletEdges ( { shape : laptopVisModel , radius : 0.2 } ) ;
70
+ const laptopVisFillet = await this . occt . fillets . filletEdges ( { shape : laptopVisModel , radius : 0.2 } ) ;
68
71
laptopFillets . push ( laptopFillet ) ;
69
72
70
- const di = new OCCT . DrawShapeDto ( laptopVisFillet ) ;
73
+ const di = new Inputs . OCCT . DrawShapeDto ( laptopVisFillet ) ;
71
74
di . faceOpacity = 0.2 ;
72
75
di . edgeWidth = 5 ;
73
76
di . edgeOpacity = 0.6 ;
74
77
di . edgeColour = this . whiteColor ;
75
78
di . faceColour = this . whiteColor ;
76
- const laptopFilletMesh = await this . bitbybit . occt . drawShape ( di ) ;
79
+ const laptopFilletMesh = await this . occt . drawShape ( di ) ;
77
80
this . laptopsFilletsMesh . push ( laptopFilletMesh ) ;
78
81
} )
79
82
80
- const polygonWire = await this . bitbybit . occt . shapes . wire . createPolygonWire ( {
83
+ const polygonWire = await this . occt . shapes . wire . createPolygonWire ( {
81
84
points : this . controlPoints
82
85
} ) ;
83
- const extrusion = await this . bitbybit . occt . operations . extrude ( {
86
+ const extrusion = await this . occt . operations . extrude ( {
84
87
shape : polygonWire , direction : [ 0 , 0 , totalDistance += this . distanceBetweenLaptops + previousLaptopLength / 2 ]
85
88
} ) ;
86
- const laptopStandFillet = await this . bitbybit . occt . fillets . filletEdges ( { shape : extrusion , radius : 1 } ) ;
87
- const laptopStandThick = await this . bitbybit . occt . operations . makeThickSolidSimple ( { shape : laptopStandFillet , offset : - 0.5 } ) ;
89
+ const laptopStandFillet = await this . occt . fillets . filletEdges ( { shape : extrusion , radius : 1 } ) ;
90
+ const laptopStandThick = await this . occt . operations . makeThickSolidSimple ( { shape : laptopStandFillet , offset : - 0.5 } ) ;
88
91
89
- this . laptopStand = await this . bitbybit . occt . booleans . difference ( { shape : laptopStandThick , shapes : laptopFillets , keepEdges : false } ) ;
90
- const li = new OCCT . DrawShapeDto ( this . laptopStand ) ;
92
+ this . laptopStand = await this . occt . booleans . difference ( { shape : laptopStandThick , shapes : laptopFillets , keepEdges : false } ) ;
93
+ const li = new Inputs . OCCT . DrawShapeDto ( this . laptopStand ) ;
91
94
li . faceOpacity = 1 ;
92
95
li . faceColour = this . holderColor ;
93
96
li . edgeColour = this . whiteColor ;
@@ -124,11 +127,11 @@ export class LaptopLogic {
124
127
}
125
128
126
129
downloadStep ( ) {
127
- this . bitbybit . occt . io . saveShapeSTEP ( { shape : this . laptopStand , filename : 'laptop-stand.step' , adjustYtoZ : false } ) ;
130
+ this . occt . io . saveShapeSTEP ( { shape : this . laptopStand , filename : 'laptop-stand.step' , adjustYtoZ : false } ) ;
128
131
}
129
132
130
133
downloadStl ( ) {
131
- this . bitbybit . occt . io . saveShapeStl ( { shape : this . laptopStand , filename : 'laptop-stand' , precision : 0.001 , adjustYtoZ : false } ) ;
134
+ this . occt . io . saveShapeStl ( { shape : this . laptopStand , filename : 'laptop-stand' , precision : 0.001 , adjustYtoZ : false } ) ;
132
135
}
133
136
134
137
async render ( laptops : Laptop [ ] ) {
0 commit comments