1 #include <DrawTrSurf_BSplineCurve2d.ixx>
2 #include <Draw_MarkerShape.hxx>
3 #include <Geom2d_BSplineCurve.hxx>
5 #include <TColgp_Array1OfPnt2d.hxx>
6 #include <TColStd_Array1OfReal.hxx>
9 DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
10 const Handle(Geom2d_BSplineCurve)& C)
11 : DrawTrSurf_Curve2d (C, Draw_vert, 100) {
13 drawKnots = Standard_True;
14 knotsForm = Draw_Losange;
15 knotsLook = Draw_violet;
17 drawPoles = Standard_True;
18 polesLook = Draw_rouge;
23 DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
24 const Handle(Geom2d_BSplineCurve)& C, const Draw_Color& CurvColor,
25 const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
26 const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
27 const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots, const Standard_Integer Discret)
28 : DrawTrSurf_Curve2d (C, CurvColor, Discret) {
30 drawKnots = ShowKnots;
31 knotsForm = KnotsShape;
32 knotsLook = KnotsColor;
34 drawPoles = ShowPoles;
35 polesLook = PolesColor;
40 void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
43 Handle(Geom2d_BSplineCurve) C = Handle(Geom2d_BSplineCurve)::DownCast(curv);
46 Standard_Integer NbPoles = C->NbPoles();
47 dis.SetColor(polesLook);
48 TColgp_Array1OfPnt2d CPoles (1, NbPoles);
50 dis.MoveTo(CPoles(1));
51 for (Standard_Integer i = 2; i <= NbPoles; i++) {
52 dis.DrawTo(CPoles(i));
55 dis.DrawTo(CPoles(1));
58 DrawTrSurf_Curve2d::DrawOn(dis);
61 Standard_Integer NbKnots = C->NbKnots();
62 TColStd_Array1OfReal CKnots (1, NbKnots);
64 dis.SetColor(knotsLook);
65 for (Standard_Integer i = 1; i <= NbKnots; i++) {
66 gp_Pnt2d P = C->Value(CKnots(i));
67 dis.DrawMarker (P, knotsForm, knotsDim);
73 void DrawTrSurf_BSplineCurve2d::ShowPoles () { drawPoles = Standard_True; }
76 void DrawTrSurf_BSplineCurve2d::ShowKnots () { drawKnots = Standard_True; }
79 void DrawTrSurf_BSplineCurve2d::ClearPoles () { drawPoles = Standard_False; }
82 void DrawTrSurf_BSplineCurve2d::ClearKnots () { drawKnots = Standard_False; }
85 void DrawTrSurf_BSplineCurve2d::FindPole (
86 const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
87 Standard_Integer& Index) const {
89 Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
90 Standard_Real Prec = XPrec / D.Zoom();
91 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
93 Standard_Integer NbPoles = bc->NbPoles();
96 while (Index <= NbPoles) {
97 P2d = bc->Pole(Index);
98 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
99 if (D.Project(P).Distance(p1) <= Prec)
107 void DrawTrSurf_BSplineCurve2d::FindKnot (
108 const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
109 Standard_Integer& Index) const {
111 Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
116 Standard_Integer NbKnots = bc->NbKnots();
117 while (Index <= NbKnots) {
118 P2d = bc->Value(bc->Knot(Index));
119 P.SetCoord (P2d.X(), P2d.Y(), 0.0);
120 if (D.Project(P).Distance(p1) <= Prec)
127 //=======================================================================
130 //=======================================================================
132 Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy()const
134 Handle(DrawTrSurf_BSplineCurve2d) DC = new DrawTrSurf_BSplineCurve2d
135 (Handle(Geom2d_BSplineCurve)::DownCast(curv->Copy()),
136 look,polesLook,knotsLook,knotsForm,knotsDim,
138 GetDiscretisation());