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.
15 #include <DrawTrSurf_BezierSurface.ixx>
16 #include <DrawTrSurf_BezierCurve.hxx>
17 #include <Geom_BezierSurface.hxx>
18 #include <gp_Pnt2d.hxx>
19 #include <TColgp_Array2OfPnt.hxx>
20 #include <TColStd_Array1OfReal.hxx>
22 DrawTrSurf_BezierSurface::DrawTrSurf_BezierSurface (
23 const Handle(Geom_BezierSurface)& S)
24 : DrawTrSurf_Surface (S, 1, 1, Draw_jaune, Draw_bleu, 30, 0.05, 0) {
26 drawPoles = Standard_True;
27 polesLook = Draw_rouge;
32 DrawTrSurf_BezierSurface::DrawTrSurf_BezierSurface (
33 const Handle(Geom_BezierSurface)& S,
34 const Standard_Integer NbUIsos, const Standard_Integer NbVIsos,
35 const Draw_Color& BoundsColor, const Draw_Color& IsosColor,
36 const Draw_Color& PolesColor, const Standard_Boolean ShowPoles,
37 const Standard_Integer Discret,const Standard_Real Deflection,
38 const Standard_Integer DrawMode)
39 : DrawTrSurf_Surface (S, NbUIsos, NbVIsos, BoundsColor, IsosColor,
40 Discret, Deflection, DrawMode){
42 drawPoles = ShowPoles;
43 polesLook = PolesColor;
48 void DrawTrSurf_BezierSurface::DrawOn (Draw_Display& dis) const {
51 Handle(Geom_BezierSurface) S = Handle(Geom_BezierSurface)::DownCast(surf);
54 Standard_Integer NbUPoles = S->NbUPoles();
55 Standard_Integer NbVPoles = S->NbVPoles();
56 dis.SetColor(polesLook);
57 TColgp_Array2OfPnt SPoles (1, NbUPoles, 1, NbVPoles);
59 for (j = 1; j <= NbVPoles; j++) {
60 dis.MoveTo(SPoles(1, j));
61 for (i = 2; i <= NbUPoles; i++) {
62 dis.DrawTo(SPoles(i, j));
65 for (i = 1; i <= NbUPoles; i++) {
66 dis.MoveTo(SPoles(i, 1));
67 for (j = 2; j <= NbVPoles; j++) {
68 dis.DrawTo(SPoles(i, j));
74 DrawTrSurf_Surface::DrawOn(dis);
78 void DrawTrSurf_BezierSurface::ShowPoles () { drawPoles = Standard_True; }
81 void DrawTrSurf_BezierSurface::ClearPoles () { drawPoles = Standard_False; }
84 void DrawTrSurf_BezierSurface::FindPole (
85 const Standard_Real X, const Standard_Real Y, const Draw_Display& D,
86 const Standard_Real XPrec, Standard_Integer& UIndex, Standard_Integer& VIndex) const {
88 Handle(Geom_BezierSurface) bs = Handle(Geom_BezierSurface)::DownCast(surf);
89 gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
90 Standard_Real Prec = XPrec / D.Zoom();
93 Standard_Integer NbUPoles = bs->NbUPoles();
94 Standard_Integer NbVPoles = bs->NbVPoles();
95 while (VIndex <= NbVPoles) {
96 while (UIndex <= NbUPoles) {
97 if (D.Project(bs->Pole(UIndex, VIndex)).Distance(p1) <= Prec)
108 //=======================================================================
111 //=======================================================================
113 Handle(Draw_Drawable3D) DrawTrSurf_BezierSurface::Copy()const
115 Handle(DrawTrSurf_BezierSurface) DS = new DrawTrSurf_BezierSurface
116 (Handle(Geom_BezierSurface)::DownCast(surf->Copy()),
118 boundsLook,isosLook,polesLook,drawPoles,
119 GetDiscretisation(),GetDeflection(),GetDrawMode());