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_BezierCurve.hxx>
20 #include <Geom_BezierCurve.hxx>
21 #include <gp_Pnt2d.hxx>
22 #include <Standard_Type.hxx>
23 #include <TColgp_Array1OfPnt.hxx>
24 #include <TColStd_Array1OfReal.hxx>
26 IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve,DrawTrSurf_Curve)
28 DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
29 const Handle(Geom_BezierCurve)& C)
30 : DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1) {
32 drawPoles = Standard_True;
33 polesLook = Draw_rouge;
38 DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
39 const Handle(Geom_BezierCurve)& C, const Draw_Color& CurvColor,
40 const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
41 const Standard_Integer Discret,const Standard_Real Deflection,
42 const Standard_Integer DrawMode ) :
43 DrawTrSurf_Curve (C, CurvColor, Discret, Deflection, DrawMode) {
45 drawPoles = ShowPoles;
46 polesLook = PolesColor;
50 void DrawTrSurf_BezierCurve::DrawOn (Draw_Display& dis) const {
53 Handle(Geom_BezierCurve) C = Handle(Geom_BezierCurve)::DownCast(curv);
56 Standard_Integer NbPoles = C->NbPoles();
57 dis.SetColor(polesLook);
58 TColgp_Array1OfPnt CPoles (1, NbPoles);
60 dis.MoveTo(CPoles(1));
61 for (Standard_Integer i = 2; i <= NbPoles; i++) {
62 dis.DrawTo(CPoles(i));
66 DrawTrSurf_Curve::DrawOn(dis);
71 void DrawTrSurf_BezierCurve::ShowPoles () { drawPoles = Standard_True; }
74 void DrawTrSurf_BezierCurve::ClearPoles () { drawPoles = Standard_False; }
77 void DrawTrSurf_BezierCurve::FindPole (
78 const Standard_Real X, const Standard_Real Y, const Draw_Display& D,
79 const Standard_Real XPrec, Standard_Integer& Index) const {
81 Handle(Geom_BezierCurve) bz = Handle(Geom_BezierCurve)::DownCast(curv);
82 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
83 Standard_Real Prec = XPrec / D.Zoom();
85 Standard_Integer NbPoles = bz->NbPoles();
86 while (Index <= NbPoles) {
87 if (D.Project(bz->Pole(Index)).Distance(p1) <= Prec)
95 //=======================================================================
98 //=======================================================================
100 Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Copy()const
102 Handle(DrawTrSurf_BezierCurve) DC = new DrawTrSurf_BezierCurve
103 (Handle(Geom_BezierCurve)::DownCast(curv->Copy()),
106 GetDiscretisation(),GetDeflection(),GetDrawMode());