Ejemplo n.º 1
0
    def densification(self):
        """Generate a denser quad mesh from the coarse quad mesh and its strip densities.
		"""

        edge_strip = {}
        for skey, edges in self.strips(data=True):
            for edge in edges:
                edge_strip[edge] = skey
                edge_strip[tuple(reversed(edge))] = skey

        meshes = []
        for fkey in self.faces():
            ab, bc, cd, da = [[
                self.edge_point(
                    u, v,
                    float(i) /
                    float(self.get_strip_density(edge_strip[(u, v)])))
                for i in range(0,
                               self.get_strip_density(edge_strip[(u, v)]) + 1)
            ] for u, v in self.face_halfedges(fkey)]
            vertices, faces = discrete_coons_patch(ab, bc, list(reversed(cd)),
                                                   list(reversed(da)))
            meshes.append(QuadMesh.from_vertices_and_faces(vertices, faces))
        self.set_quad_mesh(meshes_join_and_weld(meshes))
Ejemplo n.º 2
0
    -------
    dict
        A dictionary with polyedge keys pointing to colors.
    """

    vertices, edges = quad_mesh.polyedge_graph()
    return vertex_coloring(adjacency_from_edges(edges))


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

if __name__ == '__main__':

    import time
    import compas
    from compas_pattern.datastructures.mesh_quad.mesh_quad import QuadMesh

    mesh = QuadMesh.from_json('/Users/Robin/Desktop/cnit2.json')

    mesh.collect_strips()
    mesh.collect_polyedges()
    t0 = time.time()
    result = quad_mesh_strip_2_coloring(mesh)
    t1 = time.time()
    print(t1 - t0, result)
    #print(quad_mesh_strip_n_coloring(mesh))
    #print(quad_mesh_polyedge_2_coloring(mesh))
    #print(quad_mesh_polyedge_n_coloring(mesh))
Ejemplo n.º 3
0
    import compas
    from compas_pattern.datastructures.mesh_quad.mesh_quad import QuadMesh
    from compas_pattern.datastructures.mesh_quad_coarse.coloring import dense_quad_mesh_polyedge_2_coloring
    from compas.geometry import scale_vector
    from compas_plotters.meshplotter import MeshPlotter

    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)
Ejemplo n.º 4
0
		return False


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

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)
Ejemplo n.º 5
0
    #     [1, 2, 5, 4],
    #     [3, 4, 7, 6],
    #     [4, 5, 8, 7]
    # ]

    # mesh = QuadMesh.from_vertices_and_faces(vertices, faces)
    # add_strip_wip(mesh, [3, 4, 5])

    # plotter = MeshPlotter(mesh, figsize=(5.0, 5.0))
    # plotter.draw_vertices(text='key')
    # plotter.draw_edges()
    # plotter.draw_faces()
    # plotter.show()

    vertices = [
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [1.0, 1.0, 0.0],
        [0.0, 1.0, 0.0],
    ]

    faces = [
        [0, 1, 2, 3],
    ]

    mesh = QuadMesh.from_vertices_and_faces(vertices, faces)
    mesh.collect_strips()

    print(total_boundary_deletions(mesh, [0, 1]))
    print(collateral_strip_deletions(mesh, [0]))
Ejemplo n.º 6
0
import rhinoscriptsyntax as rs
from compas_rhino.geometry import RhinoMesh
from compas_pattern.datastructures.mesh_quad.mesh_quad import QuadMesh

guids = rs.GetObjects('get quad meshes', filter=32)
rs.EnableRedraw(False)
for guid in guids:
    mesh = QuadMesh.from_vertices_and_faces(
        *RhinoMesh.from_guid(guid).get_vertices_and_faces())
    polylines = [rs.AddPolyline(polyline) for polyline in mesh.polylines()]