//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <BOPAlgo_PaveFiller.ixx>
-
-#include <Precision.hxx>
-#include <NCollection_IncAllocator.hxx>
-#include <NCollection_UBTreeFiller.hxx>
#include <Bnd_Box.hxx>
+#include <BOPAlgo_PaveFiller.hxx>
+#include <BOPAlgo_SectionAttribute.hxx>
+#include <BOPAlgo_Tools.hxx>
+#include <BOPCol_BoxBndTree.hxx>
+#include <BOPCol_DataMapOfIntegerShape.hxx>
+#include <BOPCol_DataMapOfShapeInteger.hxx>
+#include <BOPCol_DataMapOfShapeListOfShape.hxx>
+#include <BOPCol_IndexedDataMapOfShapeBox.hxx>
+#include <BOPCol_NCVector.hxx>
+#include <BOPCol_Parallel.hxx>
+#include <BOPDS_CommonBlock.hxx>
+#include <BOPDS_CoupleOfPaveBlocks.hxx>
+#include <BOPDS_Curve.hxx>
+#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
+#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
+#include <BOPDS_DS.hxx>
+#include <BOPDS_Interf.hxx>
+#include <BOPDS_Iterator.hxx>
+#include <BOPDS_MapOfPaveBlock.hxx>
+#include <BOPDS_Pave.hxx>
+#include <BOPDS_PaveBlock.hxx>
+#include <BOPDS_VectorOfInterfEE.hxx>
+#include <BOPTools_AlgoTools.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Compound.hxx>
#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
-//
+#include <BRepTools.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <gp_Pnt.hxx>
+#include <IntTools_CommonPrt.hxx>
+#include <IntTools_Context.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
-#include <IntTools_CommonPrt.hxx>
#include <IntTools_SequenceOfRanges.hxx>
+#include <IntTools_ShrunkRange.hxx>
+#include <IntTools_Tools.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+#include <Precision.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_EdgeEdge
+//purpose :
+//=======================================================================
+class BOPAlgo_EdgeEdge :
+ public IntTools_EdgeEdge,
+ public BOPAlgo_Algo {
+
+ public:
+
+ DEFINE_STANDARD_ALLOC
+ //
+ BOPAlgo_EdgeEdge():
+ IntTools_EdgeEdge(),
+ BOPAlgo_Algo() {
+ };
+ //
+ virtual ~BOPAlgo_EdgeEdge(){
+ };
+ //
+ void SetPaveBlock1(const Handle(BOPDS_PaveBlock)& aPB) {
+ myPB1=aPB;
+ }
+ //
+ Handle(BOPDS_PaveBlock)& PaveBlock1() {
+ return myPB1;
+ }
+ //
+ void SetPaveBlock2(const Handle(BOPDS_PaveBlock)& aPB) {
+ myPB2=aPB;
+ }
+ //
+ Handle(BOPDS_PaveBlock)& PaveBlock2() {
+ return myPB2;
+ }
+ //
+ virtual void Perform() {
+ BOPAlgo_Algo::UserBreak();
+ IntTools_EdgeEdge::Perform();
+ }
+ //
+ protected:
+ Handle(BOPDS_PaveBlock) myPB1;
+ Handle(BOPDS_PaveBlock) myPB2;
+};
//
-#include <BOPTools_AlgoTools.hxx>
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_EdgeEdge> BOPAlgo_VectorOfEdgeEdge;
//
-#include <BOPCol_DataMapOfShapeInteger.hxx>
-#include <BOPCol_DataMapOfIntegerShape.hxx>
-#include <BOPCol_IndexedDataMapOfShapeBox.hxx>
+typedef BOPCol_Functor
+ <BOPAlgo_EdgeEdge,
+ BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeFunctor;
//
-#include <BOPInt_Context.hxx>
-#include <BOPInt_ShrunkRange.hxx>
-#include <BOPInt_Tools.hxx>
+typedef BOPCol_Cnt
+ <BOPAlgo_EdgeEdgeFunctor,
+ BOPAlgo_VectorOfEdgeEdge> BOPAlgo_EdgeEdgeCnt;
//
-#include <BOPDS_DataMapOfPaveBlockListOfPaveBlock.hxx>
-#include <BOPDS_MapOfPaveBlock.hxx>
-#include <BOPDS_CommonBlock.hxx>
-#include <BOPDS_CoupleOfPaveBlocks.hxx>
-#include <BOPDS_DataMapOfPaveBlockListOfInteger.hxx>
-#include <BOPDS_Iterator.hxx>
-#include <BOPDS_VectorOfInterfEE.hxx>
-#include <BOPDS_Interf.hxx>
-#include <BOPDS_Pave.hxx>
-#include <BOPDS_BoxBndTree.hxx>
-
-#include <BOPAlgo_Tools.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_TNV
+//purpose :
+//=======================================================================
+class BOPAlgo_TNV : public BOPCol_BoxBndTreeSelector{
+ public:
+ BOPAlgo_TNV()
+ : BOPCol_BoxBndTreeSelector(), myTree(NULL) {
+ };
+ //
+ ~BOPAlgo_TNV(){
+ };
+ //
+ void SetVertex(const TopoDS_Vertex& aV) {
+ myV=aV;
+ }
+ //
+ const TopoDS_Vertex& Vertex()const {
+ return myV;
+ }
+ //
+ void SetTree(BOPCol_BoxBndTree& aTree) {
+ myTree=&aTree;
+ }
+ //
+ void Perform() {
+ myTree->Select(*this);
+ }
+ //
+ protected:
+ TopoDS_Vertex myV;
+ BOPCol_BoxBndTree *myTree;
+};
+//
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_TNV> BOPAlgo_VectorOfTNV;
+//
+typedef BOPCol_Functor
+ <BOPAlgo_TNV,
+ BOPAlgo_VectorOfTNV> BOPAlgo_TNVFunctor;
+//
+typedef BOPCol_Cnt
+ <BOPAlgo_TNVFunctor,
+ BOPAlgo_VectorOfTNV> BOPAlgo_TNVCnt;
+/////////////////////////////////////////////////////////////////////////
+//=======================================================================
+//class : BOPAlgo_PVE
+//purpose :
+//=======================================================================
+class BOPAlgo_PVE {
+ public:
+ BOPAlgo_PVE()
+ : myIV(-1), myIE(-1), myFlag(-1), myT(-1.) {
+ };
+ //
+ ~BOPAlgo_PVE(){
+ };
+ //
+ void SetIndices(const Standard_Integer nV,
+ const Standard_Integer nE){
+ myIV=nV;
+ myIE=nE;
+ }
+ //
+ void Indices(Standard_Integer& nV,
+ Standard_Integer& nE) const {
+ nV=myIV;
+ nE=myIE;
+ }
+ //
+ void SetVertex(const TopoDS_Vertex& aV) {
+ myV=aV;
+ }
+ //
+ const TopoDS_Vertex& Vertex()const {
+ return myV;
+ }
+ //
+ void SetEdge(const TopoDS_Edge& aE) {
+ myE=aE;
+ }
+ //
+ const TopoDS_Edge& Edge()const {
+ return myE;
+ }
+ //
+ void SetPaveBlock(const Handle(BOPDS_PaveBlock)& aPB) {
+ myPB=aPB;
+ }
+ //
+ Handle(BOPDS_PaveBlock)& PaveBlock() {
+ return myPB;
+ }
+ //
+ Standard_Integer Flag()const {
+ return myFlag;
+ }
+ //
+ Standard_Real Parameter()const {
+ return myT;
+ }
+ //
+ void SetContext(const Handle(IntTools_Context)& aContext) {
+ myContext=aContext;
+ }
+ //
+ const Handle(IntTools_Context)& Context()const {
+ return myContext;
+ }
+ //
+ void Perform() {
+ Standard_Real dummy;
+ myFlag = myContext->ComputeVE(myV, myE, myT, dummy);
+ };
+ //
+ protected:
+ Standard_Integer myIV;
+ Standard_Integer myIE;
+ Standard_Integer myFlag;
+ Standard_Real myT;
+ TopoDS_Vertex myV;
+ TopoDS_Edge myE;
+ Handle(BOPDS_PaveBlock) myPB;
+ Handle(IntTools_Context) myContext;
+};
+//=======================================================================
+typedef BOPCol_NCVector
+ <BOPAlgo_PVE> BOPAlgo_VectorOfPVE;
+//
+typedef BOPCol_ContextFunctor
+ <BOPAlgo_PVE,
+ BOPAlgo_VectorOfPVE,
+ Handle(IntTools_Context),
+ IntTools_Context> BOPAlgo_PVEFunctor;
+//
+typedef BOPCol_ContextCnt
+ <BOPAlgo_PVEFunctor,
+ BOPAlgo_VectorOfPVE,
+ Handle(IntTools_Context)> BOPAlgo_PVECnt;
+/////////////////////////////////////////////////////////////////////////
//=======================================================================
// function: PerformEE
// purpose:
//=======================================================================
- void BOPAlgo_PaveFiller::PerformEE()
+void BOPAlgo_PaveFiller::PerformEE()
{
- Standard_Boolean bJustAdd, bOrder;
- Standard_Integer i, iX, iSize, nE1, nE2, aDiscretize;
- Standard_Integer aNbCPrts, nWhat, nWith;
- 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;
+ Standard_Integer iSize;
//
myErrorStatus=0;
//
+ FillShrunkData(TopAbs_EDGE, TopAbs_EDGE);
+ //
myIterator->Initialize(TopAbs_EDGE, TopAbs_EDGE);
iSize=myIterator->ExpectedLength();
if (!iSize) {
return;
}
//
+ Standard_Boolean bJustAdd;
+ Standard_Integer i, iX, nE1, nE2, aNbCPrts, k, aNbFdgeEdge;
+ Standard_Real aTS11, aTS12, aTS21, aTS22, aT11, aT12, aT21, aT22;
+ TopAbs_ShapeEnum aType;
+ BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2;
+ Handle(NCollection_BaseAllocator) aAllocator;
+ BOPDS_MapOfPaveBlock aMPBToUpdate;
+ BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
+ BOPDS_MapIteratorOfMapOfPaveBlock aItPB;
+ //
+ aAllocator=NCollection_BaseAllocator::CommonBaseAllocator();
//-----------------------------------------------------scope f
- aAllocator=new NCollection_IncAllocator();
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);
- aEEs.Init();
//
for (; myIterator->More(); myIterator->Next()) {
myIterator->Value(nE1, nE2, bJustAdd);
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);
//
//
Handle(BOPDS_PaveBlock)& aPB1=aIt1.ChangeValue();
if (!aPB1->HasShrunkData()) {
- FillShrunkData(aPB1);
- if (myWarningStatus) {
- continue;
- }
+ continue;
}
aPB1->ShrunkData(aTS11, aTS12, aBB1);
//
//
Handle(BOPDS_PaveBlock)& aPB2=aIt2.ChangeValue();
if (!aPB2->HasShrunkData()) {
- FillShrunkData(aPB2);
- if (myWarningStatus) {
- continue;
- }
+ continue;
}
aPB2->ShrunkData(aTS21, aTS22, aBB2);
//
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);
- //
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);
- //
- aEdgeEdge.SetRange1(aPBRange1);
- aEdgeEdge.SetRange2(aPBRange2);
- //
- aEdgeEdge.Perform();
- if (!aEdgeEdge.IsDone()) {
- continue;
- }
+ BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge.Append1();
+ //
+ anEdgeEdge.SetPaveBlock1(aPB1);
+ anEdgeEdge.SetPaveBlock2(aPB2);
//
- 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();
- //
- aNbCPrts=aCPrts.Length();
- for (i=1; i<=aNbCPrts; ++i) {
- const IntTools_CommonPrt& aCPart=aCPrts(i);
- aType=aCPart.Type();
- switch (aType) {
- case TopAbs_VERTEX: {
- Standard_Boolean bIsOnPave[4], bFlag;
- Standard_Integer nV[4], j;
- Standard_Real aT1, aT2, aTol;
- TopoDS_Vertex aVnew;
- //
- BOPInt_Tools::VertexParameters(aCPart, aT1, aT2);
- aTol=Precision::Confusion();
- //
- //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);
- //
- aPBn1->Indices(nV[0], nV[1]);
- aPBn2->Indices(nV[2], nV[3]);
- //
- if((bIsOnPave[0] && bIsOnPave[2]) || (bIsOnPave[0] && bIsOnPave[3]) ||
- (bIsOnPave[1] && bIsOnPave[2]) || (bIsOnPave[1] && bIsOnPave[3])) {
- continue;
- }
- //
- bFlag = Standard_False;
- for (j = 0; j < 4; ++j) {
- if (bIsOnPave[j]) {
- //add interf VE(nV[j], nE)
- Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPBn2 : aPBn1;
- ForceInterfVE(nV[j], aPB, aMPBToUpdate);
- bFlag = Standard_True;
- break;
- }
- }
- if (bFlag) {
- continue;
- }
- //
- BOPTools_AlgoTools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aVnew);
- // <-LXBR
- {
- Standard_Integer nVS[2], iFound, k;
- Standard_Real aTolVx, aTolVnew, aD2, aDT2;
- BOPCol_MapOfInteger aMV;
- gp_Pnt aPnew, aPx;
- //
- iFound=0;
- j=-1;
- aMV.Add(nV[0]);
- aMV.Add(nV[1]);
- //
- if (aMV.Contains(nV[2])) {
- ++j;
- nVS[j]=nV[2];
- }
- if (aMV.Contains(nV[3])) {
- ++j;
- nVS[j]=nV[3];
- }
- //
- aTolVnew=BRep_Tool::Tolerance(aVnew);
- aPnew=BRep_Tool::Pnt(aVnew);
- //
- for (k=0; k<=j; ++k) {
- const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k]));
- aTolVx=BRep_Tool::Tolerance(aVx);
- aPx=BRep_Tool::Pnt(aVx);
- aD2=aPnew.SquareDistance(aPx);
- //
- aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
- //
- if (aD2<aDT2) {
- iFound=1;
- break;
- }
- }
- //
- if (iFound) {
- continue;
- }
- }
-
- // 1
- iX=aEEs.Append()-1;
- BOPDS_InterfEE& aEE=aEEs(iX);
- aEE.SetIndices(nWhat, nWith);
- aEE.SetCommonPart(aCPart);
- // 2
- myDS->AddInterf(nWhat, nWith);
- //
- BOPDS_CoupleOfPaveBlocks aCPB;
- //
- aCPB.SetPaveBlocks(aPB1, aPB2);
- aCPB.SetIndexInterf(iX);
- aMVCPB.Add(aVnew, aCPB);
- }//case TopAbs_VERTEX:
- break;
+ anEdgeEdge.SetEdge1(aE1, aT11, aT12);
+ anEdgeEdge.SetEdge2(aE2, aT21, aT22);
+ anEdgeEdge.SetProgressIndicator(myProgressIndicator);
+ }//for (; aIt2.More(); aIt2.Next()) {
+ }//for (; aIt1.More(); aIt1.Next()) {
+ }//for (; myIterator->More(); myIterator->Next()) {
+ //
+ aNbFdgeEdge=aVEdgeEdge.Extent();
+ //======================================================
+ BOPAlgo_EdgeEdgeCnt::Perform(myRunParallel, aVEdgeEdge);
+ //======================================================
+ //
+ for (k=0; k < aNbFdgeEdge; ++k) {
+ Bnd_Box aBB1, aBB2;
+ //
+ BOPAlgo_EdgeEdge& anEdgeEdge=aVEdgeEdge(k);
+ if (!anEdgeEdge.IsDone()) {
+ continue;
+ }
+ //
+ //--------------------------------------------
+ Handle(BOPDS_PaveBlock)& aPB1=anEdgeEdge.PaveBlock1();
+ nE1=aPB1->OriginalEdge();
+ aPB1->Range(aT11, aT12);
+ aPB1->ShrunkData(aTS11, aTS12, aBB1);
+ //
+ Handle(BOPDS_PaveBlock)& aPB2=anEdgeEdge.PaveBlock2();
+ nE2=aPB2->OriginalEdge();
+ aPB2->Range(aT21, aT22);
+ aPB2->ShrunkData(aTS21, aTS22, aBB2);
+ //
+ //--------------------------------------------
+ IntTools_Range aR11(aT11, aTS11), aR12(aTS12, aT12),
+ aR21(aT21, aTS21), aR22(aTS22, aT22);
+ //
+ const IntTools_SequenceOfCommonPrts& aCPrts = anEdgeEdge.CommonParts();
+ aNbCPrts = aCPrts.Length();
+ //
+ Standard_Boolean bLineLine = Standard_False;
+ if (aNbCPrts) {
+ const TopoDS_Edge& aOE1 = *(TopoDS_Edge*)&myDS->Shape(nE1);
+ const TopoDS_Edge& aOE2 = *(TopoDS_Edge*)&myDS->Shape(nE2);
+ //
+ BRepAdaptor_Curve aBAC1(aOE1), aBAC2(aOE2);
+ //
+ bLineLine = (aBAC1.GetType() == GeomAbs_Line &&
+ aBAC2.GetType() == GeomAbs_Line);
+ }
+ //
+ for (i=1; i<=aNbCPrts; ++i) {
+ const IntTools_CommonPrt& aCPart=aCPrts(i);
+ //
+ const TopoDS_Edge& aE1=aCPart.Edge1();
+ const TopoDS_Edge& aE2=aCPart.Edge2();
+ //
+ aType=aCPart.Type();
+ switch (aType) {
+ case TopAbs_VERTEX: {
+ Standard_Boolean bIsOnPave[4], bFlag;
+ Standard_Integer nV[4], j;
+ Standard_Real aT1, aT2, aTol;
+ TopoDS_Vertex aVnew;
+ IntTools_Range aCR1, aCR2;
+ //
+ IntTools_Tools::VertexParameters(aCPart, aT1, aT2);
+ aTol = Precision::Confusion();
+ aCR1 = aCPart.Range1();
+ aCR2 = aCPart.Ranges2()(1);
+ //
+ //decide to keep the pave or not
+ bIsOnPave[0] = IntTools_Tools::IsOnPave1(aT1, aR11, aTol) ||
+ IntTools_Tools::IsOnPave1(aR11.First(), aCR1, aTol);
+ bIsOnPave[1] = IntTools_Tools::IsOnPave1(aT1, aR12, aTol) ||
+ IntTools_Tools::IsOnPave1(aR12.Last(), aCR1, aTol);
+ bIsOnPave[2] = IntTools_Tools::IsOnPave1(aT2, aR21, aTol) ||
+ IntTools_Tools::IsOnPave1(aR21.First(), aCR2, aTol);
+ bIsOnPave[3] = IntTools_Tools::IsOnPave1(aT2, aR22, aTol) ||
+ IntTools_Tools::IsOnPave1(aR22.Last(), aCR2, aTol);
+ //
+ 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])) {
+ continue;
+ }
+ //
+ bFlag = Standard_False;
+ for (j = 0; j < 4; ++j) {
+ if (bIsOnPave[j]) {
+ //add interf VE(nV[j], nE)
+ Handle(BOPDS_PaveBlock)& aPB = (j < 2) ? aPB2 : aPB1;
+ ForceInterfVE(nV[j], aPB, aMPBToUpdate);
+ bFlag = Standard_True;
+ break;
+ }
+ }
+ if (bFlag) {
+ continue;
+ }
+ //
+ BOPTools_AlgoTools::MakeNewVertex(aE1, aT1, aE2, aT2, aVnew);
+ Standard_Real aTolVnew = BRep_Tool::Tolerance(aVnew);
+ if (bLineLine) {
+ // increase tolerance for Line/Line intersection, but do not update
+ // the vertex till its intersection with some other shape
+ Standard_Real aTol = (aCR1.Last() - aCR1.First()) / 2.;
+ if (aTol > aTolVnew) {
+ aTolVnew = aTol;
+ }
+ }
+ // <-LXBR
+ {
+ Standard_Integer nVS[2], iFound;
+ Standard_Real aTolVx, aD2, aDT2;
+ BOPCol_MapOfInteger aMV;
+ gp_Pnt aPnew, aPx;
//
- case TopAbs_EDGE: {
- if (aNbCPrts > 1) {
- break;
- }
+ iFound=0;
+ j=-1;
+ aMV.Add(nV[0]);
+ aMV.Add(nV[1]);
+ //
+ if (aMV.Contains(nV[2])) {
+ ++j;
+ nVS[j]=nV[2];
+ }
+ if (aMV.Contains(nV[3])) {
+ ++j;
+ nVS[j]=nV[3];
+ }
+ //
+ aPnew=BRep_Tool::Pnt(aVnew);
+ //
+ for (Standard_Integer k1=0; k1<=j; ++k1) {
+ const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k1]));
+ aTolVx=BRep_Tool::Tolerance(aVx);
+ aPx=BRep_Tool::Pnt(aVx);
+ aD2=aPnew.SquareDistance(aPx);
+ //
+ aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx);
//
- Standard_Boolean bHasSameBounds;
- bHasSameBounds=aPB1->HasSameBounds(aPB2);
- if (!bHasSameBounds) {
+ if (aD2<aDT2) {
+ iFound=1;
break;
}
- // 1
- iX=aEEs.Append()-1;
- BOPDS_InterfEE& aEE=aEEs(iX);
- aEE.SetIndices(nWhat, nWith);
- aEE.SetCommonPart(aCPart);
- // 2
- myDS->AddInterf(nWhat, nWith);
- //
- BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
- }//case TopAbs_EDGE
+ }
+ //
+ if (iFound) {
+ continue;
+ }
+ }
+ //
+ // 1
+ BOPDS_InterfEE& aEE=aEEs.Append1();
+ iX=aEEs.Extent()-1;
+ aEE.SetIndices(nE1, nE2);
+ aEE.SetCommonPart(aCPart);
+ // 2
+ myDS->AddInterf(nE1, nE2);
+ //
+ BOPDS_CoupleOfPaveBlocks aCPB;
+ //
+ aCPB.SetPaveBlocks(aPB1, aPB2);
+ aCPB.SetIndexInterf(iX);
+ aCPB.SetTolerance(aTolVnew);
+ aMVCPB.Add(aVnew, aCPB);
+ }//case TopAbs_VERTEX:
+ break;
+ //
+ case TopAbs_EDGE: {
+ if (aNbCPrts > 1) {
break;
- default:
- break;
- }//switch (aType) {
- }//for (i=1; i<=aNbCPrts; i++) {
- // -----------t
- //
- }// for (; aIt2.More(); aIt2.Next()) {
- }// for (; aIt1.More(); aIt1.Next()) {
- }
+ }
+ //
+ Standard_Boolean bHasSameBounds;
+ bHasSameBounds=aPB1->HasSameBounds(aPB2);
+ if (!bHasSameBounds) {
+ break;
+ }
+ // 1
+ BOPDS_InterfEE& aEE=aEEs.Append1();
+ iX=aEEs.Extent()-1;
+ aEE.SetIndices(nE1, nE2);
+ aEE.SetCommonPart(aCPart);
+ // 2
+ myDS->AddInterf(nE1, nE2);
+ //
+ BOPAlgo_Tools::FillMap(aPB1, aPB2, aMPBLPB, aAllocator);
+ }//case TopAbs_EDGE
+ break;
+ default:
+ break;
+ }//switch (aType) {
+ }//for (i=1; i<=aNbCPrts; i++) {
+ }//for (k=0; k < aNbFdgeEdge; ++k) {
//
//=========================================
// post treatment
//=========================================
+ {
+ Standard_Integer aNbV;
+ Handle(BOPDS_PaveBlock) aPB1, aPB2;
+ //
+ aNbV=aMVCPB.Extent();
+ for (i=1; i<=aNbV; ++i) {
+ const BOPDS_CoupleOfPaveBlocks& aCPB=aMVCPB.FindFromIndex(i);
+ aCPB.PaveBlocks(aPB1, aPB2);
+ //
+ aMPBToUpdate.Remove(aPB1);
+ aMPBToUpdate.Remove(aPB2);
+ }
+ }
+ //
aItPB.Initialize(aMPBToUpdate);
for (; aItPB.More(); aItPB.Next()) {
Handle(BOPDS_PaveBlock) aPB=aItPB.Value();
aMPBLPB.Clear();
aMVCPB.Clear();
aMPBToUpdate.Clear();
- aAllocator.Nullify();
}
//=======================================================================
-//function : PerformVertices
+//function : PerformVerticesEE
//purpose :
//=======================================================================
- Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
- (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
- Handle(NCollection_BaseAllocator)& theAllocator)
+Standard_Integer BOPAlgo_PaveFiller::PerformVerticesEE
+ (BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
+ const Handle(NCollection_BaseAllocator)& theAllocator)
{
Standard_Integer aNbV, iRet;
//
//
Standard_Integer nVx, iV, j, nE, iFlag, iX, i, aNb;
Standard_Real aT;
- TopoDS_Shape aV;
BOPCol_ListIteratorOfListOfShape aItLS;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
BOPDS_VectorOfInterfEE& aEEs=myDS->InterfEE();
//
// 1 prepare arguments
- //
- // <- DEB
- for (i=1; i<=aNbV; ++i) {
- const TopoDS_Shape& aS=theMVCPB.FindKey(i);
- const BOPDS_CoupleOfPaveBlocks& aCPB=theMVCPB.FindFromIndex(i);
- iV=aCPB.IndexInterf();
- aMVI.Add(aS, iV);
- }
- //
// 2 Fuse vertices
- TreatNewVertices(aMVI, aImages);
+ TreatNewVertices(theMVCPB, aImages);
//
// 3 Add new vertices to myDS;
// connect indices to CPB structure
BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(iV);
Bnd_Box& aBox=aSIDS.ChangeBox();
BRepBndLib::Add(aV, aBox);
+ aBox.SetGap(aBox.GetGap() + Precision::Confusion());
//
aItLS.Initialize(aLVSD);
for (; aItLS.More(); aItLS.Next()) {
}
}
}
- //
// 5
// 5.1 Compute Extra Paves and
// 5.2. Add Extra Paves to the PaveBlocks
+ //-------------------------------------------------------------
+ Standard_Integer k, aNbVPVE;
+ BOPAlgo_VectorOfPVE aVPVE;
+ //
aNb=aMPBLI.Extent();
for(i=1; i<=aNb; ++i) {
Handle(BOPDS_PaveBlock) aPB=aMPBLI.FindKey(i);
nVx=aItLI.Value();
const TopoDS_Vertex& aVx=(*(TopoDS_Vertex *)(&myDS->Shape(nVx)));
//
- iFlag=myContext->ComputeVE (aVx, aE, aT);
- if (!iFlag) {
- aPave.SetIndex(nVx);
- aPave.SetParameter(aT);
- aPB->AppendExtPave(aPave);
- }
+ BOPAlgo_PVE& aPVE=aVPVE.Append1();
+ aPVE.SetIndices(nVx, nE);
+ aPVE.SetVertex(aVx);
+ aPVE.SetEdge(aE);
+ aPVE.SetPaveBlock(aPB);
+ }
+ }
+ //
+ aNbVPVE=aVPVE.Extent();
+ //=============================================================
+ BOPAlgo_PVECnt::Perform(myRunParallel, aVPVE, myContext);
+ //=============================================================
+ //
+ for (k=0; k < aNbVPVE; ++k) {
+ BOPAlgo_PVE& aPVE=aVPVE(k);
+ iFlag=aPVE.Flag();
+ if (!iFlag) {
+ aPVE.Indices(nVx, nE);
+ aT=aPVE.Parameter();
+ Handle(BOPDS_PaveBlock)& aPB=aPVE.PaveBlock();
+ //
+ aPave.SetIndex(nVx);
+ aPave.SetParameter(aT);
+ aPB->AppendExtPave(aPave);
}
}
// 6 Split PaveBlocksa
//
return iRet;
}
-
//=======================================================================
//function : TreatNewVertices
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::TreatNewVertices(
- const BOPCol_IndexedDataMapOfShapeInteger& aMapVI,
- BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
+void BOPAlgo_PaveFiller::TreatNewVertices
+(const BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks& theMVCPB,
+ BOPCol_IndexedDataMapOfShapeListOfShape& myImages)
{
- Standard_Integer j, i, aNbV, aNbVSD;
+ Standard_Integer i, aNbV;//, aNbVSD;
Standard_Real aTol;
- TopoDS_Shape aVF;
TopoDS_Vertex aVnew;
BOPCol_IndexedMapOfShape aMVProcessed;
-
+ BOPCol_MapOfInteger aMFence;
BOPCol_ListIteratorOfListOfInteger aIt;
- BOPCol_IndexedDataMapOfShapeListOfShape aMVLV;
- BOPCol_DataMapOfIntegerShape aMIS;
- BOPCol_IndexedDataMapOfShapeBox aMSB;
+ NCollection_Vector<BOPCol_ListOfShape> aVecOfLVSD;
//
- BOPDS_BoxBndTreeSelector aSelector;
- BOPDS_BoxBndTree aBBTree;
- NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
+ BOPCol_BoxBndTree aBBTree;
+ NCollection_UBTreeFiller <Standard_Integer,
+ Bnd_Box> aTreeFiller(aBBTree);
+ BOPAlgo_VectorOfTNV aVTNV;
//
- aNbV = aMapVI.Extent();
+ aNbV = theMVCPB.Extent();
for (i=1; i<=aNbV; ++i) {
- const TopoDS_Shape& aV=aMapVI.FindKey(i);
+ const TopoDS_Vertex& aV = *((TopoDS_Vertex*)&theMVCPB.FindKey(i));
Bnd_Box aBox;
//
- aTol=BRep_Tool::Tolerance(*(TopoDS_Vertex*)(&aV));
+ aTol = theMVCPB.FindFromIndex(i).Tolerance();
+ aBox.Add(BRep_Tool::Pnt(aV));
aBox.SetGap(aTol);
- BRepBndLib::Add(aV, aBox);
//
aTreeFiller.Add(i, aBox);
//
- aMIS.Bind(i, aV);
- aMSB.Add(aV, aBox);
+ BOPAlgo_TNV& aTNV=aVTNV.Append1();
+ aTNV.SetTree(aBBTree);
+ aTNV.SetBox(aBox);
+ aTNV.SetVertex(aV);
}
//
aTreeFiller.Fill();
-
+ //
+ //===========================================
+ BOPAlgo_TNVCnt::Perform(myRunParallel, aVTNV);
+ //===========================================
+ //
// Chains
for (i=1; i<=aNbV; ++i) {
- const TopoDS_Shape& aV=aMapVI.FindKey(i);
- //
- if (aMVProcessed.Contains(aV)) {
+ if (!aMFence.Add(i)) {
continue;
}
//
- Standard_Integer aNbIP, aIP, aNbIP1, aIP1;
+ Standard_Integer aIP, aNbIP1, aIP1;
BOPCol_ListOfShape aLVSD;
- BOPCol_MapOfInteger aMIP, aMIP1, aMIPC;
- BOPCol_MapIteratorOfMapOfInteger aIt1;
+ BOPCol_ListOfInteger aLIP, aLIP1, aLIPC;
+ BOPCol_ListIteratorOfListOfInteger aItLIP;
//
- aMIP.Add(i);
+ aLIPC.Append(i);
+ aLIP.Append(i);
for(;;) {
- aNbIP=aMIP.Extent();
- aIt1.Initialize(aMIP);
- for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- if (aMIPC.Contains(aIP)) {
- continue;
- }
- //
- const TopoDS_Shape& aVP=aMIS.Find(aIP);
- const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
+ aItLIP.Initialize(aLIP);
+ for(; aItLIP.More(); aItLIP.Next()) {
+ aIP=aItLIP.Value();
//
- aSelector.Clear();
- aSelector.SetBox(aBoxVP);
- //
- aNbVSD=aBBTree.Select(aSelector);
- if (!aNbVSD) {
- continue; // it must not be
- }
- //
- const BOPCol_ListOfInteger& aLI=aSelector.Indices();
+ BOPAlgo_TNV& aTNV=aVTNV(aIP-1);
+ const BOPCol_ListOfInteger& aLI=aTNV.Indices();
aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) {
aIP1=aIt.Value();
- if (aMIP.Contains(aIP1)) {
+ if (!aMFence.Add(aIP1)) {
continue;
}
- aMIP1.Add(aIP1);
+ aLIP1.Append(aIP1);
} //for (; aIt.More(); aIt.Next()) {
}//for(; aIt1.More(); aIt1.Next()) {
//
- aNbIP1=aMIP1.Extent();
+ aNbIP1=aLIP1.Extent();
if (!aNbIP1) {
- break; // from while(1)
+ break; // from for(;;)
}
//
- aIt1.Initialize(aMIP);
- for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- aMIPC.Add(aIP);
- }
- //
- aMIP.Clear();
- aIt1.Initialize(aMIP1);
- for(; aIt1.More(); aIt1.Next()) {
- aIP=aIt1.Key();
- aMIP.Add(aIP);
- }
- aMIP1.Clear();
- }// while(1)
- //...
- aNbIP=aMIPC.Extent();
- if (!aNbIP) {
- aMIPC.Add(i);
- }
+ aLIP = aLIP1;
+ aLIPC.Append(aLIP1); // items of aLIP1 are moved to aLIPC
+ }// for(;;) {
//
- aIt1.Initialize(aMIPC);
- for(j=0; aIt1.More(); aIt1.Next(), ++j) {
- aIP=aIt1.Key();
- const TopoDS_Shape& aVP=aMIS.Find(aIP);
- if (!j) {
- aVF=aVP;
- }
+ aItLIP.Initialize(aLIPC);
+ for(; aItLIP.More(); aItLIP.Next()) {
+ aIP=aItLIP.Value();
+ const TopoDS_Vertex& aVP=aVTNV(aIP-1).Vertex();
aLVSD.Append(aVP);
- aMVProcessed.Add(aVP);
}
- aMVLV.Add(aVF, aLVSD);
+ aVecOfLVSD.Append(aLVSD);
}// for (i=1; i<=aNbV; ++i) {
// Make new vertices
- aNbV=aMVLV.Extent();
- for (i=1; i<=aNbV; ++i) {
- const TopoDS_Shape& aV=aMVLV.FindKey(i);
- BOPCol_ListOfShape& aLVSD=aMVLV.ChangeFromIndex(i);
- aNbVSD=aLVSD.Extent();
- if (aNbVSD>1) {
- BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
- myImages.Add(aVnew, aLVSD);
- } else {
- myImages.Add(aV, aLVSD);
- }
+ aNbV = aVecOfLVSD.Size();
+ for (i = 0; i < aNbV; ++i) {
+ const BOPCol_ListOfShape& aLVSD = aVecOfLVSD(i);
+ BOPTools_AlgoTools::MakeVertex(aLVSD, aVnew);
+ myImages.Add(aVnew, aLVSD);
}
}
-
//=======================================================================
//function : FillShrunkData
//purpose :
//=======================================================================
- void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
+void BOPAlgo_PaveFiller::FillShrunkData(Handle(BOPDS_PaveBlock)& thePB)
{
Standard_Integer nE, nV1, nV2, iErr;
Standard_Real aT1, aT2, aTS1, aTS2;
- BOPInt_ShrunkRange aSR;
+ IntTools_ShrunkRange aSR;
//
myErrorStatus=0;
myWarningStatus = 0;
nE=thePB->OriginalEdge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
- aSR.SetData(aE, aT1, aT2, aV1, aV2, myContext);
+ aSR.SetContext(myContext);
+ aSR.SetData(aE, aT1, aT2, aV1, aV2);
//
aSR.Perform();
iErr=aSR.ErrorStatus();
Handle(BOPDS_PaveBlock)& aPB,
BOPDS_MapOfPaveBlock& aMPBToUpdate)
{
- Standard_Integer aNbPnt, nE;
- gp_Pnt aP;
+ Standard_Integer nE, nVx, nVSD, iFlag;
+ Standard_Real aT, aTolVNew;
//
nE = aPB->OriginalEdge();
//
return;
}
//
- if (aPB->Pave1().Index() == nV || aPB->Pave2().Index() == nV) {
+ if (aPB->Pave1().Index() == nV ||
+ aPB->Pave2().Index() == nV) {
return;
}
//
- const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nV);
- const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
- aP=BRep_Tool::Pnt(aV);
+ nVx = nV;
+ if (myDS->HasShapeSD(nV, nVSD)) {
+ nVx = nVSD;
+ }
//
- GeomAPI_ProjectPointOnCurve& aProjector=myContext->ProjPC(aE);
- aProjector.Perform(aP);
+ const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&myDS->Shape(nVx);
+ const TopoDS_Edge& aE = *(TopoDS_Edge*) &myDS->Shape(nE);
//
- aNbPnt = aProjector.NbPoints();
- if (aNbPnt) {
- Standard_Real aT, aDist;
- Standard_Integer i;
- BRep_Builder aBB;
+ iFlag = myContext->ComputeVE(aV, aE, aT, aTolVNew);
+ if (iFlag == 0 || iFlag == -4) {
BOPDS_Pave aPave;
//
- aDist=aProjector.LowerDistance();
- aT=aProjector.LowerDistanceParameter();
//
BOPDS_VectorOfInterfVE& aVEs=myDS->InterfVE();
- i=aVEs.Append()-1;
- BOPDS_InterfVE& aVE=aVEs(i);
+ aVEs.SetIncrement(10);
+ // 1
+ BOPDS_InterfVE& aVE=aVEs.Append1();
aVE.SetIndices(nV, nE);
aVE.SetParameter(aT);
- //
+ // 2
myDS->AddInterf(nV, nE);
//
- aBB.UpdateVertex(aV, aDist);
- BOPDS_ShapeInfo& aSIDS=myDS->ChangeShapeInfo(nV);
- Bnd_Box& aBox=aSIDS.ChangeBox();
- BRepBndLib::Add(aV, aBox);
- //
- aPave.SetIndex(nV);
+ // 3 update vertex V/E if necessary
+ nVx=UpdateVertex(nV, aTolVNew);
+ // 4
+ if (myDS->IsNewShape(nVx)) {
+ aVE.SetIndexNew(nVx);
+ }
+ // 5 append ext pave to pave block
+ aPave.SetIndex(nVx);
aPave.SetParameter(aT);
aPB->AppendExtPave(aPave);
//
aMPBToUpdate.Add(aPB);
}
}
-
- /*
- // DEBf
- {
- TopoDS_Compound aCx;
- BRep_Builder aBBx;
- aBBx.MakeCompound(aCx);
- aItMVCPB.Initialize(theMVCPB);
- for (; aItMVCPB.More(); aItMVCPB.Next()) {
- const TopoDS_Shape& aS=aItMVCPB.Key();
- aBBx.Add(aCx, aS);
- }
- BRepTools::Write(aCx, "cx");
- }
- // DEBt
- */