Beispiel #1
0
class ISectionChannel(object):
    def __init__(self, D, B, T, t, T1, t1, d, b, H, s):
        self.B = B
        self.T = T
        self.D = D
        self.t = t
        self.T1 = T1
        self.t1 = t1
        self.d = d
        self.b = b
        self.H = H
        self.s = s
        self.B = 2 * self.s - 2 * T1
        self.d = 2 * self.s

        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.channel1 = Channel(b, T1, self.d, t1, 0, 0, H)
        self.isection = ISection(self.B, T, D, t, 0, 0, 0, H, None)
        #self.compute_params()

    def place(self, sec_origin, uDir, wDir):
        self.sec_origin = sec_origin
        self.uDir = uDir
        self.wDir = wDir
        D = self.D / 2
        origin = numpy.array([-D + self.b - self.t1, 0., 0.])
        self.channel1.place(origin, self.uDir, self.wDir)
        origin1 = numpy.array([self.s, 0., 0.])
        self.isection.place(origin1, self.uDir, self.wDir)

    def compute_params(self):
        self.channel1.compute_params()
        self.channel1.points = self.rotateZ(self.channel1.points)
        self.isection.compute_params()
        # self.isection.points = self.rotateZ(self.isection.points)

    def create_model(self):
        prism1 = self.channel1.create_model()
        prism3 = self.isection.create_model()

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

    def rotateZ(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 = self.D
        uvoffset = offset / numpy.sqrt(2)

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

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

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

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

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

        return line, [start_pnt, end_pnt], 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