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

94.11% Statements 48/51
92.5% Branches 37/40
100% Functions 5/5
94.11% Lines 48/51

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85                        763x 763x 763x 11x 752x 495x 257x   257x 109x 148x 4x 144x 106x 38x   38x 38x       763x       232x 232x 227x 5x 1x 4x 1x 3x 1x 2x 1x   1x   232x       136x 136x 36x 100x 58x 42x 41x   1x   136x         85x 2x 83x 78x 5x 2x 3x 2x   1x          
import {
    GccEnt_Position, OpenCascadeInstance, TopAbs_State, TopoDS_Shape
} from "../../../bitbybit-dev-occt/bitbybit-dev-occt";
import * as Inputs from "../../api/inputs/inputs";
 
export class EnumService {
 
    constructor(
        private readonly occ: OpenCascadeInstance,
    ) { }
 
    getShapeTypeEnum(shape: TopoDS_Shape): Inputs.OCCT.shapeTypeEnum {
        let result = Inputs.OCCT.shapeTypeEnum.unknown;
        const st = shape.ShapeType();
        if (st === this.occ.TopAbs_ShapeEnum.TopAbs_EDGE) {
            result = Inputs.OCCT.shapeTypeEnum.edge;
        } else if (st === this.occ.TopAbs_ShapeEnum.TopAbs_WIRE) {
            result = Inputs.OCCT.shapeTypeEnum.wire;
        } else Iif (st === this.occ.TopAbs_ShapeEnum.TopAbs_VERTEX) {
            result = Inputs.OCCT.shapeTypeEnum.vertex;
        } else if (st === this.occ.TopAbs_ShapeEnum.TopAbs_SOLID) {
            result = Inputs.OCCT.shapeTypeEnum.solid;
        } else if (st === this.occ.TopAbs_ShapeEnum.TopAbs_SHELL) {
            result = Inputs.OCCT.shapeTypeEnum.shell;
        } else if (st === this.occ.TopAbs_ShapeEnum.TopAbs_FACE) {
            result = Inputs.OCCT.shapeTypeEnum.face;
        } else Iif (st === this.occ.TopAbs_ShapeEnum.TopAbs_COMPSOLID) {
            result = Inputs.OCCT.shapeTypeEnum.compSolid;
        } else if (st === this.occ.TopAbs_ShapeEnum.TopAbs_COMPOUND) {
            result = Inputs.OCCT.shapeTypeEnum.compound;
        } else E{
            result = Inputs.OCCT.shapeTypeEnum.shape;
        }
        return result;
    }
 
    getGccEntPositionFromEnum(position: Inputs.OCCT.gccEntPositionEnum): GccEnt_Position {
        let result = this.occ.GccEnt_Position.GccEnt_noqualifier;
        if (position === Inputs.OCCT.gccEntPositionEnum.unqualified) {
            result = this.occ.GccEnt_Position.GccEnt_unqualified;
        } else if (position === Inputs.OCCT.gccEntPositionEnum.enclosed) {
            result = this.occ.GccEnt_Position.GccEnt_enclosed;
        } else if (position === Inputs.OCCT.gccEntPositionEnum.enclosing) {
            result = this.occ.GccEnt_Position.GccEnt_enclosing;
        } else if (position === Inputs.OCCT.gccEntPositionEnum.outside) {
            result = this.occ.GccEnt_Position.GccEnt_outside;
        } else if (position === Inputs.OCCT.gccEntPositionEnum.noqualifier) {
            result = this.occ.GccEnt_Position.GccEnt_noqualifier;
        } else {
            result = this.occ.GccEnt_Position.GccEnt_noqualifier;
        }
        return result as GccEnt_Position;
    }
 
    getTopAbsStateEnum(state: TopAbs_State): Inputs.OCCT.topAbsStateEnum {
        let result = Inputs.OCCT.topAbsStateEnum.unknown;
        if (state === this.occ.TopAbs_State.TopAbs_IN) {
            result = Inputs.OCCT.topAbsStateEnum.in;
        } else if (state === this.occ.TopAbs_State.TopAbs_OUT) {
            result = Inputs.OCCT.topAbsStateEnum.out;
        } else if (state === this.occ.TopAbs_State.TopAbs_ON) {
            result = Inputs.OCCT.topAbsStateEnum.on;
        } else {
            result = Inputs.OCCT.topAbsStateEnum.unknown;
        }
        return result;
    }
 
 
    convertFourSidesStrictEnumToTwoCircleInclusionEnum(value: Inputs.OCCT.fourSidesStrictEnum) {
        if (value === Inputs.OCCT.fourSidesStrictEnum.inside) {
            return Inputs.OCCT.twoCircleInclusionEnum.inside;
        } else if (value === Inputs.OCCT.fourSidesStrictEnum.outside) {
            return Inputs.OCCT.twoCircleInclusionEnum.outside;
        } else if (value === Inputs.OCCT.fourSidesStrictEnum.insideOutside) {
            return Inputs.OCCT.twoCircleInclusionEnum.insideOutside;
        } else if (value === Inputs.OCCT.fourSidesStrictEnum.outsideInside) {
            return Inputs.OCCT.twoCircleInclusionEnum.outsideInside;
        } else {
            return Inputs.OCCT.twoCircleInclusionEnum.none;
        }
    }
 
}