How to use the compas.get_data function in compas

To help you get started, we’ve selected a few compas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github compas-dev / compas / docs / reference / generated / compas-datastructures-network_find_faces-2.py View on Github external
# leaves as breakpoints

import compas
from compas.datastructures import FaceNetwork
from compas.datastructures import network_find_faces
from compas.visualization import NetworkPlotter

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

network_find_faces(network, breakpoints=network.leaves())

plotter = NetworkPlotter(network)

plotter.draw_vertices(radius=0.075, facecolor={key: '#cccccc' for key in network.leaves()})
plotter.draw_edges(color={(u, v): '#cccccc' for u, v in network.edges()})
plotter.draw_faces(facecolor={fkey: '#eeeeee' for fkey in network.faces()}, text={fkey: fkey for fkey in network.faces()})

plotter.show()
github compas-dev / compas / src / compas_rhino / helpers / mesh.py View on Github external
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

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

    mesh_draw(mesh, layer='test', clear_layer=True)
github compas-dev / compas / src / compas / datastructures / network / algorithms / _traversal.py View on Github external
return path


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

if __name__ == '__main__':

    import compas

    from compas.datastructures import Network
    from compas.datastructures import network_dijkstra_path
    from compas.visualization import NetworkPlotter

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

    weight = {(u, v): 1.0 for u, v in network.edges()}
    weight.update({(v, u): weight[(u, v)] for u, v in network.edges()})

    weight[(7, 17)] = 1000
    weight[(17, 7)] = 1000

    start = 21
    end = 29

    path1 = network_dijkstra_path(network.adjacency, weight, start, end)

    start = 29
    end = 22

    path2 = network_dijkstra_path(network.adjacency, weight, start, end)
github compas-dev / compas / docs / reference / generated / compas-datastructures-network_dijkstra_path-2.py View on Github external
import compas

from compas.datastructures import Network
from compas.datastructures import network_dijkstra_path
from compas.visualization import NetworkPlotter

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

weight = dict(((u, v), network.edge_length(u, v)) for u, v in network.edges())
weight.update({(v, u): weight[(u, v)] for u, v in network.edges()})

weight[(8, 7)] = 1000
weight[(7, 8)] = 1000

start = 21
end = 22

path = network_dijkstra_path(network.adjacency, weight, start, end)

edges = []
for i in range(len(path) - 1):
    u = path[i]
    v = path[i + 1]
github compas-dev / compas / docs / reference / generated / compas-datastructures-FaceNetwork-1.py View on Github external
import compas
from compas.datastructures import FaceNetwork
from compas.datastructures import network_find_faces
from compas.visualization import FaceNetworkPlotter

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

network_find_faces(network, breakpoints=network.leaves())

plotter = FaceNetworkPlotter(network)

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

plotter.draw_faces(facecolor='#eeeeee', edgecolor='#eeeeee')
plotter.draw_edges()

plotter.show()
github compas-dev / compas / docs / reference / generated / compas-topology-dijkstra_distances-1.py View on Github external
import compas

from compas.datastructures import Network
from compas.topology import dijkstra_distances
from compas.visualization import NetworkPlotter
from compas.utilities import i_to_red

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

adjacency = {key: network.vertex_neighbours(key) for key in network.vertices()}

weight = {(u, v): network.edge_length(u, v) for u, v in network.edges()}
weight.update({(v, u): weight[(u, v)] for u, v in network.edges()})

target = 22

distances = dijkstra_distances(adjacency, weight, target)

plotter = NetworkPlotter(network)

dmax = max(distances.values())

facecolor = {key: i_to_red(distances[key] / dmax) for key in network.vertices()}
text = {key: '{:.1f}'.format(distances[key]) for key in network.vertices()}
github compas-dev / compas / src / compas / datastructures / mesh / algorithms / smoothing.py View on Github external
if callback:
            callback(mesh, k, callback_args)


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

if __name__ == '__main__':

    import compas

    from compas.datastructures import Mesh
    from compas.visualization import MeshPlotter

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

    fixed = [key for key in mesh.vertices() if mesh.vertex_degree(key) == 2]

    plotter = MeshPlotter(mesh)

    plotter.draw_vertices(facecolor={key: '#ff0000' for key in fixed})
    plotter.draw_edges()

    def callback(mesh, k, args):
        plotter, = args

        plotter.update_vertices()
        plotter.update_edges()
        plotter.update(pause=0.01)

    mesh_smooth_area(mesh, fixed=fixed, kmax=100, callback=callback, callback_args=(plotter, ))