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

100% Statements 7/7
100% Branches 0/0
100% Functions 4/4
100% Lines 7/7

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                          1x 1x       2x 50x 50x 50x 50x          
import { OpenCascadeInstance, TopoDS_Shape, TopoDS_Vertex } from "../../../bitbybit-dev-occt/bitbybit-dev-occt";
import * as Inputs from "../../api/inputs/inputs";
import { ShapeGettersService } from "./shape-getters";
 
export class VerticesService {
 
    constructor(
        private readonly occ: OpenCascadeInstance,
        private readonly shapeGettersService: ShapeGettersService
    ) { }
 
 
    getVerticesAsPoints(inputs: Inputs.OCCT.ShapeDto<TopoDS_Shape>): Inputs.Base.Point3[] {
        const vertices = this.shapeGettersService.getVertices(inputs);
        return this.verticesToPoints({ shapes: vertices });
    }
 
    verticesToPoints(inputs: Inputs.OCCT.ShapesDto<TopoDS_Vertex>): Inputs.Base.Point3[] {
        return inputs.shapes.map(v => {
            const pt = this.occ.BRep_Tool.Pnt(v);
            const res = [pt.X(), pt.Y(), pt.Z()] as Inputs.Base.Point3;
            pt.delete();
            return res;
        });
    }
 
}