Beispiel #1
0
    def decomposition_mesh(self, poles):
        """Return a quad mesh based on the decomposition polylines.
		Some fixes are added to convert the mesh formed by the decomposition polylines into a (coarse) quad mesh.

		Returns
		-------
		mesh
			A coarse quad mesh based on the topological skeleton from a Delaunay mesh.

		"""

        polylines = self.decomposition_polylines()
        boundary_keys = set([
            geometric_key(self.vertex_coordinates(vkey))
            for vkey in self.vertices_on_boundary()
        ])
        boundary_polylines = [
            polyline for polyline in polylines
            if geometric_key(polyline[0]) in boundary_keys
            and geometric_key(polyline[1]) in boundary_keys
        ]
        other_polylines = [
            polyline for polyline in polylines
            if geometric_key(polyline[0]) not in boundary_keys
            or geometric_key(polyline[1]) not in boundary_keys
        ]
        self.mesh = CoarsePseudoQuadMesh.from_polylines(
            boundary_polylines, other_polylines)
        self.solve_triangular_faces()
        self.quadrangulate_polygonal_faces()
        self.split_quads_with_poles(poles)
        self.store_pole_data(poles)
        return self.mesh
Beispiel #2
0
def get_dense_mesh():
    guid = rs.GetObject('get dense mesh', filter=32)
    vertices, faces = RhinoMesh.from_guid(guid).get_vertices_and_faces()
    clean_faces(faces)
    poles = []
    for face in faces:
        if len(face) != 4:
            poles = [
                rs.PointCoordinates(point)
                for point in rs.GetObjects('get pole points', filter=1)
            ]
            break
    singularity_mesh = CoarsePseudoQuadMesh.from_quad_mesh(
        PseudoQuadMesh.from_vertices_and_faces_with_poles(
            vertices, faces, poles))
    return singularity_mesh
Beispiel #3
0
        self.get_quad_mesh().data['attributes']['face_pole'] = face_pole
        return self.get_quad_mesh()


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

if __name__ == '__main__':

    import compas
    from compas_pattern.datastructures.mesh_quad_pseudo_coarse.mesh_quad_pseudo_coarse import CoarsePseudoQuadMesh
    from compas.datastructures import mesh_weld
    from compas_plotters.meshplotter import MeshPlotter

    mesh = CoarsePseudoQuadMesh.from_json(
        '/Users/Robin/Downloads/coarse_mesh_for_robin.json')
    # # plotter = MeshPlotter(mesh, figsize=(20, 20))
    # # plotter.draw_vertices(radius=0.4, text='key')
    # # plotter.draw_edges()
    # # plotter.draw_faces(text='key')
    # # plotter.show()

    data = {}
    for key, value in mesh.data['attributes']['face_pole'].items():
        data[int(key)] = value
    mesh.data['attributes']['face_pole'] = data
    # #print(mesh.data['attributes']['face_pole'][str(4)])

    mesh.collect_strips()
    mesh.set_strips_density(2)
    mesh.densification()
Beispiel #4
0
import rhinoscriptsyntax as rs
from compas_rhino.geometry import RhinoMesh
from compas_pattern.datastructures.mesh_quad_pseudo_coarse.mesh_quad_pseudo_coarse import CoarsePseudoQuadMesh
from compas_pattern.cad.rhino.artist import select_quad_mesh_strip
from compas_rhino.artists import MeshArtist

guid = rs.GetObject('get (coarse) quad mesh', filter=32)
poles = rs.GetObjects('get pole points', filter=1)
if poles is None:
    poles = []
else:
    poles = [rs.PointCoordinates(pole) for pole in poles]

vertices, faces = RhinoMesh.from_guid(guid).get_vertices_and_faces()
mesh = CoarsePseudoQuadMesh.from_vertices_and_faces_with_poles(
    vertices, faces, poles)
mesh.collect_strips()
mesh.set_strips_density(1)
mesh.densification()

count = 100
while count:
    count -= 1

    artist = MeshArtist(mesh.get_quad_mesh())
    guid = artist.draw_mesh()

    operation = rs.GetString('operation?',
                             strings=[
                                 'global_density_value',
                                 'global_subdivision_target_length',
Beispiel #5
0
def singular():
    """Explore a pattern, its topology (singularities, densities and symmetries) and its geoemtry (via smoothing).

    """

    layer = rs.CurrentLayer()

    pattern_from = rs.GetString('start pattern from?',
                                strings=[
                                    'coarse_pseudo_quad_mesh',
                                    'pseudo_quad_mesh', 'surface_and_features'
                                ])

    if pattern_from == 'coarse_pseudo_quad_mesh':
        guid = rs.GetObject('get coarse quad mesh', filter=32)
        vertices, faces = RhinoMesh.from_guid(guid).get_vertices_and_faces()
        clean_faces(faces)
        poles = []
        #print(faces)
        for face in faces:
            if len(face) != 4:
                poles = [
                    rs.PointCoordinates(point)
                    for point in rs.GetObjects('get pole points', filter=1)
                ]
                break
        coarse_pseudo_quad_mesh = CoarsePseudoQuadMesh.from_vertices_and_faces_with_poles(
            vertices, faces, poles)
        coarse_pseudo_quad_mesh.collect_strips()
        print(coarse_pseudo_quad_mesh.data['attributes']['strips'])
        coarse_pseudo_quad_mesh.set_strips_density(1)
        coarse_pseudo_quad_mesh.set_quad_mesh(coarse_pseudo_quad_mesh.copy())
        coarse_pseudo_quad_mesh.set_polygonal_mesh(
            coarse_pseudo_quad_mesh.copy())
        print(coarse_pseudo_quad_mesh.data['attributes']['strips'])
    elif pattern_from == 'pseudo_quad_mesh':
        guid = rs.GetObject('get quad mesh', filter=32)
        vertices, faces = RhinoMesh.from_guid(guid).get_vertices_and_faces()
        clean_faces(faces)
        poles = []
        for face in faces:
            if len(face) != 4:
                poles = [
                    rs.PointCoordinates(point)
                    for point in rs.GetObjects('get pole points', filter=1)
                ]
                break
        coarse_pseudo_quad_mesh = CoarsePseudoQuadMesh.from_quad_mesh(
            PseudoQuadMesh.from_vertices_and_faces_with_poles(
                vertices, faces, poles))
    elif pattern_from == 'surface_and_features':
        srf_guid = rs.GetObject('get surface', filter=8)
        crv_guids = rs.GetObjects('get optional curve features', filter=4)
        if crv_guids is None:
            crv_guids = []
        pt_guids = rs.GetObjects('get optional point features', filter=1)
        if pt_guids is None:
            pt_guids = []
        coarse_pseudo_quad_mesh = surface_decomposition(
            srf_guid,
            rs.GetReal('precision', number=1.),
            crv_guids=crv_guids,
            pt_guids=pt_guids,
            output_skeleton=False)[0]
        coarse_pseudo_quad_mesh.collect_strips()
        coarse_pseudo_quad_mesh.set_strips_density(1)
        coarse_pseudo_quad_mesh.set_quad_mesh(coarse_pseudo_quad_mesh.copy())
        coarse_pseudo_quad_mesh.set_polygonal_mesh(
            coarse_pseudo_quad_mesh.copy())
        artist = rhino_artist.MeshArtist(coarse_pseudo_quad_mesh)
        guid = artist.draw_mesh()
    else:
        return 0

    while True:

        #edit = rs.GetString('edit pattern?', strings = ['topology', 'density', 'symmetry', 'geometry', 'evaluate', 'exit'])
        edit = rs.GetString('edit pattern?',
                            strings=[
                                'topology', 'density', 'symmetry', 'geometry',
                                'save', 'exit'
                            ])

        if type(guid) == list:
            rs.DeleteObjects(guid)
        else:
            rs.DeleteObject(guid)

        if edit is None or edit == 'exit':
            rs.EnableRedraw(False)
            artist = rhino_artist.MeshArtist(
                coarse_pseudo_quad_mesh.get_polygonal_mesh())
            return artist.draw_mesh()

        if edit == 'topology':
            editing_topology(coarse_pseudo_quad_mesh)
            coarse_pseudo_quad_mesh.densification()
            coarse_pseudo_quad_mesh.set_polygonal_mesh(
                coarse_pseudo_quad_mesh.get_quad_mesh().copy())

        elif edit == 'density':
            editing_density(coarse_pseudo_quad_mesh)
            coarse_pseudo_quad_mesh.set_polygonal_mesh(
                coarse_pseudo_quad_mesh.get_quad_mesh().copy())

        elif edit == 'symmetry':
            editing_symmetry(coarse_pseudo_quad_mesh)

        elif edit == 'geometry':
            editing_geometry(coarse_pseudo_quad_mesh)

        rs.EnableRedraw(False)
        artist = rhino_artist.MeshArtist(
            coarse_pseudo_quad_mesh.get_polygonal_mesh())
        guid = artist.draw_mesh()
        rs.EnableRedraw(True)

        if edit == 'save':
            save_design(coarse_pseudo_quad_mesh, layer)

        if edit == 'evaluate':
            evaluate_pattern(coarse_pseudo_quad_mesh.get_polygonal_mesh())