Exemplo n.º 1
0
def second_derivative(h_surf, u=0, v=0):
    p1 = gp_Pnt()
    pu, pv = gp_Vec(), gp_Vec()
    puu, pvv = gp_Vec(), gp_Vec()
    puv = gp_Vec()
    prop = GeomLProp_SLProps(h_surf, u, v, 1, 1)
    GeomLProp_SurfaceTool.D2(h_surf, u, v, p1, pu, pv, puu, pvv, puv)
    e0 = pu.Crossed(pv)
    pu.Normalize()
    pv.Normalize()
    e0.Normalize()
    puu.Normalize()
    pvv.Normalize()
    puv.Normalize()
    print(p1)
    print("pu", pu)
    print("pv", pv)
    print("e0", e0)
    print("puu", puu)
    print("pvv", pvv)
    print("puv", puv)

    first_form = np.array([[pu.Dot(pu), pu.Dot(pv)], [pv.Dot(pu), pv.Dot(pv)]])
    secnd_form = np.array([[e0.Dot(puu), e0.Dot(puv)],
                           [e0.Dot(puv), e0.Dot(pvv)]])

    print(first_form)
    print(secnd_form)
    print(prop.GaussianCurvature())
    print(prop.MeanCurvature())
    d1, d2 = gp_Dir(), gp_Dir()
    prop.CurvatureDirections(d1, d2)
    a1 = gp_Ax3()
    v1 = dir_to_vec(d1)
    v2 = dir_to_vec(d2)
    if pu.IsParallel(v1, 1 / 1000):
        c1 = prop.MaxCurvature()
        c2 = prop.MinCurvature()
        print(v1.Dot(pu), v1.Dot(pv))
        print(v2.Dot(pu), v2.Dot(pv))
    else:
        c1 = prop.MinCurvature()
        c2 = prop.MaxCurvature()
        print(v1.Dot(pu), v1.Dot(pv))
        print(v2.Dot(pu), v2.Dot(pv))
    print(c1, 1 / c1)
    print(c2, 1 / c2)

    px = np.linspace(-1, 1, 100) * 100
    p1_y = px**2 / c1
    p2_y = px**2 / c1
    curv1 = curv_spl(px, p1_y)
    curv2 = curv_spl(px, p2_y)
Exemplo n.º 2
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
Exemplo n.º 3
0
class Torus (plotocc):

    def __init__(self):
        super().__init__()
        self.axs = gp_Ax3()
        self.radi = [500, 200]
        self.rxyz = [1.0, 1.1, 1.1]
        mat = gp_Mat(
            self.rxyz[0], 0, 0,
            0, self.rxyz[1], 0,
            0, 0, self.rxyz[2]
        )
        gtrf = gp_GTrsf(mat, gp_XYZ(0, 0, 0))
        self.t = Geom_ToroidalSurface(self.axs, *self.radi)
        self.face = BRepBuilderAPI_MakeFace(self.t, 1e-6).Face()
        self.face = BRepBuilderAPI_GTransform(self.face, gtrf).Shape()
        self.surf = BRep_Tool.Surface(self.face)
        self.prop = GeomLProp_SLProps(self.surf, 0.0, 0.0, 1, 1.0)
        self.export_stp(self.face)
        print(self.t.UPeriod())

    def get_prof(self, uv=[0, 0]):
        u, v = uv
        u1, v1 = 2 * np.pi * u, 2 * np.pi * v
        p, vu, vv = gp_Pnt(), gp_Vec(), gp_Vec()
        self.surf.D1(u1, v1, p, vu, vv)
        self.prop.SetParameters(u1, v1)
        vx = vu.Normalized()
        vy = vv.Normalized()
        vz = vx.Crossed(vy)
        print(u, v)
        print(p)
        print(vx)
        print(vy)
        print(vz)
        print(self.prop.GaussianCurvature())
        print(self.prop.MaxCurvature())
        print(self.prop.MinCurvature())
        print(self.prop.MeanCurvature())
        self.display.DisplayShape(p)
        self.display.DisplayVector(vz.Scaled(20), p)
        return p, vu, vv, vz

    def ShowTorus(self):
        self.display.DisplayShape(self.face, transparency=0.7)
        self.show_axs_pln(scale=100)
        self.show()
Exemplo n.º 4
0
def radius_at_uv(face, u, v):
    '''
    returns the mean radius at a u,v coordinate
    @param face:    surface input
    @param u,v:     u,v coordinate
    '''
    h_srf = BRep_Tool().Surface(face)
    # uv_domain = GeomLProp_SurfaceTool().Bounds(h_srf)
    curvature = GeomLProp_SLProps(h_srf, u, v, 1, 1e-6)
    try:
        _crv_min = 1. / curvature.MinCurvature()
    except ZeroDivisionError:
        _crv_min = 0.

    try:
        _crv_max = 1. / curvature.MaxCurvature()
    except ZeroDivisionError:
        _crv_max = 0.
    return abs((_crv_min + _crv_max) / 2.)