// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <BOPAlgo_PaveFiller.ixx>
-
-#include <NCollection_IncAllocator.hxx>
-
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-
-#include <BRepBndLib.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <Geom_Curve.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom2d_Curve.hxx>
-
+#include <BOPAlgo_PaveFiller.hxx>
+#include <BOPAlgo_SectionAttribute.hxx>
+#include <BOPAlgo_Tools.hxx>
+#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_NCVector.hxx>
#include <BOPCol_Parallel.hxx>
-#include <BOPCol_MapOfShape.hxx>
-
-#include <BOPDS_VectorOfListOfPaveBlock.hxx>
-#include <BOPDS_ListOfPaveBlock.hxx>
-#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_CommonBlock.hxx>
+#include <BOPDS_Curve.hxx>
+#include <BOPDS_DS.hxx>
+#include <BOPDS_FaceInfo.hxx>
+#include <BOPDS_Interf.hxx>
+#include <BOPDS_Iterator.hxx>
+#include <BOPDS_ListOfPaveBlock.hxx>
+#include <BOPDS_MapOfPaveBlock.hxx>
#include <BOPDS_Pave.hxx>
+#include <BOPDS_PaveBlock.hxx>
#include <BOPDS_ShapeInfo.hxx>
-#include <BOPDS_MapOfPaveBlock.hxx>
-#include <BOPDS_VectorOfInterfFF.hxx>
-#include <BOPDS_Interf.hxx>
#include <BOPDS_VectorOfCurve.hxx>
#include <BOPDS_VectorOfFaceInfo.hxx>
-#include <BOPDS_FaceInfo.hxx>
-#include <BOPDS_MapOfPaveBlock.hxx>
-#include <BOPDS_Curve.hxx>
-#include <BOPDS_Iterator.hxx>
-
+#include <BOPDS_VectorOfInterfFF.hxx>
+#include <BOPDS_VectorOfListOfPaveBlock.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools2D.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <gp_Pnt.hxx>
+#include <IntTools_Context.hxx>
+#include <IntTools_Tools.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+
static
Standard_Boolean IsBasedOnPlane(const TopoDS_Face& aF);
BOPAlgo_Algo() {
myT1=0.;
myT2=0.;
+ myTol = 0.;
}
//
virtual ~BOPAlgo_SplitEdge() {
return myBox;
}
//
+ Standard_Real Tolerance() const {
+ return myTol;
+ }
+ //
+ void SetDS(const BOPDS_PDS theDS) {
+ myDS = theDS;
+ }
+ //
+ void SetContext(const Handle(IntTools_Context)& aContext) {
+ myContext = aContext;
+ }
+ //
virtual void Perform () {
BOPAlgo_Algo::UserBreak();
+ myTol = BOPAlgo_Tools::ComputeToleranceOfCB(myCB, myDS, myContext);
BOPTools_AlgoTools::MakeSplitEdge(myE,
myV1, myT1,
myV2, myT2,
myESp);
- BRepBndLib::Add(myESp, myBox);
+ BRepBndLib::Add(myESp, myBox);
+ myBox.SetGap(myBox.GetGap() + Precision::Confusion());
}
//
protected:
// <-
TopoDS_Edge myESp;
Bnd_Box myBox;
+ Standard_Real myTol;
+ //
+ BOPDS_PDS myDS;
+ Handle(IntTools_Context) myContext;
};
//
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_SplitEdge> BOPAlgo_VectorOfSplitEdge;
//
-typedef BOPCol_Functor
+typedef BOPCol_ContextFunctor
<BOPAlgo_SplitEdge,
- BOPAlgo_VectorOfSplitEdge> BOPAlgo_SplitEdgeFunctor;
+ BOPAlgo_VectorOfSplitEdge,
+ Handle(IntTools_Context),
+ IntTools_Context> BOPAlgo_SplitEdgeFunctor;
//
-typedef BOPCol_Cnt
+typedef BOPCol_ContextCnt
<BOPAlgo_SplitEdgeFunctor,
- BOPAlgo_VectorOfSplitEdge> BOPAlgo_SplitEdgeCnt;
+ BOPAlgo_VectorOfSplitEdge,
+ Handle(IntTools_Context)> BOPAlgo_SplitEdgeCnt;
//
//=======================================================================
//class : BOPAlgo_MPC
return myFlag;
}
//
+ void SetData(const TopoDS_Edge& aEz,
+ const TopoDS_Vertex& aV1,
+ const Standard_Real aT1,
+ const TopoDS_Vertex& aV2,
+ const Standard_Real aT2) {
+ myEz=aEz;
+ myV1=aV1;
+ myT1=aT1;
+ myV2=aV2;
+ myT2=aT2;
+ }
+ //
+ void SetContext(const Handle(IntTools_Context)& aContext) {
+ myContext=aContext;
+ }
+ //
+ const Handle(IntTools_Context)& Context()const {
+ return myContext;
+ }
+ //
virtual void Perform() {
- BOPAlgo_Algo::UserBreak();
- BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF);
+ Standard_Integer iErr;
+ //
+ iErr=1;
+ if (!myEz.IsNull()) {
+ TopoDS_Edge aSpz;
+ //
+ BOPTools_AlgoTools::MakeSplitEdge(myEz,myV1, myT1,
+ myV2, myT2, aSpz);
+ //
+ iErr=
+ BOPTools_AlgoTools2D::AttachExistingPCurve(aSpz,
+ myE,
+ myF,
+ myContext);
+ }
+ //
+ if (iErr) {
+ BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF);
+ }
+ //
if (myFlag) {
UpdateVertices(myE, myF);
}
Standard_Boolean myFlag;
TopoDS_Edge myE;
TopoDS_Face myF;
+ TopoDS_Edge myEz;
+ TopoDS_Vertex myV1;
+ Standard_Real myT1;
+ TopoDS_Vertex myV2;
+ Standard_Real myT2;
+ //
+ Handle(IntTools_Context) myContext;
};
//
//=======================================================================
typedef BOPCol_NCVector
<BOPAlgo_MPC> BOPAlgo_VectorOfMPC;
//
-typedef BOPCol_Functor
+typedef BOPCol_ContextFunctor
<BOPAlgo_MPC,
- BOPAlgo_VectorOfMPC> BOPAlgo_MPCFunctor;
+ BOPAlgo_VectorOfMPC,
+ Handle(IntTools_Context),
+ IntTools_Context> BOPAlgo_MPCFunctor;
//
-typedef BOPCol_Cnt
+typedef BOPCol_ContextCnt
<BOPAlgo_MPCFunctor,
- BOPAlgo_VectorOfMPC> BOPAlgo_MPCCnt;
+ BOPAlgo_VectorOfMPC,
+ Handle(IntTools_Context)> BOPAlgo_MPCCnt;
//
//=======================================================================
//class : BOPAlgo_BPC
myE=aE;
}
//
+ const TopoDS_Edge& GetEdge() const {
+ return myE;
+ }
+ const TopoDS_Face& GetFace() const {
+ return myF;
+ }
+ const Handle(Geom2d_Curve)& GetCurve2d() const {
+ return myCurve;
+ }
+ Standard_Boolean IsToUpdate() const {
+ return myToUpdate;
+ }
+ //
void Perform() {
- BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF);
+ BOPTools_AlgoTools2D::BuildPCurveForEdgeOnPlane (myE, myF, myCurve, myToUpdate);
};
//
protected:
TopoDS_Edge myE;
TopoDS_Face myF;
+ Handle(Geom2d_Curve) myCurve;
+ Standard_Boolean myToUpdate;
};
//=======================================================================
typedef BOPCol_NCVector
Standard_Boolean bCB, bV1, bV2;
Standard_Integer i, nE, nV1, nV2, nSp, aNbPB, aNbVBSE, k;
Standard_Real aT1, aT2;
- BOPDS_ListIteratorOfListOfPaveBlock aItPB, aItPBCB;
+ BOPDS_ListIteratorOfListOfPaveBlock aItPB;
Handle(BOPDS_PaveBlock) aPB;
BOPDS_MapOfPaveBlock aMPB(100);
TopoDS_Vertex aV1, aV2;
TopoDS_Edge aE;
BOPAlgo_VectorOfSplitEdge aVBSE;
+ //
+ UpdateCommonBlocksWithSDVertices();
+ //
+ aNbPBP=aPBP.Extent();
//
for (i=0; i<aNbPBP; ++i) {
BOPDS_ListOfPaveBlock& aLPB=aPBP(i);
aPB->Indices(nV1, nV2);
bV1=myDS->IsNewShape(nV1);
bV2=myDS->IsNewShape(nV2);
+ bCB=myDS->IsCommonBlock(aPB);
//
- if (!(bV1 || bV2)) {
- nE=aPB->OriginalEdge();
- aPB->SetEdge(nE);
- continue;
+ if (!(bV1 || bV2)) { // no new vertices here
+ if (!myNonDestructive || (myNonDestructive && !bCB)) {
+ nE = aPB->OriginalEdge();
+ aPB->SetEdge(nE);
+ if (!myNonDestructive && bCB) {
+ const Handle(BOPDS_CommonBlock)& aCB = myDS->CommonBlock(aPB);
+ Standard_Real aTol = BOPAlgo_Tools::ComputeToleranceOfCB(aCB, myDS, myContext);
+ myDS->UpdateEdgeTolerance(nE, aTol);
+ }
+ continue;
+ }
}
}
//
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
aPB=aItPB.Value();
+ nE=aPB->OriginalEdge();
+ const BOPDS_ShapeInfo& aSIE=myDS->ShapeInfo(nE);
+ if (aSIE.HasFlag()){
+ continue;
+ }
+ //
const Handle(BOPDS_CommonBlock)& aCB=myDS->CommonBlock(aPB);
bCB=!aCB.IsNull();
if (bCB) {
if (bCB) {
aBSE.SetCommonBlock(aCB);
}
+ aBSE.SetDS(myDS);
aBSE.SetProgressIndicator(myProgressIndicator);
}
} // for (; aItPB.More(); aItPB.Next()) {
//
aNbVBSE=aVBSE.Extent();
//======================================================
- BOPAlgo_SplitEdgeCnt::Perform(myRunParallel, aVBSE);
+ BOPAlgo_SplitEdgeCnt::Perform(myRunParallel, aVBSE, myContext);
//======================================================
//
BOPDS_ShapeInfo aSI;
nSp=myDS->Append(aSI);
//
if (!aCBk.IsNull()) {
+ myDS->UpdateEdgeTolerance(nSp, aBSE.Tolerance());
aCBk->SetEdge(nSp);
}
else {
}
}
}
+
//=======================================================================
// function: SplitEdge
// purpose:
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aSp, aBox);
+ aBox.SetGap(aBox.GetGap() + Precision::Confusion());
//
nSp=myDS->Append(aSI);
return nSp;
//=======================================================================
void BOPAlgo_PaveFiller::MakePCurves()
{
-
- Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI;
+ Standard_Boolean bHasPC;
+ Standard_Integer i, nF1, nF2, aNbC, k, nE, aNbFF, aNbFI, nEx;
+ Standard_Integer j, aNbPBIn, aNbPBOn;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
- BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
TopoDS_Face aF1F, aF2F;
BOPAlgo_VectorOfMPC aVMPC;
//
aF1F.Orientation(TopAbs_FORWARD);
// In
const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
- aItMPB.Initialize(aMPBIn);
- for(; aItMPB.More(); aItMPB.Next()) {
- const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
+ aNbPBIn = aMPBIn.Extent();
+ for (j = 1; j <= aNbPBIn; ++j) {
+ const Handle(BOPDS_PaveBlock)& aPB = aMPBIn(j);
nE=aPB->Edge();
const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
//
//
// On
const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
- aItMPB.Initialize(aMPBOn);
- for(; aItMPB.More(); aItMPB.Next()) {
- const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
- if (myDS->IsCommonBlockOnEdge(aPB)) {
- nE=aPB->Edge();
- const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
+ aNbPBOn = aMPBOn.Extent();
+ for (j = 1; j <= aNbPBOn; ++j) {
+ const Handle(BOPDS_PaveBlock)& aPB = aMPBOn(j);
+ nE=aPB->Edge();
+ const TopoDS_Edge& aE=(*(TopoDS_Edge *)(&myDS->Shape(nE)));
+ bHasPC=BOPTools_AlgoTools2D::HasCurveOnSurface (aE, aF1F);
+ if (bHasPC) {
+ continue;
+ }
+ //
+ Handle(BOPDS_CommonBlock) aCB=myDS->CommonBlock(aPB);
+ if (aCB.IsNull()) {
+ continue;
+ }
+ //
+ const BOPDS_ListOfPaveBlock& aLPB=aCB->PaveBlocks();
+ if (aLPB.Extent()<2) {
+ continue;
+ }
+ //
+ BOPAlgo_MPC& aMPC=aVMPC.Append1();
+ //
+ aItLPB.Initialize(aLPB);
+ for(; aItLPB.More(); aItLPB.Next()) {
+ const Handle(BOPDS_PaveBlock)& aPBx=aItLPB.Value();
+ if (aPBx==aPB) {
+ continue;
+ }
//
- BOPAlgo_MPC& aMPC=aVMPC.Append1();
- aMPC.SetEdge(aE);
- aMPC.SetFace(aF1F);
- aMPC.SetProgressIndicator(myProgressIndicator);
+ nEx=aPBx->OriginalEdge();
+ const TopoDS_Edge& aEx=(*(TopoDS_Edge *)(&myDS->Shape(nEx)));
+ bHasPC=BOPTools_AlgoTools2D::HasCurveOnSurface (aEx, aF1F);
+ if (!bHasPC) {
+ continue;
+ }
+ //
+ Standard_Integer nV1x, nV2x;
+ Standard_Real aT1x, aT2x;
+ TopoDS_Vertex aV1x, aV2x;
+ TopoDS_Edge aEz;
+ //
+ aEz=aEx;
+ aEz.Orientation(TopAbs_FORWARD);
+ //
+ aPBx->Indices(nV1x, nV2x);
+ aPBx->Range(aT1x, aT2x);
+ //
+ aV1x=(*(TopoDS_Vertex *)(&myDS->Shape(nV1x)));
+ aV1x.Orientation(TopAbs_FORWARD);
+ //
+ aV2x=(*(TopoDS_Vertex *)(&myDS->Shape(nV2x)));
+ aV2x.Orientation(TopAbs_REVERSED);
+ //
+ aMPC.SetData(aEz, aV1x, aT1x, aV2x, aT2x);
+ //
+ break;
}
+ //
+ aMPC.SetEdge(aE);
+ aMPC.SetFace(aF1F);
+ aMPC.SetProgressIndicator(myProgressIndicator);
}
}// for (i=0; i<aNbFI; ++i) {
//
}//if (bPCurveOnS1 || bPCurveOnS2 ) {
//
//======================================================
- BOPAlgo_MPCCnt::Perform(myRunParallel, aVMPC);
+ BOPAlgo_MPCCnt::Perform(myRunParallel, aVMPC, myContext);
//======================================================
}
//=======================================================================
if (!myDS->IsCommonBlock(aPB)) {
// the PB seems to be untouced
aLPB.Clear();
+ Standard_Integer nE = aPB->OriginalEdge();
+ if (nE >= 0) {
+ myDS->ChangeShapeInfo(nE).SetReference(-1);
+ }
continue;
}
}//if (!(bV1 || bV2)) {
//=======================================================================
void BOPAlgo_PaveFiller::Prepare()
{
+ if (myNonDestructive) {
+ // do not allow storing pcurves in original edges if non-destructive mode is on
+ return;
+ }
TopAbs_ShapeEnum aType[] = {
TopAbs_VERTEX,
TopAbs_EDGE,
TopAbs_FACE
};
Standard_Boolean bJustAdd, bIsBasedOnPlane;
- Standard_Integer i, aNb, n1, nF;
+ Standard_Integer i, aNb, n1, nF, aNbF;
TopExp_Explorer aExp;
- BOPCol_MapOfShape aMF;
- BOPCol_MapIteratorOfMapOfShape aItMF;
+ BOPCol_IndexedMapOfShape aMF;
//
myErrorStatus=0;
//
}
}
//
- if (aMF.IsEmpty()) {
+ aNbF = aMF.Extent();
+ if (!aNbF) {
return;
}
//
+ // Build pcurves of edges on planes; first collect pairs edge-face.
BOPAlgo_VectorOfBPC aVBPC;
//
- aItMF.Initialize(aMF);
- for (; aItMF.More(); aItMF.Next()) {
- const TopoDS_Face& aF=*((TopoDS_Face *)&aItMF.Key());
+ for (i = 1; i <= aNbF; ++i) {
+ const TopoDS_Face& aF = *(TopoDS_Face*)&aMF(i);
aExp.Init(aF, aType[1]);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Edge& aE=*((TopoDS_Edge *)&aExp.Current());
//======================================================
BOPAlgo_BPCCnt::Perform(myRunParallel, aVBPC);
//======================================================
+
+ // pcurves are built, and now update edges
+ BRep_Builder aBB;
+ TopoDS_Edge E;
+ for (i = 0; i < aVBPC.Extent(); i++) {
+ const BOPAlgo_BPC& aBPC=aVBPC(i);
+ if (aBPC.IsToUpdate()) {
+ Standard_Real aTolE = BRep_Tool::Tolerance(aBPC.GetEdge());
+ aBB.UpdateEdge(aBPC.GetEdge(), aBPC.GetCurve2d(), aBPC.GetFace(), aTolE);
+ }
+ }
}
//=======================================================================
//function : IsBasedOnPlane