Пример #1
0
def axs_curvature(h_surf, u=0, v=0):
    prop = GeomLProp_SLProps(2, 0.01)
    prop.SetSurface(h_surf)
    prop.SetParameters(u, v)

    d1, d2 = gp_Dir(), gp_Dir()
    prop.CurvatureDirections(d1, d2)
    vz = dir_to_vec(prop.Normal())
    v1 = dir_to_vec(d1)
    v2 = dir_to_vec(d2)
    c1 = prop.MaxCurvature()
    c2 = prop.MinCurvature()

    if c1 == 0:
        r1 = 0
    else:
        r1 = 1 / c1

    if c2 == 0:
        r2 = 0
    else:
        r2 = 1 / c2

    print("Max", c1, r1, v1)
    print("Min", c2, r1, v2)
    print(v1.Dot(v2))
    print(prop.Value())
    return vz, v1, v2, r1, r2
Пример #2
0
def face_normal(face):
    from OCC.Core.BRepTools import breptools_UVBounds
    umin, umax, vmin, vmax = breptools_UVBounds(face)
    surf = BRep_Tool().Surface(face)
    props = GeomLProp_SLProps(surf, (umin+umax)/2., (vmin+vmax)/2., 1, TOLERANCE)
    norm = props.Normal()
    if face.Orientation() == TopAbs_REVERSED:
        norm.Reverse()
    return norm
Пример #3
0
def ask_point_normal_face(uv, face):
    """
    Ask the normal vector of a point given the uv coordinate of the point on a face
    """
    surface = BRep_Tool().Surface(face)
    props = GeomLProp_SLProps(surface, uv[0], uv[1], 1, 1e-6)
    #    GeomLProp_SLProps.SetParameters(surface,uv[0],uv[1])
    #    GeomLProp_SLProps.SetSurface(surface)

    gpDir = props.Normal()  # gp_Dir type
    if face.Orientation() == TopAbs_REVERSED:
        gpDir.Reverse()
        # print("face reversed")
    return gpDir.Coord()
Пример #4
0
    def curvature_at(self, u, v):
        """Compute the curvature at a point on the surface.

        Parameters
        ----------
        u : float
        v : float

        Returns
        -------
        :class:`~compas.geometry.Vector`

        """
        props = GeomLProp_SLProps(self.occ_surface, u, v, 2, 1e-6)
        gaussian = props.GaussianCurvature()
        mean = props.MeanCurvature()
        point = props.Value()
        normal = props.Normal()
        return gaussian, mean, Point.from_occ(point), Vector.from_occ(normal)