Ejemplo n.º 1
0
def points_to_bspline(pnts):
    '''
    Points to bspline
    '''
    pnts = point_list_to_TColgp_Array1OfPnt(pnts)
    crv = GeomAPI_PointsToBSpline(pnts)
    return crv.Curve()
Ejemplo n.º 2
0
def get_simple_bound(rndPts0):
    _spl1 = GeomAPI_PointsToBSpline(
        rndPts0)  #not a GeomAPI_PointsToBSplineSurface ??
    _spl1.thisown = False
    spl1 = _spl1.Curve()

    spl1_adap = GeomAdaptor_HCurve(spl1)
    spl1_adap.thisown = False
    spl1_adap_h = spl1_adap.GetHandle()
    bound1 = GeomFill_SimpleBound(spl1_adap_h, 0.001, 0.001)
    bound1.thisown = False
    bound1_h = bound1.GetHandle()
    return spl1, bound1_h
Ejemplo n.º 3
0
def resample_curve_with_uniform_deflection(curve,
                                           deflection=0.5,
                                           degreeMin=3,
                                           degreeMax=8,
                                           continuity=GeomAbs_C2,
                                           tolerance=1e-4):
    """
    fits a bspline through the samples on `curve`
    @param curve: TopoDS_Wire, TopoDS_Edge, curve
    @param n_samples:
    """
    crv = to_adaptor_3d(curve)
    defl = GCPnts_UniformDeflection(crv, deflection)
    with assert_isdone(defl, 'failed to compute UniformDeflection'):
        print("Number of points:", defl.NbPoints())
    sampled_pnts = [defl.Value(i) for i in range(1, defl.NbPoints())]
    resampled_curve = GeomAPI_PointsToBSpline(
        point_list_to_TColgp_Array1OfPnt(sampled_pnts), degreeMin, degreeMax,
        continuity, tolerance)
    return resampled_curve.Curve().GetObject()
Ejemplo n.º 4
0
def points_to_bspline(pnts):
    pts = TColgp_Array1OfPnt(0, len(pnts) - 1)
    for n, i in enumerate(pnts):
        pts.SetValue(n, i)
    crv = GeomAPI_PointsToBSpline(pts)
    return crv.Curve()