0024096: Eliminate compiler warning C4505 in MSVC++ with warning level 4
[occt.git] / src / DrawTrSurf / DrawTrSurf_BSplineCurve2d.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
4// The content of this file is subject to the Open CASCADE Technology Public
5// License Version 6.5 (the "License"). You may not use the content of this file
6// except in compliance with the License. Please obtain a copy of the License
7// at http://www.opencascade.org and read it completely before using this file.
8//
9// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11//
12// The Original Code and all software distributed under the License is
13// distributed on an "AS IS" basis, without warranty of any kind, and the
14// Initial Developer hereby disclaims all such warranties, including without
15// limitation, any warranties of merchantability, fitness for a particular
16// purpose or non-infringement. Please see the License for the specific terms
17// and conditions governing the rights and limitations under the License.
18
7fd59977 19#include <DrawTrSurf_BSplineCurve2d.ixx>
20#include <Draw_MarkerShape.hxx>
21#include <Geom2d_BSplineCurve.hxx>
22#include <gp_Pnt.hxx>
23#include <TColgp_Array1OfPnt2d.hxx>
24#include <TColStd_Array1OfReal.hxx>
25
26
b311480e 27DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
7fd59977 28 const Handle(Geom2d_BSplineCurve)& C)
29 : DrawTrSurf_Curve2d (C, Draw_vert, 100) {
30
31 drawKnots = Standard_True;
32 knotsForm = Draw_Losange;
33 knotsLook = Draw_violet;
34 knotsDim = 5;
35 drawPoles = Standard_True;
36 polesLook = Draw_rouge;
37 }
38
39
40
41 DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
42 const Handle(Geom2d_BSplineCurve)& C, const Draw_Color& CurvColor,
43 const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
44 const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
45 const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots, const Standard_Integer Discret)
46 : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
47
48 drawKnots = ShowKnots;
49 knotsForm = KnotsShape;
50 knotsLook = KnotsColor;
51 knotsDim = KnotsSize;
52 drawPoles = ShowPoles;
53 polesLook = PolesColor;
54 }
55
56
57
58void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
59{
60
61 Handle(Geom2d_BSplineCurve) C = Handle(Geom2d_BSplineCurve)::DownCast(curv);
62
63 if (drawPoles) {
64 Standard_Integer NbPoles = C->NbPoles();
65 dis.SetColor(polesLook);
66 TColgp_Array1OfPnt2d CPoles (1, NbPoles);
67 C->Poles (CPoles);
68 dis.MoveTo(CPoles(1));
69 for (Standard_Integer i = 2; i <= NbPoles; i++) {
70 dis.DrawTo(CPoles(i));
71 }
72 if (C->IsPeriodic())
73 dis.DrawTo(CPoles(1));
74 }
75
76 DrawTrSurf_Curve2d::DrawOn(dis);
77
78 if (drawKnots) {
79 Standard_Integer NbKnots = C->NbKnots();
80 TColStd_Array1OfReal CKnots (1, NbKnots);
81 C->Knots (CKnots);
82 dis.SetColor(knotsLook);
83 for (Standard_Integer i = 1; i <= NbKnots; i++) {
84 gp_Pnt2d P = C->Value(CKnots(i));
85 dis.DrawMarker (P, knotsForm, knotsDim);
86 }
87 }
88}
89
90
91 void DrawTrSurf_BSplineCurve2d::ShowPoles () { drawPoles = Standard_True; }
92
93
94 void DrawTrSurf_BSplineCurve2d::ShowKnots () { drawKnots = Standard_True; }
95
96
97 void DrawTrSurf_BSplineCurve2d::ClearPoles () { drawPoles = Standard_False; }
98
99
100 void DrawTrSurf_BSplineCurve2d::ClearKnots () { drawKnots = Standard_False; }
101
102
103 void DrawTrSurf_BSplineCurve2d::FindPole (
104 const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
105 Standard_Integer& Index) const {
106
107 Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
108 Standard_Real Prec = XPrec / D.Zoom();
109 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
110 Index++;
111 Standard_Integer NbPoles = bc->NbPoles();
112 gp_Pnt P;
113 gp_Pnt2d P2d;
114 while (Index <= NbPoles) {
115 P2d = bc->Pole(Index);
116 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
117 if (D.Project(P).Distance(p1) <= Prec)
118 return;
119 Index++;
120 }
121 Index = 0;
122 }
123
124
125 void DrawTrSurf_BSplineCurve2d::FindKnot (
126 const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
127 Standard_Integer& Index) const {
128
129 Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
130 gp_Pnt2d P2d;
131 gp_Pnt P;
132 gp_Pnt2d p1(X,Y);
133 Index++;
134 Standard_Integer NbKnots = bc->NbKnots();
135 while (Index <= NbKnots) {
136 P2d = bc->Value(bc->Knot(Index));
137 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
138 if (D.Project(P).Distance(p1) <= Prec)
139 return;
140 Index++;
141 }
142 Index = 0;
143 }
144
145//=======================================================================
146//function : Copy
147//purpose :
148//=======================================================================
149
150Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy()const
151{
152 Handle(DrawTrSurf_BSplineCurve2d) DC = new DrawTrSurf_BSplineCurve2d
153 (Handle(Geom2d_BSplineCurve)::DownCast(curv->Copy()),
154 look,polesLook,knotsLook,knotsForm,knotsDim,
155 drawPoles,drawKnots,
156 GetDiscretisation());
157
158 return DC;
159}
160