mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024208: Optimization of the edge-edge and edge-face intersection algorithms
New Edge/Edge intersection algorithm (based on the intersection between edges bounding boxes). Small correction.
This commit is contained in:
@@ -735,28 +735,12 @@ void BOPAlgo_ArgumentAnalyzer::TestTangent()
|
||||
}
|
||||
}
|
||||
else if(theType == TopAbs_EDGE) {
|
||||
Standard_Integer aDiscretize = 30;
|
||||
Standard_Real aDeflection = 0.01;
|
||||
const TopoDS_Edge& aE1 = *(TopoDS_Edge*)&(aS1);
|
||||
const TopoDS_Edge& aE2 = *(TopoDS_Edge*)&(aS2);
|
||||
|
||||
IntTools_EdgeEdge aEE;
|
||||
aEE.SetEdge1 (aE1);
|
||||
aEE.SetEdge2 (aE2);
|
||||
aEE.SetTolerance1 (BRep_Tool::Tolerance(aE1));
|
||||
aEE.SetTolerance2 (BRep_Tool::Tolerance(aE2));
|
||||
aEE.SetDiscretize (aDiscretize);
|
||||
aEE.SetDeflection (aDeflection);
|
||||
|
||||
Standard_Real f = 0., l = 0.;
|
||||
BRep_Tool::Range(aE1, f, l);
|
||||
aEE.SetRange1(f, l);
|
||||
|
||||
BRep_Tool::Range(aE2, f, l);
|
||||
aEE.SetRange2(f, l);
|
||||
|
||||
//
|
||||
IntTools_EdgeEdge aEE(aE1, aE2);
|
||||
//
|
||||
aEE.Perform();
|
||||
|
||||
if (aEE.IsDone()) {
|
||||
const IntTools_SequenceOfCommonPrts& aCPrts = aEE.CommonParts();
|
||||
Standard_Integer ii = 0;
|
||||
|
@@ -69,17 +69,14 @@
|
||||
//=======================================================================
|
||||
void BOPAlgo_PaveFiller::PerformEE()
|
||||
{
|
||||
Standard_Boolean bJustAdd, bOrder;
|
||||
Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize;
|
||||
Standard_Integer aNbCPrts, nWhat, nWith;
|
||||
Standard_Boolean bJustAdd;
|
||||
Standard_Integer i, iX, iSize, nE1, nE2;
|
||||
Standard_Integer aNbCPrts;
|
||||
Standard_Real aTS11, aTS12, aTS21, aTS22,
|
||||
aT11, aT12, aT21, aT22;
|
||||
Standard_Real aTolE1, aTolE2, aDeflection;
|
||||
TopAbs_ShapeEnum aType;
|
||||
TopoDS_Edge aEWhat, aEWith;
|
||||
BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2;
|
||||
Handle(NCollection_IncAllocator) aAllocator;
|
||||
Handle(BOPDS_PaveBlock) aPBn1, aPBn2;
|
||||
BOPDS_MapOfPaveBlock aMPBToUpdate;
|
||||
BOPDS_MapIteratorOfMapOfPaveBlock aItPB;
|
||||
//
|
||||
@@ -96,9 +93,6 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator);
|
||||
BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator);
|
||||
//
|
||||
aDiscretize=30;
|
||||
aDeflection=0.01;
|
||||
//
|
||||
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
|
||||
aEEs.SetStartSize(iSize);
|
||||
aEEs.SetIncrement(iSize);
|
||||
@@ -122,9 +116,6 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
const TopoDS_Edge& aE1=(*(TopoDS_Edge *)(&aSIE1.Shape()));
|
||||
const TopoDS_Edge& aE2=(*(TopoDS_Edge *)(&aSIE2.Shape()));
|
||||
//
|
||||
aTolE1=BRep_Tool::Tolerance(aE1);
|
||||
aTolE2=BRep_Tool::Tolerance(aE2);
|
||||
//
|
||||
BOPDS_ListOfPaveBlock& aLPB1=myDS->ChangePaveBlocks(nE1);
|
||||
BOPDS_ListOfPaveBlock& aLPB2=myDS->ChangePaveBlocks(nE2);
|
||||
//
|
||||
@@ -158,75 +149,23 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// -----------f
|
||||
//DEBft
|
||||
//printf(" nE1=%d nE2=%d\n", nE1, nE2);
|
||||
//
|
||||
IntTools_EdgeEdge aEdgeEdge;
|
||||
//
|
||||
aEdgeEdge.SetEdge1 (aE1);
|
||||
aEdgeEdge.SetEdge2 (aE2);
|
||||
aEdgeEdge.SetTolerance1 (aTolE1);
|
||||
aEdgeEdge.SetTolerance2 (aTolE2);
|
||||
aEdgeEdge.SetDiscretize (aDiscretize);
|
||||
aEdgeEdge.SetDeflection (aDeflection);
|
||||
//
|
||||
IntTools_Range aSR1(aTS11, aTS12);
|
||||
IntTools_Range aSR2(aTS21, aTS22);
|
||||
IntTools_Range anewSR1 = aSR1;
|
||||
IntTools_Range anewSR2 = aSR2;
|
||||
//
|
||||
BOPTools_AlgoTools::CorrectRange (aE1, aE2, aSR1, anewSR1);
|
||||
BOPTools_AlgoTools::CorrectRange (aE2, aE1, aSR2, anewSR2);
|
||||
IntTools_EdgeEdge anEdgeEdge;
|
||||
//
|
||||
aPB1->Range(aT11, aT12);
|
||||
aPB2->Range(aT21, aT22);
|
||||
IntTools_Range aPBRange1(aT11, aT12), aPBRange2(aT21, aT22);
|
||||
//
|
||||
IntTools_Range aPBR1 = aPBRange1;
|
||||
IntTools_Range aPBR2 = aPBRange2;
|
||||
BOPTools_AlgoTools::CorrectRange (aE1, aE2, aPBR1, aPBRange1);
|
||||
BOPTools_AlgoTools::CorrectRange (aE2, aE1, aPBR2, aPBRange2);
|
||||
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
|
||||
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
|
||||
//
|
||||
aEdgeEdge.SetRange1(aPBRange1);
|
||||
aEdgeEdge.SetRange2(aPBRange2);
|
||||
//
|
||||
aEdgeEdge.Perform();
|
||||
if (!aEdgeEdge.IsDone()) {
|
||||
anEdgeEdge.Perform();
|
||||
if (!anEdgeEdge.IsDone()) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
bOrder=aEdgeEdge.Order();
|
||||
if (!bOrder) {
|
||||
aEWhat=aE1;
|
||||
aEWith=aE2;
|
||||
nWhat=nE1;
|
||||
nWith=nE2;
|
||||
aSR1=anewSR1;
|
||||
aSR2=anewSR2;
|
||||
aPBR1=aPBRange1;
|
||||
aPBR2=aPBRange2;
|
||||
aPBn1=aPB1;
|
||||
aPBn2=aPB2;
|
||||
}
|
||||
else {
|
||||
nWhat=nE2;
|
||||
nWith=nE1;
|
||||
aEWhat=aE2;
|
||||
aEWith=aE1;
|
||||
aSR1=anewSR2;
|
||||
aSR2=anewSR1;
|
||||
aPBR1=aPBRange2;
|
||||
aPBR2=aPBRange1;
|
||||
aPBn1=aPB2;
|
||||
aPBn2=aPB1;
|
||||
}
|
||||
//
|
||||
IntTools_Range aR11(aPBR1.First(), aSR1.First()), aR12(aSR1.Last(), aPBR1.Last()),
|
||||
aR21(aPBR2.First(), aSR2.First()), aR22(aSR2.Last(), aPBR2.Last());
|
||||
//
|
||||
const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeEdge.CommonParts();
|
||||
IntTools_Range aR11(aT11, aTS11), aR12(aTS12, aT12),
|
||||
aR21(aT21, aTS21), aR22(aTS22, aT22);
|
||||
//
|
||||
const IntTools_SequenceOfCommonPrts& aCPrts = anEdgeEdge.CommonParts();
|
||||
aNbCPrts=aCPrts.Length();
|
||||
for (i=1; i<=aNbCPrts; ++i) {
|
||||
const IntTools_CommonPrt& aCPart=aCPrts(i);
|
||||
@@ -237,18 +176,25 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
Standard_Integer nV[4], j;
|
||||
Standard_Real aT1, aT2, aTol;
|
||||
TopoDS_Vertex aVnew;
|
||||
IntTools_Range aCR1, aCR2;
|
||||
//
|
||||
BOPInt_Tools::VertexParameters(aCPart, aT1, aT2);
|
||||
aTol=Precision::Confusion();
|
||||
aTol = Precision::Confusion();
|
||||
aCR1 = aCPart.Range1();
|
||||
aCR2 = aCPart.Ranges2()(1);
|
||||
//
|
||||
//decide to keep the pave or not
|
||||
bIsOnPave[0] = BOPInt_Tools::IsOnPave1(aT1, aR11, aTol);
|
||||
bIsOnPave[1] = BOPInt_Tools::IsOnPave1(aT1, aR12, aTol);
|
||||
bIsOnPave[2] = BOPInt_Tools::IsOnPave1(aT2, aR21, aTol);
|
||||
bIsOnPave[3] = BOPInt_Tools::IsOnPave1(aT2, aR22, aTol);
|
||||
bIsOnPave[0] = BOPInt_Tools::IsOnPave1(aT1, aR11, aTol) ||
|
||||
BOPInt_Tools::IsOnPave1(aR11.First(), aCR1, aTol);
|
||||
bIsOnPave[1] = BOPInt_Tools::IsOnPave1(aT1, aR12, aTol) ||
|
||||
BOPInt_Tools::IsOnPave1(aR12.Last(), aCR1, aTol);
|
||||
bIsOnPave[2] = BOPInt_Tools::IsOnPave1(aT2, aR21, aTol) ||
|
||||
BOPInt_Tools::IsOnPave1(aR21.First(), aCR2, aTol);
|
||||
bIsOnPave[3] = BOPInt_Tools::IsOnPave1(aT2, aR22, aTol) ||
|
||||
BOPInt_Tools::IsOnPave1(aR22.Last(), aCR2, aTol);
|
||||
//
|
||||
aPBn1->Indices(nV[0], nV[1]);
|
||||
aPBn2->Indices(nV[2], nV[3]);
|
||||
aPB1->Indices(nV[0], nV[1]);
|
||||
aPB2->Indices(nV[2], nV[3]);
|
||||
//
|
||||
if((bIsOnPave[0] && bIsOnPave[2]) || (bIsOnPave[0] && bIsOnPave[3]) ||
|
||||
(bIsOnPave[1] && bIsOnPave[2]) || (bIsOnPave[1] && bIsOnPave[3])) {
|
||||
@@ -259,7 +205,7 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
for (j = 0; j < 4; ++j) {
|
||||
if (bIsOnPave[j]) {
|
||||
//add interf VE(nV[j], nE)
|
||||
Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPBn2 : aPBn1;
|
||||
Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPB2 : aPB1;
|
||||
ForceInterfVE(nV[j], aPB, aMPBToUpdate);
|
||||
bFlag = Standard_True;
|
||||
break;
|
||||
@@ -269,7 +215,7 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
continue;
|
||||
}
|
||||
//
|
||||
BOPTools_AlgoTools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aVnew);
|
||||
BOPTools_AlgoTools::MakeNewVertex(aE1, aT1, aE2, aT2, aVnew);
|
||||
// <-LXBR
|
||||
{
|
||||
Standard_Integer nVS[2], iFound, k;
|
||||
@@ -312,14 +258,14 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 1
|
||||
iX=aEEs.Append()-1;
|
||||
BOPDS_InterfEE& aEE=aEEs(iX);
|
||||
aEE.SetIndices(nWhat, nWith);
|
||||
aEE.SetIndices(nE1, nE2);
|
||||
aEE.SetCommonPart(aCPart);
|
||||
// 2
|
||||
myDS->AddInterf(nWhat, nWith);
|
||||
myDS->AddInterf(nE1, nE2);
|
||||
//
|
||||
BOPDS_CoupleOfPaveBlocks aCPB;
|
||||
//
|
||||
@@ -342,10 +288,10 @@ void BOPAlgo_PaveFiller::PerformEE()
|
||||
// 1
|
||||
iX=aEEs.Append()-1;
|
||||
BOPDS_InterfEE& aEE=aEEs(iX);
|
||||
aEE.SetIndices(nWhat, nWith);
|
||||
aEE.SetIndices(nE1, nE2);
|
||||
aEE.SetCommonPart(aCPart);
|
||||
// 2
|
||||
myDS->AddInterf(nWhat, nWith);
|
||||
myDS->AddInterf(nE1, nE2);
|
||||
//
|
||||
BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
|
||||
}//case TopAbs_EDGE
|
||||
|
@@ -1399,66 +1399,66 @@ Standard_Boolean BOPAlgo_PaveFiller::ExtendedTolerance(const Standard_Integer nV
|
||||
aType1=aGAS1.GetType();
|
||||
aType2=aGAS2.GetType();
|
||||
//
|
||||
if (aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
|
||||
GeomAbs_CurveType aTypeC;
|
||||
//if (aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
|
||||
GeomAbs_CurveType aTypeC;
|
||||
//
|
||||
const IntTools_Curve& aIC=aNC.Curve();
|
||||
aTypeC=aIC.Type();
|
||||
//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
|
||||
Handle(Geom2d_Curve) aC2D[2];
|
||||
//
|
||||
aC2D[0]=aIC.FirstCurve2d();
|
||||
aC2D[1]=aIC.SecondCurve2d();
|
||||
if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) {
|
||||
Standard_Integer nV, m, n;
|
||||
Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr;
|
||||
gp_Pnt aPC[2], aPV;
|
||||
gp_Dir aDN[2];
|
||||
gp_Pnt2d aP2D;
|
||||
BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1;
|
||||
//
|
||||
const IntTools_Curve& aIC=aNC.Curve();
|
||||
aTypeC=aIC.Type();
|
||||
if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
|
||||
Handle(Geom2d_Curve) aC2D[2];
|
||||
aDT2=2e-7; // the rich criteria
|
||||
aDScPr=5.e-9; // the creasing criteria
|
||||
aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
|
||||
//
|
||||
aItMI.Initialize(aMV);
|
||||
for (; aItMI.More(); aItMI.Next()) {
|
||||
nV = aItMI.Value();
|
||||
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV));
|
||||
aPV=BRep_Tool::Pnt(aV);
|
||||
//
|
||||
aC2D[0]=aIC.FirstCurve2d();
|
||||
aC2D[1]=aIC.SecondCurve2d();
|
||||
if (!aC2D[0].IsNull() && !aC2D[1].IsNull()) {
|
||||
Standard_Integer nV, m, n;
|
||||
Standard_Real aTC[2], aD, aD2, u, v, aDT2, aScPr, aDScPr;
|
||||
gp_Pnt aPC[2], aPV;
|
||||
gp_Dir aDN[2];
|
||||
gp_Pnt2d aP2D;
|
||||
BOPCol_MapIteratorOfMapOfInteger aItMI, aItMI1;
|
||||
for (m=0; m<2; ++m) {
|
||||
aD2=aPC[m].SquareDistance(aPV);
|
||||
if (aD2>aDT2) {// no rich
|
||||
continue;
|
||||
}
|
||||
//
|
||||
aDT2=2e-7; // the rich criteria
|
||||
aDScPr=5.e-9; // the creasing criteria
|
||||
aIC.Bounds(aTC[0], aTC[1], aPC[0], aPC[1]);
|
||||
for (n=0; n<2; ++n) {
|
||||
Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
|
||||
aC2D[n]->D0(aTC[m], aP2D);
|
||||
aP2D.Coord(u, v);
|
||||
BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]);
|
||||
}
|
||||
//
|
||||
aScPr=aDN[0]*aDN[1];
|
||||
if (aScPr<0.) {
|
||||
aScPr=-aScPr;
|
||||
}
|
||||
aScPr=1.-aScPr;
|
||||
//
|
||||
aItMI.Initialize(aMV);
|
||||
for (; aItMI.More(); aItMI.Next()) {
|
||||
nV = aItMI.Value();
|
||||
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nV));
|
||||
aPV=BRep_Tool::Pnt(aV);
|
||||
//
|
||||
for (m=0; m<2; ++m) {
|
||||
aD2=aPC[m].SquareDistance(aPV);
|
||||
if (aD2>aDT2) {// no rich
|
||||
continue;
|
||||
}
|
||||
//
|
||||
for (n=0; n<2; ++n) {
|
||||
Handle(Geom_Surface)& aS=(!n)? aS1 : aS2;
|
||||
aC2D[n]->D0(aTC[m], aP2D);
|
||||
aP2D.Coord(u, v);
|
||||
BOPTools_AlgoTools3D::GetNormalToSurface(aS, u, v, aDN[n]);
|
||||
}
|
||||
//
|
||||
aScPr=aDN[0]*aDN[1];
|
||||
if (aScPr<0.) {
|
||||
aScPr=-aScPr;
|
||||
}
|
||||
aScPr=1.-aScPr;
|
||||
//
|
||||
if (aScPr>aDScPr) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// The intersection curve aIC is vanishing curve (the crease)
|
||||
aD=sqrt(aD2);
|
||||
//
|
||||
PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
|
||||
}
|
||||
}//for (jVU=1; jVU=aNbVU; ++jVU) {
|
||||
if (aScPr>aDScPr) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// The intersection curve aIC is vanishing curve (the crease)
|
||||
aD=sqrt(aD2);
|
||||
//
|
||||
PutPaveOnCurve(nV, aD, aNC, aMI, aMVTol);
|
||||
}
|
||||
}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
|
||||
}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
|
||||
}//for (jVU=1; jVU=aNbVU; ++jVU) {
|
||||
}
|
||||
//}//if (aTypeC==GeomAbs_BezierCurve || aTypeC==GeomAbs_BSplineCurve) {
|
||||
//}//if(aType1==GeomAbs_Torus || aType2==GeomAbs_Torus) {
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
Reference in New Issue
Block a user