Ejemplo n.º 1
0
def main():
    # Load a mesh in OFF format
    igl.readOFF(TUTORIAL_SHARED_PATH + "bumpy.off", V, F)

    # Create a Vector Field
    temp_field = igl.eigen.MatrixXd()
    b = igl.eigen.MatrixXi([[0]])
    bc = igl.eigen.MatrixXd([[1, 1, 1]])
    S = igl.eigen.MatrixXd()  # unused

    degree = 3
    igl.comiso.nrosy(V, F, b, bc, igl.eigen.MatrixXi(), igl.eigen.MatrixXd(),
                     igl.eigen.MatrixXd(), 1, 0.5, temp_field, S)
    temp_field2 = igl.eigen.MatrixXd()
    representative_to_nrosy(V, F, temp_field, degree, temp_field2)

    # Initialize tracer
    igl.streamlines_init(V, F, temp_field2, treat_as_symmetric, data, state)

    # Setup viewer
    viewer = igl.glfw.Viewer()
    viewer.data().set_mesh(V, F)
    viewer.callback_pre_draw = pre_draw
    viewer.callback_key_down = key_down

    viewer.core.show_lines = False

    viewer.core.is_animating = False
    viewer.core.animation_max_fps = 30.0

    # Paint mesh grayish
    C = igl.eigen.MatrixXd()
    C.setConstant(viewer.data().V.rows(), 3, .9)
    viewer.data().set_colors(C)

    # Draw vector field on sample points
    state0 = state.copy()

    igl.streamlines_next(V, F, data, state0)
    v = state0.end_point - state0.start_point
    v = v.rowwiseNormalized()

    viewer.data().add_edges(state0.start_point, state0.start_point + 0.059 * v,
                            igl.eigen.MatrixXd([[1.0, 1.0, 1.0]]))

    print("Press [space] to toggle animation")
    viewer.launch()
Ejemplo n.º 2
0
def main():
    # Load a mesh in OFF format
    igl.readOFF(TUTORIAL_SHARED_PATH + "bumpy.off", V, F)

    # Create a Vector Field
    temp_field = igl.eigen.MatrixXd()
    b = igl.eigen.MatrixXi([[0]])
    bc = igl.eigen.MatrixXd([[1, 1, 1]])
    S = igl.eigen.MatrixXd()  # unused

    degree = 3
    igl.comiso.nrosy(V, F, b, bc, igl.eigen.MatrixXi(), igl.eigen.MatrixXd(), igl.eigen.MatrixXd(), 1, 0.5, temp_field, S)
    temp_field2 = igl.eigen.MatrixXd()
    representative_to_nrosy(V, F, temp_field, degree, temp_field2)

    # Initialize tracer
    igl.streamlines_init(V, F, temp_field2, treat_as_symmetric, data, state)

    # Setup viewer
    viewer = igl.viewer.Viewer()
    viewer.data.set_mesh(V, F)
    viewer.callback_pre_draw = pre_draw
    viewer.callback_key_down = key_down

    viewer.core.show_lines = False

    viewer.core.is_animating = False
    viewer.core.animation_max_fps = 30.0

    # Paint mesh grayish
    C = igl.eigen.MatrixXd()
    C.setConstant(viewer.data.V.rows(), 3, .9)
    viewer.data.set_colors(C)

    # Draw vector field on sample points
    state0 = state.copy()

    igl.streamlines_next(V, F, data, state0)
    v = state0.end_point - state0.start_point
    v = v.rowwiseNormalized()

    viewer.data.add_edges(state0.start_point,
                          state0.start_point + 0.059 * v,
                          igl.eigen.MatrixXd([[1.0, 1.0, 1.0]]))

    print("Press [space] to toggle animation")
    viewer.launch()