1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0026750: Method IsNormal(...) for gp_Vec2d returns FALSE if the angle between two vectors is equal to -90 degree (-M_PI/2 radian)

The bug has been fixed.
Test case for this issue has been created.

Correct alignment.
This commit is contained in:
nbv 2015-10-08 10:14:30 +03:00 committed by bugmaster
parent b400611710
commit d0fcf95a09
4 changed files with 101 additions and 56 deletions

View File

@ -4485,6 +4485,41 @@ static Standard_Integer OCC24537(
return 0; 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) { void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs"; 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 ("OCC26525", "OCC26525 result edge face ", __FILE__, OCC26525, group);
theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group); theCommands.Add ("OCC24537", "OCC24537 [file]", __FILE__, OCC24537, group);
theCommands.Add ("OCC26750", "OCC26750", __FILE__, OCC26750, group);
return; return;
} }

View File

@ -114,7 +114,7 @@ public:
//! Returns True if PI - Abs(<me>.Angle(Other)) <= AngularTolerance //! Returns True if PI - Abs(<me>.Angle(Other)) <= AngularTolerance
//! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or //! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
//! Other.Magnitude() <= Resolution from gp. //! 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 //! Returns true if Abs(Angle(<me>, Other)) <= AngularTolerance or
@ -122,7 +122,7 @@ public:
//! Two vectors with opposite directions are considered as parallel. //! Two vectors with opposite directions are considered as parallel.
//! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or //! Raises VectorWithNullMagnitude if <me>.Magnitude() <= Resolution or
//! Other.Magnitude() <= Resolution from gp //! 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> //! Computes the angular value between <me> and <Other>
@ -141,24 +141,24 @@ public:
Standard_Real SquareMagnitude() const; Standard_Real SquareMagnitude() const;
void Add (const gp_Vec2d& Other); void Add (const gp_Vec2d& Other);
void operator += (const gp_Vec2d& Other) void operator += (const gp_Vec2d& Other)
{ {
Add(Other); Add(Other);
} }
//! Adds two vectors //! Adds two vectors
gp_Vec2d Added (const gp_Vec2d& Other) const; gp_Vec2d Added (const gp_Vec2d& Other) const;
gp_Vec2d operator + (const gp_Vec2d& Other) const gp_Vec2d operator + (const gp_Vec2d& Other) const
{ {
return Added(Other); return Added(Other);
} }
//! Computes the crossing product between two vectors //! Computes the crossing product between two vectors
Standard_Real Crossed (const gp_Vec2d& Right) const; Standard_Real Crossed (const gp_Vec2d& Right) const;
Standard_Real operator ^ (const gp_Vec2d& Right) const Standard_Real operator ^ (const gp_Vec2d& Right) const
{ {
return Crossed(Right); return Crossed(Right);
} }
//! Computes the magnitude of the cross product between <me> and //! Computes the magnitude of the cross product between <me> and
@ -171,41 +171,41 @@ public:
Standard_Real CrossSquareMagnitude (const gp_Vec2d& Right) const; Standard_Real CrossSquareMagnitude (const gp_Vec2d& Right) const;
void Divide (const Standard_Real Scalar); void Divide (const Standard_Real Scalar);
void operator /= (const Standard_Real Scalar) void operator /= (const Standard_Real Scalar)
{ {
Divide(Scalar); Divide(Scalar);
} }
//! divides a vector by a scalar //! divides a vector by a scalar
gp_Vec2d Divided (const Standard_Real Scalar) const; gp_Vec2d Divided (const Standard_Real Scalar) const;
gp_Vec2d operator / (const Standard_Real Scalar) const gp_Vec2d operator / (const Standard_Real Scalar) const
{ {
return Divided(Scalar); return Divided(Scalar);
} }
//! Computes the scalar product //! Computes the scalar product
Standard_Real Dot (const gp_Vec2d& Other) const; Standard_Real Dot (const gp_Vec2d& Other) const;
Standard_Real operator * (const gp_Vec2d& Other) const Standard_Real operator * (const gp_Vec2d& Other) const
{ {
return Dot(Other); return Dot(Other);
} }
gp_Vec2d GetNormal() const; gp_Vec2d GetNormal() const;
void Multiply (const Standard_Real Scalar); void Multiply (const Standard_Real Scalar);
void operator *= (const Standard_Real Scalar) void operator *= (const Standard_Real Scalar)
{ {
Multiply(Scalar); Multiply(Scalar);
} }
//! Normalizes a vector //! Normalizes a vector
//! Raises an exception if the magnitude of the vector is //! Raises an exception if the magnitude of the vector is
//! lower or equal to Resolution from package gp. //! lower or equal to Resolution from package gp.
gp_Vec2d Multiplied (const Standard_Real Scalar) const; gp_Vec2d Multiplied (const Standard_Real Scalar) const;
gp_Vec2d operator * (const Standard_Real Scalar) const gp_Vec2d operator * (const Standard_Real Scalar) const
{ {
return Multiplied(Scalar); return Multiplied(Scalar);
} }
void Normalize(); void Normalize();
@ -219,24 +219,24 @@ public:
//! Reverses the direction of a vector //! Reverses the direction of a vector
gp_Vec2d Reversed() const; gp_Vec2d Reversed() const;
gp_Vec2d operator -() const gp_Vec2d operator -() const
{ {
return Reversed(); return Reversed();
} }
//! Subtracts two vectors //! Subtracts two vectors
void Subtract (const gp_Vec2d& Right); void Subtract (const gp_Vec2d& Right);
void operator -= (const gp_Vec2d& Right) void operator -= (const gp_Vec2d& Right)
{ {
Subtract(Right); Subtract(Right);
} }
//! Subtracts two vectors //! Subtracts two vectors
gp_Vec2d Subtracted (const gp_Vec2d& Right) const; gp_Vec2d Subtracted (const gp_Vec2d& Right) const;
gp_Vec2d operator - (const gp_Vec2d& Right) const gp_Vec2d operator - (const gp_Vec2d& Right) const
{ {
return Subtracted(Right); return Subtracted(Right);
} }
//! <me> is set to the following linear form : //! <me> is set to the following linear form :

View File

@ -70,14 +70,11 @@ inline const gp_XY& gp_Vec2d::XY () const
{ return coord; } { return coord; }
inline Standard_Boolean gp_Vec2d::IsNormal inline Standard_Boolean gp_Vec2d::IsNormal
(const gp_Vec2d& Other, (const gp_Vec2d& theOther,
const Standard_Real AngularTolerance) const const Standard_Real theAngularTolerance) const
{ {
Standard_Real Ang = Angle(Other); const Standard_Real anAng = Abs(M_PI_2 - Abs(Angle(theOther)));
if (Ang < 0) Ang = - Ang; return !(anAng > theAngularTolerance);
Ang = M_PI / 2.0 - Angle(Other);
if (Ang < 0) Ang = - Ang;
return Ang <= AngularTolerance;
} }
inline Standard_Boolean gp_Vec2d::IsOpposite inline Standard_Boolean gp_Vec2d::IsOpposite
@ -241,7 +238,7 @@ inline gp_Vec2d operator* (const Standard_Real Scalar,
{ return V.Multiplied(Scalar); } { return V.Multiplied(Scalar); }
inline gp_Vec2d gp_Vec2d::GetNormal() const inline gp_Vec2d gp_Vec2d::GetNormal() const
{ {
return gp_Vec2d(this->Y(), (-1)*this->X()); return gp_Vec2d(this->Y(), (-1)*this->X());
} }

View File

@ -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