// Author: Peter KURNEV
// <pkv@irinox>
//
-
#include <IntTools_EdgeEdge.ixx>
-#include <BRep_Tool.hxx>
-
-#include <GCPnts_QuasiUniformDeflection.hxx>
-
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <Precision.hxx>
-#include <TColStd_ListOfReal.hxx>
-#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_ListOfReal.hxx>
#include <TColStd_SequenceOfReal.hxx>
-#include <IntTools.hxx>
-#include <IntTools_Range.hxx>
-#include <IntTools_CArray1OfInteger.hxx>
-#include <IntTools_CArray1OfReal.hxx>
-#include <IntTools_Array1OfRange.hxx>
-#include <IntTools_QuickSortRange.hxx>
-#include <IntTools_CompareRange.hxx>
-#include <IntTools_Root.hxx>
-#include <IntTools_Array1OfRoots.hxx>
-#include <IntTools_Compare.hxx>
-#include <IntTools_QuickSort.hxx>
-#include <IntTools_Root.hxx>
-#include <IntTools_CommonPrt.hxx>
-#include <IntTools_SequenceOfRanges.hxx>
-
#include <gp_Circ.hxx>
#include <gp_Ax1.hxx>
#include <gp_Lin.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
-#include <gce_MakeCirc.hxx>
-#include <Precision.hxx>
-#include <IntTools.hxx>
-//
-#include <Bnd_Box.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopExp.hxx>
-#include <BndLib_Add3dCurve.hxx>
-#include <IntTools_BeanBeanIntersector.hxx>
-#include <IntTools_Tools.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Curve.hxx>
+
+#include <Geom_BSplineCurve.hxx>
+#include <GeomAdaptor_Curve.hxx>
#include <CPnts_AbscissaPoint.hxx>
-#include <gp_Circ.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
#include <Extrema_ExtElC.hxx>
#include <Extrema_POnCurv.hxx>
+#include <Extrema_ExtCC.hxx>
+
#include <TopoDS_Iterator.hxx>
-#include <Geom_BSplineCurve.hxx>
+#include <BRep_Tool.hxx>
+
+#include <IntTools.hxx>
+#include <IntTools_Range.hxx>
+#include <IntTools_CArray1OfReal.hxx>
+#include <IntTools_CommonPrt.hxx>
+#include <IntTools_SequenceOfRanges.hxx>
+#include <IntTools_Tools.hxx>
+#include <IntTools_BeanBeanIntersector.hxx>
//=======================================================================
//function : IntTools_EdgeEdge::IntTools_EdgeEdge
return;
}
//
- //modified by NIZNHY-PKV Mon Oct 31 14:52:09 2011f
bIsSameCurves=IsSameCurves();
if (bIsSameCurves) {
aCommonPrt.SetType(TopAbs_EDGE);
myIsDone=Standard_True;
return;
}
- //modified by NIZNHY-PKV Mon Oct 31 14:52:11 2011t
//
IntTools_BeanBeanIntersector anIntersector(myCFrom, myCTo, myTolFrom, myTolTo);
anIntersector.SetBeanParameters(Standard_True, myTminFrom, myTmaxFrom);
//
myIsDone=Standard_True;
}
-//modified by NIZNHY-PKV Mon Oct 31 14:04:36 2011f
-//=======================================================================
-//function : IsSameCurves
-//purpose :
-//=======================================================================
-Standard_Boolean IntTools_EdgeEdge::IsSameCurves()
-{
- Standard_Boolean bRet;
- GeomAbs_CurveType aCTFrom, aCTTo;
- //
- aCTFrom = myCFrom.GetType();
- aCTTo = myCTo.GetType();
- //
- bRet = (aCTFrom==aCTTo);
- if (!bRet) {
- return bRet;
- }
- //
- bRet=Standard_False;
- //
- if (aCTTo==GeomAbs_BSplineCurve) {
- Standard_Boolean bIsRational, bIsPreiodic;
- Standard_Integer iNbPoles, iNbKnots, iDegree;
- Standard_Real dT, aEpsilon;
- //
- aEpsilon=Epsilon(myTminFrom);
- dT=myTminFrom-myTminTo;
- bRet=(fabs(dT)<aEpsilon);
- if (!bRet) {
- return bRet;
- }
- //
- aEpsilon=Epsilon(myTmaxFrom);
- dT=myTmaxFrom-myTmaxTo;
- bRet=(fabs(dT)<aEpsilon);
- if (!bRet) {
- return bRet;
- }
- //
- bIsRational=myCFrom.IsRational();
- bRet=(bIsRational==myCTo.IsRational());
- if (!bRet) {
- return bRet;
- }
- //
- iNbPoles=myCFrom.NbPoles();
- bRet=(iNbPoles==myCTo.NbPoles());
- if (!bRet) {
- return bRet;
- }
- //
- iNbKnots=myCFrom.NbKnots();
- bRet=(iNbKnots==myCTo.NbKnots());
- if (!bRet) {
- return bRet;
- }
- //
- iDegree=myCFrom.Degree();
- bRet=(iDegree==myCTo.Degree());
- if (!bRet) {
- return bRet;
- }
- //
- bIsPreiodic=myCFrom.IsPeriodic();
- bRet=(bIsPreiodic==myCTo.IsPeriodic());
- if (!bRet) {
- return bRet;
- }
- //-------------------------------------------
- Standard_Integer i, j, aM[2];
- Standard_Real aT1[2], aT2[2], aX0[4], aX1[4];
- gp_Pnt aP;
- Handle(Geom_Curve) aC;
- Handle(Geom_BSplineCurve) aBSp[2];
- TopoDS_Edge aE[2];
- //
- aE[0]=myCFrom.Edge();
- aE[1]=myCTo.Edge();
- //
- aC=BRep_Tool::Curve (aE[0], aT1[0], aT2[0]);
- aBSp[0]=Handle(Geom_BSplineCurve)::DownCast(aC);
- //
- aC=BRep_Tool::Curve (aE[1], aT1[1], aT2[1]);
- aBSp[1]=Handle(Geom_BSplineCurve)::DownCast(aC);
- //
- aEpsilon=Epsilon(aT1[0]);
- dT=aT1[0]-aT1[1];
- bRet=(fabs(dT)<aEpsilon);
- if (!bRet) {
- return bRet;
- }
- //
- aEpsilon=Epsilon(aT2[0]);
- dT=aT2[0]-aT2[1];
- bRet=(fabs(dT)<aEpsilon);
- if (!bRet) {
- return bRet;
- }
- //
- // Poles / Weights
- for(i=1; i<=iNbPoles; ++i) {
- aP=aBSp[0]->Pole(i);
- aP.Coord(aX0[0], aX0[1], aX0[2]);
- aX0[3]=aBSp[0]->Weight(i);
- //
- aP=aBSp[1]->Pole(i);
- aP.Coord(aX1[0], aX1[1], aX1[2]);
- aX1[3]=aBSp[1]->Weight(i);
- //
- for (j=0; j<4; ++j) {
- aEpsilon=Epsilon(aX0[j]);
- dT=aX0[j]-aX1[j];
- bRet=(fabs(dT)<aEpsilon);
- if(!bRet) {
- return bRet;
- }
- }
- }//for(i=1; i<iNbPoles; ++i) {
- //
- // Knots / Multiplicities
- for(i=1; i<=iNbKnots; ++i) {
- aX0[0]=aBSp[0]->Knot(i);
- aX0[1]=aBSp[1]->Knot(i);
- aEpsilon=Epsilon(aX0[0]);
- dT=aX0[0]-aX0[1];
- bRet=(fabs(dT)<aEpsilon);
- if(!bRet) {
- return bRet;
- }
- //
- aM[0]=aBSp[0]->Multiplicity(i);
- aM[1]=aBSp[1]->Multiplicity(i);
- bRet=(aM[0]==aM[1]);
- if(!bRet) {
- return bRet;
- }
- }//for(i=1; i<=iNbKnots; ++i) {
- }// if (aCTTo==GeomAbs_BSplineCurve) {
- return bRet;
-}
-//modified by NIZNHY-PKV Mon Oct 31 14:04:40 2011t
+
//=======================================================================
//function : CheckData
//purpose :
// on myCTo
//
-#include <Precision.hxx>
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <BRep_Tool.hxx>
-#include <Extrema_ExtCC.hxx>
-#include <ElCLib.hxx>
+
//=======================================================================
//function : CheckTouchVertex
//purpose : line/Circle refinement
mySeqOfCommonPrts.Append(aCommonPrt);
}
+//modified by NIZNHY-PKV Mon Dec 26 13:44:53 2011f
+static
+ Standard_Boolean IsSameReal(const Standard_Real aR1,
+ const Standard_Real aR2);
+static
+ Standard_Boolean IsSameXYZ(const gp_XYZ& aXYZ1, const gp_XYZ& aXYZ2);
+static
+ Standard_Boolean IsSameDir(const gp_Dir& aDir1, const gp_Dir& aDir2);
+static
+ Standard_Boolean IsSamePnt(const gp_Pnt& aP1, const gp_Pnt& aP2);
+static
+ Standard_Boolean IsSameAx1(const gp_Ax1& aAx1, const gp_Ax1& aAx2);
+static
+ Standard_Boolean IsSameAx2(const gp_Ax2& aAx21, const gp_Ax2& aAx22);
+static
+ Standard_Boolean IsSameElips(const gp_Elips& aElips1,
+ const gp_Elips& aElips2);
+static
+ Standard_Boolean IsSameBSplineCurve(const BRepAdaptor_Curve& myCFrom,
+ const BRepAdaptor_Curve& myCTo);
+
+//=======================================================================
+//function : IsSameCurves
+//purpose :
+//=======================================================================
+Standard_Boolean IntTools_EdgeEdge::IsSameCurves()
+{
+ Standard_Boolean bRet;
+ GeomAbs_CurveType aCTFrom, aCTTo;
+ //
+ aCTFrom=myCFrom.GetType();
+ aCTTo =myCTo.GetType();
+ //
+ bRet=(aCTFrom==aCTTo);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ bRet=IsSameReal(myTminFrom, myTminTo);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ bRet=IsSameReal(myTmaxFrom, myTmaxTo);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ bRet=!bRet; // false
+ //
+ if (aCTTo==GeomAbs_Ellipse) {
+ gp_Elips aC1, aC2;
+ //
+ aC1=myCFrom.Ellipse();
+ aC2=myCTo.Ellipse();
+ //
+ bRet=IsSameElips(aC1, aC2);
+ //
+ return bRet;
+ } //if (aCTTo==GeomAbs_Ellipse) {
+ //
+ else if (aCTTo==GeomAbs_BSplineCurve) {
+ bRet=IsSameBSplineCurve(myCFrom, myCTo);
+ if(!bRet) {
+ return bRet;
+ }
+ }// if (aCTTo==GeomAbs_BSplineCurve) {
+ return bRet;
+}
+//=======================================================================
+//function : IsSameBSplineCurve
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameBSplineCurve(const BRepAdaptor_Curve& myCFrom,
+ const BRepAdaptor_Curve& myCTo)
+{
+ Standard_Boolean bRet, bIsRational, bIsPreiodic;
+ Standard_Integer iNbPoles, iNbKnots, iDegree;
+ //
+ bIsRational=myCFrom.IsRational();
+ bRet=(bIsRational==myCTo.IsRational());
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ iNbPoles=myCFrom.NbPoles();
+ bRet=(iNbPoles==myCTo.NbPoles());
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ iNbKnots=myCFrom.NbKnots();
+ bRet=(iNbKnots==myCTo.NbKnots());
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ iDegree=myCFrom.Degree();
+ bRet=(iDegree==myCTo.Degree());
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ bIsPreiodic=myCFrom.IsPeriodic();
+ bRet=(bIsPreiodic==myCTo.IsPeriodic());
+ if (!bRet) {
+ return bRet;
+ }
+ //-------------------------------------------
+ Standard_Integer i, j, aM[2];
+ Standard_Real aT1[2], aT2[2], aX0[4], aX1[4];
+ gp_Pnt aP;
+ Handle(Geom_Curve) aC;
+ Handle(Geom_BSplineCurve) aBSp[2];
+ TopoDS_Edge aE[2];
+ //
+ aE[0]=myCFrom.Edge();
+ aE[1]=myCTo.Edge();
+ //
+ aC=BRep_Tool::Curve (aE[0], aT1[0], aT2[0]);
+ aBSp[0]=Handle(Geom_BSplineCurve)::DownCast(aC);
+ //
+ aC=BRep_Tool::Curve (aE[1], aT1[1], aT2[1]);
+ aBSp[1]=Handle(Geom_BSplineCurve)::DownCast(aC);
+ //
+ bRet=IsSameReal(aT1[0], aT1[1]);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ bRet=IsSameReal(aT2[0], aT2[1]);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ // Poles / Weights
+ for(i=1; i<=iNbPoles; ++i) {
+ aP=aBSp[0]->Pole(i);
+ aP.Coord(aX0[0], aX0[1], aX0[2]);
+ aX0[3]=aBSp[0]->Weight(i);
+ //
+ aP=aBSp[1]->Pole(i);
+ aP.Coord(aX1[0], aX1[1], aX1[2]);
+ aX1[3]=aBSp[1]->Weight(i);
+ //
+ for (j=0; j<4; ++j) {
+ bRet=IsSameReal(aX0[j], aX1[j]);
+ if(!bRet) {
+ return bRet;
+ }
+ }
+ }//for(i=1; i<iNbPoles; ++i) {
+ //
+ // Knots / Multiplicities
+ for(i=1; i<=iNbKnots; ++i) {
+ aX0[0]=aBSp[0]->Knot(i);
+ aX0[1]=aBSp[1]->Knot(i);
+ bRet=IsSameReal(aX0[0], aX0[1]);
+ if(!bRet) {
+ return bRet;
+ }
+ //
+ aM[0]=aBSp[0]->Multiplicity(i);
+ aM[1]=aBSp[1]->Multiplicity(i);
+ bRet=(aM[0]==aM[1]);
+ if(!bRet) {
+ return bRet;
+ }
+ }// for(i=1; i<=iNbKnots; ++i) {
+ return bRet;
+}
+//=======================================================================
+//function : IsSameElips
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameElips(const gp_Elips& aElips1,
+ const gp_Elips& aElips2)
+{
+ Standard_Boolean bRet;
+ Standard_Real aR1, aR2;
+ //
+ aR1=aElips1.MajorRadius();
+ aR2=aElips2.MajorRadius();
+ bRet=IsSameReal(aR1, aR2);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ aR1=aElips1.MinorRadius();
+ aR2=aElips2.MinorRadius();
+ bRet=IsSameReal(aR1, aR2);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ const gp_Ax2& aAx21=aElips1.Position();
+ const gp_Ax2& aAx22=aElips2.Position();
+ bRet=IsSameAx2(aAx21, aAx22);
+ return bRet;
+}
+//=======================================================================
+//function : IsSameAx2
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameAx2(const gp_Ax2& aAx21, const gp_Ax2& aAx22)
+{
+ Standard_Boolean bRet;
+ //
+ const gp_Ax1& aAx1=aAx21.Axis();
+ const gp_Ax1& aAx2=aAx22.Axis();
+ //
+ bRet=IsSameAx1(aAx1, aAx2);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ const gp_Dir& aDirX1=aAx21.XDirection();
+ const gp_Dir& aDirX2=aAx22.XDirection();
+ //
+ bRet=IsSameDir(aDirX1, aDirX2);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ //
+ const gp_Dir& aDirY1=aAx21.YDirection();
+ const gp_Dir& aDirY2=aAx22.YDirection();
+ //
+ bRet=IsSameDir(aDirY1, aDirY2);
+ //
+ return bRet;
+}
+//=======================================================================
+//function : IsSameAx1
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameAx1(const gp_Ax1& aAx1, const gp_Ax1& aAx2)
+{
+ Standard_Boolean bRet;
+ //
+ const gp_Pnt& aP1=aAx1.Location();
+ const gp_Pnt& aP2=aAx2.Location();
+ //
+ bRet=IsSamePnt(aP1, aP2);
+ if (!bRet) {
+ return bRet;
+ }
+ //
+ const gp_Dir& aDir1=aAx1.Direction();
+ const gp_Dir& aDir2=aAx2.Direction();
+ //
+ bRet=IsSameDir(aDir1, aDir2);
+ return bRet;
+}
+//=======================================================================
+//function : IsSamePnt
+//purpose :
+//=======================================================================
+Standard_Boolean IsSamePnt(const gp_Pnt& aP1, const gp_Pnt& aP2)
+{
+ const gp_XYZ& aXYZ1=aP1.XYZ();
+ const gp_XYZ& aXYZ2=aP2.XYZ();
+ return IsSameXYZ(aXYZ1, aXYZ2);
+}
+//=======================================================================
+//function : IsSameDir
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameDir(const gp_Dir& aDir1, const gp_Dir& aDir2)
+{
+ const gp_XYZ& aXYZ1=aDir1.XYZ();
+ const gp_XYZ& aXYZ2=aDir2.XYZ();
+ return IsSameXYZ(aXYZ1, aXYZ2);
+}
+//=======================================================================
+//function : IsSameXYZ
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameXYZ(const gp_XYZ& aXYZ1, const gp_XYZ& aXYZ2)
+{
+ Standard_Boolean bRet;
+ Standard_Integer i;
+ Standard_Real aX1[3], aX2[3];
+
+ aXYZ1.Coord(aX1[0], aX1[1], aX1[2]);
+ aXYZ2.Coord(aX2[0], aX2[1], aX2[2]);
+ //
+ for (i=0; i<3; ++i) {
+ bRet=IsSameReal(aX1[i], aX2[i]);
+ if(!bRet) {
+ break;
+ }
+ }
+ return bRet;
+}
+//=======================================================================
+//function : IsSameReal
+//purpose :
+//=======================================================================
+Standard_Boolean IsSameReal(const Standard_Real aR1,
+ const Standard_Real aR2)
+{
+ Standard_Boolean bRet;
+ Standard_Real aEpsilon;
+ //
+ aEpsilon=Epsilon(aR1);
+ bRet=(fabs(aR1-aR2)<aEpsilon);
+ return bRet;
+}
+//modified by NIZNHY-PKV Mon Dec 26 13:44:55 2011t