1
- import { OCC } from '@jupytercad/opencascade' ;
2
1
import {
3
2
IDict ,
4
3
IJCadContent ,
@@ -7,20 +6,11 @@ import {
7
6
WorkerAction
8
7
} from '@jupytercad/schema' ;
9
8
10
- import { ObjectFile , ShapesFactory } from './occapi' ;
9
+ import { ObjectFile , getShapesFactory } from './occapi' ;
11
10
12
11
import { OccParser } from './occparser' ;
13
12
import { IOperatorArg , IOperatorFuncOutput } from './types' ;
14
13
15
- let occ : OCC . OpenCascadeInstance ;
16
-
17
- export function getOcc ( ) : OCC . OpenCascadeInstance {
18
- if ( ! occ ) {
19
- occ = ( self as any ) . occ as OCC . OpenCascadeInstance ;
20
- }
21
- return occ ;
22
- }
23
-
24
14
function buildModel (
25
15
model : IJCadContent
26
16
) : { shapeData : IOperatorFuncOutput ; jcObject : IJCadObject } [ ] {
@@ -35,18 +25,18 @@ function buildModel(
35
25
if ( ! shape || ! parameters ) {
36
26
return ;
37
27
}
38
-
28
+ const shapeFactory = getShapesFactory ( ) ;
39
29
let shapeData : IOperatorFuncOutput | undefined = undefined ;
40
- if ( ShapesFactory [ shape ] ) {
41
- shapeData = ShapesFactory [ shape ] ( parameters as IOperatorArg , model ) ;
30
+ if ( shapeFactory [ shape ] ) {
31
+ shapeData = shapeFactory [ shape ] ?. ( parameters as IOperatorArg , model ) ;
42
32
} else if ( parameters [ 'Shape' ] && parameters [ 'Type' ] ) {
43
33
// Creating occ shape from brep file.
44
34
shapeData = ObjectFile (
45
35
{ content : parameters [ 'Shape' ] , type : parameters [ 'Type' ] } ,
46
36
model
47
37
) ;
48
38
} else if ( shape . startsWith ( 'Post::' ) ) {
49
- shapeData = ShapesFactory [ 'Post::Operator' ] (
39
+ shapeData = shapeFactory [ 'Post::Operator' ] ?. (
50
40
parameters as IOperatorArg ,
51
41
model
52
42
) ;
0 commit comments