Ejemplo n.º 1
0
    def to_local_geometry_xy(self):
        if self.Type == 'W':
            # wf == 'wireframe - center line of steel element, with origin at middle'
            wf_pt0 = Point(0, self.d * 0.5 - self.tw * 0.5, 0)
            wf_pt1 = Point(0, -(self.d * 0.5 - self.tw * 0.5), 0)
            wf_pt2 = translate_points([wf_pt0], Vector(-self.bf * 0.5, 0, 0))[0]
            wf_pt3 = translate_points([wf_pt0], Vector(self.bf * 0.5, 0, 0))[0]
            wf_pt4 = translate_points([wf_pt1], Vector(-self.bf * 0.5, 0, 0))[0]
            wf_pt5 = translate_points([wf_pt1], Vector(self.bf * 0.5, 0, 0))[0]

            wf_pt2 = Point(*wf_pt2)
            wf_pt3 = Point(*wf_pt3)
            wf_pt4 = Point(*wf_pt4)
            wf_pt5 = Point(*wf_pt5)

            web_surf = self.create_plate_xy(wf_pt0, wf_pt1, self.length)
            top_flange_srf = self.create_plate_xy(wf_pt2, wf_pt3, self.length)
            bottom_flange_srf = self.create_plate_xy(wf_pt4, wf_pt5, self.length)
            web_pl = self.extrude_plate(web_surf, self.tw, 'x')
            top_flange = self.extrude_plate(top_flange_srf, self.tf, 'y')
            bottom_flange = self.extrude_plate(bottom_flange_srf, self.tf, 'y')
            return [web_pl, top_flange, bottom_flange]
        if self.Type == 'HSS':
            raise NotImplementedError
        else:
            raise NotImplementedError
Ejemplo n.º 2
0
 def to_local_geometry_xy(self):
     mesh_Point3D = []
     mesh_points = []
     for pt in self.gusset_points:
         mesh_Point3D.append(
             translate_points([pt], Vector(0, 0, -0.5 * self.thickness))[0])
         mesh_Point3D.append(
             translate_points([pt], Vector(0, 0, 0.5 * self.thickness))[0])
     for pt in mesh_Point3D:
         mesh_points.append({
             'x': float(pt[0]),
             'y': float(pt[1]),
             'z': float(pt[2])
         })
     return [mesh_points]
Ejemplo n.º 3
0
def calculate_offset_pos_two_side_two_point_locked(b_struct, v_key, vecs_con_1,
                                                   vecs_con_2, pts_con_1,
                                                   pts_con_2, d_o_1, d_o_2):
    """calculate offsetted plane when the bar's both ends have two contact points

    """
    assert len(vecs_con_1) == 2 and len(pts_con_1) == 2
    assert len(vecs_con_2) == 2 and len(pts_con_2) == 2

    map(normalize_vector, vecs_con_1)
    map(normalize_vector, vecs_con_2)
    v1_1, v1_2 = vecs_con_1
    v2_1, v2_2 = vecs_con_2
    pt_1_1, pt_1_2 = pts_con_1
    pt_2_1, pt_2_2 = pts_con_2

    vm_1 = scale_vector(normalize_vector(add_vectors(v1_1, v1_2)), -1. * d_o_1)
    # original contact point (assuming two bars have the same radius)
    pt_1 = centroid_points([pt_1_1, pt_1_2])
    pt_1_new = translate_points([pt_1], vm_1)[0]

    vm_2 = scale_vector(normalize_vector(add_vectors(v2_1, v2_2)), -1. * d_o_2)
    pt_2 = centroid_points([pt_2_1, pt_2_2])
    pt_2_new = translate_points([pt_2], vm_2)[0]

    vec_x_new = normalize_vector(vector_from_points(pt_1_new, pt_2_new))
    x_ax = b_struct.vertex[v_key]["gripping_plane"][1]

    if not angle_vectors(x_ax, vec_x_new, deg=True) < 90:
        vec_x_new = scale_vector(vec_x_new, -1.)

    pt_o = b_struct.vertex[v_key]["gripping_plane"][0]
    y_ax = b_struct.vertex[v_key]["gripping_plane"][2]
    vec_z = cross_vectors(vec_x_new, y_ax)
    l_n = (pt_1_new, pt_2_new)
    pt_o_n = closest_point_on_line(pt_o, l_n)

    return pt_o_n, vec_x_new, y_ax, vec_z
Ejemplo n.º 4
0
 def extrude_plate(self, pts, thickness, direction):
     mesh_Point3D = []
     mesh_points = []
     if direction == 'x':
         for pt in pts:
             mesh_Point3D.append(translate_points([pt], Vector(-0.5 * thickness, 0, 0))[0])
             mesh_Point3D.append(translate_points([pt], Vector(0.5 * thickness, 0, 0))[0])
     if direction == 'y':
         for pt in pts:
             mesh_Point3D.append(translate_points([pt], Vector(0, -0.5 * thickness, 0))[0])
             mesh_Point3D.append(translate_points([pt], Vector(0, 0.5 * thickness, 0))[0])
     if direction == 'z':
         for pt in pts:
             mesh_Point3D.append(translate_points([pt], Vector(0, 0, -0.5 * thickness))[0])
             mesh_Point3D.append(translate_points([pt], Vector(0, 0, 0.5 * thickness))[0])
     for pt in mesh_Point3D:
         mesh_points.append({'x': float(pt[0]), 'y': float(pt[1]), 'z': float(pt[2])})
     return mesh_points
Ejemplo n.º 5
0
def test_translate_points():
    assert translate_points([[0, 1, 2]], [3, 4, 5]) == [[3, 5, 7]]
Ejemplo n.º 6
0
    def create_plate_xy(self, pt0, pt1, length):
        c0, c2 = translate_points([pt0, pt1], Vector(0, 0, 0))
        c1, c3 = translate_points([pt0, pt1], Vector(0, 0, length))

        return [Point(*c0), Point(*c1), Point(*c2), Point(*c3)]
Ejemplo n.º 7
0
def calculate_offset(o_struct, b_struct, v_key, d_o_1, d_o_2, seq):
    """[summary]

    Example usage:
        by default, seq = [v for v in b_struct.vertex]
        for v in b_struct.vertex:
            pts.append(rg.Point3d(*b_struct.vertex[v]["mean_point"]))
            calculate_gripping_plane(b_struct, v, b_struct.vertex[v]["mean_point"], nb_rot=nb_rot, nb_trans=nb_trans)
            calculate_offset(o_struct, b_struct, v, offset_d1, offset_d2, seq)
            calculate_offsets_all(o_struct, b_struct, v, offset_d1, offset_d2, seq)

    TODO: we can perform motion planning to solve for local disassembly motion

    Parameters
    ----------
    o_struct : [type]
        [description]
    b_struct : [type]
        [description]
    v_key : [type]
        vertex key in BarStructure, representing a physical bar
    d_o_1 : [type]
        [description]
    d_o_2 : [type]
        [description]
    seq : [type]
        [description]
    """
    v_pos = seq.index(v_key)
    int_v = 2 - v_pos % 3
    v_pos_max = v_pos + int_v
    list_verts_con = seq[0:v_pos_max + 1]

    # * Find v_key bar's corresponding edge in OverallStructure
    o_edge = None
    for o_node1 in o_struct.edge:
        # OverallStructure's nodes are ideal vertices where multiple bars come together
        for o_node2 in o_struct.edge[o_node1]:
            # OverallStructure's edges are bars
            bar_edge = o_struct.edge[o_node1][o_node2]
            if bar_edge["vertex_bar"] == v_key:
                # check key correspondance between OverallStructure's edge
                # and BarStructure's vertex
                o_edge = (o_node1, o_node2)
                break
        if o_edge: break

    # OverallStructure's edges are bars, find this bar's two end points' connected
    cons_1 = find_connectors(o_struct, o_edge[0])
    cons_2 = find_connectors(o_struct, o_edge[1])

    #for c in cons_1:
    #cons_all_1 = [c for c in cons_1 if c[0] <= v_key_max and c[1] <= v_key_max and (c[0] == v_key or c[1] == v_key)]
    #cons_all_2 = [c for c in cons_2 if c[0] <= v_key_max and c[1] <= v_key_max and (c[0] == v_key or c[1] == v_key)]

    cons_all_1 = [
        c for c in cons_1
        if c[0] in list_verts_con and c[1] in list_verts_con and (
            c[0] == v_key or c[1] == v_key)
    ]
    cons_all_2 = [
        c for c in cons_2
        if c[0] in list_verts_con and c[1] in list_verts_con and (
            c[0] == v_key or c[1] == v_key)
    ]

    bar_1 = b_struct.vertex[v_key]["axis_endpoints"]

    TOL = 0.1
    vecs_con_1 = []  # vectors of all connections to the bar in endpoint 1
    pts_con_1 = []  # points of connections on bar axis
    for c in cons_all_1:
        # ep = b_struct.edge[c[0]][c[1]]["endpoints"][list(b_struct.edge[c[0]][c[1]]["endpoints"].keys())[0]]
        ep = list(b_struct.edge[c[0]][c[1]]["endpoints"].values())[0]
        if is_point_on_line(ep[0], bar_1, TOL):
            vecs_con_1.append(vector_from_points(ep[0], ep[1]))
            pts_con_1.append(ep[0])
        elif is_point_on_line(ep[1], bar_1, TOL):
            vecs_con_1.append(vector_from_points(ep[1], ep[0]))
            pts_con_1.append(ep[1])
        else:
            raise RuntimeError(
                "no point found on axis - check function calculate_offset")

    vecs_con_2 = []  # vectors of all connections to the bar in endpoint 2
    pts_con_2 = []  # points of connections on bar axis
    for c in cons_all_2:
        # ep = b_struct.edge[c[0]][c[1]]["endpoints"][b_struct.edge[c[0]][c[1]]["endpoints"].keys()[0]]
        ep = list(b_struct.edge[c[0]][c[1]]["endpoints"].values())[0]
        if is_point_on_line(ep[0], bar_1, 0.1):
            vecs_con_2.append(vector_from_points(ep[0], ep[1]))
            pts_con_2.append(ep[0])
        elif is_point_on_line(ep[1], bar_1, 0.1):
            vecs_con_2.append(vector_from_points(ep[1], ep[0]))
            pts_con_2.append(ep[1])
        else:
            raise RuntimeError(
                "no point found on axis - check function calculate_offset")

    ### calculate offset for first three bars (with one neighbour each)
    if len(vecs_con_1) == 1 and len(vecs_con_2) == 1:
        v1 = normalize_vector(vecs_con_1[0])
        v2 = normalize_vector(vecs_con_2[0])
        # same_dir    = check_dir(v1, v2)

        if angle_vectors(v1, v2, deg=True) < 90:
            # not locked on the both sides, translation-only
            vm = scale_vector(normalize_vector(add_vectors(v1, v2)),
                              -1. * d_o_1)
            # shift gripping plane
            pt_o = b_struct.vertex[v_key]["gripping_plane"][0]
            x_ax = b_struct.vertex[v_key]["gripping_plane"][1]
            y_ax = b_struct.vertex[v_key]["gripping_plane"][2]
            z_ax = b_struct.vertex[v_key]["gripping_plane"][3]
            pt_o_n = translate_points([pt_o], vm)[0]
            b_struct.vertex[v_key].update(
                {"gripping_plane_offset": (pt_o_n, x_ax, y_ax, z_ax)})
        else:
            # not locked on the both sides, translation-only
            pt_1 = pts_con_1[0]
            pt_2 = pts_con_2[0]
            pt_o_n, vec_x_n, y_ax, vec_z = calculate_offset_pos_two_side_one_point_locked(
                b_struct, v_key, pt_1, pt_2, v1, v2, d_o_1, d_o_2)
            #pt_o_n  = point_mean([pt_1_n, pt_2_n])
            b_struct.vertex[v_key].update(
                {"gripping_plane_offset": (pt_o_n, vec_x_n, y_ax, vec_z)})

    ### calculate offset for bars with neighbours only on one side
    if (len(vecs_con_1) == 1
            and len(vecs_con_2) == 0) or (len(vecs_con_2) == 1
                                          and len(vecs_con_1) == 0):
        if len(vecs_con_1) == 1:
            v1 = normalize_vector(vecs_con_1[0])
        else:
            v1 = normalize_vector(vecs_con_2[0])
        vm = scale_vector(v1, -1. * d_o_1)
        pt_o = b_struct.vertex[v_key]["gripping_plane"][0]
        x_ax = b_struct.vertex[v_key]["gripping_plane"][1]
        y_ax = b_struct.vertex[v_key]["gripping_plane"][2]
        z_ax = b_struct.vertex[v_key]["gripping_plane"][3]
        pt_o_n = translate_points([pt_o], vm)[0]
        b_struct.vertex[v_key].update(
            {"gripping_plane_offset": (pt_o_n, x_ax, y_ax, z_ax)})

    if (len(vecs_con_1) == 2
            and len(vecs_con_2) == 0) or (len(vecs_con_2) == 2
                                          and len(vecs_con_1) == 0):
        # not locked on the both sides, translation-only
        if len(vecs_con_1) == 2:
            v1 = normalize_vector(vecs_con_1[0])
            v2 = normalize_vector(vecs_con_1[1])
        else:
            v1 = normalize_vector(vecs_con_2[0])
            v2 = normalize_vector(vecs_con_2[1])
        vm = scale_vector(normalize_vector(add_vectors(v1, v2)), -1. * d_o_1)
        # shift gripping plane
        pt_o = b_struct.vertex[v_key]["gripping_plane"][0]
        x_ax = b_struct.vertex[v_key]["gripping_plane"][1]
        y_ax = b_struct.vertex[v_key]["gripping_plane"][2]
        z_ax = b_struct.vertex[v_key]["gripping_plane"][3]
        pt_o_n = translate_points([pt_o], vm)[0]
        b_struct.vertex[v_key].update(
            {"gripping_plane_offset": (pt_o_n, x_ax, y_ax, z_ax)})

    ### calculate offset for other bars (with two neighbours each)
    if len(vecs_con_1) == 2 and len(vecs_con_2) == 2:
        pt_o_n, vec_x_n, y_ax, vec_z  = calculate_offset_pos_two_side_two_point_locked(b_struct, v_key, \
            vecs_con_1, vecs_con_2, pts_con_1, pts_con_2, d_o_1, d_o_2)

        #pt_o_n  = point_mean([pt_1_n, pt_2_n])
        b_struct.vertex[v_key].update(
            {"gripping_plane_offset": (pt_o_n, vec_x_n, y_ax, vec_z)})
        # return pt_o_n, vec_x_n, y_ax, vec_z

    # * gripping_planes_all by applying transformation from gripping_plane
    gripping_frame = Frame(*b_struct.vertex[v_key]["gripping_plane"][0:3])
    gripping_frame_offset = Frame(
        *b_struct.vertex[v_key]["gripping_plane_offset"][0:3])
    offset_tf = Transformation.from_frame_to_frame(gripping_frame,
                                                   gripping_frame_offset)
    gripping_frames_all = [
        Frame(*plane[0:3]).transformed(offset_tf)
        for plane in b_struct.vertex[v_key]["gripping_planes_all"]
    ]
    b_struct.vertex[v_key].update({
        "gripping_planes_offset_all":
        [Frame_to_plane_data(frame) for frame in gripping_frames_all]
    })

    # contact point projection on the central axis
    # vector connecting projected points on the bars
    return pts_con_1, vecs_con_1, pts_con_2, vecs_con_2