diff --git a/src/BndLib/BndLib.cxx b/src/BndLib/BndLib.cxx index 43062f10c3..5359b31234 100644 --- a/src/BndLib/BndLib.cxx +++ b/src/BndLib/BndLib.cxx @@ -12,17 +12,180 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include // BUG BUG BUG pas .hxx +#include #include #include #include #include #include -#include #include #include +namespace +{ + //! Compute method + template + void Compute (const Standard_Real theP1, const Standard_Real theP2, + const Standard_Real theRa ,const Standard_Real theRb, + const PointType& theXd, const PointType& theYd, const PointType& theO, + BndBoxType& theB) + { + Standard_Real aTeta1; + Standard_Real aTeta2; + if(theP2 < theP1) + { + aTeta1 = theP2; + aTeta2 = theP1; + } + else + { + aTeta1 = theP1; + aTeta2 = theP2; + } + + Standard_Real aDelta = Abs(aTeta2-aTeta1); + if(aDelta > 2. * M_PI) + { + aTeta1 = 0.; + aTeta2 = 2. * M_PI; + } + else + { + if(aTeta1 < 0.) + { + do{ aTeta1 += 2.*M_PI; } while (aTeta1 < 0.); + } + else if (aTeta1 > 2.*M_PI) + { + do { aTeta1 -= 2.*M_PI; } while (aTeta1 > 2.*M_PI); + } + aTeta2 = aTeta1 + aDelta; + } + + // One places already both ends + Standard_Real aCn1, aSn1 ,aCn2, aSn2; + aCn1 = Cos(aTeta1); aSn1 = Sin(aTeta1); + aCn2 = Cos(aTeta2); aSn2 = Sin(aTeta2); + theB.Add(PointType( theO.Coord() +theRa*aCn1*theXd.Coord() +theRb*aSn1*theYd.Coord())); + theB.Add(PointType(theO.Coord() +theRa*aCn2*theXd.Coord() +theRb*aSn2*theYd.Coord())); + + Standard_Real aRam, aRbm; + if (aDelta > M_PI/8.) + { + // Main radiuses to take into account only 8 points (/cos(Pi/8.)) + aRam = theRa/0.92387953251128674; + aRbm = theRb/0.92387953251128674; + } + else + { + // Main radiuses to take into account the arrow + Standard_Real aTc = cos(aDelta/2); + aRam = theRa/aTc; + aRbm = theRb/aTc; + } + theB.Add(PointType(theO.Coord() + aRam*aCn1*theXd.Coord() + aRbm*aSn1*theYd.Coord())); + theB.Add(PointType(theO.Coord() + aRam*aCn2*theXd.Coord() + aRbm*aSn2*theYd.Coord())); + +// cos or sin M_PI/4. +#define PI4 0.70710678118654746 + +// 8 points of the polygon +#define addPoint0 theB.Add(PointType(theO.Coord() +aRam*theXd.Coord())) +#define addPoint1 theB.Add(PointType(theO.Coord() +aRam*PI4*theXd.Coord() +aRbm*PI4*theYd.Coord())) +#define addPoint2 theB.Add(PointType(theO.Coord() +aRbm*theYd.Coord())) +#define addPoint3 theB.Add(PointType(theO.Coord() -aRam*PI4*theXd.Coord() +aRbm*PI4*theYd.Coord())) +#define addPoint4 theB.Add(PointType(theO.Coord() -aRam*theXd.Coord() )) +#define addPoint5 theB.Add(PointType(theO.Coord() -aRam*PI4*theXd.Coord() -aRbm*PI4*theYd.Coord())) +#define addPoint6 theB.Add(PointType(theO.Coord() -aRbm*theYd.Coord())) +#define addPoint7 theB.Add(PointType(theO.Coord() +aRam*PI4*theXd.Coord() -aRbm*PI4*theYd.Coord())) + + Standard_Integer aDeb = (Standard_Integer )( aTeta1/(M_PI/4.)); + Standard_Integer aFin = (Standard_Integer )( aTeta2/(M_PI/4.)); + aDeb++; + + if (aDeb > aFin) return; + + switch (aDeb) + { + case 1: + { + addPoint1; + if (aFin <= 1) break; + } + case 2: + { + addPoint2; + if (aFin <= 2) break; + } + case 3: + { + addPoint3; + if (aFin <= 3) break; + } + case 4: + { + addPoint4; + if (aFin <= 4) break; + } + case 5: + { + addPoint5; + if (aFin <= 5) break; + } + case 6: + { + addPoint6; + if (aFin <= 6) break; + } + case 7: + { + addPoint7; + if (aFin <= 7) break; + } + case 8: + { + addPoint0; + if (aFin <= 8) break; + } + case 9: + { + addPoint1; + if (aFin <= 9) break; + } + case 10: + { + addPoint2; + if (aFin <= 10) break; + } + case 11: + { + addPoint3; + if (aFin <= 11) break; + } + case 12: + { + addPoint4; + if (aFin <= 12) break; + } + case 13: + { + addPoint5; + if (aFin <= 13) break; + } + case 14: + { + addPoint6; + if (aFin <= 14) break; + } + case 15: + { + addPoint7; + if (aFin <= 15) break; + } + } + } +} // end namespace static void OpenMin(const gp_Dir& V,Bnd_Box& B) { gp_Dir OX(1.,0.,0.); @@ -220,8 +383,8 @@ void BndLib::Add( const gp_Circ& C,const Standard_Real P1, const Standard_Real P2, const Standard_Real Tol, Bnd_Box& B) { - Compute(P1,P2,C.Radius(),C.Radius(),C.XAxis().Direction().XYZ(), - C.YAxis().Direction().XYZ(),C.Location().XYZ(),B); + Compute(P1,P2,C.Radius(),C.Radius(),gp_Pnt(C.XAxis().Direction().XYZ()), + gp_Pnt(C.YAxis().Direction().XYZ()),C.Location(),B); B.Enlarge(Tol); } @@ -242,8 +405,8 @@ void BndLib::Add(const gp_Circ2d& C,const Standard_Real P1, const Standard_Real P2, const Standard_Real Tol, Bnd_Box2d& B) { - Compute(P1,P2,C.Radius(),C.Radius(),C.XAxis().Direction().XY(), - C.YAxis().Direction().XY(),C.Location().XY(),B); + Compute(P1,P2,C.Radius(),C.Radius(),gp_Pnt2d(C.XAxis().Direction().XY()), + gp_Pnt2d(C.YAxis().Direction().XY()),C.Location(),B); B.Enlarge(Tol); } @@ -265,8 +428,8 @@ void BndLib::Add( const gp_Elips& C,const Standard_Real P1, const Standard_Real P2, const Standard_Real Tol, Bnd_Box& B) { - Compute(P1,P2,C.MajorRadius(),C.MinorRadius(),C.XAxis().Direction().XYZ(), - C.YAxis().Direction().XYZ(),C.Location().XYZ(),B); + Compute(P1,P2,C.MajorRadius(),C.MinorRadius(),gp_Pnt(C.XAxis().Direction().XYZ()), + gp_Pnt(C.YAxis().Direction().XYZ()),C.Location(),B); B.Enlarge(Tol); } @@ -289,8 +452,8 @@ void BndLib::Add( const gp_Elips2d& C,const Standard_Real P1, const Standard_Real Tol, Bnd_Box2d& B) { Compute(P1,P2,C.MajorRadius(),C.MinorRadius(), - C.XAxis().Direction().XY(), - C.YAxis().Direction().XY(),C.Location().XY(),B); + gp_Pnt2d(C.XAxis().Direction().XY()), + gp_Pnt2d(C.YAxis().Direction().XY()),C.Location(),B); B.Enlarge(Tol); } @@ -483,9 +646,9 @@ void BndLib::Add( const gp_Cylinder& S,const Standard_Real UMin, } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + VMax*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + VMax*S.Axis().Direction().XYZ()),B); OpenMin(S.Axis().Direction(),B); } } @@ -498,18 +661,18 @@ void BndLib::Add( const gp_Cylinder& S,const Standard_Real UMin, } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + VMax*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + VMax*S.Axis().Direction().XYZ()),B); OpenMax(S.Axis().Direction(),B); } } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + VMin*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + VMin*S.Axis().Direction().XYZ()),B); if (Precision::IsNegativeInfinite(VMax)) { OpenMin(S.Axis().Direction(),B); } @@ -518,9 +681,9 @@ void BndLib::Add( const gp_Cylinder& S,const Standard_Real UMin, } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + VMax*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + VMax*S.Axis().Direction().XYZ()),B); } } @@ -550,10 +713,10 @@ void BndLib::Add(const gp_Cone& S,const Standard_Real UMin, } else { Compute(UMin,UMax,R+VMax*Sin(A),R+VMax*Sin(A), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + - VMax*Cos(A)*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + + VMax*Cos(A)*S.Axis().Direction().XYZ()),B); gp_Dir D(Cos(A)*S.Axis().Direction()); OpenMin(D,B); } @@ -569,10 +732,10 @@ void BndLib::Add(const gp_Cone& S,const Standard_Real UMin, } else { Compute(UMin,UMax,R+VMax*Sin(A),R+VMax*Sin(A), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + - VMax*Cos(A)*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + + VMax*Cos(A)*S.Axis().Direction().XYZ()),B); gp_Dir D(Cos(A)*S.Axis().Direction()); OpenMax(D,B); } @@ -580,10 +743,10 @@ void BndLib::Add(const gp_Cone& S,const Standard_Real UMin, } else { Compute(UMin,UMax,R+VMin*Sin(A),R+VMin*Sin(A), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + - VMin*Cos(A)*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + + VMin*Cos(A)*S.Axis().Direction().XYZ()),B); if (Precision::IsNegativeInfinite(VMax)) { gp_Dir D(Cos(A)*S.Axis().Direction()); OpenMin(D,B); @@ -594,10 +757,10 @@ void BndLib::Add(const gp_Cone& S,const Standard_Real UMin, } else { Compute(UMin,UMax,R+VMax*Sin(A),R+VMax*Sin(A), - S.XAxis().Direction().XYZ(), - S.YAxis().Direction().XYZ(), - S.Location().XYZ() + - VMax*Cos(A)*S.Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()), + gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() + + VMax*Cos(A)*S.Axis().Direction().XYZ()),B); } } @@ -630,28 +793,28 @@ void BndLib::Add(const gp_Sphere& S,const Standard_Real UMin, if (-Fi1>Precision::Angular()) { if (-Fi2>Precision::Angular()) { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + S.Location(),B); Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ()- S.Radius()*S.Position().Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ()- S.Radius()*S.Position().Axis().Direction().XYZ()),B); } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ()+ S.Radius()*S.Position().Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ()+ S.Radius()*S.Position().Axis().Direction().XYZ()),B); Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ()- S.Radius()*S.Position().Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ()- S.Radius()*S.Position().Axis().Direction().XYZ()),B); } } else { Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + S.Location(),B); Compute(UMin,UMax,S.Radius(),S.Radius(), - S.XAxis().Direction().XYZ(),S.YAxis().Direction().XYZ(), - S.Location().XYZ() +S.Radius()*S.Position().Axis().Direction().XYZ(),B); + gp_Pnt(S.XAxis().Direction().XYZ()),gp_Pnt(S.YAxis().Direction().XYZ()), + gp_Pnt(S.Location().XYZ() +S.Radius()*S.Position().Axis().Direction().XYZ()),B); } B.Enlarge(Tol); #else @@ -732,14 +895,14 @@ void BndLib::Add(const gp_Torus& S,const Standard_Real UMin, if (Fi2 -#include - -void Compute(const Standard_Real P1, - const Standard_Real P2, - const Standard_Real Ra, - const Standard_Real Rb, - const Coord& Xd, - const Coord& Yd, - const Coord& O, - Bound& B) { - - Standard_Real Teta1; - Standard_Real Teta2; - if (P2 2. * M_PI) { - Teta1 = 0.; - Teta2 = 2. * M_PI; - } - else { - - if (Teta1 < 0.) { - do { Teta1+=2.*M_PI;} while (Teta1< 0.); - } - else if (Teta1> 2.*M_PI) { - do { Teta1-=2.*M_PI;} while (Teta1> 2.*M_PI); - } - Teta2 = Teta1 + Delta; - - } - -// One places already both ends - Standard_Real Cn1,Sn1,Cn2,Sn2; - Cn1 = Cos(Teta1); Sn1 = Sin(Teta1); - Cn2 = Cos(Teta2); Sn2 = Sin(Teta2); - B.Add(Point(O +Ra*Cn1*Xd +Rb*Sn1*Yd)); - B.Add(Point(O +Ra*Cn2*Xd +Rb*Sn2*Yd)); - - Standard_Real Ram,Rbm; - if (Delta > M_PI/8.) { - // Main radiuses to take into account only 8 points (/cos(Pi/8.)) - Ram=Ra/0.92387953251128674; - Rbm=Rb/0.92387953251128674; - } - else { - // Main radiuses to take into account the arrow - Standard_Real tc=cos(Delta/2); - Ram=Ra/tc; - Rbm=Rb/tc; - } - B.Add(Point(O +Ram*Cn1*Xd +Rbm*Sn1*Yd)); - B.Add(Point(O +Ram*Cn2*Xd +Rbm*Sn2*Yd)); - - -// cos or sin M_PI/4. -#define PI4 0.70710678118654746 - -// 8 points of the polygon -#define addP0 B.Add(Point(O +Ram*Xd )) -#define addP1 B.Add(Point(O +Ram*PI4*Xd +Rbm*PI4*Yd)) -#define addP2 B.Add(Point(O +Rbm*Yd)) -#define addP3 B.Add(Point(O -Ram*PI4*Xd +Rbm*PI4*Yd)) -#define addP4 B.Add(Point(O -Ram*Xd )) -#define addP5 B.Add(Point(O -Ram*PI4*Xd -Rbm*PI4*Yd)) -#define addP6 B.Add(Point(O -Rbm*Yd)); -#define addP7 B.Add(Point(O +Ram*PI4*Xd -Rbm*PI4*Yd)) - - Standard_Integer deb = (Standard_Integer )( Teta1/(M_PI/4.)); - Standard_Integer fin = (Standard_Integer )( Teta2/(M_PI/4.)); - deb++; - - if (deb>fin) return; - - switch (deb) { - case 1 : - { - addP1; - if (fin <= 1) break; - } - case 2 : - { - addP2; - if (fin <= 2) break; - } - case 3 : - { - addP3; - if (fin <= 3) break; - } - case 4 : - { - addP4; - if (fin <= 4) break; - } - case 5 : - { - addP5; - if (fin <= 5) break; - } - case 6 : - { - addP6; - if (fin <= 6) break; - } - case 7 : - { - addP7; - if (fin <= 7) break; - } - case 8 : - { - addP0; - if (fin <= 8) break; - } - case 9 : - { - addP1; - if (fin <= 9) break; - } - case 10 : - { - addP2; - if (fin <= 10) break; - } - case 11: - { - addP3; - if (fin <= 11) break; - } - case 12: - { - addP4; - if (fin <= 12) break; - } - case 13: - { - addP5; - if (fin <= 13) break; - } - case 14: - { - addP6; - if (fin <= 14) break; - } - case 15: - { - addP7; - if (fin <= 15) break; - } - } -} - diff --git a/src/BndLib/BndLib_Compute.hxx b/src/BndLib/BndLib_Compute.hxx deleted file mode 100644 index b5e6872d82..0000000000 --- a/src/BndLib/BndLib_Compute.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// 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 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. - -void Compute(const Standard_Real P1,const Standard_Real P2, -const Standard_Real Ra,const Standard_Real Rb,const gp_XY& Xd,const gp_XY& Yd, -const gp_XY& O,Bnd_Box2d& B) ; - -void Compute(const Standard_Real P1,const Standard_Real P2, -const Standard_Real Ra,const Standard_Real Rb,const gp_XYZ& Xd,const gp_XYZ& Yd, -const gp_XYZ& O,Bnd_Box& B) ; diff --git a/src/BndLib/BndLib_Compute2d.cxx b/src/BndLib/BndLib_Compute2d.cxx deleted file mode 100644 index 9488cb9f85..0000000000 --- a/src/BndLib/BndLib_Compute2d.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// 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 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. - -#include -#include -#include -#define Coord gp_XY -#define Point gp_Pnt2d -#define Bound Bnd_Box2d -#include -#undef Coord -#undef Point -#undef Bound - diff --git a/src/BndLib/BndLib_Compute3d.cxx b/src/BndLib/BndLib_Compute3d.cxx deleted file mode 100644 index 99f2242136..0000000000 --- a/src/BndLib/BndLib_Compute3d.cxx +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// 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 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. - -#include -#include -#include -#define Coord gp_XYZ -#define Point gp_Pnt -#define Bound Bnd_Box -#include -#undef Coord -#undef Point -#undef Bound diff --git a/src/BndLib/FILES b/src/BndLib/FILES deleted file mode 100755 index a106cbef49..0000000000 --- a/src/BndLib/FILES +++ /dev/null @@ -1,4 +0,0 @@ -BndLib_Compute2d.cxx -BndLib_Compute3d.cxx -BndLib_Compute.hxx -BndLib_Compute.gxx