예제 #1
0
def curves2d_from_offset(event=None):
    '''
    @param display:
    '''
    pnt2d_array = TColgp_Array1OfPnt2d(1, 5)
    pnt2d_array.SetValue(1, gp_Pnt2d(-4, 0))
    pnt2d_array.SetValue(2, gp_Pnt2d(-7, 2))
    pnt2d_array.SetValue(3, gp_Pnt2d(-6, 3))
    pnt2d_array.SetValue(4, gp_Pnt2d(-4, 3))
    pnt2d_array.SetValue(5, gp_Pnt2d(-3, 5))

    spline_1 = Geom2dAPI_PointsToBSpline(pnt2d_array).Curve()

    dist = 1
    offset_curve1 = Geom2d_OffsetCurve(spline_1, dist)
    result = offset_curve1.IsCN(2)
    print("Offset curve yellow is C2: %r" % result)
    dist2 = 1.5
    offset_curve2 = Geom2d_OffsetCurve(spline_1, dist2)
    result2 = offset_curve2.IsCN(2)
    print("Offset curve blue is C2: %r" % result2)

    display.DisplayShape(spline_1)
    display.DisplayShape(offset_curve1, color='YELLOW')
    display.DisplayShape(offset_curve2, color='BLUE', update=True)
    def test_curves2d_from_offset(self):
        '''Test: curves 2d from offset'''
        array = []
        array.append(gp_Pnt2d(-4, 0))
        array.append(gp_Pnt2d(-7, 2))
        array.append(gp_Pnt2d(-6, 3))
        array.append(gp_Pnt2d(-4, 3))
        array.append(gp_Pnt2d(-3, 5))

        xxx = point2d_list_to_TColgp_Array1OfPnt2d(array)
        SPL1 = Geom2dAPI_PointsToBSpline(xxx).Curve()

        dist = 1
        OC = Geom2d_OffsetCurve(SPL1, dist)
        result = OC.IsCN(2)

        dist2 = 1.5
        OC2 = Geom2d_OffsetCurve(SPL1, dist2)
        result2 = OC2.IsCN(2)