]> OCCT Git - occt.git/commitdiff
0026750: Method IsNormal(...) for gp_Vec2d returns FALSE if the angle between two...
authornbv <nbv@opencascade.com>
Thu, 8 Oct 2015 07:14:30 +0000 (10:14 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 8 Oct 2015 07:17:03 +0000 (10:17 +0300)
The bug has been fixed.
Test case for this issue has been created.

Correct alignment.

src/QABugs/QABugs_19.cxx
src/gp/gp_Vec2d.hxx
src/gp/gp_Vec2d.lxx
tests/bugs/modalg_6/bug26750 [new file with mode: 0644]

index 414077d99220139076210e179dd5ad6ce683a853..cb83da824113be2b7d01703f32762955753b7048 100644 (file)
@@ -4485,6 +4485,41 @@ static Standard_Integer OCC24537(
   return 0;
 }
 
+//=======================================================================
+//function : OCC26750 
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC26750( Draw_Interpretor& theDI,
+                                  Standard_Integer  /*theNArg*/,
+                                  const char ** /*theArgVal*/)
+{
+  const gp_Vec2d aVec1(1.0, 0.0);
+  const gp_Vec2d aVec2(0.0, -1.0);
+
+  if(aVec1.IsNormal(aVec2, Precision::Angular()))
+  {
+    theDI << "gp_Vec2d OK. Vectors are normal.\n";
+  }
+  else
+  {
+    theDI << "Error in gp_Vec2d. Vectors should be normal.\n";
+  }
+
+  const gp_Dir2d aD1(1.0, 0.0);
+  const gp_Dir2d aD2(0.0, -1.0);
+
+  if(aD1.IsNormal(aD2, Precision::Angular()))
+  {
+    theDI << "gp_Dir2d OK. Vectors are normal.\n";
+  }
+  else
+  {
+    theDI << "Error in gp_Dir2d. Vectors should be normal.\n";
+  }
+  
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -4577,5 +4612,7 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
 
   theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
+  theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
+
   return;
 }
index 52d3ff784b68942daef2b25fd9e3f10094bd8c24..f405ceed6c0d0088cb4bab686ed224527f53fbe7 100644 (file)
@@ -114,7 +114,7 @@ public:
   //! Returns True if PI - Abs(<me>.Angle(Other)) <= AngularTolerance
   //! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
   //! Other.Magnitude() <= Resolution from gp.
-    Standard_Boolean IsOpposite (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
+  Standard_Boolean IsOpposite (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
   
 
   //! Returns true if Abs(Angle(<me>, Other)) <= AngularTolerance or
@@ -122,7 +122,7 @@ public:
   //! Two vectors with opposite directions are considered as parallel.
   //! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
   //! Other.Magnitude() <= Resolution from gp
-    Standard_Boolean IsParallel (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
+  Standard_Boolean IsParallel (const gp_Vec2d& Other, const Standard_Real AngularTolerance) const;
   
 
   //! Computes the angular value between <me> and <Other>
@@ -141,24 +141,24 @@ public:
     Standard_Real SquareMagnitude() const;
   
     void Add (const gp_Vec2d& Other);
-  void operator += (const gp_Vec2d& Other)
-{
-  Add(Other);
-}
+    void operator += (const gp_Vec2d& Other)
+    {
+      Add(Other);
+    }
   
   //! Adds two vectors
     gp_Vec2d Added (const gp_Vec2d& Other) const;
-  gp_Vec2d operator + (const gp_Vec2d& Other) const
-{
-  return Added(Other);
-}
+    gp_Vec2d operator + (const gp_Vec2d& Other) const
+    {
+      return Added(Other);
+    }
   
   //! Computes the crossing product between two vectors
     Standard_Real Crossed (const gp_Vec2d& Right) const;
-  Standard_Real operator ^ (const gp_Vec2d& Right) const
-{
-  return Crossed(Right);
-}
+    Standard_Real operator ^ (const gp_Vec2d& Right) const
+    {
+      return Crossed(Right);
+    }
   
 
   //! Computes the magnitude of the cross product between <me> and
@@ -171,41 +171,41 @@ public:
     Standard_Real CrossSquareMagnitude (const gp_Vec2d& Right) const;
   
     void Divide (const Standard_Real Scalar);
-  void operator /= (const Standard_Real Scalar)
-{
-  Divide(Scalar);
-}
+    void operator /= (const Standard_Real Scalar)
+    {
+      Divide(Scalar);
+    }
   
   //! divides a vector by a scalar
     gp_Vec2d Divided (const Standard_Real Scalar) const;
-  gp_Vec2d operator / (const Standard_Real Scalar) const
-{
-  return Divided(Scalar);
-}
+    gp_Vec2d operator / (const Standard_Real Scalar) const
+    {
+      return Divided(Scalar);
+    }
   
   //! Computes the scalar product
     Standard_Real Dot (const gp_Vec2d& Other) const;
-  Standard_Real operator * (const gp_Vec2d& Other) const
-{
-  return Dot(Other);
-}
-  
+    Standard_Real operator * (const gp_Vec2d& Other) const
+    {
+      return Dot(Other);
+    }
+
     gp_Vec2d GetNormal() const;
   
     void Multiply (const Standard_Real Scalar);
-  void operator *= (const Standard_Real Scalar)
-{
-  Multiply(Scalar);
-}
+    void operator *= (const Standard_Real Scalar)
+    {
+      Multiply(Scalar);
+    }
   
   //! Normalizes a vector
   //! Raises an exception if the magnitude of the vector is
   //! lower or equal to Resolution from package gp.
     gp_Vec2d Multiplied (const Standard_Real Scalar) const;
-  gp_Vec2d operator * (const Standard_Real Scalar) const
-{
-  return Multiplied(Scalar);
-}
+    gp_Vec2d operator * (const Standard_Real Scalar) const
+    {
+      return Multiplied(Scalar);
+    }
   
     void Normalize();
   
@@ -219,24 +219,24 @@ public:
   
   //! Reverses the direction of a vector
     gp_Vec2d Reversed() const;
-  gp_Vec2d operator -() const
-{
-  return Reversed();
-}
+    gp_Vec2d operator -() const
+    {
+      return Reversed();
+    }
   
   //! Subtracts two vectors
     void Subtract (const gp_Vec2d& Right);
-  void operator -= (const gp_Vec2d& Right)
-{
-  Subtract(Right);
-}
+    void operator -= (const gp_Vec2d& Right)
+    {
+      Subtract(Right);
+    }
   
   //! Subtracts two vectors
     gp_Vec2d Subtracted (const gp_Vec2d& Right) const;
-  gp_Vec2d operator - (const gp_Vec2d& Right) const
-{
-  return Subtracted(Right);
-}
+    gp_Vec2d operator - (const gp_Vec2d& Right) const
+    {
+      return Subtracted(Right);
+    }
   
 
   //! <me> is set to the following linear form :
index bfd29a994d268259b47270c15355549ac9454a31..e388835cd41006cb5edbc7c6fd97e39ae04afff4 100644 (file)
@@ -70,14 +70,11 @@ inline  const gp_XY& gp_Vec2d::XY () const
 { return coord; }
 
 inline Standard_Boolean gp_Vec2d::IsNormal
-(const gp_Vec2d& Other, 
- const Standard_Real AngularTolerance) const
+(const gp_Vec2d& theOther, 
+ const Standard_Real theAngularTolerance) const
 {
-  Standard_Real Ang = Angle(Other);
-  if (Ang < 0) Ang = - Ang;
-  Ang = M_PI / 2.0 - Angle(Other);
-  if (Ang < 0) Ang = - Ang;
-  return  Ang <= AngularTolerance;
+  const Standard_Real anAng = Abs(M_PI_2 - Abs(Angle(theOther)));
+  return !(anAng > theAngularTolerance);
 }    
 
 inline Standard_Boolean gp_Vec2d::IsOpposite
@@ -241,7 +238,7 @@ inline gp_Vec2d operator* (const Standard_Real Scalar,
 { return V.Multiplied(Scalar); }
 
 inline gp_Vec2d gp_Vec2d::GetNormal() const
-  {
+{
   return gp_Vec2d(this->Y(), (-1)*this->X());
-  }
+}
 
diff --git a/tests/bugs/modalg_6/bug26750 b/tests/bugs/modalg_6/bug26750
new file mode 100644 (file)
index 0000000..4486ec0
--- /dev/null
@@ -0,0 +1,11 @@
+puts "============"
+puts "OCC26750"
+puts "============"
+puts ""
+#############################################################################################
+## Method IsNormal(...) for gp_Vec2d returns FALSE if the angle between two vectors is equal to -90 degree (-M_PI/2 radian)
+#############################################################################################
+
+pload QAcommands
+
+OCC26750
\ No newline at end of file