Exemple #1
0
class StarAngleOpposite(object):
    def __init__(self, a, b, t, l, t1, H):
        self.l = l
        self.a = a
        self.b = b
        self.t = t
        self.t1 = t1
        self.H = H

        self.sec_origin = numpy.array([0, 0, 0])
        self.uDir = numpy.array([1.0, 0, 0])
        self.wDir = numpy.array([0.0, 0, 1.0])
        self.vDir = self.wDir * self.uDir

        self.angle1 = Angle(H, a, b, t, 0, 0)
        self.angle2 = Angle(H, b, a, t, 0, 0)
        self.plate1 = Plate(l, H, t1)

    def place(self, secOrigin, uDir, wDir):
        self.sec_origin = secOrigin
        self.uDir = uDir
        self.wDir = wDir
        origin1 = numpy.array([self.t1 / 2., 0., 0.])
        self.angle1.place(origin1, self.uDir, self.wDir)
        origin2 = numpy.array([0., self.t1 / 2., 0])
        self.angle2.place(origin2, self.uDir, self.wDir)
        origin3 = numpy.array([0., self.a / 2, 0.])
        self.plate1.place(origin3, self.uDir, self.wDir)

    def compute_params(self):
        self.angle1.computeParams()
        self.angle2.computeParams()
        self.angle2.points = self.rotate(self.angle2.points)
        self.plate1.compute_params()

    def create_model(self):
        prism1 = self.angle1.create_model()
        prism2 = self.angle2.create_model()

        prism3 = self.plate1.create_model()

        prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism3).Shape()
        return prism, [prism3]

    def rotate(self, points):
        rotated_points = []
        rmatrix = numpy.array([[0, -1, 0], [1, 0, 0], [0, 0, 1]])
        for point in points:
            point = numpy.matmul(rmatrix, point)
            rotated_points.append(point)
        return rotated_points

    def create_marking(self):
        middel_pnt = []
        line = []
        labels = ["z", "y", "u", "v"]
        offset = 2 * self.l
        uvoffset = offset / numpy.sqrt(2)

        z_points = [
            numpy.array([-offset, self.t / 2, self.H / 2]),
            numpy.array([offset, self.t / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(z_points))

        y_points = [
            numpy.array([0., -offset + self.t / 2, self.H / 2]),
            numpy.array([0, offset + self.t / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(y_points))

        u_points = [
            numpy.array([-uvoffset, uvoffset + self.t / 2, self.H / 2]),
            numpy.array([uvoffset, -uvoffset + self.t / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(u_points))

        v_points = [
            numpy.array([-uvoffset, -uvoffset + self.t / 2, self.H / 2]),
            numpy.array([uvoffset, uvoffset + self.t / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(v_points))

        start_pnt = [[-offset, self.t / 2, self.H / 2],
                     [0, -offset + self.t / 2 + 1, self.H / 2],
                     [uvoffset, -uvoffset + self.t / 2, self.H / 2],
                     [uvoffset, uvoffset + self.t / 2, self.H / 2]]
        end_pnt = [[offset, self.t / 2, self.H / 2],
                   [0, offset + self.t / 2 - 1, self.H / 2],
                   [-uvoffset, uvoffset + self.t / 2, self.H / 2],
                   [-uvoffset, -uvoffset + self.t / 2, self.H / 2]]

        return line, [start_pnt, end_pnt], labels
Exemple #2
0
    def createPlateGeometry(self):
        body = Plate(L=self.L, W=self.W, T=self.T)
        body.place(self.sec_origin, self.uDir, self.wDir)

        part1 = body.create_model()
        return part1
Exemple #3
0
class CCSpliceCoverPlateWeldedCAD(object):
    def __init__(self, C, column, flangePlate, innerFlangePlate, webPlate,
                 flangePlateWeldL, flangePlateWeldW, innerflangePlateWeldL,
                 innerflangePlateWeldW, webPlateWeldL, webPlateWeldW):

        self.C = C
        self.column = column
        self.flangePlate = flangePlate
        self.innerFlangePlate = innerFlangePlate
        self.webPlate = webPlate
        self.flangePlateWeldL = flangePlateWeldL
        self.flangePlateWeldW = flangePlateWeldW
        self.webPlateWeldL = webPlateWeldL
        self.webPlateWeldW = webPlateWeldW
        self.innerflangePlateWeldL = innerflangePlateWeldL
        self.innerflangePlateWeldW = innerflangePlateWeldW

        self.gap = float(self.C.flange_plate.gap)
        self.flangespace = float(self.C.flangespace)
        self.webspace = float(self.C.webspace)

        self.column1 = copy.deepcopy(self.column)
        self.column2 = copy.deepcopy(self.column)

        self.flangePlate1 = copy.deepcopy(self.flangePlate)
        self.flangePlate2 = copy.deepcopy(self.flangePlate)

        self.innerFlangePlate1 = copy.deepcopy(self.innerFlangePlate)
        self.innerFlangePlate2 = copy.deepcopy(self.innerFlangePlate)
        self.innerFlangePlate3 = copy.deepcopy(self.innerFlangePlate)
        self.innerFlangePlate4 = copy.deepcopy(self.innerFlangePlate)

        self.webPlate1 = copy.deepcopy(self.webPlate)
        self.webPlate2 = copy.deepcopy(self.webPlate)

        # nuber top to bottom
        self.flangePlateWeldL11 = copy.deepcopy(self.flangePlateWeldL)
        self.flangePlateWeldL12 = copy.deepcopy(self.flangePlateWeldL)
        self.flangePlateWeldL21 = copy.deepcopy(self.flangePlateWeldL)
        self.flangePlateWeldL22 = copy.deepcopy(self.flangePlateWeldL)

        self.flangePlateWeldW11 = copy.deepcopy(self.flangePlateWeldW)
        self.flangePlateWeldW12 = copy.deepcopy(self.flangePlateWeldW)
        self.flangePlateWeldW21 = copy.deepcopy(self.flangePlateWeldW)
        self.flangePlateWeldW22 = copy.deepcopy(self.flangePlateWeldW)

        # Todo: update numbering
        self.webPlateWeldL11 = copy.deepcopy(self.webPlateWeldL)
        self.webPlateWeldL12 = copy.deepcopy(self.webPlateWeldL)
        self.webPlateWeldL21 = copy.deepcopy(self.webPlateWeldL)
        self.webPlateWeldL22 = copy.deepcopy(self.webPlateWeldL)

        self.webPlateWeldW11 = copy.deepcopy(self.webPlateWeldW)
        self.webPlateWeldW12 = copy.deepcopy(self.webPlateWeldW)
        self.webPlateWeldW21 = copy.deepcopy(self.webPlateWeldW)
        self.webPlateWeldW22 = copy.deepcopy(self.webPlateWeldW)

        # numbering is clock wise starting from right side top plate
        self.innerflangePlateWeldL11 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL12 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL21 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL22 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL31 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL32 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL41 = copy.deepcopy(
            self.innerflangePlateWeldL)
        self.innerflangePlateWeldL42 = copy.deepcopy(
            self.innerflangePlateWeldL)

        self.innerflangePlateWeldW11 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW12 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW21 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW22 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW31 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW32 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW41 = copy.deepcopy(
            self.innerflangePlateWeldW)
        self.innerflangePlateWeldW42 = copy.deepcopy(
            self.innerflangePlateWeldW)

        self.weldCutPlate = Plate(L=self.column.D + 4 * self.flangePlate.T,
                                  W=self.column.B + 2 * self.flangePlate.T,
                                  T=self.gap)

    def create_3DModel(self):
        '''
        :return:  CAD model of each of the followings. Debugging each command below would give give clear picture
        '''

        self.createColumnGeometry()
        self.createPlateGeometry()
        self.createWeldedGeometry()

    def createColumnGeometry(self):
        """

        :return: Geometric Orientation of this component
        """
        column1Origin = numpy.array([0.0, 0.0, self.gap / 2])
        column1_uDir = numpy.array([1.0, 0.0, 0.0])
        column1_wDir = numpy.array([0.0, 0.0, 1.0])
        self.column1.place(column1Origin, column1_uDir, column1_wDir)

        self.column1Model = self.column1.create_model()

        column2Origin = numpy.array([0.0, 0.0, -self.gap / 2])
        column2_uDir = numpy.array([1.0, 0.0, 0.0])
        column2_wDir = numpy.array([0.0, 0.0, -1.0])
        self.column2.place(column2Origin, column2_uDir, column2_wDir)

        self.column2Model = self.column2.create_model()

    def createPlateGeometry(self):
        flangePlate1Origin = numpy.array([
            -self.flangePlate.W / 2, (self.column.D + self.flangePlate.T) / 2,
            0.0
        ])
        flangePlate1_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlate1_wDir = numpy.array([1.0, 0.0, 0.0])
        self.flangePlate1.place(flangePlate1Origin, flangePlate1_uDir,
                                flangePlate1_wDir)

        self.flangePlate1Model = self.flangePlate1.create_model()

        flangePlate2Origin = numpy.array([
            -self.flangePlate.W / 2, -(self.column.D + self.flangePlate.T) / 2,
            0.0
        ])
        flangePlate2_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlate2_wDir = numpy.array([1.0, 0.0, 0.0])
        self.flangePlate2.place(flangePlate2Origin, flangePlate2_uDir,
                                flangePlate2_wDir)

        self.flangePlate2Model = self.flangePlate2.create_model()

        webPlate1Origin = numpy.array([(self.column.t + self.webPlate.T) / 2,
                                       -self.webPlate.W / 2, 0.0])
        webPlate1_uDir = numpy.array([1.0, 0.0, 0.0])
        webPlate1_wDir = numpy.array([0.0, 1.0, 0.0])
        self.webPlate1.place(webPlate1Origin, webPlate1_uDir, webPlate1_wDir)

        self.webPlate1Model = self.webPlate1.create_model()

        webPlate2Origin = numpy.array([
            -(self.column.t + self.webPlate.T) / 2, -self.webPlate.W / 2, 0.0
        ])
        webPlate2_uDir = numpy.array([1.0, 0.0, 0.0])
        webPlate2_wDir = numpy.array([0.0, 1.0, 0.0])
        self.webPlate2.place(webPlate2Origin, webPlate2_uDir, webPlate2_wDir)

        self.webPlate2Model = self.webPlate2.create_model()

        if self.C.preference != 'Outside':
            innerFlangePlatespacing = self.flangespace + self.column.t / 2 + self.column.R1
            innerFlangePlate1Origin = numpy.array([
                innerFlangePlatespacing,
                (self.column.D - self.innerFlangePlate.T) / 2 - self.column.T,
                0.0
            ])
            innerFlangePlate1_uDir = numpy.array([0.0, 1.0, 0.0])
            innerFlangePlate1_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerFlangePlate1.place(innerFlangePlate1Origin,
                                         innerFlangePlate1_uDir,
                                         innerFlangePlate1_wDir)

            self.innerFlangePlate1Model = self.innerFlangePlate1.create_model()

            innerFlangePlate2Origin = numpy.array([
                innerFlangePlatespacing,
                -(self.column.D - self.innerFlangePlate.T) / 2 + self.column.T,
                0.0
            ])
            innerFlangePlate2_uDir = numpy.array([0.0, 1.0, 0.0])
            innerFlangePlate2_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerFlangePlate2.place(innerFlangePlate2Origin,
                                         innerFlangePlate2_uDir,
                                         innerFlangePlate2_wDir)

            self.innerFlangePlate2Model = self.innerFlangePlate2.create_model()

            innerFlangePlate3Origin = numpy.array([
                -innerFlangePlatespacing,
                -(self.column.D - --self.innerFlangePlate.T) / 2 +
                self.column.T, 0.0
            ])
            innerFlangePlate3_uDir = numpy.array([0.0, 1.0, 0.0])
            innerFlangePlate3_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerFlangePlate3.place(innerFlangePlate3Origin,
                                         innerFlangePlate3_uDir,
                                         innerFlangePlate3_wDir)

            self.innerFlangePlate3Model = self.innerFlangePlate3.create_model()

            innerFlangePlate4Origin = numpy.array([
                -innerFlangePlatespacing,
                (self.column.D - self.innerFlangePlate.T) / 2 - self.column.T,
                0.0
            ])
            innerFlangePlate4_uDir = numpy.array([0.0, 1.0, 0.0])
            innerFlangePlate4_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerFlangePlate4.place(innerFlangePlate4Origin,
                                         innerFlangePlate4_uDir,
                                         innerFlangePlate4_wDir)

            self.innerFlangePlate4Model = self.innerFlangePlate4.create_model()

    def createWeldedGeometry(self):

        # Flangeplate1
        flangePlateWeldL11Origin = numpy.array([
            self.flangePlate.W / 2, (self.column.D) / 2,
            self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldL11_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlateWeldL11_wDir = numpy.array([0.0, 0.0, -1.0])
        self.flangePlateWeldL11.place(flangePlateWeldL11Origin,
                                      flangePlateWeldL11_uDir,
                                      flangePlateWeldL11_wDir)

        self.flangePlateWeldL11Model = self.flangePlateWeldL11.create_model()

        flangePlateWeldL12Origin = numpy.array([
            -self.flangePlate.W / 2, (self.column.D) / 2,
            -self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldL12_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlateWeldL12_wDir = numpy.array([0.0, 0.0, 1.0])
        self.flangePlateWeldL12.place(flangePlateWeldL12Origin,
                                      flangePlateWeldL12_uDir,
                                      flangePlateWeldL12_wDir)

        self.flangePlateWeldL12Model = self.flangePlateWeldL12.create_model()

        flangePlateWeldW11Origin = numpy.array([
            -self.flangePlate.W / 2, (self.column.D) / 2,
            self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldW11_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlateWeldW11_wDir = numpy.array([1.0, 0.0, 0.0])
        self.flangePlateWeldW11.place(flangePlateWeldW11Origin,
                                      flangePlateWeldW11_uDir,
                                      flangePlateWeldW11_wDir)

        self.flangePlateWeldW11Model = self.flangePlateWeldW11.create_model()

        flangePlateWeldW12Origin = numpy.array([
            self.flangePlate.W / 2, (self.column.D) / 2,
            -self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldW12_uDir = numpy.array([0.0, 1.0, 0.0])
        flangePlateWeldW12_wDir = numpy.array([-1.0, 0.0, 0.0])
        self.flangePlateWeldW12.place(flangePlateWeldW12Origin,
                                      flangePlateWeldW12_uDir,
                                      flangePlateWeldW12_wDir)

        self.flangePlateWeldW12Model = self.flangePlateWeldW12.create_model()

        # FlangePlate2
        flangePlateWeldL21Origin = numpy.array([
            self.flangePlate.W / 2, -(self.column.D) / 2,
            -self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldL21_uDir = numpy.array([0.0, -1.0, 0.0])
        flangePlateWeldL21_wDir = numpy.array([0.0, 0.0, 1.0])
        self.flangePlateWeldL21.place(flangePlateWeldL21Origin,
                                      flangePlateWeldL21_uDir,
                                      flangePlateWeldL21_wDir)

        self.flangePlateWeldL21Model = self.flangePlateWeldL21.create_model()

        flangePlateWeldL22Origin = numpy.array([
            -self.flangePlate.W / 2, -(self.column.D) / 2,
            self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldL22_uDir = numpy.array([0.0, -1.0, 0.0])
        flangePlateWeldL22_wDir = numpy.array([0.0, 0.0, -1.0])
        self.flangePlateWeldL22.place(flangePlateWeldL22Origin,
                                      flangePlateWeldL22_uDir,
                                      flangePlateWeldL22_wDir)

        self.flangePlateWeldL22Model = self.flangePlateWeldL22.create_model()

        flangePlateWeldW21Origin = numpy.array([
            self.flangePlate.W / 2, -(self.column.D) / 2,
            self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldW21_uDir = numpy.array([0.0, -1.0, 0.0])
        flangePlateWeldW21_wDir = numpy.array([-1.0, 0.0, 0.0])
        self.flangePlateWeldW21.place(flangePlateWeldW21Origin,
                                      flangePlateWeldW21_uDir,
                                      flangePlateWeldW21_wDir)

        self.flangePlateWeldW21Model = self.flangePlateWeldW21.create_model()

        flangePlateWeldW22Origin = numpy.array([
            -self.flangePlate.W / 2, -(self.column.D) / 2,
            -self.flangePlateWeldL.L / 2
        ])
        flangePlateWeldW22_uDir = numpy.array([0.0, -1.0, 0.0])
        flangePlateWeldW22_wDir = numpy.array([1.0, 0.0, 0.0])
        self.flangePlateWeldW22.place(flangePlateWeldW22Origin,
                                      flangePlateWeldW22_uDir,
                                      flangePlateWeldW22_wDir)

        self.flangePlateWeldW22Model = self.flangePlateWeldW22.create_model()

        # Webplate1 (right side)
        webPlateWeldL11Origin = numpy.array([(self.column.t) / 2,
                                             self.webPlate.W / 2,
                                             -self.webPlate.L / 2])
        webPlateWeldL11_uDir = numpy.array([1.0, 0.0, 0.0])
        webPlateWeldL11_wDir = numpy.array([0.0, 0.0, 1.0])
        self.webPlateWeldL11.place(webPlateWeldL11Origin, webPlateWeldL11_uDir,
                                   webPlateWeldL11_wDir)

        self.webPlateWeldL11Model = self.webPlateWeldL11.create_model()

        webPlateWeldL12Origin = numpy.array([(self.column.t) / 2,
                                             -self.webPlate.W / 2,
                                             -self.webPlate.L / 2])
        webPlateWeldL12_uDir = numpy.array([0.0, -1.0, 0.0])
        webPlateWeldL12_wDir = numpy.array([0.0, 0.0, 1.0])
        self.webPlateWeldL12.place(webPlateWeldL12Origin, webPlateWeldL12_uDir,
                                   webPlateWeldL12_wDir)

        self.webPlateWeldL12Model = self.webPlateWeldL12.create_model()

        webPlateWeldW11Origin = numpy.array([(self.column.t) / 2,
                                             self.webPlate.W / 2,
                                             self.webPlate.L / 2])
        webPlateWeldW11_uDir = numpy.array([1.0, 0.0, 0.0])
        webPlateWeldW11_wDir = numpy.array([0.0, -1.0, 0.0])
        self.webPlateWeldW11.place(webPlateWeldW11Origin, webPlateWeldW11_uDir,
                                   webPlateWeldW11_wDir)

        self.webPlateWeldW11Model = self.webPlateWeldW11.create_model()

        webPlateWeldW12Origin = numpy.array([(self.column.t) / 2,
                                             -self.webPlate.W / 2,
                                             -self.webPlate.L / 2])
        webPlateWeldW12_uDir = numpy.array([1.0, 0.0, 0.0])
        webPlateWeldW12_wDir = numpy.array([0.0, 1.0, 0.0])
        self.webPlateWeldW12.place(webPlateWeldW12Origin, webPlateWeldW12_uDir,
                                   webPlateWeldW12_wDir)

        self.webPlateWeldW12Model = self.webPlateWeldW12.create_model()

        # Webplate2
        webPlateWeldL21Origin = numpy.array(
            [-(self.column.t) / 2, -self.webPlate.W / 2, -self.webPlate.L / 2])
        webPlateWeldL21_uDir = numpy.array([-1.0, 0.0, 0.0])
        webPlateWeldL21_wDir = numpy.array([0.0, 0.0, 1.0])
        self.webPlateWeldL21.place(webPlateWeldL21Origin, webPlateWeldL21_uDir,
                                   webPlateWeldL21_wDir)

        self.webPlateWeldL21Model = self.webPlateWeldL21.create_model()

        webPlateWeldL22Origin = numpy.array(
            [-(self.column.t) / 2, self.webPlate.W / 2, self.webPlate.L / 2])
        webPlateWeldL22_uDir = numpy.array([-1.0, 0.0, 0.0])
        webPlateWeldL22_wDir = numpy.array([0.0, 0.0, -1.0])
        self.webPlateWeldL22.place(webPlateWeldL22Origin, webPlateWeldL22_uDir,
                                   webPlateWeldL22_wDir)

        self.webPlateWeldL22Model = self.webPlateWeldL22.create_model()

        webPlateWeldW21Origin = numpy.array(
            [-(self.column.t) / 2, -self.webPlate.W / 2, self.webPlate.L / 2])
        webPlateWeldW21_uDir = numpy.array([-1.0, 0.0, 0.0])
        webPlateWeldW21_wDir = numpy.array([0.0, 1.0, 0.0])
        self.webPlateWeldW21.place(webPlateWeldW21Origin, webPlateWeldW21_uDir,
                                   webPlateWeldW21_wDir)

        self.webPlateWeldW21Model = self.webPlateWeldW21.create_model()

        webPlateWeldW22Origin = numpy.array(
            [-(self.column.t) / 2, self.webPlate.W / 2, -self.webPlate.L / 2])
        webPlateWeldW22_uDir = numpy.array([-1.0, 0.0, 0.0])
        webPlateWeldW22_wDir = numpy.array([0.0, -1.0, 0.0])
        self.webPlateWeldW22.place(webPlateWeldW22Origin, webPlateWeldW22_uDir,
                                   webPlateWeldW22_wDir)

        self.webPlateWeldW22Model = self.webPlateWeldW22.create_model()

        if self.C.preference != 'Outside':
            # innerplate1 (right top)
            innerFlangePlatespacing = self.flangespace + self.column.t / 2 + self.column.R1
            innerflangePlateWeldL11Origin = numpy.array([
                innerFlangePlatespacing + self.innerFlangePlate.W,
                (self.column.D) / 2 - self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL11_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldL11_wDir = numpy.array([0.0, 0.0, 1.0])
            self.innerflangePlateWeldL11.place(innerflangePlateWeldL11Origin,
                                               innerflangePlateWeldL11_uDir,
                                               innerflangePlateWeldL11_wDir)

            self.innerflangePlateWeldL11Model = self.innerflangePlateWeldL11.create_model(
            )

            innerflangePlateWeldL12Origin = numpy.array([
                innerFlangePlatespacing, (self.column.D) / 2 - self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL12_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldL12_wDir = numpy.array([0.0, 0.0, -1.0])
            self.innerflangePlateWeldL12.place(innerflangePlateWeldL12Origin,
                                               innerflangePlateWeldL12_uDir,
                                               innerflangePlateWeldL12_wDir)

            self.innerflangePlateWeldL12Model = self.innerflangePlateWeldL12.create_model(
            )

            innerflangePlateWeldW11Origin = numpy.array([
                innerFlangePlatespacing + self.innerFlangePlate.W,
                (self.column.D) / 2 - self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW11_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldW11_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerflangePlateWeldW11.place(innerflangePlateWeldW11Origin,
                                               innerflangePlateWeldW11_uDir,
                                               innerflangePlateWeldW11_wDir)

            self.innerflangePlateWeldW11Model = self.innerflangePlateWeldW11.create_model(
            )

            innerflangePlateWeldW12Origin = numpy.array([
                innerFlangePlatespacing, (self.column.D) / 2 - self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW12_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldW12_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerflangePlateWeldW12.place(innerflangePlateWeldW12Origin,
                                               innerflangePlateWeldW12_uDir,
                                               innerflangePlateWeldW12_wDir)

            self.innerflangePlateWeldW12Model = self.innerflangePlateWeldW12.create_model(
            )

            # innerplate2 (top left)
            innerflangePlateWeldL21Origin = numpy.array([
                -innerFlangePlatespacing, (self.column.D) / 2 - self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL21_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldL21_wDir = numpy.array([0.0, 0.0, 1.0])
            self.innerflangePlateWeldL21.place(innerflangePlateWeldL21Origin,
                                               innerflangePlateWeldL21_uDir,
                                               innerflangePlateWeldL21_wDir)

            self.innerflangePlateWeldL21Model = self.innerflangePlateWeldL21.create_model(
            )

            innerflangePlateWeldL22Origin = numpy.array([
                -innerFlangePlatespacing - self.innerFlangePlate.W,
                (self.column.D) / 2 - self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL22_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldL22_wDir = numpy.array([0.0, 0.0, -1.0])
            self.innerflangePlateWeldL22.place(innerflangePlateWeldL22Origin,
                                               innerflangePlateWeldL22_uDir,
                                               innerflangePlateWeldL22_wDir)

            self.innerflangePlateWeldL22Model = self.innerflangePlateWeldL22.create_model(
            )

            innerflangePlateWeldW21Origin = numpy.array([
                -innerFlangePlatespacing, (self.column.D) / 2 - self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW21_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldW21_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerflangePlateWeldW21.place(innerflangePlateWeldW21Origin,
                                               innerflangePlateWeldW21_uDir,
                                               innerflangePlateWeldW21_wDir)

            self.innerflangePlateWeldW21Model = self.innerflangePlateWeldW21.create_model(
            )

            innerflangePlateWeldW22Origin = numpy.array([
                -innerFlangePlatespacing - self.innerFlangePlate.W,
                (self.column.D) / 2 - self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW22_uDir = numpy.array([0.0, -1.0, 0.0])
            innerflangePlateWeldW22_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerflangePlateWeldW22.place(innerflangePlateWeldW22Origin,
                                               innerflangePlateWeldW22_uDir,
                                               innerflangePlateWeldW22_wDir)

            self.innerflangePlateWeldW22Model = self.innerflangePlateWeldW22.create_model(
            )

            # innerplate3 (Right bottom)
            innerflangePlateWeldL31Origin = numpy.array([
                innerFlangePlatespacing + self.innerFlangePlate.W,
                -(self.column.D) / 2 + self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL31_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldL31_wDir = numpy.array([0.0, 0.0, -1.0])
            self.innerflangePlateWeldL31.place(innerflangePlateWeldL31Origin,
                                               innerflangePlateWeldL31_uDir,
                                               innerflangePlateWeldL31_wDir)

            self.innerflangePlateWeldL31Model = self.innerflangePlateWeldL31.create_model(
            )

            innerflangePlateWeldL32Origin = numpy.array([
                innerFlangePlatespacing, -(self.column.D) / 2 + self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL32_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldL32_wDir = numpy.array([0.0, 0.0, 1.0])
            self.innerflangePlateWeldL32.place(innerflangePlateWeldL32Origin,
                                               innerflangePlateWeldL32_uDir,
                                               innerflangePlateWeldL32_wDir)

            self.innerflangePlateWeldL32Model = self.innerflangePlateWeldL32.create_model(
            )

            innerflangePlateWeldW31Origin = numpy.array([
                innerFlangePlatespacing, -(self.column.D) / 2 + self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW31_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldW31_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerflangePlateWeldW31.place(innerflangePlateWeldW31Origin,
                                               innerflangePlateWeldW31_uDir,
                                               innerflangePlateWeldW31_wDir)

            self.innerflangePlateWeldW31Model = self.innerflangePlateWeldW31.create_model(
            )

            innerflangePlateWeldW32Origin = numpy.array([
                innerFlangePlatespacing + self.innerFlangePlate.W,
                -(self.column.D) / 2 + self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW32_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldW32_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerflangePlateWeldW32.place(innerflangePlateWeldW32Origin,
                                               innerflangePlateWeldW32_uDir,
                                               innerflangePlateWeldW32_wDir)

            self.innerflangePlateWeldW32Model = self.innerflangePlateWeldW32.create_model(
            )

            # innetplate4 (left bottom)
            innerflangePlateWeldL41Origin = numpy.array([
                -innerFlangePlatespacing, -(self.column.D) / 2 + self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL41_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldL41_wDir = numpy.array([0.0, 0.0, -1.0])
            self.innerflangePlateWeldL41.place(innerflangePlateWeldL41Origin,
                                               innerflangePlateWeldL41_uDir,
                                               innerflangePlateWeldL41_wDir)

            self.innerflangePlateWeldL41Model = self.innerflangePlateWeldL41.create_model(
            )

            innerflangePlateWeldL42Origin = numpy.array([
                -innerFlangePlatespacing - self.innerFlangePlate.W,
                -(self.column.D) / 2 + self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldL42_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldL42_wDir = numpy.array([0.0, 0.0, 1.0])
            self.innerflangePlateWeldL42.place(innerflangePlateWeldL42Origin,
                                               innerflangePlateWeldL42_uDir,
                                               innerflangePlateWeldL42_wDir)

            self.innerflangePlateWeldL42Model = self.innerflangePlateWeldL42.create_model(
            )

            innerflangePlateWeldW41Origin = numpy.array([
                -innerFlangePlatespacing - self.innerFlangePlate.W,
                -(self.column.D) / 2 + self.column.T,
                self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW41_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldW41_wDir = numpy.array([1.0, 0.0, 0.0])
            self.innerflangePlateWeldW41.place(innerflangePlateWeldW41Origin,
                                               innerflangePlateWeldW41_uDir,
                                               innerflangePlateWeldW41_wDir)

            self.innerflangePlateWeldW41Model = self.innerflangePlateWeldW41.create_model(
            )

            innerflangePlateWeldW42Origin = numpy.array([
                -innerFlangePlatespacing, -(self.column.D) / 2 + self.column.T,
                -self.innerFlangePlate.L / 2
            ])
            innerflangePlateWeldW42_uDir = numpy.array([0.0, 1.0, 0.0])
            innerflangePlateWeldW42_wDir = numpy.array([-1.0, 0.0, 0.0])
            self.innerflangePlateWeldW42.place(innerflangePlateWeldW42Origin,
                                               innerflangePlateWeldW42_uDir,
                                               innerflangePlateWeldW42_wDir)

            self.innerflangePlateWeldW42Model = self.innerflangePlateWeldW42.create_model(
            )

        # to cut the welds
        weldCutPlateOrigin = numpy.array([-self.weldCutPlate.W / 2, 0.0, 0.0])
        weldCutPlate_uDir = numpy.array([0.0, 0.0, 1.0])
        weldCutPlate_wDir = numpy.array([1.0, 0.0, 0.0])
        self.weldCutPlate.place(weldCutPlateOrigin, weldCutPlate_uDir,
                                weldCutPlate_wDir)

        self.weldCutPlateModel = self.weldCutPlate.create_model()

    def get_column_models(self):
        """

        :return: CAD mode for the columns
        """
        columns = BRepAlgoAPI_Fuse(self.column1Model,
                                   self.column2Model).Shape()

        return columns

    def get_plate_models(self):
        """
        :return: CAD model for all the plates
        """

        if self.C.preference != 'Outside':
            plates_sec = [
                self.flangePlate1Model, self.flangePlate2Model,
                self.innerFlangePlate1Model, self.innerFlangePlate2Model,
                self.innerFlangePlate3Model, self.innerFlangePlate4Model,
                self.webPlate1Model, self.webPlate2Model
            ]
        else:
            plates_sec = [
                self.flangePlate1Model, self.flangePlate2Model,
                self.webPlate1Model, self.webPlate2Model
            ]

        plates = plates_sec[0]

        for comp in plates_sec[1:]:
            plates = BRepAlgoAPI_Fuse(comp, plates).Shape()

        return plates

    def get_welded_modules(self):
        """
        :return: CAD model for all the welds
        """
        if self.C.preference != 'Outside':
            welded_sec = [self.flangePlateWeldL11Model, self.flangePlateWeldL12Model, self.flangePlateWeldL21Model,
                          self.flangePlateWeldL22Model, self.flangePlateWeldW11Model, self.flangePlateWeldW12Model,
                          self.flangePlateWeldW21Model, self.flangePlateWeldW22Model, \
                          self.webPlateWeldL11Model, self.webPlateWeldL12Model, self.webPlateWeldL21Model,
                          self.webPlateWeldL22Model, self.webPlateWeldW11Model, self.webPlateWeldW12Model,
                          self.webPlateWeldW21Model, self.webPlateWeldW22Model, \
                          self.innerflangePlateWeldL11Model, self.innerflangePlateWeldL12Model,
                          self.innerflangePlateWeldL21Model, self.innerflangePlateWeldL22Model,
                          self.innerflangePlateWeldL31Model, self.innerflangePlateWeldL32Model,
                          self.innerflangePlateWeldL41Model, self.innerflangePlateWeldL42Model, \
                          self.innerflangePlateWeldW11Model, self.innerflangePlateWeldW12Model,
                          self.innerflangePlateWeldW21Model, self.innerflangePlateWeldW22Model,
                          self.innerflangePlateWeldW31Model, self.innerflangePlateWeldW32Model,
                          self.innerflangePlateWeldW41Model, self.innerflangePlateWeldW42Model]
        else:
            welded_sec = [self.flangePlateWeldL11Model, self.flangePlateWeldL12Model, self.flangePlateWeldL21Model,
                          self.flangePlateWeldL22Model, self.flangePlateWeldW11Model, self.flangePlateWeldW12Model,
                          self.flangePlateWeldW21Model, self.flangePlateWeldW22Model, \
                          self.webPlateWeldL11Model, self.webPlateWeldL12Model, self.webPlateWeldL21Model,
                          self.webPlateWeldL22Model, self.webPlateWeldW11Model, self.webPlateWeldW12Model,
                          self.webPlateWeldW21Model, self.webPlateWeldW22Model]

        welds = welded_sec[0]

        for comp in welded_sec[1:]:
            welds = BRepAlgoAPI_Fuse(comp, welds).Shape()

        welds = BRepAlgoAPI_Cut(welds, self.weldCutPlateModel).Shape()

        return welds
        # return self.innerflangePlateWeldW42Model

    def get_models(self):
        columns = self.get_column_models()
        plate_conectors = self.get_plate_models()
        welds = self.get_welded_modules()

        CAD = BRepAlgoAPI_Fuse(columns, plate_conectors).Shape()
        CAD = BRepAlgoAPI_Fuse(CAD, welds).Shape()

        return CAD
Exemple #4
0
class IsectionCoverPlate(object):
    def __init__(self, D, B, T, t, s, l, t1, H):
        self.B = B
        self.T = T
        self.D = D
        self.t = t
        self.l = l
        self.s = s
        self.t1 = t1
        self.H = H

        self.Isection1 = ISection(B, T, D, t, 0, 0, 0, H, None)
        self.Isection2 = ISection(B, T, D, t, 0, 0, 0, H, None)
        self.Plate1 = Plate(t1, H, l)
        self.Plate2 = Plate(t1, H, l)

    def place(self, sec_origin, uDir, wDir):
        self.sec_origin = sec_origin
        self.uDir = uDir
        self.wDir = wDir

        origin = numpy.array([-self.s / 2., 0., 0.])
        self.Isection1.place(origin, self.uDir, self.wDir)
        origin1 = numpy.array([self.s / 2., 0., 0.])
        self.Isection2.place(origin1, self.uDir, self.wDir)
        origin2 = numpy.array([0., (self.D + self.t1) / 2, 0.])
        self.Plate1.place(origin2, self.uDir, self.wDir)
        origin3 = numpy.array([0., -(self.D + self.t1) / 2, 0.])
        self.Plate2.place(origin3, self.uDir, self.wDir)
        #self.compute_params()

    def compute_params():
        self.Isection1.compute_params()
        self.Isection2.compute_params()
        self.Plate1.compute_params()
        self.Plate2.compute_params()

    def create_model(self):

        prism1 = self.Isection1.create_model()
        prism2 = self.Isection2.create_model()

        prism3 = self.Plate1.create_model()
        prism4 = self.Plate2.create_model()

        prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism3).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism4).Shape()
        return prism, [prism3, prism4]

    def create_marking(self):
        middel_pnt = []
        line = []
        labels = ["z", "y", "u", "v"]
        offset = self.B + self.s
        uvoffset = offset / numpy.sqrt(2)

        #b = self.B/2+self.s/2
        z_points = [
            numpy.array([-offset, 0., self.H / 2]),
            numpy.array([offset, 0., self.H / 2])
        ]
        line.append(makeEdgesFromPoints(z_points))

        y_points = [
            numpy.array([0, -offset, self.H / 2]),
            numpy.array([0, offset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(y_points))

        u_points = [
            numpy.array([-uvoffset, uvoffset, self.H / 2]),
            numpy.array([uvoffset, -uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(u_points))

        v_points = [
            numpy.array([-uvoffset, -uvoffset, self.H / 2]),
            numpy.array([uvoffset, uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(v_points))

        start_pnt = [[-offset, 0, self.H / 2], [0, -offset + 1, self.H / 2],
                     [uvoffset, -uvoffset, self.H / 2],
                     [uvoffset, uvoffset, self.H / 2]]
        end_pnt = [[offset, 0, self.H / 2], [0, offset - 2, self.H / 2],
                   [-uvoffset, uvoffset, self.H / 2],
                   [-uvoffset, -uvoffset, self.H / 2]]

        return line, [start_pnt, end_pnt], labels
Exemple #5
0
class Box(object):
    def __init__(self, A, B, t, H, s, s1):
        self.A = A
        self.B = B
        self.H = H
        self.t = t
        self.s = s
        self.B = s + t
        self.s1 = s1
        self.A = s1 + t

        self.sec_origin = numpy.array([0, 0, 0])
        self.uDir = numpy.array([1.0, 0, 0])
        self.wDir = numpy.array([0.0, 0, 1.0])
        self.vDir = self.wDir * self.uDir

        self.plate1 = Plate(self.B, H, t)
        self.plate2 = Plate(t, H, self.A)
        self.plate3 = Plate(self.B, H, t)
        self.plate4 = Plate(t, H, self.A)

    def place(self, secOrigin, uDir, wDir):
        self.sec_origin = secOrigin
        self.uDir = uDir
        self.wDir = wDir
        origin5 = numpy.array([0., 0., 0.])
        origin5 = numpy.array([-self.A / 2 - self.t / 2, 0., 0.])
        self.plate1.place(origin5, self.uDir, self.wDir)
        origin6 = numpy.array([0., -self.B / 2 + self.t / 2., 0.])
        self.plate2.place(origin6, self.uDir, self.wDir)
        origin7 = numpy.array([self.A / 2 + self.t / 2., 0., 0.])
        self.plate3.place(origin7, self.uDir, self.wDir)
        origin8 = numpy.array([0., self.B / 2 - self.t / 2, 0.])
        self.plate4.place(origin8, self.uDir, self.wDir)

    def compute_params(self):
        self.plate1.compute_params()
        self.plate2.compute_params()
        self.plate3.compute_params()
        self.plate4.compute_params()

    def create_model(self):
        prism1 = self.plate1.create_model()
        prism2 = self.plate2.create_model()
        prism3 = self.plate3.create_model()
        prism4 = self.plate4.create_model()

        prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape()
        prism = BRepAlgoAPI_Fuse(prism, prism3).Shape()
        prism = BRepAlgoAPI_Fuse(prism, prism4).Shape()
        return prism

    def create_marking(self):
        middel_pnt = []
        line = []
        labels = ["z", "y", "u", "v"]
        offset = (self.s + self.s1) / 2
        uvoffset = offset / numpy.sqrt(2)

        z_points = [
            numpy.array([-offset, 0., self.H / 2]),
            numpy.array([offset, 0., self.H / 2])
        ]
        line.append(makeEdgesFromPoints(z_points))

        y_points = [
            numpy.array([0., -offset, self.H / 2]),
            numpy.array([0, offset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(y_points))

        u_points = [
            numpy.array([-uvoffset, uvoffset, self.H / 2]),
            numpy.array([uvoffset, -uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(u_points))

        v_points = [
            numpy.array([-uvoffset, -uvoffset, self.H / 2]),
            numpy.array([uvoffset, uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(v_points))

        pnt_start = [[-offset, 0, self.H / 2], [0, -offset + 1, self.H / 2],
                     [uvoffset, -uvoffset, self.H / 2],
                     [uvoffset, uvoffset, self.H / 2]]
        pnt_end = [[offset, 0, self.H / 2], [0, offset - 3, self.H / 2],
                   [-uvoffset, uvoffset, self.H / 2],
                   [-uvoffset, -uvoffset, self.H / 2]]

        return line, [pnt_start, pnt_end], labels
class ChannelSectionOpposite(object):
    def __init__(self, D, B, T, t, s, l, t1, H):
        self.B = B
        self.T = T
        self.D = D
        self.t = t
        self.l = l
        self.s = s
        self.t1 = t1
        self.H = H

        self.sec_origin = numpy.array([0, 0, 0])
        self.uDir = numpy.array([1.0, 0, 0])
        self.wDir = numpy.array([0.0, 0, 1.0])

        self.Plate1 = Plate(t1, H, l)
        self.Plate2 = Plate(t1, H, l)
        self.channel1 = Channel(B, T, D, t, 0, 0, H)
        self.channel2 = Channel(B, T, D, t, 0, 0, H)
        #self.compute_params()

    def place(self, sec_origin, uDir, wDir):
        self.sec_origin = sec_origin
        self.uDir = uDir
        self.wDir = wDir
        space = self.s / 2 + self.B
        origin = numpy.array([space, 0., 0.])
        self.channel1.place(origin, self.uDir, self.wDir)
        origin1 = numpy.array([space, 0., 0.])
        self.channel2.place(origin1, self.uDir, self.wDir)
        origin2 = numpy.array([0., -self.t1 / 2, 0.])
        self.Plate1.place(origin2, self.uDir, self.wDir)
        origin3 = numpy.array([0., self.D + self.t1 / 2, 0.])
        self.Plate2.place(origin3, self.uDir, self.wDir)
        #self.compute_params()

    def compute_params(self):
        self.channel1.compute_params()
        self.channel2.compute_params()
        self.channel2.points = self.rotateY(self.channel2.points)
        self.channel2.points = self.rotateY(self.channel2.points)
        self.Plate1.compute_params()
        self.Plate2.compute_params()

    def create_model(self):
        prism1 = self.channel1.create_model()
        prism2 = self.channel2.create_model()

        prism3 = self.Plate1.create_model()
        prism4 = self.Plate2.create_model()

        prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism3).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism4).Shape()
        return prism, [prism3, prism4]

    def rotateY(self, points):
        rotated_points = []
        rmatrix = numpy.array([[0, 0, 1], [0, 1, 0], [-1, 0, 0]])
        for point in points:
            point = numpy.matmul(rmatrix, point)
            rotated_points.append(point)
        return rotated_points

    def create_marking(self):
        middel_pnt = []
        line = []
        labels = ["z", "y", "u", "v"]
        offset = self.s + 2 * self.B
        uvoffset = offset / numpy.sqrt(2)

        z_points = [
            numpy.array([-offset, self.D / 2, self.H / 2]),
            numpy.array([offset, self.D / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(z_points))

        y_points = [
            numpy.array([0., -offset + self.D / 2, self.H / 2]),
            numpy.array([0, offset + self.D / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(y_points))

        u_points = [
            numpy.array([-uvoffset, uvoffset + self.D / 2, self.H / 2]),
            numpy.array([uvoffset, -uvoffset + self.D / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(u_points))

        v_points = [
            numpy.array([-uvoffset, -uvoffset + self.D / 2, self.H / 2]),
            numpy.array([uvoffset, uvoffset + self.D / 2, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(v_points))

        start_pnt = [[-offset, self.D / 2, self.H / 2],
                     [0, -offset + self.D / 2 + 1, self.H / 2],
                     [uvoffset, -uvoffset + self.D / 2, self.H / 2],
                     [uvoffset, uvoffset + self.D / 2, self.H / 2]]
        end_pnt = [[offset, self.D / 2, self.H / 2],
                   [0, offset + self.D / 2 - 2, self.H / 2],
                   [-uvoffset, uvoffset + self.D / 2, self.H / 2],
                   [-uvoffset, -uvoffset + self.D / 2, self.H / 2]]

        return line, [start_pnt, end_pnt], labels
Exemple #7
0
class BoxAngle(object):
    def __init__(self, a, b, t, l, t1, l1, H, s, s1):
        self.l = s + 2 * t1
        self.a = a
        self.b = b
        self.t = t
        self.s = s
        self.s1 = s1
        self.t1 = t1
        self.l1 = s1 + 2 * t1 + 2 * t
        self.H = H

        self.sec_origin = numpy.array([0, 0, 0])
        self.uDir = numpy.array([1.0, 0, 0])
        self.wDir = numpy.array([0.0, 0, 1.0])
        self.vDir = self.wDir * self.uDir

        self.angle1 = Angle(H, a, b, t, 0, 0)
        self.angle2 = Angle(H, b, a, t, 0, 0)
        self.angle3 = Angle(H, a, b, t, 0, 0)
        self.angle4 = Angle(H, b, a, t, 0, 0)
        self.plate1 = Plate(self.l, H, t1)
        self.plate2 = Plate(t1, H, self.l1)
        self.plate3 = Plate(self.l, H, t1)
        self.plate4 = Plate(t1, H, self.l1)

    def place(self, secOrigin, uDir, wDir):
        self.sec_origin = secOrigin
        self.uDir = uDir
        self.wDir = wDir
        verti = -self.t - self.s1 / 2  #-self.s1/2 - self.b
        hori = -self.t - self.s / 2
        t = self.t1 / 2

        origin1 = numpy.array([verti, hori, 0.])
        self.angle1.place(origin1, self.uDir, self.wDir)
        origin2 = numpy.array([hori, verti, 0.])
        self.angle2.place(origin2, self.uDir, self.wDir)
        origin3 = numpy.array([verti, hori, 0.])
        self.angle3.place(origin3, self.uDir, self.wDir)
        origin4 = numpy.array([hori, verti, 0.])
        self.angle4.place(origin4, self.uDir, self.wDir)

        origin5 = numpy.array([-self.l1 / 2 + t, 0., 0.])
        self.plate1.place(origin5, self.uDir, self.wDir)
        origin6 = numpy.array([0., -self.l / 2 - t, 0.])
        self.plate2.place(origin6, self.uDir, self.wDir)
        origin7 = numpy.array([self.l1 / 2 - t, 0., 0.])
        self.plate3.place(origin7, self.uDir, self.wDir)
        origin8 = numpy.array([0., self.l / 2 + t, 0.])
        self.plate4.place(origin8, self.uDir, self.wDir)

    def compute_params(self):
        self.angle1.computeParams()
        self.angle2.computeParams()

        self.angle2.points = self.rotate(self.angle2.points, numpy.pi / 2)
        self.angle3.computeParams()
        self.angle3.points = self.rotate(self.angle3.points, numpy.pi)
        self.angle4.computeParams()
        self.angle4.points = self.rotate(self.angle4.points, 3 * numpy.pi / 2)

        self.plate1.compute_params()
        self.plate2.compute_params()
        self.plate3.compute_params()
        self.plate4.compute_params()

    def create_model(self):
        prism1 = self.angle1.create_model()
        prism2 = self.angle2.create_model()
        prism3 = self.angle3.create_model()
        prism4 = self.angle4.create_model()

        prism5 = self.plate1.create_model()
        prism6 = self.plate2.create_model()
        prism7 = self.plate3.create_model()
        prism8 = self.plate4.create_model()

        prism = BRepAlgoAPI_Fuse(prism1, prism2).Shape()
        prism = BRepAlgoAPI_Fuse(prism, prism3).Shape()
        prism = BRepAlgoAPI_Fuse(prism, prism4).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism5).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism6).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism7).Shape()
        # prism = BRepAlgoAPI_Fuse(prism, prism8).Shape()
        return prism, [prism5, prism6, prism7, prism8]

    def rotate(self, points, x):
        rotated_points = []
        rmatrix = numpy.array([[numpy.cos(x), -numpy.sin(x), 0],
                               [numpy.sin(x), numpy.cos(x), 0], [0, 0, 1]])
        for point in points:
            point = numpy.matmul(rmatrix, point)
            rotated_points.append(point)
        return rotated_points

    def create_marking(self):
        middel_pnt = []
        line = []
        labels = ["z", "y", "u", "v"]
        offset = (self.s + self.s1) / 2
        uvoffset = offset / numpy.sqrt(2)

        z_points = [
            numpy.array([-offset, 0., self.H / 2]),
            numpy.array([offset, 0., self.H / 2])
        ]
        line.append(makeEdgesFromPoints(z_points))

        y_points = [
            numpy.array([0., -offset, self.H / 2]),
            numpy.array([0, offset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(y_points))

        u_points = [
            numpy.array([-uvoffset, uvoffset, self.H / 2]),
            numpy.array([uvoffset, -uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(u_points))

        v_points = [
            numpy.array([-uvoffset, -uvoffset, self.H / 2]),
            numpy.array([uvoffset, uvoffset, self.H / 2])
        ]
        line.append(makeEdgesFromPoints(v_points))

        start_pnt = [[-offset, 0, self.H / 2], [0, -offset + 1, self.H / 2],
                     [uvoffset, -uvoffset, self.H / 2],
                     [uvoffset, uvoffset, self.H / 2]]
        end_pnt = [[offset, 0, self.H / 2], [0, offset - 2, self.H / 2],
                   [-uvoffset, uvoffset, self.H / 2],
                   [-uvoffset, -uvoffset, self.H / 2]]

        return line, [start_pnt, end_pnt], labels