0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / DrawTrSurf / DrawTrSurf_BezierCurve2d.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
7fd59977 15
42cf5bc1 16#include <Draw_Color.hxx>
17#include <Draw_Display.hxx>
18#include <Draw_Drawable3D.hxx>
19#include <DrawTrSurf_BezierCurve2d.hxx>
7fd59977 20#include <Geom2d_BezierCurve.hxx>
21#include <gp_Pnt.hxx>
42cf5bc1 22#include <Standard_Type.hxx>
7fd59977 23#include <TColgp_Array1OfPnt2d.hxx>
24#include <TColStd_Array1OfReal.hxx>
25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BezierCurve2d,DrawTrSurf_Curve2d)
27
b311480e 28DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
7fd59977 29 const Handle(Geom2d_BezierCurve)& C) :
30 DrawTrSurf_Curve2d (C, Draw_vert, 50) {
31
32 drawPoles = Standard_True;
33 polesLook = Draw_rouge;
34 }
35
36
37 DrawTrSurf_BezierCurve2d::DrawTrSurf_BezierCurve2d (
38 const Handle(Geom2d_BezierCurve)& C, const Draw_Color& CurvColor,
39 const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
40 const Standard_Integer Discret) : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
41
42 drawPoles = ShowPoles;
43 polesLook = PolesColor;
44 }
45
46
47void DrawTrSurf_BezierCurve2d::DrawOn (Draw_Display& dis) const
48{
49
50 Handle(Geom2d_BezierCurve) C = Handle(Geom2d_BezierCurve)::DownCast(curv);
51
52 if (drawPoles) {
53 dis.SetColor(polesLook);
54 TColgp_Array1OfPnt2d CPoles (1, C->NbPoles());
55 C->Poles (CPoles);
56 dis.MoveTo(CPoles(1));
57 for (Standard_Integer i = 2; i <= C->NbPoles(); i++) {
58 dis.DrawTo(CPoles(i));
59 }
60 }
61
62 DrawTrSurf_Curve2d::DrawOn(dis);
63
64}
65
66
67
68void DrawTrSurf_BezierCurve2d::ShowPoles ()
69{
70 drawPoles = Standard_True;
71}
72
73
74void DrawTrSurf_BezierCurve2d::ClearPoles ()
75{
76 drawPoles = Standard_False;
77}
78
79
80void DrawTrSurf_BezierCurve2d::FindPole (
81 const Standard_Real X,
82 const Standard_Real Y,
83 const Draw_Display& D,
84 const Standard_Real XPrec,
85 Standard_Integer& Index) const
86{
87
88 Handle(Geom2d_BezierCurve) bz = Handle(Geom2d_BezierCurve)::DownCast(curv);
89 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
90 Standard_Real Prec = XPrec / D.Zoom();
91 Index++;
92 Standard_Integer NbPoles = bz->NbPoles();
93 gp_Pnt P;
94 gp_Pnt2d P2d;
95 while (Index <= NbPoles) {
96 P2d = bz->Pole(Index);
97 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
98 if (D.Project(P).Distance(p1) <= Prec)
99 return;
100 Index++;
101 }
102 Index = 0;
103}
104
105//=======================================================================
106//function : Copy
107//purpose :
108//=======================================================================
109
110Handle(Draw_Drawable3D) DrawTrSurf_BezierCurve2d::Copy()const
111{
112 Handle(DrawTrSurf_BezierCurve2d) DC = new DrawTrSurf_BezierCurve2d
113 (Handle(Geom2d_BezierCurve)::DownCast(curv->Copy()),
114 look,polesLook,
115 drawPoles,
116 GetDiscretisation());
117
118 return DC;
119}