1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +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

@ -976,8 +976,18 @@ Zoom persistent selection introduces a new structure *Graphic3d_TransformPers* f
* Matrix stack utilities from *OpenGl_Utils* namespace have been moved to *OpenGl_MatrixStack* class and *OpenGl_MatrixStack.hxx* header respectively.
* *OpenGl_View* methods *Begin/EndTransformPersistence* have been removed. Please, use *Graphic3d_TransformPers::Apply()* instead to apply persistence to perspective and world-view projection matrices.
@subsection Correction of texture mapping of objects
@subsection upgrade_occt700_correction_of_texture Correction of texture mapping of objects
Interaction of texture and environment texture is fixed. Textured objects have priority over the environment mapping.
Redundant enumerations V3d_TypeOfSurface and Graphic3d_TypeOfSurface, class OpenGl_SurfaceDetailState, corresponding methods from Graphic3d_CView, OpenGl_ShaderManager, OpenGl_View, V3d_View, V3d_Viewer are deleted.
Draw command VSetTextureMode is deleted.
@section upgrade_occt710 Upgrade to OCCT 7.1.0
@subsection upgrade_occt710_correction_of_Parab2d Correction in gp_Parab2d, gce_MakeParab2d and GCE2d_MakeParabola classes
1. Constructors GCE2d_MakeParabola(const gp_Ax22d& D, const gp_Pnt2d& F), gce_MakeParab2d(const gp_Ax22d& D, const gp_Pnt2d& F) and gp_Parab2d(const gp_Ax22d& D, const gp_Pnt2d& F) have been deleted.
2. Objects created with some constructors of gp_Parab2d class may be differ from previous version. Please see updated documentation for gp_Parab2d class (file gp_Parab2d.hxx).
3. Result returned by gp_Parab2d::Directrix() method has another direction in compare with previous OCCT-version.

View File

@ -51,14 +51,6 @@ GCE2d_MakeParabola::GCE2d_MakeParabola(const gp_Ax22d& Axis ,
}
}
GCE2d_MakeParabola::GCE2d_MakeParabola(const gp_Ax22d& Axis ,
const gp_Pnt2d& F )
{
TheError = gce_Done;
gp_Parab2d para(Axis,F);
TheParabola = new Geom2d_Parabola(para);
}
GCE2d_MakeParabola::GCE2d_MakeParabola(const gp_Ax2d& D ,
const gp_Pnt2d& F ,
const Standard_Boolean Sense )

View File

@ -70,11 +70,6 @@ public:
//! Status is "NegativeFocusLength" if Focal < 0.0
Standard_EXPORT GCE2d_MakeParabola(const gp_Ax2d& MirrorAxis, const Standard_Real Focal, const Standard_Boolean Sense);
//! Creates a parabola with the local coordinate system and the focus point.
//! The sense of parametrization is given by Sense.
Standard_EXPORT GCE2d_MakeParabola(const gp_Ax22d& D, const gp_Pnt2d& F);
//! D is the directrix of the parabola and F the focus point.
//! The symmetry axis "XAxis" of the parabola is normal to the
//! directrix and pass through the focus point F, but its

View File

@ -1709,6 +1709,272 @@ static Standard_Integer OCC27466(Draw_Interpretor& theDI,
return 0;
}
#include <GCE2d_MakeParabola.hxx>
#include <gp_Ax22d.hxx>
#include <Geom2d_Parabola.hxx>
#include <gp_Parab2d.hxx>
namespace Parab2d_Bug26747
{
//Directrix and X-axe direction
gp_Ax2d Axes;
//Focus
gp_Pnt2d FocusPoint;
//Focal length
Standard_Real FocalLength;
//Coordiantes of the vertex
Standard_Real VertX, VertY;
//Parameter
Standard_Real Parameter;
//Coefficients
Standard_Real Coeffs[6];
}
//========================================================================
//function : OCC26747_CheckParabola
//purpose : Checks if created parabola is correct
//========================================================================
static void OCC26747_CheckParabola(Draw_Interpretor& theDI,
const char *theName,
const Standard_Boolean theSense = Standard_True)
{
const Standard_Real aCompareTol = 1.0e-12;
// Directrix, Focus
GCE2d_MakeParabola aPrb(Parab2d_Bug26747::Axes, Parab2d_Bug26747::FocusPoint, theSense);
DrawTrSurf::Set(theName, aPrb.Value());
gp_Pnt2d aVert(aPrb.Value()->Parab2d().Location());
theDI << "Focal Length: " << aPrb.Value()->Parab2d().Focal() << "\n";
theDI << "Vertex (" << aVert.X() << ", " << aVert.Y() << ")\n";
theDI << "Parameter = " << aPrb.Value()->Parab2d().Parameter() << "\n";
Standard_Real aF[6] = {RealLast(), RealLast(), RealLast(),
RealLast(), RealLast(), RealLast()};
aPrb.Value()->Parab2d().Coefficients(aF[0], aF[1], aF[2], aF[3], aF[4], aF[5]);
theDI << "A = " << aF[0] << ", B = " << aF[1] << ", C = " << aF[2] <<
", D = " << aF[3] << ", E = " << aF[4] << ", F = " << aF[5] << "\n";
if(Abs(aPrb.Value()->Parab2d().Focal() -
Parab2d_Bug26747::FocalLength) > aCompareTol)
theDI << "Error in focal length computation!\n";
if( (Abs(aVert.X() - Parab2d_Bug26747::VertX) > aCompareTol) ||
(Abs(aVert.Y() - Parab2d_Bug26747::VertY) > aCompareTol))
theDI << "Error in vertex computation!\n";
if(Abs(aPrb.Value()->Parab2d().Parameter() -
Parab2d_Bug26747::Parameter) > aCompareTol)
theDI << "Error in parameter computation!\n";
for(int i = 0; i < 6; i++)
{
if(Abs(aF[i] - Parab2d_Bug26747::Coeffs[i]) > aCompareTol)
{
theDI << "Error in " << i << "-th coefficient computation!\n";
}
}
}
//========================================================================
//function : OCC26747_1
//purpose : Creates a 2D-parabola for testing
//========================================================================
static Standard_Integer OCC26747_1(Draw_Interpretor& theDI,
Standard_Integer theNArg,
const char ** theArgVal)
{
if(theNArg < 2)
{
theDI << "Use: OCC26747_1 result\n";
return 1;
}
//Expected parabola:
// ^ Y
// |
// |
// |
// |
// | o
// | A o F
// | o x
// | o
// | o
// |
// ---------------------------> X
// where
// Y-axe is the directrix of the parabola,
// A(0.5, 3.0) is a Vertex of the parabola,
// F(1.0, 3.0) is the focus of the parabola,
// Focal length is 0.5,
// Parameter of the parabola is 1.
// Equation: (y-3)^2=2*p*(x-0.5), i.e. (y-3)^2=2*(x-0.5)
// A * X^2 + B * Y^2 + 2*C*X*Y + 2*D*X + 2*E*Y + F = 0.
// OR
// 0 * X^2 + 1 * Y^2 + 2*0*X*Y + 2*(-1)*X + 2*(-3)*Y + 10 = 0.
Parab2d_Bug26747::Axes = gp_Ax2d(gp_Pnt2d(0.0, 3.0), gp_Dir2d(0.0, 1.0));
Parab2d_Bug26747::FocusPoint.SetCoord(1.0, 3.0);
Parab2d_Bug26747::FocalLength = 0.5;
Parab2d_Bug26747::VertX = 0.5;
Parab2d_Bug26747::VertY = 3.0;
Parab2d_Bug26747::Parameter = 1.0;
Parab2d_Bug26747::Coeffs[0] = 0.0;
Parab2d_Bug26747::Coeffs[1] = 1.0;
Parab2d_Bug26747::Coeffs[2] = 0.0;
Parab2d_Bug26747::Coeffs[3] = -1.0;
Parab2d_Bug26747::Coeffs[4] = -3.0;
Parab2d_Bug26747::Coeffs[5] = 10.0;
OCC26747_CheckParabola(theDI, theArgVal[1]);
return 0;
}
//=======================================================================
//function : OCC26747_2
//purpose : Creates a 2D-parabola for testing
//=======================================================================
static Standard_Integer OCC26747_2(Draw_Interpretor& theDI,
Standard_Integer theNArg,
const char ** theArgVal)
{
if(theNArg < 2)
{
theDI << "Use: OCC26747_2 result\n";
return 1;
}
//Expected parabola:
// ^ Y
// |
// o |
// o |
// F x o A |
// o |
// o |
// |
// <------------------------
// X
// where (in UCS - User Coordinate System, - which
// is shown in the picture):
// Y-axe is the directrix of the parabola,
// A(0.5, 3.0) is a Vertex of the parabola,
// F(1.0, 3.0) is the focus of the parabola.
//
// In WCS (World Coordinate System) these points have coordinates:
// A(-0.5, 3.0), F(-1.0, 3.0).
//
// Focal length is 0.5,
// Parameter of the parabola is 1.
// Equation (in WCS): (y-3)^2=2*p*(-x-0.5), i.e. (y-3)^2=2*(-x-0.5)
// A * X^2 + B * (Y^2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
// 0 * X^2 + 1 * (Y^2) + 2*0*(X*Y) + 2*1*X + 2*(-3)*Y + 10 = 0.
Parab2d_Bug26747::Axes = gp_Ax2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(0.0, 1.0));
Parab2d_Bug26747::FocusPoint.SetCoord(-1.0, 3.0);
Parab2d_Bug26747::FocalLength = 0.5;
Parab2d_Bug26747::VertX = -0.5;
Parab2d_Bug26747::VertY = 3.0;
Parab2d_Bug26747::Parameter = 1.0;
Parab2d_Bug26747::Coeffs[0] = 0.0;
Parab2d_Bug26747::Coeffs[1] = 1.0;
Parab2d_Bug26747::Coeffs[2] = 0.0;
Parab2d_Bug26747::Coeffs[3] = 1.0;
Parab2d_Bug26747::Coeffs[4] = -3.0;
Parab2d_Bug26747::Coeffs[5] = 10.0;
OCC26747_CheckParabola(theDI, theArgVal[1], Standard_False);
return 0;
}
//=======================================================================
//function : OCC26747_3
//purpose : Creates a 2D-parabola for testing
//=======================================================================
static Standard_Integer OCC26747_3(Draw_Interpretor& theDI,
Standard_Integer theNArg,
const char ** theArgVal)
{
if(theNArg < 2)
{
theDI << "Use: OCC26747_2 result\n";
return 1;
}
//Expected parabola:
// ^ Y
// |
// o |
// o |
// F x o A
// o |
// o |
// |
// <------------------
// X
// where (in UCS - User Coordinate System, - which
// is shown in the picture):
// Y-axe is the directrix of the parabola,
// A(0.0, 3.0) is a Vertex of the parabola,
// F(0.0, 3.0) is the focus of the parabola (the Focus
// matches with the Apex).
//
// In WCS (World Coordinate System) these points have coordinates:
// A(0.0, 3.0), F(0.0, 3.0).
//
// Focal length is 0.0,
// Parameter of the parabola is 0.0.
// Equation (in WCS): (y-3)^2=2*p*(-x-0.0), i.e. (y-3)^2=0 (looks like a line y=3)
// A * X^2 + B * (Y^2) + 2*C*(X*Y) + 2*D*X + 2*E*Y + F = 0.
// 0 * X^2 + 1 * (Y^2) + 2*0*(X*Y) + 2*0*X + 2*(-3)*Y + 9 = 0.
Parab2d_Bug26747::Axes = gp_Ax2d(gp_Pnt2d(0.0, 0.0), gp_Dir2d(0.0, 1.0));
Parab2d_Bug26747::FocusPoint.SetCoord(0.0, 3.0);
Parab2d_Bug26747::FocalLength = 0.0;
Parab2d_Bug26747::VertX = 0.0;
Parab2d_Bug26747::VertY = 3.0;
Parab2d_Bug26747::Parameter = 0.0;
Parab2d_Bug26747::Coeffs[0] = 0.0;
Parab2d_Bug26747::Coeffs[1] = 1.0;
Parab2d_Bug26747::Coeffs[2] = 0.0;
Parab2d_Bug26747::Coeffs[3] = 0.0;
Parab2d_Bug26747::Coeffs[4] = -3.0;
Parab2d_Bug26747::Coeffs[5] = 9.0;
OCC26747_CheckParabola(theDI, theArgVal[1], Standard_False);
return 0;
}
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
@ -1721,6 +1987,9 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
theCommands.Add("OCC27341",
"OCC27341 res shape axo/top/bottom/front/back/left/right",
__FILE__, OCC27341, group);
theCommands.Add ("OCC26747_1", "OCC26747_1 result", __FILE__, OCC26747_1, group);
theCommands.Add ("OCC26747_2", "OCC26747_2 result", __FILE__, OCC26747_2, group);
theCommands.Add ("OCC26747_3", "OCC26747_3 result", __FILE__, OCC26747_3, group);
return;
}

View File

@ -52,13 +52,6 @@ gce_MakeParab2d::gce_MakeParab2d(const gp_Ax2d& D ,
TheError = gce_Done;
}
gce_MakeParab2d::gce_MakeParab2d(const gp_Ax22d& D ,
const gp_Pnt2d& F )
{
TheParab2d = gp_Parab2d(D,F);
TheError = gce_Done;
}
//=========================================================================
// Creation d une Parabole 2d de gp de centre <Center> et de sommet +
// <S1> . +

View File

@ -82,11 +82,6 @@ public:
Standard_EXPORT gce_MakeParab2d(const gp_Ax2d& D, const gp_Pnt2d& F, const Standard_Boolean Sense = Standard_True);
//! Creates a parabola with the local coordinate system and
//! the focus point.
//! The sense of parametrization is given by Sense.
Standard_EXPORT gce_MakeParab2d(const gp_Ax22d& D, const gp_Pnt2d& F);
//! Make an Parab2d with S1 as the Focal point and Center
//! as the apex of the parabola
//! Warning

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

View File

@ -0,0 +1,17 @@
puts "========"
puts "OCC25605"
puts "========"
puts ""
#################################################
# 0026747: Some constructors of gp_Parab2d classes have not understandable interface and create wrong parabola
#################################################
pload QAcommands
OCC26747_1 result
v2d
don result
2dfit
checkview -screenshot -2d -l -path ${imagedir}/${test_image}.png

View File

@ -0,0 +1,17 @@
puts "========"
puts "OCC26747"
puts "========"
puts ""
#################################################
# 0026747: Some constructors of gp_Parab2d classes have not understandable interface and create wrong parabola
#################################################
pload QAcommands
OCC26747_2 result
v2d
don result
2dfit
checkview -screenshot -2d -l -path ${imagedir}/${test_image}.png

View File

@ -0,0 +1,17 @@
puts "========"
puts "OCC26747"
puts "========"
puts ""
#################################################
# 0026747: Some constructors of gp_Parab2d classes have not understandable interface and create wrong parabola
#################################################
pload QAcommands
OCC26747_3 result
v2d
don result
2dfit
checkview -screenshot -2d -l -path ${imagedir}/${test_image}.png