0028316: Coding Rules - Elimilate confusing aliases of Standard_Real type in V3d_View
[occt.git] / src / Aspect / Aspect_RectangularGrid.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 5c3f9e6..c470c2c
@@ -1,21 +1,34 @@
-// Modified    23/02/98 : FMN ; Remplacement PI par Standard_PI
-
-#define CSR577 //GG 25/09/00 Avoid to have unaccuracy coordinates computation
-//             when the grid is activated.
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
-#define xTRACE
+// Modified    23/02/98 : FMN ; Remplacement PI par Standard_PI
 
-#include <Aspect_RectangularGrid.ixx>
+#include <Aspect_RectangularGrid.hxx>
+#include <Standard_NegativeValue.hxx>
+#include <Standard_NullValue.hxx>
+#include <Standard_NumericError.hxx>
+#include <Standard_Type.hxx>
 
+IMPLEMENT_STANDARD_RTTIEXT(Aspect_RectangularGrid,Aspect_Grid)
 
 Aspect_RectangularGrid::Aspect_RectangularGrid(
-                               const Quantity_Length aXStep,
-                               const Quantity_Length aYStep,
-                               const Quantity_Length anXOrigin,
-                               const Quantity_Length anYOrigin,
-                               const Quantity_PlaneAngle aFirstAngle,
-                               const Quantity_PlaneAngle aSecondAngle,
-                               const Quantity_PlaneAngle aRotationAngle)
+                               const Standard_Real aXStep,
+                               const Standard_Real aYStep,
+                               const Standard_Real anXOrigin,
+                               const Standard_Real anYOrigin,
+                               const Standard_Real aFirstAngle,
+                               const Standard_Real aSecondAngle,
+                               const Standard_Real aRotationAngle)
 :Aspect_Grid(anXOrigin,anYOrigin,aRotationAngle),myXStep(aXStep),myYStep(aYStep),myFirstAngle(aFirstAngle),mySecondAngle(aSecondAngle)
 
 {
@@ -30,7 +43,7 @@ Aspect_RectangularGrid::Aspect_RectangularGrid(
 
 
 
-void Aspect_RectangularGrid::SetXStep(const Quantity_Length aStep) {
+void Aspect_RectangularGrid::SetXStep(const Standard_Real aStep) {
   Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
   Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
   myXStep = aStep;
@@ -38,7 +51,7 @@ void Aspect_RectangularGrid::SetXStep(const Quantity_Length aStep) {
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::SetYStep(const Quantity_Length aStep) {
+void Aspect_RectangularGrid::SetYStep(const Standard_Real aStep) {
   Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
   Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
   myYStep = aStep;
@@ -46,9 +59,9 @@ void Aspect_RectangularGrid::SetYStep(const Quantity_Length aStep) {
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::SetAngle(const Quantity_PlaneAngle anAngle1,
-                                            const Quantity_PlaneAngle anAngle2){
-
+void Aspect_RectangularGrid::SetAngle (const Standard_Real anAngle1,
+                                       const Standard_Real anAngle2)
+{
   Standard_NumericError_Raise_if(!CheckAngle (anAngle1,anAngle2 ),
                                  "axis are parallel");
   myFirstAngle = anAngle1;
@@ -58,11 +71,11 @@ void Aspect_RectangularGrid::SetAngle(const Quantity_PlaneAngle anAngle1,
 }
 
 void Aspect_RectangularGrid::SetGridValues(
-       const Quantity_Length theXOrigin,
-       const Quantity_Length theYOrigin,
-       const Quantity_Length theXStep,
-       const Quantity_Length theYStep,
-       const Quantity_PlaneAngle theRotationAngle) {
+       const Standard_Real theXOrigin,
+       const Standard_Real theYOrigin,
+       const Standard_Real theXStep,
+       const Standard_Real theYStep,
+       const Standard_Real theRotationAngle) {
 
   myXOrigin = theXOrigin;
   myYOrigin = theYOrigin;
@@ -77,45 +90,34 @@ void Aspect_RectangularGrid::SetGridValues(
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::Compute(const Quantity_Length X,
-                         const Quantity_Length Y,
-                         Quantity_Length& gridX,
-                         Quantity_Length& gridY) const {
+void Aspect_RectangularGrid::Compute(const Standard_Real X,
+                         const Standard_Real Y,
+                         Standard_Real& gridX,
+                         Standard_Real& gridY) const {
     Standard_Real D1 = b1 * X - a1 * Y - c1;
     Standard_Real D2 = b2 * X - a2 * Y - c2;
     Standard_Integer n1 = Standard_Integer ( Abs(D1)/myXStep + 0.5);
     Standard_Integer n2 = Standard_Integer ( Abs(D2)/myYStep + 0.5);
     Standard_Real offset1 = c1 + Standard_Real(n1) * Sign (myXStep , D1);
     Standard_Real offset2 = c2 + Standard_Real(n2) * Sign (myYStep , D2);
-#ifdef CSR577
     Standard_Real Delta = a1*b2 - b1*a2;
     gridX = ( offset2*a1 - offset1*a2) /Delta;
     gridY = ( offset2*b1 - offset1*b2) /Delta;
-#else
-    Standard_Real Delta = b1*a2 - a1*b2;
-    gridX = ( offset1*a2 - offset2*a1) /Delta;
-    gridY = ( offset1*b2 - offset2*b1) /Delta;
-#endif
-#ifdef TRACE
-    cout << "Aspect_RectangularGrid::Compute (" << Quantity_Length (X) << ", "
-         << Quantity_Length (Y) << ", " << Quantity_Length (gridX) << ", "
-         << Quantity_Length (gridY) << ")" << endl;
-#endif
 }
 
-Quantity_Length Aspect_RectangularGrid::XStep() const {
+Standard_Real Aspect_RectangularGrid::XStep() const {
   return myXStep;
 }
 
-Quantity_Length Aspect_RectangularGrid::YStep() const {
+Standard_Real Aspect_RectangularGrid::YStep() const {
   return myYStep;
 }
 
-Quantity_Length Aspect_RectangularGrid::FirstAngle() const {
+Standard_Real Aspect_RectangularGrid::FirstAngle() const {
   return myFirstAngle;
 }
 
-Quantity_Length Aspect_RectangularGrid::SecondAngle() const {
+Standard_Real Aspect_RectangularGrid::SecondAngle() const {
   return mySecondAngle;
 }
 
@@ -130,7 +132,6 @@ void Aspect_RectangularGrid::Init () {
 //  b2 = Sin (mySecondAngle + RotationAngle() + M_PI / 2.);
 //  c2 = XOrigin() * b2 - YOrigin() * a2;
 
-#ifdef CSR577
   Standard_Real angle1 = myFirstAngle + RotationAngle();
   Standard_Real angle2 = mySecondAngle + RotationAngle();
   if ( angle1 != 0. ) {
@@ -149,15 +150,6 @@ void Aspect_RectangularGrid::Init () {
   } else {
     a2 = -1.; b2 = 0.; c2 = YOrigin();
   }
-#else
-  a1 = -Sin (myFirstAngle + RotationAngle()); 
-  b1 = Cos (myFirstAngle + RotationAngle());
-  c1 = XOrigin() * b1 - YOrigin() * a1;
-
-  a2 = -Sin (mySecondAngle + RotationAngle() + M_PI / 2.); 
-  b2 = Cos (mySecondAngle + RotationAngle() + M_PI / 2.);
-  c2 = XOrigin() * b2 - YOrigin() * a2;
-#endif
 //-zov
 }