Exemplo n.º 1
0
    def func0(mesh, vkey):
        normal = mesh.vertex_normal(vkey)
        return scale_vector(normal, 1)

    def func1(mesh, vkey):
        normal = mesh.vertex_normal(vkey)
        return scale_vector(normal, -1)

    mesh = QuadMesh.from_json('/Users/Robin/Desktop/json/debug.json')
    mesh.collect_strips()
    mesh.collect_polyedges()

    polyedge_key_to_colour = dense_quad_mesh_polyedge_2_coloring(mesh)
    polyedges_0 = [
        mesh.data['attributes']['polyedges'][key]
        for key, colour in polyedge_key_to_colour.items() if colour == 0
    ]
    polyedges_1 = [
        mesh.data['attributes']['polyedges'][key]
        for key, colour in polyedge_key_to_colour.items() if colour == 1
    ]

    vkey_to_group = fold_vertex_group(mesh, polyedges_1)
    #fold(mesh, vkey_to_group, func0, func1)

    plotter = MeshPlotter(mesh, figsize=(20, 20))
    plotter.draw_vertices(radius=0.4, text=vkey_to_group)
    plotter.draw_edges()
    plotter.draw_faces()
    plotter.show()
from compas_plotters.meshplotter import MeshPlotter

# read input data
filepath = 'data/01_decomposition.json'
with open(filepath, 'r') as fp:
    data = json.load(fp)

# get outer boundary polyline, inner boundary polylines, polyline features and point features
outer_boundary, inner_boundaries, polyline_features, point_features = data

# Delaunay triangulation of the surface formed by the planar polylines using the points as Delaunay vertices
mesh = boundary_triangulation(outer_boundary,
                              inner_boundaries,
                              polyline_features,
                              point_features,
                              src='numpy')

# start instance for skeleton-based decomposition
decomposition = SkeletonDecomposition.from_mesh(mesh)

# # build decomposition mesh
mesh = decomposition.decomposition_mesh(point_features)

# plot decomposition mesh
plotter = MeshPlotter(mesh, figsize=(5, 5))
plotter.draw_edges()
plotter.draw_vertices()
plotter.draw_faces()
plotter.show()
Exemplo n.º 3
0
if __name__ == '__main__':

	import random as rd
	import compas
	from compas_pattern.datastructures.mesh_quad.mesh_quad import QuadMesh
	from compas.datastructures import mesh_smooth_centroid
	from compas_plotters.meshplotter import MeshPlotter

	mesh = QuadMesh.from_obj(compas.get('faces.obj'))
	mesh.collect_strips()
	walker = Walker(mesh)
	walker.start()
	orders = [2,0,2]
	#orders = [rd.randint(0,1) for _ in range(10)]
	#orders = [2] + orders + [2]
	#orders = [2, 1, 3, 0, 3, 2, 1, 3, 2, 2]
	print(orders)
	walker.interpret_orders(orders)
	print(walker.polyedge)
	print('added: ', walker.added_polyedges)
	print('deleted: ', walker.delete_strips)

	mesh_smooth_centroid(walker.mesh, kmax=1)

	plotter = MeshPlotter(walker.mesh)
	plotter.draw_vertices(radius=.1, text='key')
	plotter.draw_edges()
	plotter.draw_faces()
	plotter.show()

Exemplo n.º 4
0
# find_form(mesh)
# print('load path: ', load_path(mesh))

t0 = time.time()
opt_design = None
opt_param = None
opt_perf = None
n = 10
for i in range(n):
    t = float(i) / float(n)
    perf = func(t, mesh, polyline_points)
    if opt_perf is None or perf < opt_perf:
        opt_perf = perf
        opt_param = t
        opt_design = mesh.copy()
t1 = time.time()
print('computing time: ', t1 - t0)
print('opt parameter: ', opt_param, 'optimal performance: ', opt_perf)

# for vkey, attr in mesh.vertices(True):
#     attr['x'], attr['y'], attr['z'] = attr['x'], attr['z'], attr['y']

# t = [0.5]
# print(descent_numpy(t, func, iterations=100, gtol=10**(-1), bounds=[[0, 1]], args=(mesh, polyline_points)))

plotter = MeshPlotter(opt_design, figsize=(20, 20))
plotter.draw_vertices(radius=0.05)
plotter.draw_edges()
plotter.draw_faces()
plotter.show()