Exemplo n.º 1
0
    def collect_data_density(self):
        """Collect the existing density mesh in the density layer.

		Parameters
		----------

		Returns
		-------

		"""

        objects = rs.ObjectsByLayer('density')

        if objects is not None:

            if len(objects) == 1:
                if rs.ObjectType(objects[0]) == 32:

                    vertices, faces = RhinoGeometry.from_guid(
                        objects[0]).get_vertices_and_faces()
                    self.density_mesh = Mesh.from_vertices_and_faces(
                        vertices, faces)

                else:
                    print 'the object in the density layer is not a mesh'

            elif len(objects) > 1:
                print 'too many objects in the density layer'
Exemplo n.º 2
0
import rhinoscriptsyntax as rs

import compas_rhino as rhino
from compas_rhino.geometry import RhinoGeometry

from compas.datastructures.mesh import Mesh
from compas_pattern.datastructures.pseudo_quad_mesh import PseudoQuadMesh
from compas_pattern.datastructures.pseudo_quad_mesh import pqm_from_mesh
from compas_pattern.cad.rhino.utilities import draw_mesh

from compas_pattern.algorithms.editing import editing

# mesh selection
guid = rs.GetObject('get mesh')
mesh = RhinoGeometry.from_guid(guid)
vertices, faces = mesh.get_vertices_and_faces()
mesh = PseudoQuadMesh.from_vertices_and_faces(vertices, faces)

poles = rs.GetObjects('pole points', filter=1)
if poles is None:
    poles = []
poles = [rs.PointCoordinates(pole) for pole in poles]

vertices, face_vertices = pqm_from_mesh(mesh, poles)

mesh = PseudoQuadMesh.from_vertices_and_faces(vertices, face_vertices)

editing(mesh)

mesh = mesh.to_mesh()
Exemplo n.º 3
0
def start():
    from compas.geometry.algorithms.smoothing import mesh_smooth_centroid
    from compas.geometry.algorithms.smoothing import mesh_smooth_area

    from compas_pattern.algorithms.smoothing import define_constraints
    from compas_pattern.algorithms.smoothing import apply_constraints

    guid = rs.GetObject('get mesh')
    dense_mesh = RhinoGeometry.from_guid(guid)
    vertices, faces = dense_mesh.get_vertices_and_faces()
    dense_mesh = Mesh.from_vertices_and_faces(vertices, faces)

    #lines = rs.GetObjects('lines', filter = 4)
    #edges = [[rs.CurveStartPoint(line), rs.CurveEndPoint(line)] for line in lines]
    #dense_mesh = Mesh.from_lines(edges)

    #faces = list(dense_mesh.faces())
    #for fkey in faces:
    #    if len(dense_mesh.face_vertices(fkey)) > 10:
    #        delete_face(dense_mesh, fkey)
    #        print '-1 face'

    #dense_mesh = conway_ambo(dense_mesh)
    #dense_mesh = conway_dual(dense_mesh)
    #dense_mesh = conway_gyro(dense_mesh)
    #dense_mesh = conway_dual(dense_mesh)
    #dense_mesh = conway_gyro(dense_mesh)
    #dense_mesh = conway_kis(dense_mesh)

    #rs.EnableRedraw(False)
    #draw_mesh(dense_mesh)
    #rs.EnableRedraw(True)
    #return

    surface_guid = rs.GetSurfaceObject('surface constraint')[0]

    smooth_mesh = dense_mesh.copy()

    smoothing_iterations = rs.GetInteger('number of iterations for smoothing',
                                         number=20)
    damping_value = rs.GetReal('damping value for smoothing', number=.5)

    rs.EnableRedraw(False)

    #constraints, surface_boundaries = custom_constraints(smooth_mesh, surface_guid)
    constraints, surface_boundaries = define_constraints(
        smooth_mesh, surface_guid)

    rs.EnableRedraw(False)
    fixed_vertices = [
        vkey for vkey, constraint in constraints.items()
        if constraint[0] == 'fixed'
    ]
    mesh_smooth_area(smooth_mesh,
                     fixed=fixed_vertices,
                     kmax=smoothing_iterations,
                     damping=damping_value,
                     callback=apply_constraints,
                     callback_args=[smooth_mesh, constraints])

    smooth_mesh_guid = draw_mesh(smooth_mesh)

    #layer = 'smooth_mesh'
    #rs.AddLayer(layer)
    #rs.ObjectLayer(smooth_mesh_guid, layer = layer)

    rs.EnableRedraw(True)