Example #1
0
    -----
    This function does not care about the directions being unified or not. It
    just reverses whatever direction it finds.

    """
    mesh.halfedge = {key: {} for key in mesh.vertices()}
    for fkey in mesh.faces():
        mesh.face[fkey][:] = mesh.face[fkey][::-1]
        for u, v in mesh.face_halfedges(fkey):
            mesh.halfedge[u][v] = fkey
            if u not in mesh.halfedge[v]:
                mesh.halfedge[v][u] = None


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.utilities import print_profile
    from compas.datastructures import Mesh

    unify = print_profile(mesh_unify_cycles)

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    unify(mesh)
Example #2
0
# Main
# ==============================================================================

if __name__ == "__main__":

    from numpy import array

    from math import pi
    from compas.utilities import print_profile
    from compas.geometry import Box
    from compas.geometry import Translation
    from compas.geometry import Rotation
    from compas.datastructures import Mesh
    from compas.datastructures import mesh_transform_numpy

    mesh_transform_numpy = print_profile(mesh_transform_numpy)

    box = Box.from_corner_corner_height([0.0, 0.0, 0.0], [1.0, 1.0, 0.0], 1.0)
    mesh = Mesh.from_vertices_and_faces(box.vertices, box.faces)

    T = Translation([-2.0, 0.0, 3.0])
    R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], pi / 2)

    T = array(T)
    R = array(R)

    M = R.dot(T)

    mesh_transform_numpy(mesh, M)

    print(mesh.get_vertices_attribute('x'))
Example #3
0
    return network_copy


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    from math import pi

    from compas.utilities import print_profile
    from compas.geometry import Box
    from compas.geometry import matrix_from_translation
    from compas.geometry import Translation
    from compas.geometry import Rotation
    from compas.datastructures import network

    network_transform = print_profile(network_transform)

    box = Box.from_corner_corner_height([0.0, 0.0, 0.0], [1.0, 1.0, 0.0], 1.0)
    network = network.from_vertices_and_faces(box.vertices, box.faces)

    T = matrix_from_translation([-2.0, 0.0, 3.0])
    T = Translation([-2.0, 0.0, 3.0])
    R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], pi / 2)

    network_transform(network, R)

    print(network.get_vertices_attribute('x'))
Example #4
0
from math import pi

from compas.utilities import print_profile
from compas.geometry import Box
from compas.geometry import matrix_from_translation
from compas.geometry import Translation
from compas.geometry import Rotation
from compas.datastructures import Mesh
from compas.datastructures import mesh_transform

mesh_transform = print_profile(mesh_transform)

box = Box.from_corner_corner_height([0.0, 0.0, 0.0], [1.0, 1.0, 0.0], 1.0)
mesh = Mesh.from_vertices_and_faces(box.vertices, box.faces)

T = matrix_from_translation([-2.0, 0.0, 3.0])
T = Translation([-2.0, 0.0, 3.0])
R = Rotation.from_axis_and_angle([0.0, 0.0, 1.0], pi / 2)

mesh_transform(mesh, R)

print(mesh.get_vertices_attribute('x'))