Skip to content

Commit 84178a5

Browse files
memory management issues fixed
1 parent c3b3106 commit 84178a5

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/lib/workers/occ/occ-helper.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class OccHelper {
6363
inputs.shapes.forEach(shape => {
6464
builder.Add(resCompound, shape);
6565
});
66-
// builder.delete();
66+
builder.delete();
6767
return resCompound;
6868
}
6969

@@ -160,12 +160,16 @@ export class OccHelper {
160160

161161
gcMakeEllipse(center: Base.Point3, direction: Base.Vector3, minorRadius: number, majorRadius: number): Geom_Ellipse {
162162
const ax = this.gpAx2(center, direction);
163-
const ellipse = new this.occ.GC_MakeEllipse_2(ax, minorRadius, majorRadius);
164-
const ellipseVal = ellipse.Value();
165-
const ell = ellipseVal.get();
166-
ellipse.delete();
167-
ax.delete();
168-
return ell;
163+
const ellipse = new this.occ.GC_MakeEllipse_2(ax, majorRadius, minorRadius);
164+
if (ellipse.IsDone()) {
165+
const ellipseVal = ellipse.Value();
166+
const ell = ellipseVal.get();
167+
ellipse.delete();
168+
ax.delete();
169+
return ell;
170+
} else {
171+
throw new Error("Ellipse could not be created.");
172+
}
169173
}
170174

171175
bRepBuilderAPIMakeEdge(curve: Geom_Curve): TopoDS_Edge {
@@ -1180,15 +1184,16 @@ export class OccHelper {
11801184
rotation.delete();
11811185
}
11821186
let actualShape = this.getActualTypeOfShape(rotated);
1183-
rotated.delete();
1187+
if (inputs.angle !== 0) {
1188+
rotated.delete();
1189+
}
11841190
return actualShape;
11851191
}
11861192

11871193
surfaceFromFace(inputs: Inputs.OCCT.ShapeDto<TopoDS_Face>) {
11881194
const face = inputs.shape;
11891195
const surface = this.occ.BRep_Tool.Surface_2(face);
11901196
const srf = surface.get();
1191-
surface.delete();
11921197
return srf;
11931198
}
11941199

src/lib/workers/occ/services/booleans.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ export class OCCTBooleans {
6666
return difference;
6767
}
6868

69-
intersection(inputs: Inputs.OCCT.IntersectionDto<TopoDS_Shape>): TopoDS_Shape[] {
70-
return this.och.intersection(inputs);
69+
intersection(inputs: Inputs.OCCT.IntersectionDto<TopoDS_Shape>): TopoDS_Shape {
70+
let int = this.och.intersection(inputs);
71+
const res = this.och.makeCompound({ shapes: int });
72+
return res;
7173
}
7274

7375
}

src/lib/workers/occ/services/shapes/face.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export class OCCTFace {
128128
gpPnt.delete();
129129
}
130130
}
131-
surface.delete();
132131
handle.delete();
133132
return { result: points };
134133
}
@@ -207,7 +206,6 @@ export class OCCTFace {
207206
points.push(pt);
208207
gpPnt.delete();
209208
}
210-
surface.delete();
211209
handle.delete();
212210
return { result: points };
213211
}
@@ -331,7 +329,6 @@ export class OCCTFace {
331329
surface.D0(u, v, gpPnt);
332330
const pt = [gpPnt.X(), gpPnt.Y(), gpPnt.Z()];
333331
gpPnt.delete();
334-
surface.delete();
335332
handle.delete();
336333
return { result: pt };
337334
}

src/lib/workers/occ/services/shapes/wire.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export class OCCTWire {
135135
edgeMaker.delete();
136136
edge.delete();
137137
geomCurve.delete();
138-
geomBezierCurveHandle.delete();
139138
ptList.delete();
140139
return result;
141140
}
@@ -205,17 +204,14 @@ export class OCCTWire {
205204
let face: TopoDS_Face = inputs.shapes[1] as TopoDS_Face;
206205
const srf = this.och.surfaceFromFace({ shape: face });
207206
let result = this.placeWire(wire, srf);
208-
srf.delete();
209207
return result;
210208
}
211209

212210
placeWiresOnFace(inputs: Inputs.OCCT.ShapeShapesDto<TopoDS_Face, TopoDS_Wire>) {
213211
let wires = inputs.shapes;
214212
let face = inputs.shape;
215213
const srf = this.och.surfaceFromFace({ shape: face });
216-
217214
let result = wires.map(wire => this.placeWire(wire, srf));
218-
srf.delete();
219215
return result;
220216
}
221217

@@ -237,7 +233,6 @@ export class OCCTWire {
237233
}
238234
plane.delete();
239235
c2dHandle.delete();
240-
c2.delete();
241236
}
242237
crv.delete();
243238
});

0 commit comments

Comments
 (0)