All files / lib/services shape-fix.ts

94.44% Statements 17/18
100% Branches 0/0
75% Functions 3/4
94.44% Lines 17/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                  1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x       3x 3x 3x 3x 3x 3x      
import { OccHelper } from "../occ-helper";
import { OpenCascadeInstance, TopoDS_Shape, TopoDS_Wire } from "../../bitbybit-dev-occt/bitbybit-dev-occt";
import * as Inputs from "../api/inputs/inputs";
 
export class OCCTShapeFix {
 
    constructor(
        private readonly occ: OpenCascadeInstance,
        private readonly och: OccHelper
    ) {
    }
 
    fixEdgeOrientationsAlongWire(inputs: Inputs.OCCT.ShapeDto<TopoDS_Wire>): TopoDS_Wire {
        return this.och.edgesService.fixEdgeOrientationsAlongWire(inputs);
    }
 
    basicShapeRepair(inputs: Inputs.OCCT.BasicShapeRepairDto<TopoDS_Shape>): TopoDS_Shape {
        const shapeFix = new this.occ.ShapeFix_Shape_1();
        shapeFix.Init(inputs.shape);
        shapeFix.SetPrecision(inputs.precision);
        shapeFix.SetMaxTolerance(inputs.maxTolerance);
        shapeFix.SetMinTolerance(inputs.minTolerance);
        const messageProgress = new this.occ.Message_ProgressRange_1();
        shapeFix.Perform(messageProgress);
        messageProgress.delete();
        const result = shapeFix.Shape();
        shapeFix.delete();
        return result;
    }
 
    fixSmallEdgeOnWire(inputs: Inputs.OCCT.FixSmallEdgesInWireDto<TopoDS_Wire>) {
        const wireFix = new this.occ.ShapeFix_Wire_1();
        wireFix.Load_1(inputs.shape);
        wireFix.FixSmall_1(inputs.lockvtx, inputs.precsmall);
        wireFix.Perform();
        const result = wireFix.Wire();
        return result;
    }
}