예제 #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
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
 def adaptor(self):
     if self._adaptor is not None and not self.is_dirty:
         pass
     else:
         self._adaptor = BRepAdaptor_Curve(self)
         self._adaptor_handle = BRepAdaptor_HCurve(self._adaptor)
     return self._adaptor
예제 #4
0
def poles_from_bsplinecurve_edge(occedge):
    """
    This function fetches the poles of a bspline OCCedge.
 
    Parameters
    ----------
    occedge : OCCedge
        The OCCedge to be examined. The OCCedge needs to contain a bspline curve
        
    Returns
    -------
    List of poles : pyptlist
        List of poles of the bspline curve
    """
    adaptor = BRepAdaptor_Curve(occedge)
    adaptor_handle = BRepAdaptor_HCurve(adaptor)
    handle_bspline = Handle_Geom_BSplineCurve()
    bspline = handle_bspline.DownCast(adaptor.Curve().Curve()).GetObject()

    npoles =  bspline.NbPoles()
    polelist = []
    for np in range(npoles):
        pole = bspline.Pole(np+1)
        pypole = (pole.X(), pole.Y(), pole.Z())
        polelist.append(pypole)
        
    if topods_Edge(occedge).Orientation() == TopAbs_REVERSED:
        polelist.reverse()

    return polelist
예제 #5
0
def make_constrained_surface_from_edges(edges):
    """
    DOESNT RESPECT BOUNDARIES
    """
    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
예제 #6
0
def poles_from_bsplinecurve_edge(occedge):
    '''
    occedge: the edge to be measured
    type: occedge
    '''
    #occutil_edge = edge.Edge(occedge)
    adaptor = BRepAdaptor_Curve(occedge)
    adaptor_handle = BRepAdaptor_HCurve(adaptor)
    handle_bspline = Handle_Geom_BSplineCurve()
    bspline = handle_bspline.DownCast(adaptor.Curve().Curve()).GetObject()

    npoles = bspline.NbPoles()
    polelist = []
    for np in range(npoles):
        pole = bspline.Pole(np + 1)
        pypole = (pole.X(), pole.Y(), pole.Z())
        polelist.append(pypole)

    if topods_Edge(occedge).Orientation() == TopAbs_REVERSED:
        polelist.reverse()

    return polelist
예제 #7
0
def adapt_edge_to_hcurve(edg):
    c = BRepAdaptor_HCurve()
    c.ChangeCurve().Initialize(edg)
    return c