Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_is_vertex_on_boundary():
mesh = Mesh.from_obj(compas.get('faces.obj'))
assert mesh.is_vertex_on_boundary(0)
assert not mesh.is_vertex_on_boundary(15)
self.clear_vertices()
self.clear_edges()
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import compas
from compas.datastructures import Network
network = Network.from_obj(compas.get('grid_irregular.obj'))
artist = NetworkArtist(network=network)
#artist.clear_layer()
artist.draw_vertices(radius=0.05)
artist.draw_vertexlabels()
#artist.clear_vertexlabels()
import compas
import compas_rhino
from compas.datastructures import Mesh
__author__ = ['Tom Van Mele', ]
__copyright__ = 'Copyright 2016 - Block Research Group, ETH Zurich'
__license__ = 'MIT License'
__email__ = 'van.mele@arch.ethz.ch'
mesh = Mesh.from_ply(compas.get('stanford_armadillo.ply'))
compas_rhino.mesh_draw(mesh)
# self.draw_edges(
# color={(u, v): '#ff0000' for u, v in edges},
# width={(u, v): 5.0 for u, v in edges}
# )
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import compas
from compas.datastructures import Network
network = Network.from_obj(compas.get('grid_irregular.obj'))
plotter = NetworkPlotter(network, figsize=(10, 8))
plotter.draw_vertices(radius=0.1, picker=10)
plotter.draw_edges()
default = [plotter.defaults['vertex.facecolor'] for key in network.vertices()]
highlight = '#ff0000'
def on_pick(event):
index = event.ind[0]
colors = default[:]
colors[index] = highlight
plotter.vertexcollection.set_facecolor(colors)
return True
# ==============================================================================
# Main
# ==============================================================================
if __name__ == '__main__':
import compas
from compas.datastructures import Network
from compas_plotters import NetworkPlotter
network = Network.from_obj(compas.get('lines.obj'))
network.add_edge(6, 15)
if not network_is_planar(network):
crossings = network_find_crossings(network)
else:
crossings = []
print(crossings)
plotter = NetworkPlotter(network)
plotter.draw_vertices(radius=0.15, text={key: key for key in network.vertices()})
plotter.draw_edges(color={edge: '#ff0000' for edges in crossings for edge in edges})
plotter.show()
def main():
mesh = Mesh.from_obj(compas.get('faces.obj'))
for line, distance in zip(pairwise(point_list), distances):
segments.append(offset_line(line, distance, normal))
return segments
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import compas
from compas_plotters import MeshPlotter
from compas.datastructures import Mesh
mesh = Mesh.from_obj(compas.get('faces.obj'))
polygons = []
lines = []
for fkey in mesh.faces():
points = mesh.face_coordinates(fkey)
offset = offset_polyline(points, 0.1)
polygons.append({
'points': offset,
'edgecolor': '#ff0000'
})
for a, b in zip(points, offset):
lines.append({
'start': a,
'end': b,
'color': '#00ff00'
})
self.clear_faces()
self.clear_edges()
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import compas
from compas.datastructures import VolMesh
from compas_rhino.artists.volmeshartist import VolMeshArtist
volmesh = VolMesh.from_obj(compas.get('boxes.obj'))
artist = VolMeshArtist(volmesh, layer='VolMeshArtist')
artist.clear_layer()
artist.draw_vertices()
artist.redraw(0.0)
artist.draw_vertexlabels()
artist.redraw(1.0)
artist.draw_faces()
artist.redraw(1.0)
artist.draw_facelabels()
artist.redraw(1.0)
area[:len(b)] += b
return spdiags(area, 0, xyz.shape[0], xyz.shape[0])
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import doctest
import compas
from compas.datastructures import Mesh
mesh = Mesh.from_obj(compas.get('faces.obj'))
doctest.testmod()
tovisit -= visited
components.append(list(visited))
return components
# ==============================================================================
# Main
# ==============================================================================
if __name__ == "__main__":
import compas
from compas.datastructures import Network
from compas_plotters import NetworkPlotter
network = Network.from_obj(compas.get('grid_irregular.obj'))
components = connected_components(network.adjacency)
key_color = vertex_coloring(network.adjacency)
colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00']
plotter = NetworkPlotter(network, figsize=(10, 7))
plotter.draw_vertices(facecolor={key: colors[key_color[key]] for key in network.vertices()})
plotter.draw_edges()
plotter.show()