0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / DrawTrSurf / DrawTrSurf_BezierCurve.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
42cf5bc1 15
16#include <Draw_Color.hxx>
17#include <Draw_Display.hxx>
18#include <Draw_Drawable3D.hxx>
19#include <DrawTrSurf_BezierCurve.hxx>
7fd59977 20#include <Geom_BezierCurve.hxx>
21#include <gp_Pnt2d.hxx>
42cf5bc1 22#include <Standard_Type.hxx>
7fd59977 23#include <TColgp_Array1OfPnt.hxx>
24#include <TColStd_Array1OfReal.hxx>
25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve,DrawTrSurf_Curve)
27
b311480e 28DrawTrSurf_BezierCurve::DrawTrSurf_BezierCurve (
7fd59977 29 const Handle(Geom_BezierCurve)& C)
30 : DrawTrSurf_Curve (C, Draw_vert, 16, 0.05, 1) {
31
32 drawPoles = Standard_True;
33 polesLook = Draw_rouge;
34 }
35
36
37
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) {
44
45 drawPoles = ShowPoles;
46 polesLook = PolesColor;
47 }
48
49
50 void DrawTrSurf_BezierCurve::DrawOn (Draw_Display& dis) const {
51
52
53 Handle(Geom_BezierCurve) C = Handle(Geom_BezierCurve)::DownCast(curv);
54
55 if (drawPoles) {
56 Standard_Integer NbPoles = C->NbPoles();
57 dis.SetColor(polesLook);
58 TColgp_Array1OfPnt CPoles (1, NbPoles);
59 C->Poles (CPoles);
60 dis.MoveTo(CPoles(1));
61 for (Standard_Integer i = 2; i <= NbPoles; i++) {
62 dis.DrawTo(CPoles(i));
63 }
64 }
65
66 DrawTrSurf_Curve::DrawOn(dis);
67 }
68
69
70
71 void DrawTrSurf_BezierCurve::ShowPoles () { drawPoles = Standard_True; }
72
73
74 void DrawTrSurf_BezierCurve::ClearPoles () { drawPoles = Standard_False; }
75
76
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 {
80
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();
84 Index++;
85 Standard_Integer NbPoles = bz->NbPoles();
86 while (Index <= NbPoles) {
87 if (D.Project(bz->Pole(Index)).Distance(p1) <= Prec)
88 return;
89 Index++;
90 }
91 Index = 0;
92 }
93
94
95//=======================================================================
96//function : Copy
97//purpose :
98//=======================================================================
99
100Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve::Copy()const
101{
102 Handle(DrawTrSurf_BezierCurve) DC = new DrawTrSurf_BezierCurve
103 (Handle(Geom_BezierCurve)::DownCast(curv->Copy()),
104 look,polesLook,
105 drawPoles,
106 GetDiscretisation(),GetDeflection(),GetDrawMode());
107
108 return DC;
109}
110
111
112
113
114