1 // Created on: 1995-03-10
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Draw_Box.hxx>
19 #include <Draw_Color.hxx>
20 #include <Draw_Display.hxx>
22 #include <Standard_Type.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(Draw_Box,Draw_Drawable3D)
26 //=======================================================================
27 //function : Constructor
29 //=======================================================================
30 Draw_Box::Draw_Box(const Bnd_OBB& theOBB,
31 const Draw_Color& theColor) :myOBB(theOBB), myColor(theColor)
35 //=======================================================================
38 //=======================================================================
39 void Draw_Box::ToWCS(const Standard_Real theX,
40 const Standard_Real theY,
41 const Standard_Real theZ,
44 const gp_XYZ & aC = myOBB.Center();
45 const gp_XYZ aXDir = myOBB.XDirection(),
46 aYDir = myOBB.YDirection(),
47 aZDir = myOBB.ZDirection();
49 theP.SetXYZ(aC + theX*aXDir + theY*aYDir + theZ*aZDir);
52 //=======================================================================
55 //=======================================================================
56 void Draw_Box::MoveX(const Standard_Real theShift, gp_Pnt& thePt) const
58 const gp_XYZ aXDir = myOBB.XDirection();
59 thePt.SetXYZ(thePt.XYZ() + theShift*aXDir);
62 //=======================================================================
65 //=======================================================================
66 void Draw_Box::MoveY(const Standard_Real theShift, gp_Pnt& thePt) const
68 const gp_XYZ aYDir = myOBB.YDirection();
69 thePt.SetXYZ(thePt.XYZ() + theShift*aYDir);
72 //=======================================================================
75 //=======================================================================
76 void Draw_Box::MoveZ(const Standard_Real theShift, gp_Pnt& thePt) const
78 const gp_XYZ aZDir = myOBB.ZDirection();
79 thePt.SetXYZ(thePt.XYZ() + theShift*aZDir);
82 //=======================================================================
85 //=======================================================================
86 void Draw_Box::DrawOn(Draw_Display& theDIS) const
93 theDIS.SetColor(myColor);
95 const Standard_Real aHx = myOBB.XHSize(),
100 ToWCS(-aHx, -aHy, -aHz, aP);
103 for(Standard_Integer i = 0; i<2; i++)
114 ToWCS(-aHx, -aHy, aHz, aP);
118 for(Standard_Integer i = 0; i < 4; i++)
122 case 0: ToWCS(-aHx, -aHy, -aHz, aP); break;
123 case 1: ToWCS(aHx, -aHy, -aHz, aP); break;
124 case 2: ToWCS(aHx, aHy, -aHz, aP); break;
125 case 3: ToWCS(-aHx, aHy, -aHz, aP); break;