1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026747: Some constructors of gp_Parab2d class contain redundant parameters

1. Useless constructors have been deleted.
2. Value returned by gp_Parab2d::Directrix() method has been corrected to exclude reversing the directrix.
3. Documentation of gp_Parab2d class has been updated (in hxx-file).
4. Upgrade Guide has been updated according to corrections made in this issue.

Creation of test cases for this issue.
This commit is contained in:
nbv
2016-04-11 11:12:45 +03:00
committed by bugmaster
parent 91d9637224
commit c1609fbea6
12 changed files with 397 additions and 94 deletions

View File

@@ -23,40 +23,25 @@
#include <gp_Vec2d.hxx>
#include <Standard_ConstructionError.hxx>
gp_Parab2d::gp_Parab2d (const gp_Ax22d& D,
const gp_Pnt2d& F)
gp_Parab2d::gp_Parab2d (const gp_Ax2d& theDirectrix,
const gp_Pnt2d& theFocus,
const Standard_Boolean theSense)
{
gp_XY DCoord = D.XDirection().XY();
gp_XY GCoord = D.YDirection().XY();
gp_XY PCoord = D.Location().XY();
gp_XY MCoord = F.XY();
focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord));
if (focalLength < 0) focalLength = - focalLength;
gp_XY N = GCoord;
N.Multiply (focalLength);
MCoord.Add (N);
N.Reverse();
pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N));
focalLength = focalLength / 2.0;
}
const gp_Pnt2d &aDirLoc = theDirectrix.Location();
const gp_Dir2d &aDirVec = theDirectrix.Direction();
gp_Parab2d::gp_Parab2d (const gp_Ax2d& D,
const gp_Pnt2d& F,
const Standard_Boolean Sense)
{
gp_XY DCoord = D.Direction().XY();
gp_XY PCoord = D.Location().XY();
gp_XY MCoord = F.XY();
focalLength = DCoord.Dot ( MCoord.Subtracted (PCoord));
if (focalLength < 0) focalLength = - focalLength;
gp_XY N;
if (Sense) N.SetCoord(DCoord.Y(), -DCoord.X());
else N.SetCoord(-DCoord.Y(), DCoord.X());
N.Multiply (focalLength);
MCoord.Add (N);
N.Reverse();
pos = gp_Ax22d (gp_Pnt2d (MCoord), gp_Dir2d (N),Sense);
focalLength = focalLength / 2.0;
const gp_Vec2d aFVec(aDirLoc, theFocus);
const gp_Pnt2d anOrigin(aDirLoc.XY()+aDirVec.XY()*(aFVec.Dot(aDirVec)));
const gp_Pnt2d anApex(0.5*(anOrigin.XY()+theFocus.XY()));
focalLength = 0.5*anOrigin.Distance(theFocus);
gp_Dir2d aXDir = (focalLength > 0.0) ? gp_Dir2d(theFocus.XY()-anOrigin.XY()) :
theDirectrix.Rotated(aDirLoc,
theSense ? -M_PI_2 : M_PI_2).Direction();
pos = gp_Ax22d(anApex, aXDir, aDirVec);
}
void gp_Parab2d::Coefficients

View File

@@ -62,35 +62,45 @@ public:
//! Creates an indefinite parabola.
gp_Parab2d();
gp_Parab2d();
//! Creates a parabola with its vertex point, its axis of symmetry
//! ("XAxis") and its focal length.
//! The sense of parametrization is given by Sense.
//! Warnings : It is possible to have Focal = 0.
//! Raises ConstructionError if Focal < 0.0
gp_Parab2d(const gp_Ax2d& MirrorAxis, const Standard_Real Focal, const Standard_Boolean Sense = Standard_True);
//! The sense of parametrization is given by theSense. If theSense == TRUE
//! (by default) then right-handed coordinate system is used,
//! otherwise - left-handed.
//! Warnings : It is possible to have FocalLength = 0. In this case,
//! the parabola looks like a line, which is parallel to the symmetry-axis.
//! Raises ConstructionError if FocalLength < 0.0
gp_Parab2d(const gp_Ax2d& theMirrorAxis,
const Standard_Real theFocalLength,
const Standard_Boolean theSense = Standard_True);
//! Creates a parabola with its vertex point, its axis of symmetry
//! ("XAxis") and its focal length.
//! The sense of parametrization is given by A.
//! Warnings : It is possible to have Focal = 0.
//! ("XAxis"), correspond Y-axis and its focal length.
//! Warnings : It is possible to have FocalLength = 0. In this case,
//! the parabola looks like a line, which is parallel to the symmetry-axis.
//! Raises ConstructionError if Focal < 0.0
gp_Parab2d(const gp_Ax22d& A, const Standard_Real Focal);
gp_Parab2d(const gp_Ax22d& theAxes, const Standard_Real theFocalLength);
//! Creates a parabola with the directrix and the focus point.
//! The sense of parametrization is given by Sense.
Standard_EXPORT gp_Parab2d(const gp_Ax2d& D, const gp_Pnt2d& F, const Standard_Boolean Sense = Standard_True);
//! Y-axis of the parabola (in User Coordinate System - UCS) is
//! the direction of theDirectrix. X-axis always directs from theDirectrix
//! to theFocus point and always comes through theFocus.
//! Apex of the parabola is a middle point between the theFocus and the
//! intersection point of theDirectrix and the X-axis.
//! Warnings : It is possible to have FocalLength = 0 (when theFocus lies
//! in theDirectrix). In this case, X-direction of the parabola is defined
//! by theSense parameter. If theSense == TRUE (by default) then right-handed
//! coordinate system is used, otherwise - left-handed. Result parabola will look
//! like a line, which is perpendicular to the directrix.
Standard_EXPORT gp_Parab2d(const gp_Ax2d& theDirectrix,
const gp_Pnt2d& theFocus,
const Standard_Boolean theSense = Standard_True);
//! Creates a parabola with the directrix and the focus point.
//! The Sense of parametrization is given by D.
Standard_EXPORT gp_Parab2d(const gp_Ax22d& D, const gp_Pnt2d& F);
//! Changes the focal distance of the parabola
//! Warnings : It is possible to have Focal = 0.
//! Raises ConstructionError if Focal < 0.0
@@ -114,9 +124,12 @@ public:
void SetAxis (const gp_Ax22d& A);
//! Computes the coefficients of the implicit equation of the parabola.
//! Computes the coefficients of the implicit equation of the parabola
//! (in WCS - World Coordinate System).
//! A * (X**2) + B * (Y**2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
Standard_EXPORT void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D, Standard_Real& E, Standard_Real& F) const;
Standard_EXPORT void Coefficients (Standard_Real& A, Standard_Real& B,
Standard_Real& C, Standard_Real& D,
Standard_Real& E, Standard_Real& F) const;
//! Computes the directrix of the parabola.

View File

@@ -14,23 +14,23 @@
#include <Standard_ConstructionError.hxx>
inline gp_Parab2d::gp_Parab2d () :
focalLength(RealLast())
{ }
inline gp_Parab2d::gp_Parab2d () :focalLength(RealLast()){ }
inline gp_Parab2d::gp_Parab2d (const gp_Ax22d& A,
const Standard_Real Focal) :
pos (A),
focalLength (Focal)
{ Standard_ConstructionError_Raise_if(Focal < 0.0,""); }
inline gp_Parab2d::gp_Parab2d (const gp_Ax2d& MirrorAxis,
const Standard_Real Focal,
const Standard_Boolean Sense) :
focalLength (Focal)
inline gp_Parab2d::gp_Parab2d(const gp_Ax22d& theMirrorAxis,
const Standard_Real theFocalLength) :
pos (theMirrorAxis),
focalLength (theFocalLength)
{
pos = gp_Ax22d(MirrorAxis,Sense);
Standard_ConstructionError_Raise_if(Focal < 0.0,"");
Standard_ConstructionError_Raise_if(theFocalLength < 0.0,"");
}
inline gp_Parab2d::gp_Parab2d(const gp_Ax2d& theMirrorAxis,
const Standard_Real theFocalLength,
const Standard_Boolean theSense) :
focalLength (theFocalLength)
{
pos = gp_Ax22d(theMirrorAxis,theSense);
Standard_ConstructionError_Raise_if(theFocalLength < 0.0,"");
}
inline void gp_Parab2d::SetFocal (const Standard_Real Focal)
@@ -52,8 +52,8 @@ inline gp_Ax2d gp_Parab2d::Directrix() const
{
gp_Pnt2d P (pos.Location().X() - focalLength * pos.XDirection().X(),
pos.Location().Y() - focalLength * pos.XDirection().Y() );
gp_Dir2d V (pos.YDirection().Reversed());
return gp_Ax2d (P, V);
gp_Dir2d V (pos.YDirection());
return gp_Ax2d(P, V);
}
inline Standard_Real gp_Parab2d::Focal() const