From: jfa Date: Fri, 23 Dec 2011 14:23:54 +0000 (+0000) Subject: Porting to OCCT development version: Standard_PI -> M_PI X-Git-Tag: V6_5_0a1~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=21f352b21b086421921499bbc9b92e7c7e23ab70;p=modules%2Fgeom.git Porting to OCCT development version: Standard_PI -> M_PI --- diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx index bc74e16a4..2d001d179 100644 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx +++ b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File: BlockFix_PeriodicSurfaceModifier.cxx // Created: 15.12.04 10:08:50 // Author: Sergey KUUL -// + #include #include @@ -74,7 +73,7 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, Handle(Geom_CylindricalSurface)::DownCast(S); Standard_Real Umin, Umax, Vmin, Vmax; BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if( Umin<-Precision::PConfusion() || Umax>2*PI+Precision::PConfusion() ) { + if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { gp_Ax3 ax3 = aCyl->Position(); gp_Ax1 NDir = ax3.Axis(); gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); @@ -89,7 +88,7 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); Standard_Real Umin, Umax, Vmin, Vmax; BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if( Umin<-Precision::PConfusion() || Umax>2*PI+Precision::PConfusion() ) { + if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { gp_Ax3 ax3 = aSphere->Position(); gp_Ax1 NDir = ax3.Axis(); gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx index 2ad363b42..570e3921f 100644 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx +++ b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File: BlockFix.cxx // Created: Tue Dec 7 11:59:05 2004 // Author: Pavel DURANDIN -// + #include #include @@ -84,7 +83,7 @@ static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { Standard_Real Umin, Umax, Vmin, Vmax; ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax); - Standard_Real PI2 = PI/2.; + Standard_Real PI2 = M_PI/2.; if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); gp_Sphere sp = aSphere->Sphere(); diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx index 97eeb848c..68bc3a92a 100644 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cxx +++ b/src/GEOMAlgo/BlockFix_UnionEdges.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File: BlockFix_UnionEdges.cxx // Created: 07.12.04 15:27:30 // Author: Sergey KUUL -// + #include #include @@ -214,7 +213,7 @@ static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, lpar = -lpar; } } - if(lpar -// + #include #include @@ -432,14 +430,12 @@ void GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE, const Standard_Real aUMin, const Standard_Real aUMax) { - Standard_Real aT1, aT2, aTx, aUx, aTol, aTwoPI; + Standard_Real aT1, aT2, aTx, aUx, aTol; gp_Pnt2d aP2D; Handle(Geom_Surface) aS; Handle(Geom2d_Curve) aC2D; BRep_Builder aBB; // - aTwoPI=PI+PI; - // aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); if (!aC2D.IsNull()) { if (BRep_Tool::IsClosed(aE, aF)) { diff --git a/src/GEOMAlgo/GEOMAlgo_Tools3D.cxx b/src/GEOMAlgo/GEOMAlgo_Tools3D.cxx index a46a011df..f75e6df11 100755 --- a/src/GEOMAlgo/GEOMAlgo_Tools3D.cxx +++ b/src/GEOMAlgo/GEOMAlgo_Tools3D.cxx @@ -278,7 +278,7 @@ Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, GetApproxNormalToFaceOnEdge (aE1, theFace1, aT, aPF1, aDNF1, theContext); GetApproxNormalToFaceOnEdge (aE2, theFace2, aT, aPF2, aDNF2, theContext); // - aTwoPI=2.*PI; + aTwoPI = 2.*M_PI; gp_Vec aVBF (aPx, aPF ); gp_Vec aVBF1(aPx, aPF1); gp_Vec aVBF2(aPx, aPF2); @@ -321,7 +321,7 @@ Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, NMTTools_ListIteratorOfListOfCoupleOfShape aIt; // aAngleMin=100.; - aTwoPI=PI+PI; + aTwoPI = M_PI+M_PI; BRep_Tool::Range(theE1, aT1, aT2); aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); // Ref @@ -338,7 +338,7 @@ Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, const TopoDS_Face& aF2=TopoDS::Face(aCS.Shape2()); // if (aF2==theF1) { - aAngle=PI; + aAngle=M_PI; } else if (aF2.IsSame(theF1)) { aAngle=aTwoPI; @@ -1055,7 +1055,7 @@ Standard_Real AngleWithRef(const gp_Dir& theD1, Standard_Real aCosinus, aSinus, aBeta, aHalfPI, aScPr; gp_XYZ aXYZ; // - aHalfPI=0.5*PI; + aHalfPI=0.5*M_PI; // const gp_XYZ& aXYZ1=theD1.XYZ(); const gp_XYZ& aXYZ2=theD2.XYZ(); @@ -1068,7 +1068,7 @@ Standard_Real AngleWithRef(const gp_Dir& theD1, aBeta=aHalfPI*(1.-aCosinus); } else { - aBeta=2.*PI-aHalfPI*(3.+aCosinus); + aBeta=2.*M_PI-aHalfPI*(3.+aCosinus); } // aScPr=aXYZ.Dot(theDRef.XYZ()); diff --git a/src/GEOMAlgo/GEOMAlgo_WireSplitter.cxx b/src/GEOMAlgo/GEOMAlgo_WireSplitter.cxx index 9876cac0c..66cd6a655 100755 --- a/src/GEOMAlgo/GEOMAlgo_WireSplitter.cxx +++ b/src/GEOMAlgo/GEOMAlgo_WireSplitter.cxx @@ -18,13 +18,10 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File: GEOMAlgo_WireSplitter.cxx -// Created: // Author: Peter KURNEV -// -// + #include #include @@ -728,7 +725,7 @@ static Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, const Standard_Real aAngleOut) { - Standard_Real aTwoPi=Standard_PI+Standard_PI; + Standard_Real aTwoPi = M_PI+M_PI; Standard_Real dA, A1, A2, AIn, AOut ; AIn=aAngleIn; @@ -741,7 +738,7 @@ static AOut=AOut-aTwoPi; } - A1=AIn+Standard_PI; + A1 = AIn + M_PI; if (A1 >= aTwoPi) { A1=A1-aTwoPi; @@ -850,7 +847,7 @@ Standard_Real Angle (const gp_Dir2d& aDir2D) Standard_Real anAngle = aRefDir.Angle(aDir2D); if (anAngle < 0.) - anAngle += Standard_PI + Standard_PI; + anAngle += M_PI + M_PI; return anAngle; } diff --git a/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx index 04d9adb05..fdbfda86e 100644 --- a/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -173,7 +172,7 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const { double aD = aCI.GetD(); double anAngle = aCI.GetAngle(); - if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) ) + if ( (anAngle > 0) && (anAngle < (M_PI/2.)) ) fill.AddDA(aD, anAngle, E, F); } } @@ -215,7 +214,7 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const { double aD = aCI.GetD(); double anAngle = aCI.GetAngle(); - if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) ) + if ( (anAngle > 0) && (anAngle < (M_PI/2.)) ) fill.AddDA(aD, anAngle, E, F); } } @@ -251,7 +250,7 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const { double aD = aCI.GetD(); double anAngle = aCI.GetAngle(); - if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) ) + if ( (anAngle > 0) && (anAngle < (M_PI/2.)) ) fill.AddDA(aD, anAngle, E, F); } } @@ -293,7 +292,6 @@ Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const //======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_ChamferDriver_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); @@ -301,7 +299,6 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_ChamferDriver_Type_() static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_ChamferDriver", sizeof(GEOMImpl_ChamferDriver), diff --git a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx index f8d68462f..eecfee7ab 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1d.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1d.cxx @@ -15,761 +15,759 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : GEOMImpl_Fillet1d.cxx -// Module : GEOMImpl -// -#include "GEOMImpl_Fillet1d.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * class GEOMImpl_Fillet1d - */ - - -//======================================================================= -//function : Constructor -//purpose : -//======================================================================= -GEOMImpl_Fillet1d::GEOMImpl_Fillet1d(const TopoDS_Edge& theEdge1, - const TopoDS_Edge& theEdge2, - const gp_Pln& thePlane) -: myEdgesExchnged( Standard_False ) -{ - myPlane = new Geom_Plane(thePlane); - - BRepAdaptor_Curve aBAC1(theEdge1); - BRepAdaptor_Curve aBAC2(theEdge2); - if (aBAC1.GetType() < aBAC2.GetType()) - { // first curve must be more complicated - myEdge1 = theEdge2; - myEdge2 = theEdge1; - myEdgesExchnged = Standard_True; - } - else - { - myEdge1 = theEdge1; - myEdge2 = theEdge2; - } - - Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(myEdge1, myStart1, myEnd1); - Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(myEdge2, myStart2, myEnd2); - - myCurve1 = GeomProjLib::Curve2d(aCurve1, myStart1, myEnd1, myPlane); - myCurve2 = GeomProjLib::Curve2d(aCurve2, myStart2, myEnd2, myPlane); - - while (myCurve1->IsPeriodic() && myStart1 >= myEnd1) - myEnd1 += myCurve1->Period(); - while (myCurve2->IsPeriodic() && myStart2 >= myEnd2) - myEnd2 += myCurve2->Period(); - - if (aBAC1.GetType() == aBAC2.GetType()) - { - if (myEnd2 - myStart2 < myEnd1 - myStart1) - { // first curve must be parametrically shorter - TopoDS_Edge anEdge = myEdge1; - myEdge1 = myEdge2; - myEdge2 = anEdge; - Handle(Geom2d_Curve) aCurve = myCurve1; - myCurve1 = myCurve2; - myCurve2 = aCurve; - Standard_Real a = myStart1; - myStart1 = myStart2; - myStart2 = a; - a = myEnd1; - myEnd1 = myEnd2; - myEnd2 = a; - myEdgesExchnged = Standard_True; - } - } -} - -//======================================================================= -//function : isRadiusIntersected -//purpose : local function -//======================================================================= -static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve, - const gp_Pnt2d theStart, - const gp_Pnt2d theEnd, - const Standard_Boolean theStartConnected) -{ - const Standard_Real aTol = Precision::Confusion(); - const Standard_Real anAngTol = Precision::Angular(); - Geom2dAPI_InterCurveCurve anInter(theCurve, new Geom2d_Line(theStart, - gp_Dir2d(gp_Vec2d(theStart, theEnd))), aTol); - Standard_Integer a; - gp_Pnt2d aPoint; - for(a = anInter.NbPoints(); a > 0; a--) - { - aPoint = anInter.Point(a); - if ( aPoint.Distance(theStart) < aTol && !theStartConnected ) - return Standard_True; - if (aPoint.Distance(theEnd) < aTol * 200) - return Standard_True; - if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) - return Standard_True; - } - Handle(Geom2d_Curve) aCurve; - for(a = anInter.NbSegments(); a > 0; a--) - { - anInter.Segment(a, aCurve); - aPoint = aCurve->Value(aCurve->FirstParameter()); - if (aPoint.Distance(theStart) < aTol) - if (!theStartConnected) - return Standard_True; - if (aPoint.Distance(theEnd) < aTol) - return Standard_True; - if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) - return Standard_True; - aPoint = aCurve->Value(aCurve->LastParameter()); - if (aPoint.Distance(theStart) < aTol) - if (!theStartConnected) - return Standard_True; - if (aPoint.Distance(theEnd) < aTol) - return Standard_True; - if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) - return Standard_True; - } - return Standard_False; -} - - -//======================================================================= -//function : fillPoint -//purpose : -//======================================================================= -void GEOMImpl_Fillet1d::fillPoint(GEOMImpl_Fillet1dPoint* thePoint) -{ - gp_Pnt2d aPoint; - gp_Vec2d aVec; - const Standard_Real aTol = Precision::Confusion(); - myCurve1->D1(thePoint->GetParam(), aPoint, aVec); - if (aVec.SquareMagnitude() < aTol) - return; - - gp_Vec2d aPerp(((myStartSide)?-1:1) * aVec.Y(), ((myStartSide)?1:-1) * aVec.X()); - aPerp.Normalize(); - aPerp.Multiply(myRadius); - gp_Pnt2d aCenter = aPoint.Translated(aPerp); - thePoint->SetCenter(aCenter); - - // on the intersection point - Standard_Boolean aValid = Standard_True; - Geom2dAPI_ProjectPointOnCurve aProjInt(aPoint, myCurve2); - if (aProjInt.NbPoints() && aPoint.Distance(aProjInt.NearestPoint()) < aTol) - aValid = Standard_False; - else - aValid = !isRadiusIntersected(myCurve2, aPoint, aCenter, Standard_True); - - Geom2dAPI_ProjectPointOnCurve aProj(aCenter, myCurve2); - Standard_Integer a, aNB = aProj.NbPoints(); - for(a = aNB; a > 0; a--) - { - if (aPoint.Distance(aProj.Point(a)) < aTol) - continue; - - Standard_Boolean aValid2 = aValid; - if (aValid2) - aValid2 = !isRadiusIntersected(myCurve1, aCenter, aProj.Point(a), Standard_False); - - // checking the right parameter - Standard_Real aParam = aProj.Parameter(a); - while(myCurve2->IsPeriodic() && aParam < myStart2) - aParam += myCurve2->Period(); - - thePoint->AddValue(aProj.Distance(a) * aProj.Distance(a) - myRadius * myRadius, - (aParam >= myStart2 && aParam <= myEnd2 && aValid2)); - if (fabs(fabs(aProj.Distance(a)) - myRadius) < aTol) - thePoint->SetParam2(aParam); - } -} - -//======================================================================= -//function : fillDiff -//purpose : -//======================================================================= -void GEOMImpl_Fillet1d::fillDiff(GEOMImpl_Fillet1dPoint* thePoint, Standard_Real theDiffStep, Standard_Boolean theFront) -{ - GEOMImpl_Fillet1dPoint* aDiff = - new GEOMImpl_Fillet1dPoint(thePoint->GetParam() + (theFront?(theDiffStep):(-theDiffStep))); - fillPoint(aDiff); - if (!thePoint->ComputeDifference(aDiff)) - { - aDiff->SetParam(thePoint->GetParam() + (theFront?(-theDiffStep):(theDiffStep))); - fillPoint(aDiff); - thePoint->ComputeDifference(aDiff); - } - delete aDiff; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -Standard_Boolean GEOMImpl_Fillet1d::Perform(const Standard_Real theRadius) -{ - myDegreeOfRecursion = 0; - myResultParams.Clear(); - myResultOrientation.Clear(); - - Standard_Real aNBSteps = 100; - Geom2dAdaptor_Curve aGAC(myCurve1); - switch (aGAC.GetType()) - { - case GeomAbs_Line: - aNBSteps = 2; - break; - case GeomAbs_Circle: - aNBSteps = 4; - break; - case GeomAbs_Ellipse: - aNBSteps = 5; - break; - case GeomAbs_BezierCurve: - case GeomAbs_BSplineCurve: - aNBSteps = 2 + aGAC.Degree() * aGAC.NbPoles(); - break; - default: // unknown: maximum - aNBSteps = 100; - } - - myRadius = theRadius; - Standard_Real aParam, aStep, aDStep; - aStep = (myEnd1 - myStart1) / aNBSteps; - aDStep = aStep/1000.; - - Standard_Integer aCycle; - for(aCycle = 2, myStartSide = Standard_False; aCycle; myStartSide = !myStartSide, aCycle--) - { - GEOMImpl_Fillet1dPoint *aLeft = NULL, *aRight = NULL; - - for(aParam = myStart1 + aStep; aParam < myEnd1 || fabs(myEnd1 - aParam) < Precision::Confusion(); aParam += aStep) - { - if (!aLeft) - { - aLeft = new GEOMImpl_Fillet1dPoint(aParam - aStep); - fillPoint(aLeft); - fillDiff(aLeft, aDStep, Standard_True); - } - - aRight = new GEOMImpl_Fillet1dPoint(aParam); - fillPoint(aRight); - fillDiff(aRight, aDStep, Standard_False); - - aLeft->FilterPoints(aRight); - performNewton(aLeft, aRight); - - delete aLeft; - aLeft = aRight; - } - delete aLeft; - } - - if (myResultParams.Extent()) - return Standard_True; - - return Standard_False; -} - -//======================================================================= -//function : processPoint -//purpose : -//======================================================================= -Standard_Boolean GEOMImpl_Fillet1d::processPoint(GEOMImpl_Fillet1dPoint* theLeft, - GEOMImpl_Fillet1dPoint* theRight, - Standard_Real theParameter) -{ - if (theParameter >= theLeft->GetParam() && theParameter < theRight->GetParam()) - { - Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); - if (theParameter - theLeft->GetParam() < aDX / 100.) - { - theParameter = theLeft->GetParam() + aDX / 100.; - } - if (theRight->GetParam() - theParameter < aDX / 100.) - { - theParameter = theRight->GetParam() - aDX / 100.; - } - - // Protection on infinite loop. - myDegreeOfRecursion++; - Standard_Real diffx = 0.001 * aDX; - if (myDegreeOfRecursion > 1000) - { - diffx *= 10.0; - if (myDegreeOfRecursion > 10000) - { - diffx *= 10.0; - if (myDegreeOfRecursion > 100000) - { - return Standard_True; - } - } - } - - GEOMImpl_Fillet1dPoint* aPoint1 = theLeft->Copy(); - GEOMImpl_Fillet1dPoint* aPoint2 = new GEOMImpl_Fillet1dPoint(theParameter); - fillPoint(aPoint2); - fillDiff(aPoint2, diffx, Standard_True); - - aPoint1->FilterPoints(aPoint2); - performNewton(aPoint1, aPoint2); - aPoint2->FilterPoints(theRight); - performNewton(aPoint2, theRight); - - delete aPoint1; - delete aPoint2; - return Standard_True; - } - - return Standard_False; -} - -//======================================================================= -//function : performNewton -//purpose : -//======================================================================= -void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft, - GEOMImpl_Fillet1dPoint* theRight) -{ - Standard_Integer a; - // check the left: if this is solution store it and remove it from the list of researching points of theLeft - a = theLeft->HasSolution(myRadius); - if (a) - { - if (theLeft->IsValid(a)) - { - myResultParams.Append(theLeft->GetParam()); - myResultOrientation.Append(myStartSide); - } - return; - } - - Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); - if ( aDX < Precision::Confusion() / 1000000.) - { - a = theRight->HasSolution(myRadius); - if (a) - if (theRight->IsValid(a)) - { - myResultParams.Append(theRight->GetParam()); - myResultOrientation.Append(myStartSide); - } - return; - } - - for(a = 1; a <= theLeft->GetNBValues(); a++) - { - Standard_Integer aNear = theLeft->GetNear(a); - - Standard_Real aA = (theRight->GetDiff(aNear) - theLeft->GetDiff(a)) / aDX; - Standard_Real aB = theLeft->GetDiff(a) - aA * theLeft->GetParam(); - Standard_Real aC = theLeft->GetValue(a) - theLeft->GetDiff(a) * theLeft->GetParam() + - aA * theLeft->GetParam() * theLeft->GetParam() / 2.0; - Standard_Real aDet = aB * aB - 2.0 * aA * aC; - - if ( fabs(aDet) < gp::Resolution() ) - continue; - - if (fabs(aA) < Precision::Confusion()) - { // linear case - if (fabs(aB) > 10e-20) - { - Standard_Real aX0 = - aC / aB; // use extremum - if (aX0 > theLeft->GetParam() && aX0 < theRight->GetParam()) - processPoint(theLeft, theRight, aX0); - } - else - { - processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise - } - } - else - { - if (fabs(aB) > fabs(aDet * 1000000.)) - { // possible floating point operations accurancy errors - processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise - } - else - { - if (aDet > 0) - { // two solutions - aDet = sqrt(aDet); - Standard_Boolean aRes = processPoint(theLeft, theRight, (- aB + aDet) / aA); - if (!aRes) - aRes = processPoint(theLeft, theRight, (- aB - aDet) / aA); - if (!aRes) - processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise - } - else - { - Standard_Real aX0 = - aB / aA; // use extremum - if (aX0 > theLeft->GetParam() && aX0 < theRight->GetParam()) - processPoint(theLeft, theRight, aX0); - else - processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise - } - } - } - } -} - -//======================================================================= -//function : Result -//purpose : -//======================================================================= -TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint, - TopoDS_Edge& theEdge1, - TopoDS_Edge& theEdge2) -{ - TopoDS_Edge aResult; - gp_Pnt2d aTargetPoint2d; - Standard_Real aX, aY; - ElSLib::PlaneParameters(myPlane->Pln().Position(), thePoint, aX, aY); - aTargetPoint2d.SetCoord(aX, aY); - - // choose the nearest circle - Standard_Real aDistance, aP; - GEOMImpl_Fillet1dPoint *aNearest; - Standard_Integer a; - TColStd_ListIteratorOfListOfReal anIter(myResultParams); - for(aNearest = NULL, a = 1; anIter.More(); anIter.Next(), a++) - { - myStartSide = (myResultOrientation.Value(a)) ? Standard_True : Standard_False; - GEOMImpl_Fillet1dPoint *aPoint = new GEOMImpl_Fillet1dPoint(anIter.Value()); - fillPoint(aPoint); - if (!aPoint->HasSolution(myRadius)) - continue; - aP = fabs(aPoint->GetCenter().Distance(aTargetPoint2d) - myRadius); - if (!aNearest || aP < aDistance) - { - aNearest = aPoint; - aDistance = aP; - } - else - { - delete aPoint; - } - } - - if (!aNearest) - return aResult; - - // create circle edge - gp_Pnt aCenter = ElSLib::PlaneValue(aNearest->GetCenter().X(), - aNearest->GetCenter().Y(), - myPlane->Pln().Position()); - Handle(Geom_Circle) aCircle = - new Geom_Circle(gp_Ax2(aCenter, myPlane->Pln().Axis().Direction()), myRadius); - gp_Pnt2d aPoint2d1, aPoint2d2; - myCurve1->D0(aNearest->GetParam(), aPoint2d1); - myCurve2->D0(aNearest->GetParam2(), aPoint2d2); - gp_Pnt aPoint1 = ElSLib::PlaneValue(aPoint2d1.X(), aPoint2d1.Y(), myPlane->Pln().Position()); - gp_Pnt aPoint2 = ElSLib::PlaneValue(aPoint2d2.X(), aPoint2d2.Y(), myPlane->Pln().Position()); - - GeomAPI_ProjectPointOnCurve aProj(thePoint, aCircle); - Standard_Real aTarGetParam = aProj.LowerDistanceParameter(); - gp_Pnt aPointOnCircle = aProj.NearestPoint(); - - // Check extrema point manually, because there is a bug in Open CASCADE - // in calculation of nearest point to a circle near the parameter 0.0 - gp_Pnt p0 = ElCLib::Value(0.0, aCircle->Circ()); - if (p0.Distance(thePoint) < aPointOnCircle.Distance(thePoint)) - { - aTarGetParam = 0.0; - aPointOnCircle = p0; - } - - aProj.Perform(aPoint1); - Standard_Real aParam1 = aProj.LowerDistanceParameter(); - aProj.Perform(aPoint2); - Standard_Real aParam2 = aProj.LowerDistanceParameter(); - Standard_Boolean aIsOut = ((aParam1 < aTarGetParam && aParam2 < aTarGetParam) || - (aParam1 > aTarGetParam && aParam2 > aTarGetParam)); - if (aParam1 > aParam2) - aIsOut = !aIsOut; - BRepBuilderAPI_MakeEdge aBuilder(aCircle->Circ(), - aIsOut ? aParam2 : aParam1, - aIsOut? aParam1 : aParam2); - aResult = aBuilder.Edge(); - - // divide edges - Standard_Real aStart, anEnd; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(myEdge1, aStart, anEnd); - gp_Vec aDir; - aCurve->D1(aNearest->GetParam(), aPoint1, aDir); - - gp_Vec aCircleDir; - aCircle->D1(aParam1, aPoint1, aCircleDir); - if ((aCircleDir.Angle(aDir) > PI / 2.0) ^ aIsOut) - aStart = aNearest->GetParam(); - else - anEnd = aNearest->GetParam(); - - if (fabs(aStart - anEnd) > Precision::Confusion()) - { - //Divide edge - BRepBuilderAPI_MakeEdge aDivider1(aCurve, aStart, anEnd); - if (myEdgesExchnged) - theEdge2 = aDivider1.Edge(); - else - theEdge1 = aDivider1.Edge(); - } - - aCurve = BRep_Tool::Curve(myEdge2, aStart, anEnd); - aCurve->D1(aNearest->GetParam2(), aPoint2, aDir); - - aCircle->D1(aParam2, aPoint2, aCircleDir); - if ((aCircleDir.Angle(aDir) > PI / 2.0) ^ (!aIsOut)) - aStart = aNearest->GetParam2(); - else - anEnd = aNearest->GetParam2(); - - if (fabs(aStart - anEnd) > Precision::Confusion()) - { - BRepBuilderAPI_MakeEdge aDivider2(aCurve, aStart, anEnd); - if (myEdgesExchnged) - theEdge1 = aDivider2.Edge(); - else - theEdge2 = aDivider2.Edge(); - } - - delete aNearest; - return aResult; -} - -//======================================================================= -//function : AddValue -//purpose : -//======================================================================= -void GEOMImpl_Fillet1dPoint::AddValue(Standard_Real theValue, Standard_Boolean theValid) -{ - Standard_Integer a; - for(a = 1; a <= myV.Length(); a++) - { - if (theValue < myV.Value(a)) - { - myV.InsertBefore(a, theValue); - myValid.InsertBefore(a, (Standard_Integer)theValid); - return; - } - } - myV.Append(theValue); - myValid.Append((Standard_Integer)theValid); -} - -//======================================================================= -//function : ComputeDifference -//purpose : -//======================================================================= -Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoint* thePoint) -{ - Standard_Integer a; - Standard_Boolean aDiffsSet = (myD.Length() != 0); - Standard_Real aDX = thePoint->GetParam() - myParam, aDY; - if (thePoint->myV.Length() == myV.Length()) - { // absolutely the same points - for(a = 1; a <= myV.Length(); a++) - { - aDY = thePoint->myV.Value(a) - myV.Value(a); - if ( aDiffsSet ) - myD.SetValue(a, fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); - else - myD.Append( fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); - } - return Standard_True; - } - // between the diffeerent points searching for nearest analogs - Standard_Integer b; - for(a = 1; a <= myV.Length(); a++) - { - for(b = 1; b <= thePoint->myV.Length(); b++) - { - if (b == 1 || fabs(thePoint->myV.Value(b) - myV.Value(a)) < fabs(aDY)) - aDY = thePoint->myV.Value(b) - myV.Value(a); - } - if (aDiffsSet) - { - if ( fabs(aDX) > gp::Resolution() && fabs(aDY / aDX) < fabs(myD.Value(a))) - myD.SetValue(a, aDY / aDX); - else - myD.SetValue(a, 0); - } - else - { - myD.Append( fabs(aDX) > gp::Resolution() ? aDY/aDX : 0); - } - } - - return Standard_False; -} - -//======================================================================= -//function : FilterPoints -//purpose : -//======================================================================= -void GEOMImpl_Fillet1dPoint::FilterPoints(GEOMImpl_Fillet1dPoint* thePoint) -{ - Standard_Integer a, b; - TColStd_SequenceOfReal aDiffs; - Standard_Real aY, aY2, aDX = thePoint->GetParam() - myParam; - for(a = 1; a <= myV.Length(); a++) - { - // searching for near point from thePoint - Standard_Integer aNear = 0; - Standard_Real aDiff = aDX * 10000.; - aY = myV.Value(a) + myD.Value(a) * aDX; - for(b = 1; b <= thePoint->myV.Length(); b++) - { - // calculate hypothesis value of the Y2 with the constant first and second derivative - aY2 = aY + aDX * (thePoint->myD.Value(b) - myD.Value(a)) / 2.0; - if (aNear == 0 || fabs(aY2 - thePoint->myV.Value(b)) < fabs(aDiff)) - { - aNear = b; - aDiff = aY2 - thePoint->myV.Value(b); - } - }//for b... - - if (aNear) - { - if (myV.Value(a) * thePoint->myV.Value(aNear) > 0) - {// the same sign at the same sides of the interval - if (myV.Value(a) * myD.Value(a) > 0) - { - if (fabs(myD.Value(a)) > Precision::Confusion()) - aNear = 0; - } - else - { - if (fabs(myV.Value(a)) > fabs(thePoint->myV.Value(aNear))) - if (thePoint->myV.Value(aNear) * thePoint->myD.Value(aNear) < 0 && - fabs(thePoint->myD.Value(aNear)) > Precision::Confusion()) - { - aNear = 0; - } - } - } - } - - if (aNear) - { - if (myV.Value(a) * thePoint->myV.Value(aNear) > 0) - { - if ((myV.Value(a) + myD.Value(a) * aDX) * myV.Value(a) > Precision::Confusion() && - (thePoint->myV.Value(aNear) + thePoint->myD.Value(aNear) * aDX) * thePoint->myV.Value(aNear) > Precision::Confusion()) - { - aNear = 0; - } - } - } - - if (aNear) - { - if ( fabs(aDX) < gp::Resolution() || fabs(aDiff / aDX) > 1.e+7) - { - aNear = 0; - } - } - - if (aNear == 0) - { // there is no near: remove it from the list - myV.Remove(a); - myD.Remove(a); - myValid.Remove(a); - a--; - } - else - { - Standard_Boolean aFound = Standard_False; - for(b = 1; b <= myNear.Length(); b++) - { - if (myNear.Value(b) == aNear) - { - if (fabs(aDiffs.Value(b)) < fabs(aDiff)) - { // return this 'near' - aFound = Standard_True; - myV.Remove(a); - myD.Remove(a); - myValid.Remove(a); - a--; - break; - } - else - { // remove the old 'near' - myV.Remove(b); - myD.Remove(b); - myValid.Remove(b); - myNear.Remove(b); - aDiffs.Remove(b); - a--; - break; - } - } - }//for b... - if (!aFound) - { - myNear.Append(aNear); - aDiffs.Append(aDiff); - } - } - }//for a... -} - -//======================================================================= -//function : Copy -//purpose : -//======================================================================= -GEOMImpl_Fillet1dPoint* GEOMImpl_Fillet1dPoint::Copy() -{ - GEOMImpl_Fillet1dPoint* aCopy = new GEOMImpl_Fillet1dPoint(myParam); - Standard_Integer a; - for(a = 1; a <= myV.Length(); a++) - { - aCopy->myV.Append(myV.Value(a)); - aCopy->myD.Append(myD.Value(a)); - aCopy->myValid.Append(myValid.Value(a)); - } - return aCopy; -} - -//======================================================================= -//function : HasSolution -//purpose : -//======================================================================= -Standard_Integer GEOMImpl_Fillet1dPoint::HasSolution(const Standard_Real theRadius) -{ - Standard_Integer a; - for(a = 1; a <= myV.Length(); a++) - { - if (fabs(sqrt(fabs(fabs(myV.Value(a)) + theRadius * theRadius)) - theRadius) < Precision::Confusion() / 10.) - return a; - } - return 0; -} - -//======================================================================= -//function : RemoveSolution -//purpose : -//======================================================================= -void GEOMImpl_Fillet1dPoint::RemoveSolution(Standard_Integer theIndex) -{ - myV.Remove(theIndex); - myD.Remove(theIndex); - myValid.Remove(theIndex); - myNear.Remove(theIndex); -} + +// File : GEOMImpl_Fillet1d.cxx +// Module : GEOMImpl + +#include "GEOMImpl_Fillet1d.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * class GEOMImpl_Fillet1d + */ + +//======================================================================= +//function : Constructor +//purpose : +//======================================================================= +GEOMImpl_Fillet1d::GEOMImpl_Fillet1d(const TopoDS_Edge& theEdge1, + const TopoDS_Edge& theEdge2, + const gp_Pln& thePlane) +: myEdgesExchnged( Standard_False ) +{ + myPlane = new Geom_Plane(thePlane); + + BRepAdaptor_Curve aBAC1(theEdge1); + BRepAdaptor_Curve aBAC2(theEdge2); + if (aBAC1.GetType() < aBAC2.GetType()) + { // first curve must be more complicated + myEdge1 = theEdge2; + myEdge2 = theEdge1; + myEdgesExchnged = Standard_True; + } + else + { + myEdge1 = theEdge1; + myEdge2 = theEdge2; + } + + Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(myEdge1, myStart1, myEnd1); + Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(myEdge2, myStart2, myEnd2); + + myCurve1 = GeomProjLib::Curve2d(aCurve1, myStart1, myEnd1, myPlane); + myCurve2 = GeomProjLib::Curve2d(aCurve2, myStart2, myEnd2, myPlane); + + while (myCurve1->IsPeriodic() && myStart1 >= myEnd1) + myEnd1 += myCurve1->Period(); + while (myCurve2->IsPeriodic() && myStart2 >= myEnd2) + myEnd2 += myCurve2->Period(); + + if (aBAC1.GetType() == aBAC2.GetType()) + { + if (myEnd2 - myStart2 < myEnd1 - myStart1) + { // first curve must be parametrically shorter + TopoDS_Edge anEdge = myEdge1; + myEdge1 = myEdge2; + myEdge2 = anEdge; + Handle(Geom2d_Curve) aCurve = myCurve1; + myCurve1 = myCurve2; + myCurve2 = aCurve; + Standard_Real a = myStart1; + myStart1 = myStart2; + myStart2 = a; + a = myEnd1; + myEnd1 = myEnd2; + myEnd2 = a; + myEdgesExchnged = Standard_True; + } + } +} + +//======================================================================= +//function : isRadiusIntersected +//purpose : local function +//======================================================================= +static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve, + const gp_Pnt2d theStart, + const gp_Pnt2d theEnd, + const Standard_Boolean theStartConnected) +{ + const Standard_Real aTol = Precision::Confusion(); + const Standard_Real anAngTol = Precision::Angular(); + Geom2dAPI_InterCurveCurve anInter(theCurve, new Geom2d_Line(theStart, + gp_Dir2d(gp_Vec2d(theStart, theEnd))), aTol); + Standard_Integer a; + gp_Pnt2d aPoint; + for(a = anInter.NbPoints(); a > 0; a--) + { + aPoint = anInter.Point(a); + if ( aPoint.Distance(theStart) < aTol && !theStartConnected ) + return Standard_True; + if (aPoint.Distance(theEnd) < aTol * 200) + return Standard_True; + if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) + return Standard_True; + } + Handle(Geom2d_Curve) aCurve; + for(a = anInter.NbSegments(); a > 0; a--) + { + anInter.Segment(a, aCurve); + aPoint = aCurve->Value(aCurve->FirstParameter()); + if (aPoint.Distance(theStart) < aTol) + if (!theStartConnected) + return Standard_True; + if (aPoint.Distance(theEnd) < aTol) + return Standard_True; + if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) + return Standard_True; + aPoint = aCurve->Value(aCurve->LastParameter()); + if (aPoint.Distance(theStart) < aTol) + if (!theStartConnected) + return Standard_True; + if (aPoint.Distance(theEnd) < aTol) + return Standard_True; + if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol)) + return Standard_True; + } + return Standard_False; +} + + +//======================================================================= +//function : fillPoint +//purpose : +//======================================================================= +void GEOMImpl_Fillet1d::fillPoint(GEOMImpl_Fillet1dPoint* thePoint) +{ + gp_Pnt2d aPoint; + gp_Vec2d aVec; + const Standard_Real aTol = Precision::Confusion(); + myCurve1->D1(thePoint->GetParam(), aPoint, aVec); + if (aVec.SquareMagnitude() < aTol) + return; + + gp_Vec2d aPerp(((myStartSide)?-1:1) * aVec.Y(), ((myStartSide)?1:-1) * aVec.X()); + aPerp.Normalize(); + aPerp.Multiply(myRadius); + gp_Pnt2d aCenter = aPoint.Translated(aPerp); + thePoint->SetCenter(aCenter); + + // on the intersection point + Standard_Boolean aValid = Standard_True; + Geom2dAPI_ProjectPointOnCurve aProjInt(aPoint, myCurve2); + if (aProjInt.NbPoints() && aPoint.Distance(aProjInt.NearestPoint()) < aTol) + aValid = Standard_False; + else + aValid = !isRadiusIntersected(myCurve2, aPoint, aCenter, Standard_True); + + Geom2dAPI_ProjectPointOnCurve aProj(aCenter, myCurve2); + Standard_Integer a, aNB = aProj.NbPoints(); + for(a = aNB; a > 0; a--) + { + if (aPoint.Distance(aProj.Point(a)) < aTol) + continue; + + Standard_Boolean aValid2 = aValid; + if (aValid2) + aValid2 = !isRadiusIntersected(myCurve1, aCenter, aProj.Point(a), Standard_False); + + // checking the right parameter + Standard_Real aParam = aProj.Parameter(a); + while(myCurve2->IsPeriodic() && aParam < myStart2) + aParam += myCurve2->Period(); + + thePoint->AddValue(aProj.Distance(a) * aProj.Distance(a) - myRadius * myRadius, + (aParam >= myStart2 && aParam <= myEnd2 && aValid2)); + if (fabs(fabs(aProj.Distance(a)) - myRadius) < aTol) + thePoint->SetParam2(aParam); + } +} + +//======================================================================= +//function : fillDiff +//purpose : +//======================================================================= +void GEOMImpl_Fillet1d::fillDiff(GEOMImpl_Fillet1dPoint* thePoint, Standard_Real theDiffStep, Standard_Boolean theFront) +{ + GEOMImpl_Fillet1dPoint* aDiff = + new GEOMImpl_Fillet1dPoint(thePoint->GetParam() + (theFront?(theDiffStep):(-theDiffStep))); + fillPoint(aDiff); + if (!thePoint->ComputeDifference(aDiff)) + { + aDiff->SetParam(thePoint->GetParam() + (theFront?(-theDiffStep):(theDiffStep))); + fillPoint(aDiff); + thePoint->ComputeDifference(aDiff); + } + delete aDiff; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_Fillet1d::Perform(const Standard_Real theRadius) +{ + myDegreeOfRecursion = 0; + myResultParams.Clear(); + myResultOrientation.Clear(); + + Standard_Real aNBSteps = 100; + Geom2dAdaptor_Curve aGAC(myCurve1); + switch (aGAC.GetType()) + { + case GeomAbs_Line: + aNBSteps = 2; + break; + case GeomAbs_Circle: + aNBSteps = 4; + break; + case GeomAbs_Ellipse: + aNBSteps = 5; + break; + case GeomAbs_BezierCurve: + case GeomAbs_BSplineCurve: + aNBSteps = 2 + aGAC.Degree() * aGAC.NbPoles(); + break; + default: // unknown: maximum + aNBSteps = 100; + } + + myRadius = theRadius; + Standard_Real aParam, aStep, aDStep; + aStep = (myEnd1 - myStart1) / aNBSteps; + aDStep = aStep/1000.; + + Standard_Integer aCycle; + for(aCycle = 2, myStartSide = Standard_False; aCycle; myStartSide = !myStartSide, aCycle--) + { + GEOMImpl_Fillet1dPoint *aLeft = NULL, *aRight = NULL; + + for(aParam = myStart1 + aStep; aParam < myEnd1 || fabs(myEnd1 - aParam) < Precision::Confusion(); aParam += aStep) + { + if (!aLeft) + { + aLeft = new GEOMImpl_Fillet1dPoint(aParam - aStep); + fillPoint(aLeft); + fillDiff(aLeft, aDStep, Standard_True); + } + + aRight = new GEOMImpl_Fillet1dPoint(aParam); + fillPoint(aRight); + fillDiff(aRight, aDStep, Standard_False); + + aLeft->FilterPoints(aRight); + performNewton(aLeft, aRight); + + delete aLeft; + aLeft = aRight; + } + delete aLeft; + } + + if (myResultParams.Extent()) + return Standard_True; + + return Standard_False; +} + +//======================================================================= +//function : processPoint +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_Fillet1d::processPoint(GEOMImpl_Fillet1dPoint* theLeft, + GEOMImpl_Fillet1dPoint* theRight, + Standard_Real theParameter) +{ + if (theParameter >= theLeft->GetParam() && theParameter < theRight->GetParam()) + { + Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); + if (theParameter - theLeft->GetParam() < aDX / 100.) + { + theParameter = theLeft->GetParam() + aDX / 100.; + } + if (theRight->GetParam() - theParameter < aDX / 100.) + { + theParameter = theRight->GetParam() - aDX / 100.; + } + + // Protection on infinite loop. + myDegreeOfRecursion++; + Standard_Real diffx = 0.001 * aDX; + if (myDegreeOfRecursion > 1000) + { + diffx *= 10.0; + if (myDegreeOfRecursion > 10000) + { + diffx *= 10.0; + if (myDegreeOfRecursion > 100000) + { + return Standard_True; + } + } + } + + GEOMImpl_Fillet1dPoint* aPoint1 = theLeft->Copy(); + GEOMImpl_Fillet1dPoint* aPoint2 = new GEOMImpl_Fillet1dPoint(theParameter); + fillPoint(aPoint2); + fillDiff(aPoint2, diffx, Standard_True); + + aPoint1->FilterPoints(aPoint2); + performNewton(aPoint1, aPoint2); + aPoint2->FilterPoints(theRight); + performNewton(aPoint2, theRight); + + delete aPoint1; + delete aPoint2; + return Standard_True; + } + + return Standard_False; +} + +//======================================================================= +//function : performNewton +//purpose : +//======================================================================= +void GEOMImpl_Fillet1d::performNewton(GEOMImpl_Fillet1dPoint* theLeft, + GEOMImpl_Fillet1dPoint* theRight) +{ + Standard_Integer a; + // check the left: if this is solution store it and remove it from the list of researching points of theLeft + a = theLeft->HasSolution(myRadius); + if (a) + { + if (theLeft->IsValid(a)) + { + myResultParams.Append(theLeft->GetParam()); + myResultOrientation.Append(myStartSide); + } + return; + } + + Standard_Real aDX = theRight->GetParam() - theLeft->GetParam(); + if ( aDX < Precision::Confusion() / 1000000.) + { + a = theRight->HasSolution(myRadius); + if (a) + if (theRight->IsValid(a)) + { + myResultParams.Append(theRight->GetParam()); + myResultOrientation.Append(myStartSide); + } + return; + } + + for(a = 1; a <= theLeft->GetNBValues(); a++) + { + Standard_Integer aNear = theLeft->GetNear(a); + + Standard_Real aA = (theRight->GetDiff(aNear) - theLeft->GetDiff(a)) / aDX; + Standard_Real aB = theLeft->GetDiff(a) - aA * theLeft->GetParam(); + Standard_Real aC = theLeft->GetValue(a) - theLeft->GetDiff(a) * theLeft->GetParam() + + aA * theLeft->GetParam() * theLeft->GetParam() / 2.0; + Standard_Real aDet = aB * aB - 2.0 * aA * aC; + + if ( fabs(aDet) < gp::Resolution() ) + continue; + + if (fabs(aA) < Precision::Confusion()) + { // linear case + if (fabs(aB) > 10e-20) + { + Standard_Real aX0 = - aC / aB; // use extremum + if (aX0 > theLeft->GetParam() && aX0 < theRight->GetParam()) + processPoint(theLeft, theRight, aX0); + } + else + { + processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise + } + } + else + { + if (fabs(aB) > fabs(aDet * 1000000.)) + { // possible floating point operations accurancy errors + processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise + } + else + { + if (aDet > 0) + { // two solutions + aDet = sqrt(aDet); + Standard_Boolean aRes = processPoint(theLeft, theRight, (- aB + aDet) / aA); + if (!aRes) + aRes = processPoint(theLeft, theRight, (- aB - aDet) / aA); + if (!aRes) + processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise + } + else + { + Standard_Real aX0 = - aB / aA; // use extremum + if (aX0 > theLeft->GetParam() && aX0 < theRight->GetParam()) + processPoint(theLeft, theRight, aX0); + else + processPoint(theLeft, theRight, theLeft->GetParam() + aDX / 2.0); // linear division otherwise + } + } + } + } +} + +//======================================================================= +//function : Result +//purpose : +//======================================================================= +TopoDS_Edge GEOMImpl_Fillet1d::Result(const gp_Pnt& thePoint, + TopoDS_Edge& theEdge1, + TopoDS_Edge& theEdge2) +{ + TopoDS_Edge aResult; + gp_Pnt2d aTargetPoint2d; + Standard_Real aX, aY; + ElSLib::PlaneParameters(myPlane->Pln().Position(), thePoint, aX, aY); + aTargetPoint2d.SetCoord(aX, aY); + + // choose the nearest circle + Standard_Real aDistance, aP; + GEOMImpl_Fillet1dPoint *aNearest; + Standard_Integer a; + TColStd_ListIteratorOfListOfReal anIter(myResultParams); + for(aNearest = NULL, a = 1; anIter.More(); anIter.Next(), a++) + { + myStartSide = (myResultOrientation.Value(a)) ? Standard_True : Standard_False; + GEOMImpl_Fillet1dPoint *aPoint = new GEOMImpl_Fillet1dPoint(anIter.Value()); + fillPoint(aPoint); + if (!aPoint->HasSolution(myRadius)) + continue; + aP = fabs(aPoint->GetCenter().Distance(aTargetPoint2d) - myRadius); + if (!aNearest || aP < aDistance) + { + aNearest = aPoint; + aDistance = aP; + } + else + { + delete aPoint; + } + } + + if (!aNearest) + return aResult; + + // create circle edge + gp_Pnt aCenter = ElSLib::PlaneValue(aNearest->GetCenter().X(), + aNearest->GetCenter().Y(), + myPlane->Pln().Position()); + Handle(Geom_Circle) aCircle = + new Geom_Circle(gp_Ax2(aCenter, myPlane->Pln().Axis().Direction()), myRadius); + gp_Pnt2d aPoint2d1, aPoint2d2; + myCurve1->D0(aNearest->GetParam(), aPoint2d1); + myCurve2->D0(aNearest->GetParam2(), aPoint2d2); + gp_Pnt aPoint1 = ElSLib::PlaneValue(aPoint2d1.X(), aPoint2d1.Y(), myPlane->Pln().Position()); + gp_Pnt aPoint2 = ElSLib::PlaneValue(aPoint2d2.X(), aPoint2d2.Y(), myPlane->Pln().Position()); + + GeomAPI_ProjectPointOnCurve aProj(thePoint, aCircle); + Standard_Real aTarGetParam = aProj.LowerDistanceParameter(); + gp_Pnt aPointOnCircle = aProj.NearestPoint(); + + // Check extrema point manually, because there is a bug in Open CASCADE + // in calculation of nearest point to a circle near the parameter 0.0 + gp_Pnt p0 = ElCLib::Value(0.0, aCircle->Circ()); + if (p0.Distance(thePoint) < aPointOnCircle.Distance(thePoint)) + { + aTarGetParam = 0.0; + aPointOnCircle = p0; + } + + aProj.Perform(aPoint1); + Standard_Real aParam1 = aProj.LowerDistanceParameter(); + aProj.Perform(aPoint2); + Standard_Real aParam2 = aProj.LowerDistanceParameter(); + Standard_Boolean aIsOut = ((aParam1 < aTarGetParam && aParam2 < aTarGetParam) || + (aParam1 > aTarGetParam && aParam2 > aTarGetParam)); + if (aParam1 > aParam2) + aIsOut = !aIsOut; + BRepBuilderAPI_MakeEdge aBuilder(aCircle->Circ(), + aIsOut ? aParam2 : aParam1, + aIsOut? aParam1 : aParam2); + aResult = aBuilder.Edge(); + + // divide edges + Standard_Real aStart, anEnd; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(myEdge1, aStart, anEnd); + gp_Vec aDir; + aCurve->D1(aNearest->GetParam(), aPoint1, aDir); + + gp_Vec aCircleDir; + aCircle->D1(aParam1, aPoint1, aCircleDir); + if ((aCircleDir.Angle(aDir) > M_PI / 2.0) ^ aIsOut) + aStart = aNearest->GetParam(); + else + anEnd = aNearest->GetParam(); + + if (fabs(aStart - anEnd) > Precision::Confusion()) + { + //Divide edge + BRepBuilderAPI_MakeEdge aDivider1(aCurve, aStart, anEnd); + if (myEdgesExchnged) + theEdge2 = aDivider1.Edge(); + else + theEdge1 = aDivider1.Edge(); + } + + aCurve = BRep_Tool::Curve(myEdge2, aStart, anEnd); + aCurve->D1(aNearest->GetParam2(), aPoint2, aDir); + + aCircle->D1(aParam2, aPoint2, aCircleDir); + if ((aCircleDir.Angle(aDir) > M_PI / 2.0) ^ (!aIsOut)) + aStart = aNearest->GetParam2(); + else + anEnd = aNearest->GetParam2(); + + if (fabs(aStart - anEnd) > Precision::Confusion()) + { + BRepBuilderAPI_MakeEdge aDivider2(aCurve, aStart, anEnd); + if (myEdgesExchnged) + theEdge1 = aDivider2.Edge(); + else + theEdge2 = aDivider2.Edge(); + } + + delete aNearest; + return aResult; +} + +//======================================================================= +//function : AddValue +//purpose : +//======================================================================= +void GEOMImpl_Fillet1dPoint::AddValue(Standard_Real theValue, Standard_Boolean theValid) +{ + Standard_Integer a; + for(a = 1; a <= myV.Length(); a++) + { + if (theValue < myV.Value(a)) + { + myV.InsertBefore(a, theValue); + myValid.InsertBefore(a, (Standard_Integer)theValid); + return; + } + } + myV.Append(theValue); + myValid.Append((Standard_Integer)theValid); +} + +//======================================================================= +//function : ComputeDifference +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_Fillet1dPoint::ComputeDifference(GEOMImpl_Fillet1dPoint* thePoint) +{ + Standard_Integer a; + Standard_Boolean aDiffsSet = (myD.Length() != 0); + Standard_Real aDX = thePoint->GetParam() - myParam, aDY; + if (thePoint->myV.Length() == myV.Length()) + { // absolutely the same points + for(a = 1; a <= myV.Length(); a++) + { + aDY = thePoint->myV.Value(a) - myV.Value(a); + if ( aDiffsSet ) + myD.SetValue(a, fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); + else + myD.Append( fabs(aDX) > gp::Resolution() ? (aDY/aDX) : 0); + } + return Standard_True; + } + // between the diffeerent points searching for nearest analogs + Standard_Integer b; + for(a = 1; a <= myV.Length(); a++) + { + for(b = 1; b <= thePoint->myV.Length(); b++) + { + if (b == 1 || fabs(thePoint->myV.Value(b) - myV.Value(a)) < fabs(aDY)) + aDY = thePoint->myV.Value(b) - myV.Value(a); + } + if (aDiffsSet) + { + if ( fabs(aDX) > gp::Resolution() && fabs(aDY / aDX) < fabs(myD.Value(a))) + myD.SetValue(a, aDY / aDX); + else + myD.SetValue(a, 0); + } + else + { + myD.Append( fabs(aDX) > gp::Resolution() ? aDY/aDX : 0); + } + } + + return Standard_False; +} + +//======================================================================= +//function : FilterPoints +//purpose : +//======================================================================= +void GEOMImpl_Fillet1dPoint::FilterPoints(GEOMImpl_Fillet1dPoint* thePoint) +{ + Standard_Integer a, b; + TColStd_SequenceOfReal aDiffs; + Standard_Real aY, aY2, aDX = thePoint->GetParam() - myParam; + for(a = 1; a <= myV.Length(); a++) + { + // searching for near point from thePoint + Standard_Integer aNear = 0; + Standard_Real aDiff = aDX * 10000.; + aY = myV.Value(a) + myD.Value(a) * aDX; + for(b = 1; b <= thePoint->myV.Length(); b++) + { + // calculate hypothesis value of the Y2 with the constant first and second derivative + aY2 = aY + aDX * (thePoint->myD.Value(b) - myD.Value(a)) / 2.0; + if (aNear == 0 || fabs(aY2 - thePoint->myV.Value(b)) < fabs(aDiff)) + { + aNear = b; + aDiff = aY2 - thePoint->myV.Value(b); + } + }//for b... + + if (aNear) + { + if (myV.Value(a) * thePoint->myV.Value(aNear) > 0) + {// the same sign at the same sides of the interval + if (myV.Value(a) * myD.Value(a) > 0) + { + if (fabs(myD.Value(a)) > Precision::Confusion()) + aNear = 0; + } + else + { + if (fabs(myV.Value(a)) > fabs(thePoint->myV.Value(aNear))) + if (thePoint->myV.Value(aNear) * thePoint->myD.Value(aNear) < 0 && + fabs(thePoint->myD.Value(aNear)) > Precision::Confusion()) + { + aNear = 0; + } + } + } + } + + if (aNear) + { + if (myV.Value(a) * thePoint->myV.Value(aNear) > 0) + { + if ((myV.Value(a) + myD.Value(a) * aDX) * myV.Value(a) > Precision::Confusion() && + (thePoint->myV.Value(aNear) + thePoint->myD.Value(aNear) * aDX) * thePoint->myV.Value(aNear) > Precision::Confusion()) + { + aNear = 0; + } + } + } + + if (aNear) + { + if ( fabs(aDX) < gp::Resolution() || fabs(aDiff / aDX) > 1.e+7) + { + aNear = 0; + } + } + + if (aNear == 0) + { // there is no near: remove it from the list + myV.Remove(a); + myD.Remove(a); + myValid.Remove(a); + a--; + } + else + { + Standard_Boolean aFound = Standard_False; + for(b = 1; b <= myNear.Length(); b++) + { + if (myNear.Value(b) == aNear) + { + if (fabs(aDiffs.Value(b)) < fabs(aDiff)) + { // return this 'near' + aFound = Standard_True; + myV.Remove(a); + myD.Remove(a); + myValid.Remove(a); + a--; + break; + } + else + { // remove the old 'near' + myV.Remove(b); + myD.Remove(b); + myValid.Remove(b); + myNear.Remove(b); + aDiffs.Remove(b); + a--; + break; + } + } + }//for b... + if (!aFound) + { + myNear.Append(aNear); + aDiffs.Append(aDiff); + } + } + }//for a... +} + +//======================================================================= +//function : Copy +//purpose : +//======================================================================= +GEOMImpl_Fillet1dPoint* GEOMImpl_Fillet1dPoint::Copy() +{ + GEOMImpl_Fillet1dPoint* aCopy = new GEOMImpl_Fillet1dPoint(myParam); + Standard_Integer a; + for(a = 1; a <= myV.Length(); a++) + { + aCopy->myV.Append(myV.Value(a)); + aCopy->myD.Append(myD.Value(a)); + aCopy->myValid.Append(myValid.Value(a)); + } + return aCopy; +} + +//======================================================================= +//function : HasSolution +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Fillet1dPoint::HasSolution(const Standard_Real theRadius) +{ + Standard_Integer a; + for(a = 1; a <= myV.Length(); a++) + { + if (fabs(sqrt(fabs(fabs(myV.Value(a)) + theRadius * theRadius)) - theRadius) < Precision::Confusion() / 10.) + return a; + } + return 0; +} + +//======================================================================= +//function : RemoveSolution +//purpose : +//======================================================================= +void GEOMImpl_Fillet1dPoint::RemoveSolution(Standard_Integer theIndex) +{ + myV.Remove(theIndex); + myD.Remove(theIndex); + myValid.Remove(theIndex); + myNear.Remove(theIndex); +} diff --git a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx index 1e5de6d4c..1e2bb562f 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx @@ -15,7 +15,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -92,7 +91,7 @@ static TopoDS_Vertex anotherVertex( const TopoDS_Edge& theE, } return aV; } - + //======================================================================= //function : takePlane //purpose : local function returns plane of given edges @@ -116,8 +115,8 @@ static Standard_Boolean takePlane( const TopoDS_Edge& theE1, gp_Dir aDir1( aXYZ - aXYZ1 ); gp_Dir aDir2( aXYZ2 - aXYZ ); Standard_Real anAngle = aDir1.Angle(aDir2); - if ( fabs(anAngle) <= gp::Resolution() || - fabs(anAngle - PI) <= gp::Resolution() ) + if ( fabs(anAngle) <= gp::Resolution() || + fabs(anAngle - M_PI) <= gp::Resolution() ) return false; thePlane = gp_Pln( gp_Pnt(aXYZ), aDir1^ aDir2); } @@ -214,25 +213,25 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const if ( anEdgeToEdgeMap.IsBound( anEdge2 ) ) anEdge2 = TopoDS::Edge(anEdgeToEdgeMap.Find( anEdge2 )); if ( anEdge1.IsNull() || anEdge2.IsNull() || anEdge1.IsSame( anEdge2 ) ) continue; //no input data to make fillet - + // create plane on 2 edges gp_Pln aPlane; if ( !takePlane(anEdge1, anEdge2, aV, aPlane) ) continue; // seems edges does not belong to same plane or parallel (fillet can not be build) - + GEOMImpl_Fillet1d aFilletAlgo(anEdge1, anEdge2, aPlane); if ( !aFilletAlgo.Perform(rad) ) continue; // can not create fillet with given radius - + // take fillet result in given vertex TopoDS_Edge aModifE1, aModifE2; TopoDS_Edge aNewE = aFilletAlgo.Result(BRep_Tool::Pnt(aV), aModifE1, aModifE2); if (aNewE.IsNull()) continue; // no result found - + // add new created edges and take modified edges aListOfNewEdge.Append( aNewE ); - + // check if face edges modified, // if yes, than map to original edges (from vertex-edges list), because edges can be modified before if (aModifE1.IsNull() || !anEdge1.IsSame( aModifE1 )) @@ -245,10 +244,10 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const StdFail_NotDone::Raise("1D Fillet can't be computed on the given shape with the given radius"); return 0; } - + // create new wire instead of original for ( TopExp_Explorer anExp( aWire, TopAbs_EDGE ); anExp.More(); anExp.Next() ) { - TopoDS_Shape anEdge = anExp.Current(); + TopoDS_Shape anEdge = anExp.Current(); if ( !anEdgeToEdgeMap.IsBound( anEdge ) ) aListOfNewEdge.Append( anEdge ); else if (!anEdgeToEdgeMap.Find( anEdge ).IsNull()) @@ -266,7 +265,7 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const aWire = aWireTool.Wire(); aFunction->SetValue(aWire); log.SetTouched(Label()); - + return 1; } @@ -277,7 +276,6 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(TFunction_Logbook& log) const //======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_Fillet1dDriver_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); @@ -285,7 +283,6 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_Fillet1dDriver_Type_() static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_Fillet1dDriver", sizeof(GEOMImpl_Fillet1dDriver), @@ -310,5 +307,5 @@ const Handle(GEOMImpl_Fillet1dDriver) Handle(GEOMImpl_Fillet1dDriver)::DownCast( } } - return _anOtherObject ; + return _anOtherObject; } diff --git a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx index b06c44ae7..15442235c 100644 --- a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx @@ -159,7 +159,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const } else if( C->IsKind(STANDARD_TYPE(Geom_Circle)) || C->IsKind(STANDARD_TYPE(Geom_Ellipse)) ) { - nbp = (int)25*fabs(Last-First)/(2*PI); + nbp = (int)25*fabs(Last-First)/(2.*M_PI); } else if( C->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) { Handle(Geom_BezierCurve) C3d = Handle(Geom_BezierCurve)::DownCast(C); @@ -384,7 +384,6 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const //======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_FillingDriver_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); @@ -392,7 +391,6 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_FillingDriver_Type_() static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_FillingDriver", sizeof(GEOMImpl_FillingDriver), @@ -407,8 +405,8 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_FillingDriver_Type_() //function : DownCast //purpose : //======================================================================= - -const Handle(GEOMImpl_FillingDriver) Handle(GEOMImpl_FillingDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +const Handle(GEOMImpl_FillingDriver) Handle(GEOMImpl_FillingDriver)::DownCast + (const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_FillingDriver) _anOtherObject; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index bbd8a6962..4a69c1be9 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1404,7 +1404,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle( //Make a Python command GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution(" - << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return aRevolution; @@ -1462,7 +1462,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways //Make a Python command GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways(" - << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return aRevolution; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index 4d500a92d..33d7b59b7 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -2069,7 +2069,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine gp_Lin aLin2 = L2->Lin(); anAngle = aLin1.Angle(aLin2); - anAngle /= PI180; // convert radians into degrees + anAngle *= 180. / M_PI; // convert radians into degrees if (anAngle > 90.0) { anAngle = 180.0 - anAngle; @@ -2135,7 +2135,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetAngleBtwVectors (Handle(GEOM_Objec gp_Vec aV2 (BRep_Tool::Pnt(aP21), BRep_Tool::Pnt(aP22)) ; anAngle = aV1.Angle(aV2); - anAngle /= PI180; // convert radians into degrees + anAngle *= 180. / M_PI; // convert radians into degrees SetErrorCode(OK); } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 1f958e170..bc1b8cbce 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -4122,7 +4122,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec if ( isFound && iType == TopAbs_FACE ) { // check normals at pOnWhat and pOnWhere - const double angleTol = PI/180.; + const double angleTol = M_PI/180.; gp_Vec normToWhat = GetNormal( TopoDS::Face(Exp_aWhat.Current()), aWhatDistance); gp_Vec normToWhere = GetNormal( TopoDS::Face(Exp_aWhere.Current()), aWhereDistance); if ( normToWhat * normToWhere < 0 ) diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 14cf10774..3e8134ecd 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -1666,7 +1666,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t //Make a Python command GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject - << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return theObject; @@ -1719,7 +1719,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec //Make a Python command GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject - << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return aCopy; diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index e5f911209..93263f51e 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -600,7 +599,7 @@ static void FindFirstPairFaces(const TopoDS_Shape& S1, const TopoDS_Shape& S2, gp_Vec aDir(P1,P2); int i=1; - double MinAng = PI; + double MinAng = M_PI; int numface = 0; for (; i<=Fs.Length(); i++) { gp_Vec tmpDir(PM1,Ps(i)); @@ -833,7 +832,7 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections C->D1(lp,P2,Vec2); double ang = fabs(Vec1.Angle(Vec2)); SumAng += ang; - if (SumAng>4*PI) { + if (SumAng>4*M_PI) { SumAng = ang; SplitEdgeNums.Append(i-1); int j; @@ -1543,7 +1542,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath, // main direction for comparing gp_Vec VM(PLocs.Value(i),PLocs.Value(i+1)); // find corresponding edge from next section - double minang = PI; + double minang = M_PI; gp_Pnt P11 = BRep_Tool::Pnt(V11); gp_Pnt P21 = BRep_Tool::Pnt(V21); TopoDS_Shape E2; @@ -1892,9 +1891,9 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(SecVs(i))); gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(SecVs(i+1))); gp_Vec aDir(P1,P2); - if (fabs(aDir.Angle(aDir1))>PI/2.) + if (fabs(aDir.Angle(aDir1)) > M_PI/2.) aDir1.Reverse(); - if (fabs(aDir.Angle(aDir2))>PI/2.) + if (fabs(aDir.Angle(aDir2)) > M_PI/2.) aDir2.Reverse(); TopExp_Explorer anExpE(F1,TopAbs_EDGE); @@ -2457,7 +2456,6 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const //======================================================================= Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipeDriver_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); if (aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx index f2c57ac76..b77ce06da 100644 --- a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -100,7 +99,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Dir aDir(gp_Vec(aP1, aP2)); gp_Ax1 anAx1(aP1, aDir); Standard_Real anAngle = RI.GetAngle(); - if (fabs(anAngle) < Precision::Angular()) anAngle += 2*PI; // NPAL19665,19769 + if (fabs(anAngle) < Precision::Angular()) anAngle += 2.*M_PI; // NPAL19665,19769 aTrsf.SetRotation(anAx1, anAngle); //NPAL18620: performance problem: multiple locations are accumulated @@ -135,7 +134,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const gp_Dir aDir (aVec1 ^ aVec2); gp_Ax1 anAx1 (aCP, aDir); Standard_Real anAngle = aVec1.Angle(aVec2); - if (fabs(anAngle) < Precision::Angular()) anAngle += 2*PI; // NPAL19665 + if (fabs(anAngle) < Precision::Angular()) anAngle += 2.*M_PI; // NPAL19665 aTrsf.SetRotation(anAx1, anAngle); //NPAL18620: performance problem: multiple locations are accumulated // in shape and need a great time to process @@ -177,7 +176,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const B.Add(aCompound, anOriginal); } else { - aTrsf.SetRotation(AX1, i*angle*PI180); + aTrsf.SetRotation(AX1, i*angle*M_PI/180.); //TopLoc_Location aLocRes (aTrsf * aTrsfOrig); // gp_Trsf::Multiply() has a bug gp_Trsf aTrsfNew (aTrsfOrig); aTrsfNew.PreMultiply(aTrsf); @@ -274,7 +273,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const B.Add(aCompound, anOriginal.Located(aLocRes)); } else { - aTrsf2.SetRotation(AX1, j*ang*PI180); + aTrsf2.SetRotation(AX1, j*ang*M_PI/180.); //TopLoc_Location aLocRes (aTrsf2 * aTrsf1 * aTrsfOrig); // gp_Trsf::Multiply() has a bug gp_Trsf aTrsfNew (aTrsfOrig); aTrsfNew.PreMultiply(aTrsf1); diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index f086e4a78..f354f96a0 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -608,14 +608,14 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const NewFpar = ElCLib::Parameter(PrevCircle, P1); NewLpar = ElCLib::Parameter(PrevCircle, P2); if (NewLpar < NewFpar) - NewLpar += 2.*PI; + NewLpar += 2.*M_PI; //Standard_Real MemNewFpar = NewFpar, MemNewLpar = NewLpar; if (ConnectByOrigin == TopAbs_FORWARD) ElCLib::AdjustPeriodic(FparSeq.Last(), - FparSeq.Last() + 2.*PI, + FparSeq.Last() + 2.*M_PI, Precision::PConfusion(), NewFpar, NewLpar); else - ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*PI, + ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*M_PI, FparSeq.Last(), Precision::PConfusion(), NewFpar, NewLpar); Done = Standard_True; @@ -644,13 +644,13 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const NewFpar = ElCLib::Parameter(PrevEllipse, P1); NewLpar = ElCLib::Parameter(PrevEllipse, P2); if (NewLpar < NewFpar) - NewLpar += 2.*PI; + NewLpar += 2.*M_PI; if (ConnectByOrigin == TopAbs_FORWARD) ElCLib::AdjustPeriodic(FparSeq.Last(), - FparSeq.Last() + 2.*PI, + FparSeq.Last() + 2.*M_PI, Precision::PConfusion(), NewFpar, NewLpar); else - ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*PI, + ElCLib::AdjustPeriodic(FparSeq.Last() - 2.*M_PI, FparSeq.Last(), Precision::PConfusion(), NewFpar, NewLpar); Done = Standard_True; diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index 613280dd1..7e3d3819f 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GenerationGUI_RevolDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #include "GenerationGUI_RevolDlg.h" #include @@ -319,9 +318,11 @@ bool GenerationGUI_RevolDlg::execute (ObjectList& objects) for (int i = 0; i < myBaseObjects.count(); i++) { if (!GroupPoints->CheckButton1->isChecked()) - anObj = anOper->MakeRevolutionAxisAngle(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180); + anObj = anOper->MakeRevolutionAxisAngle(myBaseObjects[i].get(), myAxis.get(), + getAngle() * M_PI / 180.); else - anObj = anOper->MakeRevolutionAxisAngle2Ways(myBaseObjects[i].get(), myAxis.get(), getAngle() * PI180); + anObj = anOper->MakeRevolutionAxisAngle2Ways(myBaseObjects[i].get(), myAxis.get(), + getAngle() * M_PI / 180.); if (!anObj->_is_nil()) { if (!IsPreview()) { diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx index 38e00c508..d80594e04 100644 --- a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx @@ -349,8 +349,8 @@ SALOME_Prs* MeasureGUI_AngleDlg::buildPrs() aLabel.sprintf("%.1f", anAngle); Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension - (anEdge1, anEdge2, aPlane, anAngle * PI180, - TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().data())); + (anEdge1, anEdge2, aPlane, anAngle * M_PI / 180., + TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().data())); Handle(Geom_Line) geom_lin1,geom_lin2; gp_Pnt ptat11,ptat12,ptat21,ptat22; Standard_Boolean isInfinite1,isInfinite2; diff --git a/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx b/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx index c5696e029..78abab26c 100644 --- a/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx +++ b/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx @@ -18,11 +18,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _NMTDS_CArray1OfIndexRange_HeaderFile #define _NMTDS_CArray1OfIndexRange_HeaderFile +#include + #ifndef _Standard_Address_HeaderFile #include #endif @@ -32,11 +33,11 @@ #ifndef _Standard_Boolean_HeaderFile #include #endif + class Standard_OutOfRange; class Standard_OutOfMemory; class NMTDS_IndexRange; - #ifndef _Standard_HeaderFile #include #endif @@ -108,33 +109,25 @@ Standard_EXPORT NMTDS_IndexRange& ChangeValue(const Standard_Integer Index) ; return ChangeValue(Index); } - - Standard_EXPORT void SetBlockLength(const Standard_Integer aBL) ; - - Standard_EXPORT Standard_Integer BlockLength() const; - - - +#if OCC_VERSION_LARGE > 0x06050200 +Standard_EXPORT void Purge(); +#endif protected: // Methods PROTECTED // - // Fields PROTECTED // - private: // Methods PRIVATE // - - Standard_EXPORT NMTDS_CArray1OfIndexRange(const NMTDS_CArray1OfIndexRange& AnArray); @@ -144,11 +137,8 @@ Standard_EXPORT NMTDS_CArray1OfIndexRange& Assign(const NMTDS_CArray1OfIndexRa return Assign(Other); } - - Standard_EXPORT Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; - // Fields PRIVATE // Standard_Address myStart; @@ -156,16 +146,9 @@ Standard_Integer myLength; Standard_Integer myFactLength; Standard_Integer myBlockLength; Standard_Boolean myIsAllocated; - - }; - - - - // other Inline functions and methods (like "C++: function call" methods) // - #endif diff --git a/src/NMTTools/NMTTools_CommonBlockPool.hxx b/src/NMTTools/NMTTools_CommonBlockPool.hxx index 8a2c4ae9d..cd322c430 100644 --- a/src/NMTTools/NMTTools_CommonBlockPool.hxx +++ b/src/NMTTools/NMTTools_CommonBlockPool.hxx @@ -18,11 +18,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _NMTTools_CommonBlockPool_HeaderFile #define _NMTTools_CommonBlockPool_HeaderFile +#include + #ifndef _Standard_Address_HeaderFile #include #endif @@ -32,11 +33,11 @@ #ifndef _Standard_Boolean_HeaderFile #include #endif + class Standard_OutOfRange; class Standard_OutOfMemory; class NMTTools_ListOfCommonBlock; - #ifndef _Standard_HeaderFile #include #endif @@ -108,47 +109,35 @@ Standard_EXPORT NMTTools_ListOfCommonBlock& ChangeValue(const Standard_Integer return ChangeValue(Index); } - - Standard_EXPORT void SetBlockLength(const Standard_Integer aBL) ; - - Standard_EXPORT Standard_Integer BlockLength() const; - - - +#if OCC_VERSION_LARGE > 0x06050200 +Standard_EXPORT void Purge(); +#endif protected: // Methods PROTECTED // - // Fields PROTECTED // - private: // Methods PRIVATE // - - Standard_EXPORT NMTTools_CommonBlockPool(const NMTTools_CommonBlockPool& AnArray); - Standard_EXPORT NMTTools_CommonBlockPool& Assign(const NMTTools_CommonBlockPool& Other) ; NMTTools_CommonBlockPool& operator =(const NMTTools_CommonBlockPool& Other) { return Assign(Other); } - - Standard_EXPORT Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; - // Fields PRIVATE // Standard_Address myStart; @@ -160,12 +149,7 @@ Standard_Boolean myIsAllocated; }; - - - - // other Inline functions and methods (like "C++: function call" methods) // - #endif diff --git a/src/NMTTools/NMTTools_PaveFiller_6.cxx b/src/NMTTools/NMTTools_PaveFiller_6.cxx index 1a9e9cd8a..d713e8851 100644 --- a/src/NMTTools/NMTTools_PaveFiller_6.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_6.cxx @@ -1511,8 +1511,8 @@ void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF, // aA=aDN[0].Angle(aDN[1]); aA=fabs(aA); - if (aA>0.5*PI) { - aA=PI-aA; + if (aA > 0.5*M_PI) { + aA = M_PI - aA; } // if (aAaAmax) { diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index 04c2ccc31..7a945dc23 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -18,14 +18,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_AISShape.cxx // Author : Nicolas REJNERI // Module : GEOM -// $Header$ -// + /*! \class GEOM_AISShape GEOM_AISShape.hxx \brief .... @@ -254,7 +252,7 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent else aDir = -aDirVec; - Prs3d_Arrow::Draw(aPrs, aP2, aDir, PI/180.*5., aDist/10.); + Prs3d_Arrow::Draw(aPrs, aP2, aDir, M_PI/180.*5., aDist/10.); } } } diff --git a/src/OBJECT/GEOM_OCCReader.cxx b/src/OBJECT/GEOM_OCCReader.cxx index ee7b01b9a..ff1e0f3a0 100644 --- a/src/OBJECT/GEOM_OCCReader.cxx +++ b/src/OBJECT/GEOM_OCCReader.cxx @@ -18,14 +18,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_OCCReader.h // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ -// + #include "GEOM_OCCReader.h" // VTK Includes @@ -810,7 +808,7 @@ void GEOM_OCCReader::TransferEdgeWData(const TopoDS_Edge& aEdge, if (aDist < gp::Resolution()) return; gp_Dir aDirection (aDirVec); - Standard_Real anAngle = PI/180.*5.; + Standard_Real anAngle = M_PI/180. * 5.; Standard_Real aLength = aDist/10.; Standard_Real dx,dy,dz; @@ -848,8 +846,8 @@ void GEOM_OCCReader::TransferEdgeWData(const TopoDS_Edge& aEdge, int NbPoints = 15; for (int i = 1; i <= NbPoints; i++, ptPrev = ptCur) { - cosinus = cos(2. * PI / NbPoints * (i-1)); - sinus = sin(2. * PI / NbPoints * (i-1)); + cosinus = cos(2. * M_PI / NbPoints * (i-1)); + sinus = sin(2. * M_PI / NbPoints * (i-1)); gp_XYZ aP = aPc + (aDirI.XYZ() * cosinus + aDirJ.XYZ() * sinus) * aLength * Tg; coord[0] = aP.X(); @@ -1069,5 +1067,3 @@ const TopoDS_Shape& GEOM_OCCReader::getTopo() { int GEOM_OCCReader::getDisplayMode() { return amode; } - - diff --git a/src/OCC2VTK/GEOM_EdgeSource.cxx b/src/OCC2VTK/GEOM_EdgeSource.cxx index 40ee058a5..abcd23fc7 100755 --- a/src/OCC2VTK/GEOM_EdgeSource.cxx +++ b/src/OCC2VTK/GEOM_EdgeSource.cxx @@ -15,7 +15,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include "GEOM_EdgeSource.h" @@ -194,7 +193,7 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, else aDirection = -aDirVec; - Standard_Real anAngle = PI/180.*5.; + Standard_Real anAngle = M_PI/180.*5.; Standard_Real aLength = aDist/10.; Standard_Real dx,dy,dz; @@ -231,8 +230,8 @@ void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, int NbPoints = 15; for (int i = 1; i <= NbPoints; i++, ptPrev = ptCur) { - cosinus = cos(2. * PI / NbPoints * (i-1)); - sinus = sin(2. * PI / NbPoints * (i-1)); + cosinus = cos(2. * M_PI / NbPoints * (i-1)); + sinus = sin(2. * M_PI / NbPoints * (i-1)); gp_XYZ aP = aPc + (aDirI.XYZ() * cosinus + aDirJ.XYZ() * sinus) * aLength * Tg; coord[0] = aP.X(); diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx index c1579d1d7..1b62ce4b1 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.cxx +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : OperationGUI_ChamferDlg.cxx // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #include "OperationGUI_ChamferDlg.h" #include @@ -839,7 +838,7 @@ bool OperationGUI_ChamferDlg::execute (ObjectList& objects) else { anObj = anOper->MakeChamferEdgeAD(myShape, mySpinBox[ SpinBox23 ]->value(), - mySpinBox[ SpinBox24 ]->value() * PI180, + mySpinBox[ SpinBox24 ]->value() * M_PI / 180., myFace[ Face1 ], myFace[ Face2 ]); if (!anObj->_is_nil()) @@ -871,7 +870,7 @@ bool OperationGUI_ChamferDlg::execute (ObjectList& objects) else { anObj = anOper->MakeChamferFacesAD(myShape, mySpinBox[ SpinBox33 ]->value(), - mySpinBox[ SpinBox34 ]->value() * PI180, + mySpinBox[ SpinBox34 ]->value() * M_PI / 180., anArray); if (!anObj->_is_nil()) { @@ -899,7 +898,7 @@ bool OperationGUI_ChamferDlg::execute (ObjectList& objects) else { anObj = anOper->MakeChamferEdgesAD(myShape, mySpinBox[ SpinBox43 ]->value(), - mySpinBox[ SpinBox44 ]->value() * PI180, + mySpinBox[ SpinBox44 ]->value() * M_PI / 180., anArray); if (!anObj->_is_nil()) { diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx index 1d29ecb29..17739eb7b 100755 --- a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_ShapeProcessDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #include "RepairGUI_ShapeProcessDlg.h" #include @@ -450,7 +449,7 @@ void RepairGUI_ShapeProcessDlg::reset() const char* get_convert( const char* theParam, const QString& theValue ) { if ( !strcmp( theParam, "SplitAngle.Angle" ) ) { - double doubleValue = theValue.toDouble() * PI / 180; + double doubleValue = theValue.toDouble() * M_PI / 180.; return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() ); } return CORBA::string_dup( theValue.toLatin1().constData() ); @@ -463,7 +462,7 @@ const char* get_convert( const char* theParam, const QString& theValue ) const char* set_convert( const char* theParam, const char* theValue ) { if ( !strcmp( theParam, "SplitAngle.Angle" ) ) { - double doubleValue = atof( theValue ) * 180 / PI; + double doubleValue = atof( theValue ) * 180. / M_PI; TCollection_AsciiString str( doubleValue ); return CORBA::string_dup( str.ToCString() ); } diff --git a/src/SKETCHER/Sketcher_Profile.cxx b/src/SKETCHER/Sketcher_Profile.cxx index e2d113e20..ff396a44b 100644 --- a/src/SKETCHER/Sketcher_Profile.cxx +++ b/src/SKETCHER/Sketcher_Profile.cxx @@ -18,14 +18,12 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM SKETCHER : basic sketcher // File : Sketcher_Profile.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: -// + #include #include @@ -189,7 +187,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) } case 'T': { - if (n1 != 3) goto badargs; + if (n1 != 3) goto badargs; Standard_Real vx = a(1).RealValue(); Standard_Real vy = a(2).RealValue(); if (a(0) == "TT") { @@ -209,7 +207,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) case 'R': { if (n1 != 2) goto badargs; - angle = a(1).RealValue() * PI180; + angle = a(1).RealValue() * M_PI / 180.; if (a(0) == "RR") { dx = Cos(angle); dy = Sin(angle); @@ -242,42 +240,43 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) if (n1 != 3) goto badargs; radius = a(1).RealValue(); if (Abs(radius) > Precision::Confusion()) { - angle = a(2).RealValue() * PI180; + angle = a(2).RealValue() * M_PI / 180.; move = circle; } else move = none; break; - } - case 'A': // TAngential arc by end point - { + } + case 'A': // TAngential arc by end point + { if (n1 != 3) goto badargs; Standard_Real vx = a(1).RealValue(); - Standard_Real vy = a(2).RealValue(); + Standard_Real vy = a(2).RealValue(); if (a(0) == "AA") { vx -= x; vy -= y; } Standard_Real det = dx * vy - dy * vx; if ( Abs(det) > Precision::Confusion()) { - Standard_Real c = (dx * vx + dy * vy) - / Sqrt((dx * dx + dy * dy) * (vx * vx + vy * vy)); // Cosine of alpha = arc of angle / 2 , alpha in [0,Pi] - radius = (vx * vx + vy * vy)* Sqrt(dx * dx + dy * dy) // radius = distance between start and end point / 2 * sin(alpha) - / (2.0 * det); // radius is > 0 or < 0 + // Cosine of alpha = arc of angle / 2 , alpha in [0,Pi] + Standard_Real c = (dx * vx + dy * vy) / Sqrt((dx * dx + dy * dy) * (vx * vx + vy * vy)); + // radius = distance between start and end point / 2 * sin(alpha) + // radius is > 0 or < 0 + radius = (vx * vx + vy * vy)* Sqrt(dx * dx + dy * dy) / (2.0 * det); if (Abs(radius) > Precision::Confusion()) { - angle = 2.0 * acos(c); // angle in [0,2Pi] + angle = 2.0 * acos(c); // angle in [0,2Pi] move = circle; } else move = none; break; - } + } else move = none; break; - } + } case 'U': // Arc by end point and radiUs - { + { if (n1 != 5) goto badargs; Standard_Real vx = a(1).RealValue(); Standard_Real vy = a(2).RealValue(); @@ -289,23 +288,24 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) } Standard_Real length = Sqrt(vx * vx + vy * vy); if ( (4.0 - (vx * vx + vy * vy) / (radius * radius) >= 0.0 ) && (length > Precision::Confusion()) ) { - Standard_Real c = 0.5 * Sqrt(4.0 - (vx * vx + vy * vy) / (radius * radius)); // Cosine of alpha = arc angle / 2 , alpha in [0,Pi/2] - angle = 2.0 * acos(c); // angle in [0,Pi] + // Cosine of alpha = arc angle / 2 , alpha in [0,Pi/2] + Standard_Real c = 0.5 * Sqrt(4.0 - (vx * vx + vy * vy) / (radius * radius)); + angle = 2.0 * acos(c); // angle in [0,Pi] if ( reversed == 2 ) - angle = angle - 2 * PI; - dx = 0.5 * ( vy * 1.0/radius - + vx * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius))); - dy = - 0.5 * ( vx * 1.0/radius - - vy * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius))); + angle = angle - 2 * M_PI; + dx = 0.5 * ( vy * 1.0/radius + + vx * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius))); + dy = - 0.5 * ( vx * 1.0/radius + - vy * Sqrt(4.0 / (vx * vx + vy * vy) - 1.0 / (radius * radius))); move = circle; } else{ move = none; } break; - } + } case 'E': // Arc by end point and cEnter - { + { if (n1 != 7) goto badargs; Standard_Real vx = a(1).RealValue(); Standard_Real vy = a(2).RealValue(); @@ -318,7 +318,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) vx -= x; vy -= y; vxc -= x; - vyc -= y; + vyc -= y; } radius = Sqrt( vxc * vxc + vyc * vyc ); Standard_Real det = vx * vyc - vy * vxc; @@ -330,27 +330,27 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) if ( error > Precision::Confusion() ){ MESSAGE("Warning : The specified end point is not on the Arc, distance = "< Precision::Confusion() && control_Tolerance == 1) // Don't create the arc if the end point + if ( error > Precision::Confusion() && control_Tolerance == 1) // Don't create the arc if the end point move = none; // is too far from it - else if ( (length > Precision::Confusion()) && - (length2 > Precision::Confusion()) && + else if ( (length > Precision::Confusion()) && + (length2 > Precision::Confusion()) && (length3 > Precision::Confusion()) ) { - Standard_Real c = ( radius * radius - (vx * vxc + vy * vyc) ) - / ( radius * Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc)) ) ; // Cosine of arc angle - angle = acos(c); // angle in [0,Pi] + Standard_Real c = ( radius * radius - (vx * vxc + vy * vyc) ) + / ( radius * Sqrt((vx-vxc) * (vx-vxc) + (vy-vyc) * (vy-vyc)) ) ; // Cosine of arc angle + angle = acos(c); // angle in [0,Pi] if ( reversed == 2 ) - angle = angle - 2 * PI; + angle = angle - 2 * M_PI; if (det < 0) - angle = -angle; + angle = -angle; dx = vyc / radius; - dy = -vxc / radius; + dy = -vxc / radius; move = circle; } else { move = none; } break; - } + } case 'I': { if (n1 != 2) goto badargs; diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index d19be5a2e..4dd135d4c 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : TransformationGUI_RotationDlg.cxx // Author : Lucien PIGNOLONI, Open CASCADE S.A.S. -// + #include "TransformationGUI_RotationDlg.h" #include @@ -494,7 +493,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.count(); i++) { myCurrObject = myObjects[i]; - anObj = anOper->RotateCopy(myObjects[i].get(), myAxis.get(), GetAngle() * PI180); + anObj = anOper->RotateCopy(myObjects[i].get(), myAxis.get(), GetAngle() * M_PI / 180.); if (!anObj->_is_nil()) { if(!IsPreview()) { anObj->SetParameters(aParameters.join(":").toLatin1().constData()); @@ -506,7 +505,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.count(); i++) { myCurrObject = myObjects[i]; - anObj = anOper->Rotate(myObjects[i].get(), myAxis.get(), GetAngle() * PI180); + anObj = anOper->Rotate(myObjects[i].get(), myAxis.get(), GetAngle() * M_PI / 180.); if (!anObj->_is_nil()) { if(!IsPreview()) { anObj->SetParameters(aParameters.join(":").toLatin1().constData());