1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Draw_Color.hxx>
17 #include <Draw_Display.hxx>
18 #include <Draw_Drawable3D.hxx>
19 #include <DrawTrSurf_BezierCurve2d.hxx>
20 #include <Geom2d_BezierCurve.hxx>
22 #include <Standard_Type.hxx>
23 #include <TColgp_Array1OfPnt2d.hxx>
24 #include <TColStd_Array1OfReal.hxx>
26 DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
27 const Handle(Geom2d_BezierCurve)& C) :
28 DrawTrSurf_Curve2d (C, Draw_vert, 50) {
30 drawPoles = Standard_True;
31 polesLook = Draw_rouge;
35 DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
36 const Handle(Geom2d_BezierCurve)& C, const Draw_Color& CurvColor,
37 const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
38 const Standard_Integer Discret) : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
40 drawPoles = ShowPoles;
41 polesLook = PolesColor;
45 void DrawTrSurf_BezierCurve2d::DrawOn (Draw_Display& dis) const
48 Handle(Geom2d_BezierCurve) C = Handle(Geom2d_BezierCurve)::DownCast(curv);
51 dis.SetColor(polesLook);
52 TColgp_Array1OfPnt2d CPoles (1, C->NbPoles());
54 dis.MoveTo(CPoles(1));
55 for (Standard_Integer i = 2; i <= C->NbPoles(); i++) {
56 dis.DrawTo(CPoles(i));
60 DrawTrSurf_Curve2d::DrawOn(dis);
66 void DrawTrSurf_BezierCurve2d::ShowPoles ()
68 drawPoles = Standard_True;
72 void DrawTrSurf_BezierCurve2d::ClearPoles ()
74 drawPoles = Standard_False;
78 void DrawTrSurf_BezierCurve2d::FindPole (
79 const Standard_Real X,
80 const Standard_Real Y,
81 const Draw_Display& D,
82 const Standard_Real XPrec,
83 Standard_Integer& Index) const
86 Handle(Geom2d_BezierCurve) bz = Handle(Geom2d_BezierCurve)::DownCast(curv);
87 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
88 Standard_Real Prec = XPrec / D.Zoom();
90 Standard_Integer NbPoles = bz->NbPoles();
93 while (Index <= NbPoles) {
94 P2d = bz->Pole(Index);
95 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
96 if (D.Project(P).Distance(p1) <= Prec)
103 //=======================================================================
106 //=======================================================================
108 Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Copy()const
110 Handle(DrawTrSurf_BezierCurve2d) DC = new DrawTrSurf_BezierCurve2d
111 (Handle(Geom2d_BezierCurve)::DownCast(curv->Copy()),
114 GetDiscretisation());