Ejemplo n.º 1
0
    def kinks(self, threshold=1e-3):
        """Return the XYZ coordinates of kinks, i.e. tangency discontinuities, along the surface's boundaries.

        Returns
        -------
        list
            The list of XYZ coordinates of surface boundary kinks.

        """
        kinks = []
        borders = self.borders(type=0)

        for border in borders:
            border = RhinoCurve(border)
            extremities = map(
                lambda x: rs.EvaluateCurve(border.guid,
                                           rs.CurveParameter(border.guid, x)),
                [0., 1.])

            if border.is_closed():
                start_tgt, end_tgt = border.tangents(extremities)
                if angle_vectors(start_tgt, end_tgt) > threshold:
                    kinks += extremities

            else:
                kinks += extremities

        return list(set(kinks))
Ejemplo n.º 2
0
 def identify_vertices_on_curve(diagram, guid):
     gkey_key = diagram.gkey_key()
     keys = []
     curve = RhinoCurve(guid)
     for key in diagram.vertices():
         xyz = diagram.vertex_coordinates(key)
         closest = curve.closest_point(xyz)
         gkey = geometric_key(closest)
         if gkey in gkey_key:
             if key == gkey_key[gkey]:
                 keys.append(key)
     return keys
Ejemplo n.º 3
0
    def from_guid(guid):
        """Create a ``RhinoGeometry`` instance of the correct type based on a given guid.

        Parameters
        ----------
        guid : str or System.Guid
            The *guid* of the Rhino object.

        Returns
        -------
        RhinoPoint
            If the type of the Rhino object is ``rs.filter.point``.
        RhinoCurve
            If the type of the Rhino object is ``rs.filter.curve``.
        RhinoMesh
            If the type of the Rhino object is ``rs.filter.mesh``.
        RhinoSurface
            If the type of the Rhino object is ``rs.filter.surface``.

        Examples
        --------
        >>>

        """
        from compas_rhino.geometry import RhinoPoint
        from compas_rhino.geometry import RhinoCurve
        from compas_rhino.geometry import RhinoMesh
        from compas_rhino.geometry import RhinoSurface

        otype = rs.ObjectType(guid)

        if otype == rs.filter.point:
            return RhinoPoint(guid)

        if otype == rs.filter.curve:
            return RhinoCurve(guid)

        if otype == rs.filter.mesh:
            return RhinoMesh(guid)

        if otype == rs.filter.surface:
            return RhinoSurface(guid)
Ejemplo n.º 4
0
    def closest_point_on_boundaries(self, xyz):
        """Return the XYZ coordinates of the closest point on the boundaries of the surface from input XYZ-coordinates.
    
        Parameters
        ----------
        xyz : list
            XYZ coordinates.

        Returns
        -------
        list
            The XYZ coordinates of the closest point on the boundaries of the surface.

        """
        borders = self.borders(type=0)
        proj_dist = {
            tuple(proj_xyz): distance_point_point(xyz, proj_xyz)
            for proj_xyz in
            [RhinoCurve(border).closest_point(xyz) for border in borders]
        }
        delete_objects(borders)
        return min(proj_dist, key=proj_dist.get)
Ejemplo n.º 5
0
kmax = 300

# select the original mesh
# select the border
# select the fixed points

guid_target = compas_rhino.select_mesh()
guid_border = compas_rhino.select_polyline()
guid_points = compas_rhino.select_points()

# wrap the Rhino mesh object for convenience
# wrap the Rhino curve object for convenience
# get the point coordinates

target = RhinoMesh(guid_target)
border = RhinoCurve(guid_border)
points = compas_rhino.get_point_coordinates(guid_points)

# make a mesh datastructure from the Rhino mesh
# triangulate the mesh

mesh = mesh_from_guid(Mesh, guid_target)
mesh_quads_to_triangles(mesh)

# identify the fixed vertices
# by matching the coordinates of the selected points
# up to a precision

keys = mesh_identify_vertices(mesh, points, '1f')
fixed = set(keys)