Ejemplo n.º 1
0
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0, -5))
    array.SetValue(2, gp_Pnt(1, 2, 1))
    array.SetValue(3, gp_Pnt(2, 3, 2))
    array.SetValue(4, gp_Pnt(4, 3, -2))
    array.SetValue(5, gp_Pnt(10, 5, -2))
    beziercurve = Geom_BezierCurve(array)
    # the first bezier curve
    array1 = TColgp_Array1OfPnt(1, 5)
    array1.SetValue(1, gp_Pnt(0, 0, -5))
    array1.SetValue(2, gp_Pnt(2, -2, 1))
    array1.SetValue(3, gp_Pnt(2, -3, 2))
    array1.SetValue(4, gp_Pnt(-4, 1, -2))
    array1.SetValue(5, gp_Pnt(1, 5, -2))
    beziercurve1 = Geom_BezierCurve(array1)

    array2 = TColgp_Array1OfPnt(1, 5)
    array2.SetValue(1, gp_Pnt(0, 0, -5))
    array2.SetValue(2, gp_Pnt(-2, 2, 1))
    array2.SetValue(3, gp_Pnt(2, -2, 2))
    array2.SetValue(4, gp_Pnt(-4, 8, -2))
    array2.SetValue(5, gp_Pnt(1, 5, -9))
    beziercurve2 = Geom_BezierCurve(array2)

    surface1 = GeomFill_BezierCurves(beziercurve, beziercurve1, beziercurve2,
                                     GeomFill_CurvedStyle)
    surface2 = GeomFill_BezierCurves(beziercurve, beziercurve1,
                                     GeomFill_StretchStyle)
    surface3 = GeomFill_BezierCurves(beziercurve, beziercurve1,
                                     GeomFill_CoonsStyle)
    display.DisplayShape(surface1.Surface(), color='RED')
Ejemplo n.º 2
0
def _bezier(poles, weights=None):
    _poles = opencascade_array1_of_pnt(poles)
    if weights:
        _weights = opencascade_array1_of_real(weights)

    if weights:
        curve = Geom_BezierCurve(_poles, _weights)
    else:
        curve = Geom_BezierCurve(_poles)

    return Curve(curve)
Ejemplo n.º 3
0
def edge(event=None):
    # The blud edge
    BlueEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(-80, -50, -20),
                                       gp_Pnt(-30, -60, -60))
    V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(-20, 10, -30))
    V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10, 7, -25))
    YellowEdge = BRepBuilderAPI_MakeEdge(V1.Vertex(), V2.Vertex())

    #The white edge
    line = gp_Lin(gp_Ax1(gp_Pnt(10, 10, 10), gp_Dir(1, 0, 0)))
    WhiteEdge = BRepBuilderAPI_MakeEdge(line, -20, 10)

    #The red edge
    Elips = gp_Elips(gp_Ax2(gp_Pnt(10, 0, 0), gp_Dir(1, 1, 1)), 60, 30)
    RedEdge = BRepBuilderAPI_MakeEdge(Elips, 0, math.pi / 2)

    # The green edge and the both extreme vertex
    P1 = gp_Pnt(-15, 200, 10)
    P2 = gp_Pnt(5, 204, 0)
    P3 = gp_Pnt(15, 200, 0)
    P4 = gp_Pnt(-15, 20, 15)
    P5 = gp_Pnt(-5, 20, 0)
    P6 = gp_Pnt(15, 20, 0)
    P7 = gp_Pnt(24, 120, 0)
    P8 = gp_Pnt(-24, 120, 12.5)
    array = TColgp_Array1OfPnt(1, 8)
    array.SetValue(1, P1)
    array.SetValue(2, P2)
    array.SetValue(3, P3)
    array.SetValue(4, P4)
    array.SetValue(5, P5)
    array.SetValue(6, P6)
    array.SetValue(7, P7)
    array.SetValue(8, P8)
    curve = Geom_BezierCurve(array)
    ME = BRepBuilderAPI_MakeEdge(curve.GetHandle())
    GreenEdge = ME
    V3 = ME.Vertex1()
    V4 = ME.Vertex2()

    display.DisplayColoredShape(BlueEdge.Edge(), 'BLUE')
    display.DisplayShape(V1.Vertex())
    display.DisplayShape(V2.Vertex())
    display.DisplayColoredShape(WhiteEdge.Edge(), 'WHITE')
    display.DisplayColoredShape(YellowEdge.Edge(), 'YELLOW')
    display.DisplayColoredShape(RedEdge.Edge(), 'RED')
    display.DisplayColoredShape(GreenEdge.Edge(), 'GREEN')
    display.DisplayShape(V3)
    display.DisplayShape(V4, update=True)
Ejemplo n.º 4
0
def thicken_spline(event=None):
    # Creation of points for the spine
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(1, 4, 0))
    array.SetValue(2, gp_Pnt(2, 2, 0))
    array.SetValue(3, gp_Pnt(3, 3, 0))
    array.SetValue(4, gp_Pnt(4, 3, 0))
    array.SetValue(5, gp_Pnt(5, 5, 0))

    # Creation of a Bezier Curve as the spine
    bz_curv = Geom_BezierCurve(array)
    bz_curv_edge = BRepBuilderAPI_MakeEdge(bz_curv).Edge()
    bz_curv_wire = BRepBuilderAPI_MakeWire(bz_curv_edge).Wire()
    display.DisplayShape(bz_curv_wire)

    # Creation of profile to sweep along the spine
    circle = gp_Circ(gp_ZOX(), 1)
    circle.SetLocation(array[0])
    circle_edge = BRepBuilderAPI_MakeEdge(circle).Edge()
    circle_wire = BRepBuilderAPI_MakeWire(circle_edge).Wire()

    # Creation of the law to dictate the evolution of the profile
    brep1 = BRepOffsetAPI_MakePipeShell(bz_curv_wire)
    law_f = Law_Linear()
    law_f.Set(0, 0.5, 1, 1)
    brep1.SetLaw(circle_wire, law_f, False, True)
    return brep1.Shape()
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0,-5))
    array.SetValue(2, gp_Pnt(1, 2,1))
    array.SetValue(3, gp_Pnt(2, 3,2))
    array.SetValue(4, gp_Pnt(4, 3,-2))
    array.SetValue(5, gp_Pnt(10, 5,-2))
    beziercurve = Geom_BezierCurve(array)
    # the first bezier curve
    array1 = TColgp_Array1OfPnt(1, 5)
    array1.SetValue(1, gp_Pnt(0, 0, -5))
    array1.SetValue(2, gp_Pnt(2, -2, 1))
    array1.SetValue(3, gp_Pnt(2, -3, 2))
    array1.SetValue(4, gp_Pnt(-4, 1, -2))
    array1.SetValue(5, gp_Pnt(1, 5, -2))
    beziercurve1 = Geom_BezierCurve(array1)

    array2 = TColgp_Array1OfPnt(1, 5)
    array2.SetValue(1, gp_Pnt(0, 0, -5))
    array2.SetValue(2, gp_Pnt(-2, 2, 1))
    array2.SetValue(3, gp_Pnt(2, -2, 2))
    array2.SetValue(4, gp_Pnt(-4, 8, -2))
    array2.SetValue(5, gp_Pnt(1, 5, -9))
    beziercurve2 = Geom_BezierCurve(array2)

    plane = Geom_Plane(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0, 1, 1))
    display.DisplayShape(plane, color='RED')

    surface1=GeomFill_BezierCurves(beziercurve,beziercurve1,beziercurve2,GeomFill_CurvedStyle)
    surface2 = GeomFill_BezierCurves(beziercurve, beziercurve1, GeomFill_StretchStyle)
    surface3 = GeomFill_BezierCurves(beziercurve, beziercurve1, GeomFill_CoonsStyle)

    bounds = True
    toldegen = 1e-6
    face = BRepBuilderAPI_MakeFace()
    face.Init(surface1.Surface(), bounds, toldegen)
    face.Build()

    shapes = face.Shape()

    fix=AIS_FixRelation(shapes,plane)
    display.Context.Display(fix, True)
    display.DisplayShape(shapes, color="RED")
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0,-5))
    array.SetValue(2, gp_Pnt(1, 2,1))
    array.SetValue(3, gp_Pnt(2, 3,2))
    array.SetValue(4, gp_Pnt(4, 3,-2))
    array.SetValue(5, gp_Pnt(5, 5,-2))
    beziercurve = Geom_BezierCurve(array)
    surface=Geom_SurfaceOfRevolution(beziercurve,gp_Ax1(gp_Pnt(0.0,0.0,0.0),gp_Dir(1.0,1.0,0.0)))
    print(surface.Bounds())
    poles=beziercurve.Poles()

    for j in range(array.Lower(), array.Upper()+1):
        p = array.Value(j)
        display.DisplayShape(p, update=False)
    display.DisplayShape(surface, update=True, color='Blue')
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0,-5))
    array.SetValue(2, gp_Pnt(1, 2,1))
    array.SetValue(3, gp_Pnt(2, 3,2))
    array.SetValue(4, gp_Pnt(4, 3,-2))
    array.SetValue(5, gp_Pnt(100, 5,-2))
    beziercurve = Geom_BezierCurve(array)
    poles=beziercurve.Poles()
    collection=TColStd_HSequenceOfTransient()
    collection.Append(beziercurve)
    collection.Append(beziercurve)
    collection.Append(beziercurve)
    collection.Append(beziercurve)
    for idx in range(1,collection.Length()+1):
        print(idx,Geom_BezierCurve.DownCast(collection.Value(idx)))
    display.DisplayShape(beziercurve, color='RED')
    def __init__(self):
        super(Sketch_CommandBezierCurve, self).__init__("BezierCurve.")
        self.IndexCounter = 1
        self.tempPnt2d = gp.Origin2d()
        self.myFirstgp_Pnt = gp.Origin()
        self.tempPnt = gp.Origin()
        self.curEdge = TopoDS_Edge()

        self.myBezierCurveAction = BezierCurveAction.Nothing
        curgp_Array1CurvePoles2d = TColgp_Array1OfPnt2d(1, 2)
        curgp_Array1CurvePoles2d.SetValue(1, gp.Origin2d())
        curgp_Array1CurvePoles2d.SetValue(2, gp.Origin2d())
        self.myGeom2d_BezierCurve = Geom2d_BezierCurve(
            curgp_Array1CurvePoles2d)

        curgp_Array1CurvePoles = TColgp_Array1OfPnt(1, 2)
        curgp_Array1CurvePoles.SetValue(1, gp.Origin())
        curgp_Array1CurvePoles.SetValue(2, gp.Origin())
        self.myGeom_BezierCurve = Geom_BezierCurve(curgp_Array1CurvePoles)

        self.myRubberAIS_Shape = AIS_Shape(self.curEdge)
 def CloseBezierCurve(self):
     self.myContext.Remove(self.myRubberAIS_Shape, True)
     self.bezier_curve.Compute()
     self.bezierNode = BezierNode(self.bezier_curve.GetName(),
                                  self.rootNode)
     self.bezierNode.setSketchObject(self.bezier_curve)
     self.AddObject(self.bezier_curve.GetGeometry2d(),
                    self.bezier_curve.GetAIS_Object(),
                    Sketch_GeometryType.CurveSketchObject)
     # create new object
     curgp_Array1CurvePoles2d = TColgp_Array1OfPnt2d(1, 2)
     curgp_Array1CurvePoles2d.SetValue(1, gp.Origin2d())
     curgp_Array1CurvePoles2d.SetValue(2, gp.Origin2d())
     self.myGeom2d_BezierCurve = Geom2d_BezierCurve(
         curgp_Array1CurvePoles2d)
     curgp_Array1CurvePoles = TColgp_Array1OfPnt(1, 2)
     curgp_Array1CurvePoles.SetValue(1, gp.Origin())
     curgp_Array1CurvePoles.SetValue(2, gp.Origin())
     self.myGeom_BezierCurve = Geom_BezierCurve(curgp_Array1CurvePoles)
     self.IndexCounter = 1
     self.myBezierCurveAction = BezierCurveAction.Input_1Point
Ejemplo n.º 10
0
 def _create_edge_from_bezier_pts(cls, start, end, *control_pts):
     create_gp_pnt = cls._get_create_gp_pnt_func()
     arr = TColgp_Array1OfPnt(0, 1 + len(control_pts))
     arr.SetValue(0, create_gp_pnt((start.real, start.imag)))
     index = 1
     for cp in control_pts:
         arr.SetValue(index, create_gp_pnt((cp.real, cp.imag)))
         index += 1
     arr.SetValue(index, create_gp_pnt((end.real, end.imag)))
     bcurve = Geom_BezierCurve(arr)
     bspline = g2dc.GeomConvert_CompCurveToBSplineCurve(
         bcurve).BSplineCurve()
     edge = BRepBuilderAPI_MakeEdge(bspline).Edge()
     return edge
Ejemplo n.º 11
0
 def makeBezierCurve(self, point_array, last_point=None):
     if last_point:
         array = TColgp_Array1OfPnt(1, len(point_array) + 1)
         for i, p in enumerate(point_array):
             array.SetValue(i + 1, p)
         array.SetValue(len(point_array) + 1, last_point)
     else:
         array = TColgp_Array1OfPnt(1, len(point_array))
         for i, p in enumerate(point_array):
             array.SetValue(i + 1, p)
     bezier_curve = Geom_BezierCurve(array)
     if self._tmp_geometry:
         edge = BRepBuilderAPI_MakeEdge(bezier_curve)
         shapes = edge.Shape()
         self._tmp_geometry.SetShape(shapes)
         self._tmp_geometry.Redisplay(False)
     else:
         ais_bezier = self._display.DisplayShape(bezier_curve)
         self._tmp_geometry = ais_bezier
def beziercurve():
    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0, -5))
    array.SetValue(2, gp_Pnt(1, 2, 1))
    array.SetValue(3, gp_Pnt(2, 3, 2))
    array.SetValue(4, gp_Pnt(4, 3, -2))
    array.SetValue(5, gp_Pnt(100, 5, -2))
    beziercurve = Geom_BezierCurve(array)
    poles = beziercurve.Poles()
    for p in poles:
        print(p.X(), p.Y(), p.Z())
    beziercurve.Increase(5)
    poles = beziercurve.Poles()
    for p in poles:
        print(p.X(), p.Y(), p.Z())
    print(beziercurve.Continuity(), beziercurve.Degree(),
          beziercurve.Continuity(), poles)

    for j in range(array.Lower(), array.Upper() + 1):
        p = array.Value(j)
        display.DisplayShape(p)
    ais_curve = display.DisplayShape(beziercurve, color='RED')
    start_pnt = gp_Trsf()
    start_pnt.SetValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0)
    end_pnt = gp_Trsf()
    end_pnt.SetValues(1, 0, 0, 100, 0, 1, 0, 100, 0, 0, 1, 100)
    animation = AIS_Animation(TCollection_AsciiString("obj1"))
    animation_obj = AIS_AnimationObject(TCollection_AsciiString("obj1"),
                                        display.Context, ais_curve, start_pnt,
                                        end_pnt)
    animation_obj.SetOwnDuration(2)
    animation_obj.SetStartPts(0)
    animation.Add(animation_obj)

    duration = animation.Duration()
    animation.StartTimer(0, 1.0, True)
    while not animation.IsStopped():
        animation.UpdateTimer()
        display.Context.UpdateCurrentViewer()
Ejemplo n.º 13
0
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0, -5))
    array.SetValue(2, gp_Pnt(1, 2, 1))
    array.SetValue(3, gp_Pnt(2, 3, 2))
    array.SetValue(4, gp_Pnt(4, 3, -2))
    array.SetValue(5, gp_Pnt(10, 5, -2))
    beziercurve = Geom_BezierCurve(array)

    edge = BRepBuilderAPI_MakeEdge(beziercurve)
    shapes = edge.Shape()
    ais_shape = AIS_Shape(shapes)
    display.Context.Display(ais_shape, True)
    transform = gp_Trsf()
    transform.SetTranslation(gp_Vec(10, 10, -50))
    transform.SetRotation(gp_Ax1(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0.0, 1.0, 0.0)),
                          180)
    curve_transform = BRepBuilderAPI_Transform(transform)
    curve_transform.Perform(shapes, False)
    shape2 = AIS_Shape(shapes)
    display.Context.Display(shape2, True)
    display.FitAll()
Ejemplo n.º 14
0
def beziercurve():

    # the first bezier curve
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0, -5))
    array.SetValue(2, gp_Pnt(1, 2, 1))
    array.SetValue(3, gp_Pnt(2, 3, 2))
    array.SetValue(4, gp_Pnt(4, 3, -2))
    array.SetValue(5, gp_Pnt(100, 5, -2))
    beziercurve = Geom_BezierCurve(array)
    poles = beziercurve.Poles()
    for p in poles:
        print(p.X(), p.Y(), p.Z())
    beziercurve.Increase(5)
    poles = beziercurve.Poles()
    for p in poles:
        print(p.X(), p.Y(), p.Z())
    print(beziercurve.Continuity(), beziercurve.Degree(),
          beziercurve.Continuity(), poles)

    for j in range(array.Lower(), array.Upper() + 1):
        p = array.Value(j)
        display.DisplayShape(p)
    display.DisplayShape(beziercurve, color='RED')
class Sketch_CommandBezierCurve(Sketch_Command):
    def __init__(self):
        super(Sketch_CommandBezierCurve, self).__init__("BezierCurve.")
        self.IndexCounter = 1
        self.tempPnt2d = gp.Origin2d()
        self.myFirstgp_Pnt = gp.Origin()
        self.tempPnt = gp.Origin()
        self.curEdge = TopoDS_Edge()

        self.myBezierCurveAction = BezierCurveAction.Nothing
        curgp_Array1CurvePoles2d = TColgp_Array1OfPnt2d(1, 2)
        curgp_Array1CurvePoles2d.SetValue(1, gp.Origin2d())
        curgp_Array1CurvePoles2d.SetValue(2, gp.Origin2d())
        self.myGeom2d_BezierCurve = Geom2d_BezierCurve(
            curgp_Array1CurvePoles2d)

        curgp_Array1CurvePoles = TColgp_Array1OfPnt(1, 2)
        curgp_Array1CurvePoles.SetValue(1, gp.Origin())
        curgp_Array1CurvePoles.SetValue(2, gp.Origin())
        self.myGeom_BezierCurve = Geom_BezierCurve(curgp_Array1CurvePoles)

        self.myRubberAIS_Shape = AIS_Shape(self.curEdge)

    def Action(self):
        self.myBezierCurveAction = BezierCurveAction.Input_1Point

    def MouseInputEvent(self, thePnt2d: gp_Pnt2d, buttons, modifier):
        self.curPnt2d = self.myAnalyserSnap.MouseInput(thePnt2d)

        if self.myBezierCurveAction == BezierCurveAction.Nothing:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_1Point:
            # calculate first 2d and 3d point
            self.myFirstgp_Pnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                            self.curPnt2d.Y())
            self.myFirstgp_Pnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                             self.curPnt2d)
            # save first point
            self.myFirstPoint.SetPnt(self.myFirstgp_Pnt)
            # draw first point
            # self.myRubberLine.SetPoints(self.myFirstPoint, self.myFirstPoint)
            # initialize bezier curve data structure created in sketch geometry
            self.bezier_curve = Sketch_BezierCurve(self.myContext,
                                                   self.curCoordinateSystem)
            # render the first point and auxiliry line
            self.bezier_curve.AddPoles(self.curPnt2d)
            # render the rubber line
            # self.myContext.Display(self.myRubberLine, True)
            # ready for 2nd point input
            self.myBezierCurveAction = BezierCurveAction.Input_2Point
            self.IndexCounter = 2

        elif self.myBezierCurveAction == BezierCurveAction.Input_2Point:
            self.myGeom2d_BezierCurve.SetPole(1, self.myFirstgp_Pnt2d)
            self.myGeom2d_BezierCurve.SetPole(self.IndexCounter, self.curPnt2d)

            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.myGeom_BezierCurve.SetPole(1, self.myFirstgp_Pnt)
            self.myGeom_BezierCurve.SetPole(self.IndexCounter, self.tempPnt)

            self.mySecondPoint.SetPnt(self.tempPnt)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve,
                                         self.myFirstgp_Pnt, self.tempPnt)
            if ME.IsDone():
                self.bezier_curve.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                self.myRubberAIS_Shape.Set(self.curEdge)
                # self.myContext.Remove(self.myRubberLine, True)
                self.myContext.Display(self.myRubberAIS_Shape, True)

                self.myGeom2d_BezierCurve.InsertPoleAfter(
                    self.IndexCounter, self.curPnt2d)
                self.myGeom_BezierCurve.InsertPoleAfter(
                    self.IndexCounter, self.tempPnt)

                self.IndexCounter += 1
                self.myBezierCurveAction = BezierCurveAction.Input_OtherPoints
        elif self.myBezierCurveAction == BezierCurveAction.Input_OtherPoints:
            self.myGeom2d_BezierCurve.SetPole(self.IndexCounter, self.curPnt2d)

            self.tempPnt = elclib.To3d(self.curCoordinateSystem.Ax2(),
                                       self.curPnt2d)
            self.myGeom_BezierCurve.SetPole(self.IndexCounter, self.tempPnt)

            self.mySecondPoint.SetPnt(self.tempPnt)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve)
            if ME.IsDone():
                self.bezier_curve.AddPoles(self.curPnt2d)
                self.curEdge = ME.Edge()
                if self.IndexCounter > MAXIMUMPOLES:
                    self.CloseBezierCurve()
                else:
                    self.myRubberAIS_Shape.Set(self.curEdge)
                    self.myContext.Redisplay(self.myRubberAIS_Shape, True)

                    self.myGeom2d_BezierCurve.InsertPoleAfter(
                        self.IndexCounter, self.curPnt2d)
                    self.myGeom_BezierCurve.InsertPoleAfter(
                        self.IndexCounter, self.tempPnt)
                    self.tempPnt2d = gp_Pnt2d(self.curPnt2d.X(),
                                              self.curPnt2d.Y())
                    self.IndexCounter += 1
        return False

    def MouseMoveEvent(self, thePnt2d: gp_Pnt2d, buttons, modifiers):
        self.curPnt2d = self.myAnalyserSnap.MouseMove(thePnt2d)
        if self.myBezierCurveAction == BezierCurveAction.Nothing:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_1Point:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_2Point:
            self.mySecondPoint.SetPnt(
                elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            # self.myRubberLine.SetPoints(self.myFirstPoint, self.mySecondPoint)
            # self.myContext.Redisplay(self.myRubberLine, True)
        elif self.myBezierCurveAction == BezierCurveAction.Input_OtherPoints:
            self.myGeom2d_BezierCurve.SetPole(self.IndexCounter, self.curPnt2d)
            self.mySecondPoint.SetPnt(
                elclib.To3d(self.curCoordinateSystem.Ax2(), self.curPnt2d))
            self.myGeom_BezierCurve.SetPole(self.IndexCounter,
                                            self.mySecondPoint.Pnt())
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve)
            if ME.IsDone():
                self.curEdge = ME.Edge()
                self.myRubberAIS_Shape.Set(self.curEdge)
                self.myContext.Redisplay(self.myRubberAIS_Shape, True)
            else:
                self.IndexCounter -= 1

    def CancelEvent(self):
        if self.myBezierCurveAction == BezierCurveAction.Nothing:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_1Point:
            pass
        elif self.myBezierCurveAction == BezierCurveAction.Input_2Point:
            # self.myContext.Remove(self.myRubberLine, True)
            self.bezier_curve.RemoveDisplay()
        elif self.myBezierCurveAction == BezierCurveAction.Input_OtherPoints:
            self.myGeom2d_BezierCurve.RemovePole(self.IndexCounter)
            self.myGeom_BezierCurve.RemovePole(self.IndexCounter)
            ME = BRepBuilderAPI_MakeEdge(self.myGeom_BezierCurve,
                                         self.myFirstgp_Pnt, self.tempPnt)
            if ME.IsDone():
                self.curEdge = ME.Edge()
                self.IndexCounter -= 1
                self.CloseBezierCurve()
        self.myBezierCurveAction = BezierCurveAction.Nothing

    def GetTypeOfMethod(self):
        return Sketch_ObjectTypeOfMethod.BezierCurve_Method

    def CloseBezierCurve(self):
        self.myContext.Remove(self.myRubberAIS_Shape, True)
        self.bezier_curve.Compute()
        self.bezierNode = BezierNode(self.bezier_curve.GetName(),
                                     self.rootNode)
        self.bezierNode.setSketchObject(self.bezier_curve)
        self.AddObject(self.bezier_curve.GetGeometry2d(),
                       self.bezier_curve.GetAIS_Object(),
                       Sketch_GeometryType.CurveSketchObject)
        # create new object
        curgp_Array1CurvePoles2d = TColgp_Array1OfPnt2d(1, 2)
        curgp_Array1CurvePoles2d.SetValue(1, gp.Origin2d())
        curgp_Array1CurvePoles2d.SetValue(2, gp.Origin2d())
        self.myGeom2d_BezierCurve = Geom2d_BezierCurve(
            curgp_Array1CurvePoles2d)
        curgp_Array1CurvePoles = TColgp_Array1OfPnt(1, 2)
        curgp_Array1CurvePoles.SetValue(1, gp.Origin())
        curgp_Array1CurvePoles.SetValue(2, gp.Origin())
        self.myGeom_BezierCurve = Geom_BezierCurve(curgp_Array1CurvePoles)
        self.IndexCounter = 1
        self.myBezierCurveAction = BezierCurveAction.Input_1Point