Exemple #1
0
        'pz': 0.0,
        'rx': 0.0,
        'ry': 0.0,
        'rz': 0.0,
    }

    dea = {
        'qpre': 1.0,
        'fpre': 0.0,
        'lpre': 0.0,
        'linit': 0.0,
        'E': 0.0,
        'radius': 0.0,
    }

    lines = compas.get_data('lines.obj')

    network = Network.from_obj(lines)
    network.update_default_vertex_attributes(dva)
    network.update_default_edge_attributes(dea)

    for key, attr in network.vertices(True):
        attr['is_fixed'] = network.vertex_degree(key) == 1

    count = 1
    for u, v, attr in network.edges(True):
        attr['qpre'] = count
        count += 1

    res = drx(network)
Exemple #2
0
    del self.face[fkey]

    return f, g


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

if __name__ == "__main__":

    import compas
    from compas.datastructures import Mesh
    from compas.plotters import MeshPlotter
    from compas.topology import mesh_quads_to_triangles

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

    mesh_quads_to_triangles(mesh)

    split = mesh.split_edge_tri(15, 20)

    facecolor = {key: '#cccccc' if key != split else '#ff0000' for key in mesh.vertices()}

    plotter = MeshPlotter(mesh, figsize=(10, 7))

    plotter.draw_vertices(text={key: key for key in mesh.vertices()}, radius=0.2, facecolor=facecolor)
    plotter.draw_faces(text={fkey: fkey for fkey in mesh.faces()})

    plotter.show()
Exemple #3
0
def mesh_identify_vertices(mesh, points, precision=None):
    keys = []
    gkey_key = {
        geometric_key(mesh.vertex_coordinates(key), precision): key
        for key in mesh.vertices()
    }
    for xyz in points:
        gkey = geometric_key(xyz, precision)
        if gkey in gkey_key:
            key = gkey_key[gkey]
            keys.append(key)
    return keys


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

if __name__ == "__main__":

    import compas
    from compas.datastructures import Mesh
    from compas_rhino import mesh_draw
    from compas_rhino import mesh_select_vertex
    from compas_rhino import mesh_move_vertex

    mesh = Mesh.from_obj(compas.get_data('quadmesh_planar.obj'))

    mesh_draw(mesh, layer='test', clear_layer=True)
Exemple #4
0
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures.mesh import Mesh

    from compas.visualization.viewers.viewer import Viewer

    from compas.visualization.viewers.core.drawing import draw_points
    from compas.visualization.viewers.core.drawing import draw_lines
    from compas.visualization.viewers.core.drawing import draw_circle

    mesh = Mesh.from_obj(compas.get_data('hypar.obj'))

    for key, attr in mesh.vertices(True):
        attr['is_fixed'] = mesh.vertex_degree(key) == 2

    planarize_mesh_shapeop(mesh,
                           fixed=mesh.vertices_where({'is_fixed': True}),
                           kmax=100)

    # deviations = []

    # for fkey, attr in mesh.faces(True):
    #     points = mesh.face_coordinates(fkey)
    #     base, normal = bestfit_plane_from_points(points)

    #     angles = []
Exemple #5
0
    #     temp = zip(names, defaults)
    #     if not keys:
    #         return [[attr.get(name, default) for name, default in temp] for u, v, attr in self.edges_iter(True)]
    #     return [[self.edge[u][v].get(name, default) for name, default in temp] for u, v in keys]


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

if __name__ == '__main__':

    import compas
    from compas.viewers import VolMeshViewer

    mesh = VolMesh.from_obj(compas.get_data('boxes.obj'))

    mesh.scale(0.5)

    mesh = VolMesh.from_data(mesh.to_data())

    viewer = VolMeshViewer(mesh, 600, 600, grid_on=False, zoom=5.)

    viewer.grid_on = False
    viewer.axes_on = False

    viewer.axes.x_color = (0.1, 0.1, 0.1)
    viewer.axes.y_color = (0.1, 0.1, 0.1)
    viewer.axes.z_color = (0.1, 0.1, 0.1)

    viewer.setup()
import compas
import compas_rhino

from compas.files.ply import PLYreader
from compas.datastructures.mesh import Mesh

__author__ = [
    'Tom Van Mele',
]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__ = 'MIT License'
__email__ = '*****@*****.**'

filename = compas.get_data('stanford/dragon_recon/dragon_vrip.ply')

reader = PLYreader(filename)

reader.read()

for line in reader.header:
    print(line)

vertices = [(vertex['x'], vertex['y'], vertex['z'])
            for vertex in reader.vertices]
faces = [face['vertex_indices'] for face in reader.faces]

mesh = Mesh.from_vertices_and_faces(vertices, faces)

compas_rhino.draw_mesh(mesh)
Exemple #7
0
    pass


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import os
    import compas

    from compas.datastructures.mesh import Mesh

    filename = os.path.join(
        compas.get_data('stanford/bunny/reconstruction/bun_zipper.ply'))
    filename = os.path.join(
        compas.get_data('stanford/dragon_recon/dragon_vrip.ply'))
    filename = os.path.join(compas.get_data('stanford/Armadillo.ply'))

    reader = PLYreader(filename)

    reader.read()

    for line in reader.header:
        print(line)

    vertices = [(vertex['x'], vertex['y'], vertex['z'])
                for vertex in reader.vertices]
    faces = [face['vertex_indices'] for face in reader.faces]
Exemple #8
0
    del mesh.face[fkey]

    return f, g


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import compas
    from compas.datastructures.mesh.mesh import Mesh
    from compas.visualization.plotters.meshplotter import MeshPlotter

    data = compas.get_data('faces.obj')
    mesh = Mesh.from_obj(data)

    mesh_split_edge(mesh, 17, 32)

    print(mesh.face_vertices(11, ordered=True))
    print(mesh.face_vertices(16, ordered=True))

    print(mesh.halfedge[32][36])
    print(mesh.halfedge[36][32])

    print(mesh.halfedge[36][17])
    print(mesh.halfedge[17][36])

    plotter = MeshPlotter(mesh)
        return faces

    # --------------------------------------------------------------------------
    # selections
    # --------------------------------------------------------------------------


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == '__main__':

    from compas.visualization.plotters.networkplotter import NetworkPlotter

    network = Network.from_obj(compas.get_data('open_edges.obj'))

    print(network)

    plotter = NetworkPlotter(network)

    plotter.defaults['vertex.fontsize'] = 10.0

    plotter.draw_vertices(
        facecolor={key: '#ff0000' for key in network.leaves()},
        radius=0.2,
        text={key: key for key in network.vertices()}
    )

    plotter.draw_edges()
Exemple #10
0
    def __init__(self):
        pass

    def compose(self):
        pass


class OBJWriter(object):
    """"""
    def __init__(self):
        pass

    def write(self):
        pass


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == '__main__':

    import compas

    obj = OBJ(compas.get_data('faces.obj'))

    print(obj.parser.vertices)
    print(obj.parser.lines)
    print(obj.parser.points)
    print(obj.parser.faces)
Exemple #11
0
    return True


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

if __name__ == '__main__':

    import compas

    from compas.datastructures import Network
    from compas.plotters import NetworkPlotter

    network = Network.from_obj(compas.get_data('fink.obj'))

    crossings = network_find_crossings(network)

    print(network_count_crossings(network))
    print(crossings)
    print(len(crossings))

    ecolor = {}
    for e1, e2 in crossings:
        ecolor[e1] = '#ff0000'
        ecolor[e2] = '#ff0000'

    plotter = NetworkPlotter(network, figsize=(10, 7))

    plotter.draw_vertices()
Exemple #12
0
import compas
import compas_rhino

from compas.files.ply import PLYreader
from compas.datastructures.mesh import Mesh

__author__ = [
    'Tom Van Mele',
]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__ = 'MIT License'
__email__ = '*****@*****.**'

filename = compas.get_data('stanford/bunny/reconstruction/bun_zipper.ply')

reader = PLYreader(filename)

reader.read()

for line in reader.header:
    print(line)

vertices = [(vertex['x'], vertex['y'], vertex['z'])
            for vertex in reader.vertices]
faces = [face['vertex_indices'] for face in reader.faces]

mesh = Mesh.from_vertices_and_faces(vertices, faces)

compas_rhino.draw_mesh(mesh)
import compas
import compas_rhino

from compas.files.ply import PLYreader
from compas.datastructures.mesh import Mesh

__author__ = [
    'Tom Van Mele',
]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__ = 'MIT License'
__email__ = '*****@*****.**'

filename = compas.get_data('stanford/Armadillo.ply')

reader = PLYreader(filename)

reader.read()

for line in reader.header:
    print(line)

vertices = [(vertex['x'], vertex['y'], vertex['z'])
            for vertex in reader.vertices]
faces = [face['vertex_indices'] for face in reader.faces]

mesh = Mesh.from_vertices_and_faces(vertices, faces)

compas_rhino.draw_mesh(mesh)
Exemple #14
0
            * s: subdivide using quad subdivision
        """
        if key == 'u':
            self.volmesh.unify_cycle_directions()
            return
        if key == 'f':
            self.volmesh.flip_cycle_directions()
            return

    def special(self, key, x, y):
        """
        Assign volmesh functionality to function keys.
        """
        pass


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == '__main__':

    import compas
    from compas.datastructures.volmesh.volmesh import VolMesh

    mesh = VolMesh.from_json(compas.get_data('boxes.json'))

    viewer = VolMeshViewer(mesh)
    viewer.setup()
    viewer.show()
        i = k_i[key]
        attr['x'] = xyz[i][0]
        attr['y'] = xyz[i][1]
        attr['z'] = xyz[i][2]


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == "__main__":
    import compas

    from compas.visualization.viewers.networkviewer import NetworkViewer

    network = ForceNetwork.from_obj(compas.get_data('saddle.obj'))

    dva = {'is_fixed': False, 'p': [0.0, 0.0, 0.0], 'v': [0.0, 0.0, 0.0]}
    dea = {'q': 1.0}

    network.update_default_vertex_attributes(dva)
    network.update_default_edge_attributes(dea)

    for key, attr in network.vertices(True):
        attr['is_fixed'] = network.is_vertex_leaf(key)

    for key in network.get_any_vertices(3):
        network.vertex[key]['p'][2] = -1.0

    for index, (u, v, attr) in enumerate(network.edges(True)):
        if index % 2 == 0:
Exemple #16
0
            return True
        return False


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

if __name__ == "__main__":

    import compas

    from compas.datastructures import Network
    from compas_rhino.helpers.artists.networkartist import NetworkArtist
    from compas_rhino.helpers.modifiers.vertexmodifier import VertexModifier

    network = Network.from_obj(compas.get_data('grid_irregular.obj'))

    artist = NetworkArtist(network)

    artist.clear()
    artist.draw_vertices()
    artist.draw_edges()
    artist.redraw()

    if VertexModifier.move_vertex(network, 0):
        artist.clear()
        artist.draw_vertices()
        artist.draw_edges()
        artist.redraw()
    return CtQC


def CitQCi():
    pass


def CitQCf():
    pass


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import compas
    from compas.datastructures.network import Network

    network = Network.from_obj(compas.get_data('lines.obj'))

    key_index = network.key_index()
    edges = [(key_index[u], key_index[v]) for u, v in network.edges()]

    n = network.number_of_vertices()

    C = connectivity_matrix(edges, n)

    print C
Exemple #18
0
        guid = uuid.uuid4()
        s_item = TPL_TOOLBARGROUPITEM.format(guid, tb_name, tb_guid)
        e_item = ET.fromstring(s_item)
        root.append(e_item)


# ==============================================================================
# Debugging
# ==============================================================================

if __name__ == "__main__":

    import compas
    import os

    test = compas.get_data('ruitest.json')

    with open(test, 'rb') as fp:
        config = json.loads(fp.read())

    macros = config['rui']['macros']
    menus = config['rui']['menus']
    toolbars = config['rui']['toolbars']
    toolbargroups = config['rui']['toolbargroups']

    rui = Rui(os.path.join(os.path.dirname(test), 'test.rui'))

    rui.init()

    rui.add_macros(macros)
    rui.add_menus(menus)