Example #1
0
                  r=--120.0)
    fta.add_cam_move(a=24.8592205112,
                     e=35.3839345289,
                     d=4.41536277196,
                     f=(0.500000035416,
                        0.287922133088,
                        0.409750220151),
                     r=-93.3680789265,
                     n=n_cam_move,
                     duration=10,
                     vot_start=0.0, vot_end=1.0,
                     azimuth_move='damped',
                     elevation_move='damped',
                     distance_move='damped')
    fta.add_cam_move(a=24.8592205112,
                     e=35.3839345289,
                     d=4.41536277196,
                     f=(0.500000035416,
                        0.287922133088,
                        0.409750220151),
                     r=-93.3680789265,
                     n=n_cam_move,
                     duration=10,
                     vot_start=1.0, vot_end=0.0,
                     azimuth_move='damped',
                     elevation_move='damped',
                     distance_move='damped')

    fta.plot()
    fta.configure_traits()
Example #2
0
                  e=61.453898329,
                  d=5.0,
                  f=(1.58015494765,
                     1.12671403563,
                     -0.111520325399),
                  r=-105.783218753)

    if show_init_task:
        ftv.add(it.target_faces[0].viz3d['default'])
        it.formed_object.viz3d['cp'].set(tube_radius=0.002)
        ftv.add(it.formed_object.viz3d['cp'])
        #ftv.add(it.formed_object.viz3d['node_numbers'], order=5)
        it.u_1

    if show_fold_angle_cntl:
        ft = bsf_process.fold_angle_cntl
        print 'NDOFS', ft.formed_object.n_dofs
        print ft.sim_step
        ft.sim_history.set(anim_t_start=0, anim_t_end=10)
        ft.config.gu['dofs'].set(anim_t_start=0, anim_t_end=5)
        ft.sim_history.viz3d['cp'].set(tube_radius=0.002)
        ftv.add(ft.sim_history.viz3d['cp'])
#        ftv.add(ft.sim_history.viz3d['node_numbers'])
        ft.config.gu['dofs'].viz3d['default'].scale_factor = 0.5
        ftv.add(ft.config.gu['dofs'].viz3d['default'])
        ft.u_1
        fta.add_cam_move(duration=10, n=20)

    fta.plot()
    fta.configure_traits()
def run_examples():
    factor = 10

    kw1 = dict(a=0.36,
               c=0.12,
               h=0.55,
               d_r=0.01 / factor, d_up=0.01 / factor, d_down=0.02 / factor,
               # d_r=0.0005, d_up=0.0005, d_down=0.01,
               t_max=1.0,
               n_cell_x=2, n_cell_y=2,
               n_fold_steps=5 * factor,
               n_load_steps=1)
    kw2 = dict(a=2,
               h=7,
               c=3,
               d_r=0.01, d_up=0.01, d_down=0.02,
               t_max=0.5,
               n_cell_x=4, n_cell_y=4,
               n_fold_steps=20,
               n_load_steps=1)
    kw3 = dict(a=2,
               h=3,
               c=2,
               d_r=0.01, d_up=0.01, d_down=0.02,
               t_max=1.0,
               n_cell_x=1, n_cell_y=1,
               n_fold_steps=40,
               n_load_steps=1)
    kw4 = dict(a=0.36,
               c=0.18,  # 0.17,  # 0.12
               h=0.4,  # 0.4,  # 0.55
               d_r=0.1 / factor, d_up=0.01 / factor, d_down=0.04 / factor,
               #               d_r=0.01 / factor, d_up=0.01 / factor, d_down=0.04 / factor,
               #               d_r=0.05, d_up=0.005, d_down=0.01,
               t_max=1.0,
               psi_max=np.pi,  # * 0.99976,
               n_cell_x=3, n_cell_y=4,  # 3,
               n_fold_steps=60,
               n_load_steps=1)

    bsf_process = WBShellFormingProcess(**kw4)

    ftv = WBShellFormingProcessFTV(model=bsf_process)

    fa = bsf_process.factory_task

    if True:
        import pylab as p
        fig, ax = p.subplots(1, 1, figsize=(8.27, 11.69), dpi=300)
        fa.formed_object.plot_mpl(ax,
                                  nodes=False, lines=False,
                                  facets=False, linewidth=0.2)
        p.axis('off')
        N_h_F = fa.N_h[::3, :]
        N_i_F = fa.N_i[1::3, :]

        F_lower = np.array(
            [N_i_F, N_h_F[:-1, :-1], N_h_F[1:, :-1]], dtype=np.float_)
        F_upper = np.array(
            [N_i_F, N_h_F[:-1, 1:], N_h_F[1:, 1:]], dtype=np.float_)
        F_I = np.vstack([F_lower.reshape(3, -1).T,
                         F_upper.reshape(3, -1).T])
        L_F_I = F_I[:, [[0, 1], [1, 2], [2, 0]]]
        p.savefig('/tmp/wb_trr.jpg', bbox_inches=0)

    it = bsf_process.init_displ_task

    animate = False
    show_init_task = False
    show_fold_angle_cntl = False
    show_trr = True
    show_fold_kinem_cntl = False

    fta = FTA(ftv=ftv, figsize_factor=1.5)
    fta.init_view(a=33.4389721223,
                  e=61.453898329,
                  d=5.0,
                  f=(1.58015494765,
                     1.12671403563,
                     -0.111520325399),
                  r=-105.783218753)

    if show_init_task:
        ftv.add(it.target_faces[0].viz3d['default'])
        it.formed_object.viz3d['cp'].trait_set(tube_radius=0.1)
        ftv.add(it.formed_object.viz3d['cp'])
        #ftv.add(it.formed_object.viz3d['node_numbers'], order=5)
        it.u_1

    if show_fold_angle_cntl:
        ft = bsf_process.fold_angle_cntl

        ft.sim_history.trait_set(anim_t_start=0, anim_t_end=10)
#        ft.config.gu['dofs'].trait_set(anim_t_start=0, anim_t_end=5)
        ft.sim_history.viz3d['cp'].trait_set(tube_radius=0.02)
        print(ft.sim_step)

        ft.sim_history.set(anim_t_start=0, anim_t_end=10)
#        ft.config.gu['dofs'].set(anim_t_start=0, anim_t_end=5)
        ft.sim_history.viz3d['cp'].set(tube_radius=0.002)
        ftv.add(ft.sim_history.viz3d['cp'])
#        ftv.add(ft.sim_history.viz3d['node_numbers'])
#        ft.config.gu['dofs'].viz3d['default'].scale_factor = 0.5
#        ftv.add(ft.config.gu['dofs'].viz3d['default'])
        ft.u_1

        # bsf_process.generate_fe_mesh(0.5)

        fta.add_cam_move(duration=10, n=20)

        arg_phi, phi = bsf_process.max_slope

        fig, (ax1, ax3) = p.subplots(2, 1, sharex=True)
        ax2 = ax1.twinx()
        n_u, n_v, c = bsf_process.curvature_t
        ax1.plot(ft.t_arr, c, 'b-',
                 label='curvature')
        ax2.plot(ft.t_arr, n_u, 'g-', label='height u')
        ax2.plot(ft.t_arr, n_v, 'y-', label='height v')
        ax3.plot(ft.t_arr, phi, 'r-', label='slope')

        # p.show()

    if show_trr:

        ft = bsf_process.fold_angle_cntl

        ft.sim_history.trait_set(anim_t_start=0, anim_t_end=20)
        ft.sim_history.viz3d['cp'].trait_set(tube_radius=0.005)
        ftv.add(ft.sim_history.viz3d['cp'])
        ft.u_1

        mt_up = MoveTask(previous_task=ft,
                         u_target=[0, 0, 0.4],
                         rotation_axis=[0, 1, 0],
                         rotation_center=[1, 0, 0],
                         rotation_angle=np.pi / 8,
                         n_steps=30)
        mt_up.sim_history.trait_set(anim_t_start=20.01, anim_t_end=50)
        mt_up.sim_history.viz3d['cp'].trait_set(tube_radius=0.005)
        ftv.add(mt_up.sim_history.viz3d['cp'])
        mt_up.u_1

        mt_fp_down = MoveTask(previous_task=ft,
                              u_target=[0, 0, 0.4],
                              rotation_axis=[0, 1, 0],
                              rotation_center=[1, 0, 0],
                              rotation_angle=0,
                              n_steps=20)
        mt_fp_down.sim_history.trait_set(anim_t_start=50.01, anim_t_end=70)
        mt_fp_down.sim_history.viz3d['cp'].trait_set(tube_radius=0.001)
        ftv.add(mt_fp_down.sim_history.viz3d['cp'])
        mt_fp_down.u_1

        lower_plate_ft = bsf_process.interlock_plate  # lower_plate
        lower_plate_ft.formed_object.viz3d['cp'].trait_set(
            lines=False, tube_radius=0.001)
        lower_plate_ft.formed_object.trait_set(
            anim_t_start=30.0, anim_t_end=50)
        ftv.add(lower_plate_ft.formed_object.viz3d['cp'])

        mt_lp_down = MoveTask(previous_task=lower_plate_ft,
                              u_target=[0, 0, 0.4],
                              rotation_axis=[0, 1, 0],
                              rotation_center=[1, 0, 0],
                              rotation_angle=0,
                              n_steps=20)
        mt_lp_down.sim_history.trait_set(anim_t_start=50.01, anim_t_end=70)
        mt_lp_down.sim_history.viz3d['cp'].trait_set(
            lines=False, tube_radius=0.005)
        ftv.add(mt_lp_down.sim_history.viz3d['cp'])
        mt_lp_down.u_1

        upper_plate_ft = bsf_process.upper_plate
        upper_plate_ft.formed_object.viz3d['cp'].trait_set(
            lines=False, tube_radius=0.001)
        upper_plate_ft.formed_object.trait_set(
            anim_t_start=50.0, anim_t_end=70)
        ftv.add(upper_plate_ft.formed_object.viz3d['cp'])

        # bsf_process.generate_fe_mesh(0.5)

        fta.init_cam_station.trait_set(
            azimuth=185,
            elevation=5.,
            distance=5.34,
            roll=90.0,
            focal_point=(1.1, 1.2, 0.0),
        )
        elevation = 77.0
        # Turn from crease pattern view to folding position
        fta.add_cam_move(duration=10, n=30,
                         a=139.71,
                         e=elevation,
                         d=4.26,
                         r=99.5,
                         f=(1.13, 1.17, 0.11),
                         azimuth_move='damped',
                         elevation_move='damped',
                         distance_move='damped',
                         vot_start=0, vot_end=0)
        # Show the folding process
        fta.add_cam_move(duration=10, n=60,
                         azimuth_move='damped',
                         elevation_move='damped',
                         distance_move='damped',
                         vot_start=0, vot_end=1)
        # Wait
        fta.add_cam_move(duration=1, n=5,
                         vot_start=0, vot_end=0)
        # Lift the folded plate
        fta.add_cam_move(duration=9, n=30,
                         a=181,
                         r=90,
                         azimuth_move='damped',
                         roll_move='damped',
                         vot_start=0, vot_end=1)
        # Wait
        fta.add_cam_move(duration=1, n=5,
                         vot_start=1, vot_end=1)
        # Put it down again
        fta.add_cam_move(duration=9, n=20,
                         vot_start=1, vot_end=0)
        # Wait
        fta.add_cam_move(duration=1, n=10,
                         vot_start=0, vot_end=0)
        # Turn around
        fta.add_cam_move(duration=9, n=40,
                         e=elevation - 180,
                         f=(0.0, 1.17, 0.5),
                         elevation_move='damped',
                         vot_start=0, vot_end=0)
        # Wait
        fta.add_cam_move(duration=1, n=10,
                         vot_start=0, vot_end=0)
        # Move to the upper plate
        fta.add_cam_move(duration=9, n=20,
                         vot_start=0, vot_end=1)

        # Turn it back
        fta.add_cam_move(duration=4, n=40,
                         e=elevation + 4,
                         d=3.8,
                         elevation_move='damped',
                         distance_move='damped',
                         f=(1.1, 1.1, 0.5),
                         vot_start=1, vot_end=1)
        # Wait
        fta.add_cam_move(duration=1, n=10,
                         vot_start=1, vot_end=1)

    if show_fold_kinem_cntl:
        ft = bsf_process.fold_kinem_cntl

        print(ft.sim_step)

        ft.sim_history.trait_set(anim_t_start=0, anim_t_end=10)
        ft.config.gu['dofs'].trait_set(anim_t_start=0, anim_t_end=5)
        ft.sim_history.viz3d['cp'].trait_set(tube_radius=0.002)
        ftv.add(ft.sim_history.viz3d['cp'])
        ft.config.gu['dofs'].viz3d['default'].scale_factor = 0.5
        ftv.add(ft.config.gu['dofs'].viz3d['default'])
        ft.u_1

        fta.add_cam_move(duration=10, n=20)

    fta.plot()
    fta.configure_traits()