def gen_layer_model(lyr, part_vtp, model_temp, mode_emb='center'):
    """
    Generates a random instance of a layer
    :param lyr: TomoParticles object with the layer used a reference
    :param part_vtp: vtkPolyData object with the particle shape
    :param model_temp: model template class (child of Model class) for doing the simulations
    :param mode_emb: particle embedding mode (default 'center')
    :return: a simulated instance of TomoParticles
    """

    # The trivial case
    if lyr.get_num_particles() <= 0:
        return None

    # Instance simulation
    model = model_temp(lyr.get_voi(), part_vtp)
    # disperse_io.save_vtp(lyr.get_particles()[0].get_vtp(), '/fs/pool/pool-lucic2/antonio/workspace/psd_an/ex/syn/sub/relion/fils/pst/ampar_vs_nmdar/org/col_pre_v2/col_all_az/col_scol_sim_5_maxd_15_nn1_2_nn2_2_nn3_2_test/tomos/hold_voi.vtp')
    tomo_sim = model.gen_instance(lyr.get_num_particles(), lyr.get_tomo_fname(), mode=mode_emb)

    return tomo_sim