コード例 #1
0
def build_geom_plate(edges):
    bpSrf = GeomPlate_BuildPlateSurface(3, 9, 12)

    # add curve constraints
    for edg in edges:
        c = BRepAdaptor_HCurve()
        print('edge:', edg)
        c.ChangeCurve().Initialize(edg)
        constraint = BRepFill_CurveConstraint(c.GetHandle(), 0)
        bpSrf.Add(constraint.GetHandle())

    # add point constraint
    try:
        bpSrf.Perform()
    except RuntimeError:
        print('Failed to build the geom plate surface')

    maxSeg, maxDeg, critOrder = 9, 8, 0

    srf = bpSrf.Surface()
    plate = GeomPlate_MakeApprox(srf, 1e-04, 100, 9, 1e-03, 0)

    uMin, uMax, vMin, vMax = srf.GetObject().Bounds()
    face = make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6)
    return face
コード例 #2
0
def build_plate(polygon, points):
    '''
    build a surface from a constraining polygon(s) and point(s)
    @param polygon:     list of polygons ( TopoDS_Shape)
    @param points:      list of points ( gp_Pnt )
    '''
    # plate surface
    bpSrf = GeomPlate_BuildPlateSurface(3, 15, 2)

    # add curve constraints
    for poly in polygon:
        for edg in WireExplorer(poly).ordered_edges():
            c = BRepAdaptor_HCurve()
            c.ChangeCurve().Initialize(edg)
            constraint = BRepFill_CurveConstraint(c.GetHandle(), 0)
            bpSrf.Add(constraint.GetHandle())

    # add point constraint
    for pt in points:
        bpSrf.Add(GeomPlate_PointConstraint(pt, 0).GetHandle())
        bpSrf.Perform()

    maxSeg, maxDeg, critOrder = 9, 8, 0
    tol = 1e-4
    dmax = max([tol, 10 * bpSrf.G0Error()])

    srf = bpSrf.Surface()
    plate = GeomPlate_MakeApprox(srf, tol, maxSeg, maxDeg, dmax, critOrder)
    uMin, uMax, vMin, vMax = srf.GetObject().Bounds()

    return make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-4)
コード例 #3
0
ファイル: testPlateSurface.py プロジェクト: mkravchuk/crpoint
def getTestFace():

    P1 = gp_Pnt(0., 0., 0.)
    P12 = gp_Pnt(0., 2., 2.)
    P2 = gp_Pnt(0., 10., 0.)
    P3 = gp_Pnt(0., 10., 10.)
    P4 = gp_Pnt(0., 0., 10.)
    P5 = gp_Pnt(5., 5., 5.)
    SceneDrawPoint('p1', P1)
    SceneDrawPoint('p12', P12)
    SceneDrawPoint('p2', P2)
    SceneDrawPoint('p3', P3)
    SceneDrawPoint('p4', P4)
    SceneDrawPoint('p5', P5)
    W = BRepBuilderAPI_MakePolygon()
    W.Add(P1)
    W.Add(P12)
    W.Add(P2)
    W.Add(P3)
    W.Add(P4)
    W.Add(P1)

    SceneDrawShape('w', W.Shape())

    # Initialize a BuildPlateSurface
    BPSurf = GeomPlate_BuildPlateSurface(3, 15, 2)

    # Create the curve constraints
    anExp = BRepTools_WireExplorer()
    anExp.Init(W.Wire())

    while anExp.More():
        E = anExp.Current()
        C = BRepAdaptor_HCurve()
        C.ChangeCurve().Initialize(E)
        Cont = BRepFill_CurveConstraint(C, 0)
        BPSurf.Add(Cont)
        anExp.Next()

    # Point constraint
    PCont = GeomPlate_PointConstraint(P5, 0)
    BPSurf.Add(PCont)

    # Compute the Plate surface
    BPSurf.Perform()

    # Approximation of the Plate surface
    MaxSeg = 9
    MaxDegree = 8
    CritOrder = 0
    PSurf = BPSurf.Surface()
    dmax = max(0.0001, 10 * BPSurf.G0Error())
    Tol = 0.0001
    Mapp = GeomPlate_MakeApprox(PSurf, Tol, MaxSeg, MaxDegree, dmax, CritOrder)
    Surf = Mapp.Surface()
    # create a face corresponding to the approximated Plate Surface
    Umin, Umax, Vmin, Vmax = PSurf.Bounds()
    #MF = BRepBuilderAPI_MakeFace (Surf, Umin, Umax, Vmin, Vmax, Tol)
    MF = BRepBuilderAPI_MakeFace(Surf, Tol)
    return MF
コード例 #4
0
def make_constrained_surface_from_edges(edges):
    '''
    DOESNT RESPECT BOUNDARIES
    '''
    from OCC.Core.GeomPlate import GeomPlate_MakeApprox, GeomPlate_BuildPlateSurface
    from OCC.Core.Core.BRepFill import BRepFill_CurveConstraint
    bpSrf = GeomPlate_BuildPlateSurface(3, 15, 2)
    for edg in edges:
        c = BRepAdaptor_HCurve()
        c.ChangeCurve().Initialize(edg)
        constraint = BRepFill_CurveConstraint(c.GetHandle(), 0)
        bpSrf.Add(constraint.GetHandle())
    bpSrf.Perform()
    maxSeg, maxDeg, critOrder = 9, 8, 0
    tol = 1e-4
    srf = bpSrf.Surface()
    plate = GeomPlate_MakeApprox(srf, tol, maxSeg, maxDeg, tol, critOrder)
    uMin, uMax, vMin, vMax = srf.GetObject().Bounds()
    face = make_face(plate.Surface(), uMin, uMax, vMin, vMax)
    return face
コード例 #5
0
def build_geom_plate(edges):
    bpSrf = GeomPlate_BuildPlateSurface(3, 9, 12)

    # add curve constraints
    for edg in edges:
        c = BRepAdaptor_HCurve()
        print('edge:', edg)
        c.ChangeCurve().Initialize(edg)
        constraint = BRepFill_CurveConstraint(c, 0)
        bpSrf.Add(constraint)

    # add point constraint
    try:
        bpSrf.Perform()
    except RuntimeError:
        print('failed to build the geom plate surface ')

    srf = bpSrf.Surface()
    plate = GeomPlate_MakeApprox(srf, 0.01, 10, 5, 0.01, 0, GeomAbs_C0)

    uMin, uMax, vMin, vMax = srf.Bounds()
    face = make_face(plate.Surface(), uMin, uMax, vMin, vMax, 1e-6)
    return face
コード例 #6
0
def adapt_edge_to_hcurve(edg):
    c = BRepAdaptor_HCurve()
    c.ChangeCurve().Initialize(edg)
    return c