File tree Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Expand file tree Collapse file tree 4 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,15 @@ function buildModel(
63
63
return outputModel ;
64
64
}
65
65
66
- function loadFile ( payload : { content : IJCadContent } ) : IDict | null {
66
+ function loadFile (
67
+ payload : { content : IJCadContent } ,
68
+ raiseOnFailure = false
69
+ ) : IDict | null {
67
70
const { content } = payload ;
68
71
const outputModel = buildModel ( content ) ;
69
72
70
73
const parser = new OccParser ( outputModel ) ;
71
- const result = parser . execute ( ) ;
74
+ const result = parser . execute ( raiseOnFailure ) ;
72
75
const postResult : IDict < IPostOperatorInput > = { } ;
73
76
outputModel . forEach ( item => {
74
77
if ( item . jcObject . shape ?. startsWith ( 'Post::' ) ) {
@@ -82,9 +85,14 @@ function loadFile(payload: { content: IJCadContent }): IDict | null {
82
85
return { result, postResult } ;
83
86
}
84
87
88
+ function dryRun ( payload : { content : IJCadContent } ) {
89
+ return loadFile ( payload , true ) ;
90
+ }
91
+
85
92
const WorkerHandler : {
86
93
[ key in WorkerAction ] : ( payload : any ) => any ;
87
94
} = { } as any ;
88
95
WorkerHandler [ WorkerAction . LOAD_FILE ] = loadFile ;
96
+ WorkerHandler [ WorkerAction . DRY_RUN ] = dryRun ;
89
97
90
98
export default WorkerHandler ;
Original file line number Diff line number Diff line change @@ -154,7 +154,9 @@ export function operatorCache<T>(
154
154
return (
155
155
args : T ,
156
156
content : IJCadContent
157
- ) : { occShape : OCC . TopoDS_Shape ; metadata ?: IShapeMetadata | undefined } => {
157
+ ) :
158
+ | { occShape : OCC . TopoDS_Shape ; metadata ?: IShapeMetadata | undefined }
159
+ | undefined => {
158
160
const expandedArgs = expand_operator ( name , args , content ) ;
159
161
const hash = `${ hashCode ( JSON . stringify ( expandedArgs ) ) } ` ;
160
162
if ( SHAPE_CACHE . has ( hash ) ) {
@@ -168,10 +170,6 @@ export function operatorCache<T>(
168
170
} ;
169
171
SHAPE_CACHE . set ( hash , cacheData ) ;
170
172
return cacheData ;
171
- } else {
172
- throw new Error (
173
- `Unknown error while creating ${ name } : ${ JSON . stringify ( content ) } `
174
- ) ;
175
173
}
176
174
}
177
175
} ;
Original file line number Diff line number Diff line change @@ -11,18 +11,23 @@ interface IShapeList {
11
11
export class OccParser {
12
12
private _shapeList : IShapeList [ ] ;
13
13
private _occ : OCC . OpenCascadeInstance = ( self as any ) . occ ;
14
+
14
15
constructor ( shapeList : IShapeList [ ] ) {
15
16
this . _shapeList = shapeList ;
16
17
}
17
18
18
- execute ( ) : IDict < IParsedShape > {
19
+ execute ( raiseOnFailure = false ) : IDict < IParsedShape > {
19
20
const maxDeviation = 0.1 ;
20
21
const threejsData : IDict < IParsedShape > = { } ;
21
22
this . _shapeList . forEach ( data => {
22
23
const { shapeData, jcObject } = data ;
23
24
const { occShape, metadata } = shapeData ;
24
25
if ( ! occShape ) {
25
- return ;
26
+ if ( raiseOnFailure ) {
27
+ throw Error ( 'Unknown failure' ) ;
28
+ } else {
29
+ return ;
30
+ }
26
31
}
27
32
new this . _occ . BRepMesh_IncrementalMesh_2 (
28
33
occShape ,
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ self.onmessage = async (event: MessageEvent): Promise<void> => {
57
57
}
58
58
case WorkerAction . DRY_RUN : {
59
59
try {
60
- WorkerHandler [ WorkerAction . LOAD_FILE ] ( message . payload ) ;
60
+ WorkerHandler [ WorkerAction . DRY_RUN ] ( message . payload ) ;
61
61
} catch ( e ) {
62
62
let msg = '' ;
63
63
You can’t perform that action at this time.
0 commit comments