All files / lib/services/base shells.service.ts

100% Statements 15/15
100% Branches 0/0
100% Functions 5/5
100% Lines 14/14

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                                3x 3x 6x       14x 14x 122x   14x 14x 14x 14x 14x 14x 14x 14x          
import { OpenCascadeInstance, TopoDS_Face, TopoDS_Shell } from "../../../bitbybit-dev-occt/bitbybit-dev-occt";
import * as Inputs from "../../api/inputs/inputs";
import { ShapeGettersService } from "./shape-getters";
import { FacesService } from "./faces.service";
import { ConverterService } from "./converter.service";
 
export class ShellsService {
 
    constructor(
        private readonly occ: OpenCascadeInstance,
        private readonly shapeGettersService: ShapeGettersService,
        private readonly converterService: ConverterService,
        private readonly facesService: FacesService,
    ) { }
 
    getShellSurfaceArea(inputs: Inputs.OCCT.ShapeDto<TopoDS_Shell>): number {
        const faces = this.shapeGettersService.getFaces(inputs);
        const faceAreas = this.facesService.getFacesAreas({ shapes: faces });
        return faceAreas.reduce((p, c) => p + c, 0);
    }
 
    sewFaces(inputs: Inputs.OCCT.SewDto<TopoDS_Face>): TopoDS_Shell {
        const sew = new this.occ.BRepBuilderAPI_Sewing(inputs.tolerance, true, true, true, false);
        inputs.shapes.forEach(face => {
            sew.Add(face);
        });
        const messageProgress = new this.occ.Message_ProgressRange_1();
        sew.Perform(messageProgress);
        const res = sew.SewedShape();
        const result = this.converterService.getActualTypeOfShape(res);
        sew.delete();
        messageProgress.delete();
        res.delete();
        return result;
    }
 
 
}