diff --git a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx index b513c29099..9737fe4445 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderFace.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderFace.cxx @@ -348,6 +348,7 @@ void BOPAlgo_BuilderFace::PerformLoops() // aWSp.SetWES(aWES); aWSp.SetRunParallel(myRunParallel); + aWSp.SetContext(myContext); aWSp.Perform(); iErr=aWSp.ErrorStatus(); if (iErr) { @@ -839,7 +840,7 @@ Standard_Boolean IsInside(const TopoDS_Shape& theHole, if (!BRep_Tool::Degenerated(aE)) { // aT=BOPTools_AlgoTools2D::IntermediatePoint(aE); - BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV); + BOPTools_AlgoTools2D::PointOnSurface(aE, aF2, aT, aU, aV, theContext); aP2D.SetCoord(aU, aV); // IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index b0607eaaa8..1427514023 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -715,7 +715,7 @@ void BOPAlgo_Builder::FillImagesFaces1() } else { aFSD=(*(TopoDS_Face*)(&myShapesSD.Find(aFSp))); - iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD); + iSense=BOPTools_AlgoTools::Sense(aFSp, aFSD, myContext); if (iSense<0) { aFSD.Reverse(); } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx index 2e10665065..408a71df9f 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.cxx @@ -151,7 +151,7 @@ BOPDS_PDS BOPAlgo_PaveFiller::PDS() //function : Context //purpose : //======================================================================= -Handle(IntTools_Context) BOPAlgo_PaveFiller::Context() +const Handle(IntTools_Context)& BOPAlgo_PaveFiller::Context() { return myContext; } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.hxx b/src/BOPAlgo/BOPAlgo_PaveFiller.hxx index 8d5675ecc0..a4ad488d07 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.hxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.hxx @@ -84,7 +84,7 @@ public: Standard_EXPORT const BOPCol_ListOfShape& Arguments() const; - Standard_EXPORT Handle(IntTools_Context) Context(); + Standard_EXPORT const Handle(IntTools_Context)& Context(); Standard_EXPORT void SetSectionAttribute (const BOPAlgo_SectionAttribute& theSecAttr); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx index d9ea039311..da6781af7c 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx @@ -243,6 +243,7 @@ void BOPAlgo_PaveFiller::PerformVZ() Standard_Boolean bJustAdd; Standard_Integer iSize, nV, nZ, k, aNbVVS; TopAbs_State aState; + BOPDS_MapOfPassKey aMPK; // myErrorStatus=0; // @@ -263,11 +264,21 @@ void BOPAlgo_PaveFiller::PerformVZ() continue; } // - const BOPDS_ShapeInfo& aSIV=myDS->ShapeInfo(nV); - const BOPDS_ShapeInfo& aSIZ=myDS->ShapeInfo(nZ); + if (myDS->HasInterfShapeSubShapes(nV, nZ)) { + continue; + } // - const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aSIV.Shape()); - const TopoDS_Solid& aZ=*((TopoDS_Solid*)&aSIZ.Shape()); + Standard_Integer nVSD = nV; + myDS->HasShapeSD(nV, nVSD); + // + BOPDS_PassKey aPK; + aPK.SetIds(nVSD, nZ); + if (!aMPK.Add(aPK)) { + continue; + } + // + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&myDS->Shape(nVSD)); + const TopoDS_Solid& aZ=*((TopoDS_Solid*)&myDS->Shape(nZ)); // BOPAlgo_VertexSolid& aVertexSolid=aVVS.Append1(); aVertexSolid.SetIndices(nV, nZ); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index e543b9a68d..805ff4aec7 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -427,6 +427,11 @@ void BOPAlgo_PaveFiller::PerformEE() continue; } // + const IntTools_SequenceOfCommonPrts& aCPrts = anEdgeEdge.CommonParts(); + aNbCPrts = aCPrts.Length(); + if (!aNbCPrts) { + continue; + } //-------------------------------------------- Handle(BOPDS_PaveBlock)& aPB1=anEdgeEdge.PaveBlock1(); nE1=aPB1->OriginalEdge(); @@ -456,11 +461,8 @@ void BOPAlgo_PaveFiller::PerformEE() 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 bAnalytical = Standard_False; - if (aNbCPrts) { + { const TopoDS_Edge& aOE1 = *(TopoDS_Edge*)&myDS->Shape(nE1); const TopoDS_Edge& aOE2 = *(TopoDS_Edge*)&myDS->Shape(nE2); // diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index eafa19676e..da31950f81 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -273,7 +273,13 @@ void BOPAlgo_PaveFiller::PerformEF() if (!aEdgeFace.IsDone()) { continue; } - //~~~ + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts(); + aNbCPrts = aCPrts.Length(); + if (!aNbCPrts) { + continue; + } + // aEdgeFace.Indices(nE, nF); // const TopoDS_Edge& aE=aEdgeFace.Edge(); @@ -290,29 +296,27 @@ void BOPAlgo_PaveFiller::PerformEF() // anewSR.Range(aTS1, aTS2); // - // extend vertices ranges using Edge/Edge intersections - // between the edge aE and the edges of the face aF. - // thereby the edge's intersection range is reduced - ReduceIntersectionRange(nV[0], nV[1], nE, nF, aTS1, aTS2); + if (aCPrts(1).Type() == TopAbs_VERTEX) { + // for the intersection type VERTEX + // extend vertices ranges using Edge/Edge intersections + // between the edge aE and the edges of the face aF. + // thereby the edge's intersection range is reduced + ReduceIntersectionRange(nV[0], nV[1], nE, nF, aTS1, aTS2); + } // IntTools_Range aR1(aT1, aTS1), aR2(aTS2, aT2); // BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF); const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn(); const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn(); - //~~~ - const IntTools_SequenceOfCommonPrts& aCPrts=aEdgeFace.CommonParts(); - aNbCPrts = aCPrts.Length(); // Standard_Boolean bLinePlane = Standard_False; if (aNbCPrts) { BRepAdaptor_Curve aBAC(aE); - BRepAdaptor_Surface aBAS(aF, Standard_False); - // bLinePlane = (aBAC.GetType() == GeomAbs_Line && - aBAS.GetType() == GeomAbs_Plane); + myContext->SurfaceAdaptor(aF).GetType() == GeomAbs_Plane); } - + // for (i=1; i<=aNbCPrts; ++i) { const IntTools_CommonPrt& aCPart=aCPrts(i); aType=aCPart.Type(); @@ -766,6 +770,10 @@ void BOPAlgo_PaveFiller::ReduceIntersectionRange(const Standard_Integer theV1, return; } // + if (!myDS->HasInterfShapeSubShapes(theE, theF)) { + return; + } + // BOPDS_VectorOfInterfEE& aEEs = myDS->InterfEE(); Standard_Integer aNbEEs = aEEs.Extent(); if (!aNbEEs) { diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 4893969c66..95e19914ff 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -189,7 +189,6 @@ void BOPAlgo_PaveFiller::PerformFF() Standard_Integer nF1, nF2, aNbCurves, aNbPoints, i, aNbLP; Standard_Integer aNbFaceFace, k; Standard_Real aApproxTol, aTolR3D, aTolR2D, aTolFF, aTolReal; - BRepAdaptor_Surface aBAS1, aBAS2; BOPCol_MapOfInteger aMI; BOPAlgo_VectorOfFaceFace aVFaceFace; // @@ -220,8 +219,8 @@ void BOPAlgo_PaveFiller::PerformFF() myDS->UpdateFaceInfoIn(nF2); } // - aBAS1.Initialize(aF1, Standard_False); - aBAS2.Initialize(aF2, Standard_False); + const BRepAdaptor_Surface& aBAS1 = myContext->SurfaceAdaptor(aF1); + const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(aF2); if (aBAS1.GetType() == GeomAbs_Plane && aBAS2.GetType() == GeomAbs_Plane) { Standard_Boolean bToIntersect; @@ -235,7 +234,7 @@ void BOPAlgo_PaveFiller::PerformFF() } } // - ToleranceFF(aBAS1, aBAS2, aTolFF); + ToleranceFF(aBAS1, aBAS2, aTolFF); // if (myGlue == BOPAlgo_GlueOff) { BOPAlgo_FaceFace& aFaceFace=aVFaceFace.Append1(); @@ -613,7 +612,8 @@ void BOPAlgo_PaveFiller::MakeBlocks() // Make p-curves BOPTools_AlgoTools::MakePCurve(aES, aF1, aF2, aIC, mySectionAttribute.PCurveOnS1(), - mySectionAttribute.PCurveOnS2()); + mySectionAttribute.PCurveOnS2(), + myContext); // // Append the Pave Block to the Curve j aLPBC.Append(aPB); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx index 96118337e0..f2e74766cf 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx @@ -258,7 +258,7 @@ class BOPAlgo_MPC : public BOPAlgo_Algo { } // if (iErr) { - BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF); + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(myE, myF, myContext); } // if (myFlag) { diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter.cxx b/src/BOPAlgo/BOPAlgo_WireSplitter.cxx index 7f9765e799..e6de3f21c0 100644 --- a/src/BOPAlgo/BOPAlgo_WireSplitter.cxx +++ b/src/BOPAlgo/BOPAlgo_WireSplitter.cxx @@ -79,6 +79,22 @@ BOPAlgo_WireEdgeSet& BOPAlgo_WireSplitter::WES() return *myWES; } //======================================================================= +//function : SetContext +//purpose : +//======================================================================= +void BOPAlgo_WireSplitter::SetContext(const Handle(IntTools_Context)& theContext) +{ + myContext = theContext; +} +//======================================================================= +//function : Context +//purpose : +//======================================================================= +const Handle(IntTools_Context)& BOPAlgo_WireSplitter::Context() +{ + return myContext; +} +//======================================================================= // function: CheckData // purpose: //======================================================================= @@ -103,6 +119,11 @@ void BOPAlgo_WireSplitter::Perform() return; } // + // create a context + if (myContext.IsNull()) { + myContext = new IntTools_Context; + } + // MakeConnexityBlocks(); MakeWires(); } @@ -251,56 +272,59 @@ void BOPAlgo_WireSplitter::MakeConnexityBlocks() } } ///////////////////////////////////////////////////////////////////////// +class BOPAlgo_WS_ConnexityBlock { +public: + BOPAlgo_WS_ConnexityBlock() {}; + ~BOPAlgo_WS_ConnexityBlock() {}; -typedef BOPCol_NCVector \ - BOPTools_VectorOfConnexityBlock; + void SetFace(const TopoDS_Face& theF) { + myFace = theF; + } + + const TopoDS_Face& Face() const { + return myFace; + } + + void SetConnexityBlock(const BOPTools_ConnexityBlock& theCB) { + myCB = theCB; + } + + const BOPTools_ConnexityBlock& ConnexityBlock() const { + return myCB; + } + + void SetContext(const Handle(IntTools_Context)& aContext) { + myContext = aContext; + } + // + const Handle(IntTools_Context)& Context()const { + return myContext; + } + + void Perform() { + BOPAlgo_WireSplitter::SplitBlock(myFace, myCB, myContext); + } -//======================================================================= -//class : WireSplitterFunctor -//purpose : -//======================================================================= -class BOPAlgo_WireSplitterFunctor -{ protected: TopoDS_Face myFace; - BOPTools_VectorOfConnexityBlock* myPVCB; + BOPTools_ConnexityBlock myCB; + Handle(IntTools_Context) myContext; +}; + +typedef BOPCol_NCVector \ + BOPAlgo_VectorOfConnexityBlock; +// +typedef BOPCol_ContextFunctor + BOPAlgo_SplitBlockFunctor; +// +typedef BOPCol_ContextCnt + BOPAlgo_SplitBlockCnt; -public: - // - BOPAlgo_WireSplitterFunctor(const TopoDS_Face& aF, - BOPTools_VectorOfConnexityBlock& aVCB) - : myFace(aF), myPVCB(&aVCB) - { - } - // - void operator()( const Standard_Integer& theIndex ) const - { - BOPTools_VectorOfConnexityBlock& aVCB = *myPVCB; - BOPTools_ConnexityBlock& aCB = aVCB(theIndex); - BOPAlgo_WireSplitter::SplitBlock(myFace, aCB); - } -}; -//======================================================================= -//class : BOPAlgo_WireSplitterCnt -//purpose : -//======================================================================= -class BOPAlgo_WireSplitterCnt -{ -public: - //------------------------------- - // Perform - Standard_EXPORT - static void Perform(const Standard_Boolean bRunParallel, - const TopoDS_Face& aF, - BOPTools_VectorOfConnexityBlock& aVCB) - { - // - BOPAlgo_WireSplitterFunctor aWSF(aF, aVCB); - Standard_Integer aNbVCB = aVCB.Extent(); - // - OSD_Parallel::For(0, aNbVCB, aWSF, !bRunParallel); - } -}; //======================================================================= //function : MakeWires //purpose : @@ -312,7 +336,9 @@ void BOPAlgo_WireSplitter::MakeWires() TopoDS_Wire aW; BOPTools_ListIteratorOfListOfConnexityBlock aItCB; BOPCol_ListIteratorOfListOfShape aIt; - BOPTools_VectorOfConnexityBlock aVCB; + BOPAlgo_VectorOfConnexityBlock aVCB; + // + const TopoDS_Face& aF=myWES->Face(); // aItCB.Initialize(myLCB); for (; aItCB.More(); aItCB.Next()) { @@ -324,18 +350,18 @@ void BOPAlgo_WireSplitter::MakeWires() myWES->AddShape(aW); } else { - aVCB.Append(aCB); + BOPAlgo_WS_ConnexityBlock& aWSCB = aVCB.Append1(); + aWSCB.SetFace(aF); + aWSCB.SetConnexityBlock(aCB); } } - // + //=================================================== + BOPAlgo_SplitBlockCnt::Perform(myRunParallel, aVCB, myContext); + //=================================================== aNbVCB=aVCB.Extent(); - const TopoDS_Face& aF=myWES->Face(); - //=================================================== - BOPAlgo_WireSplitterCnt::Perform(myRunParallel, aF, aVCB); - //=================================================== for (k=0; k #include #include +#include class BOPAlgo_WireEdgeSet; class TopoDS_Wire; class TopoDS_Face; - class BOPAlgo_WireSplitter : public BOPAlgo_Algo { public: @@ -39,50 +39,44 @@ public: Standard_EXPORT BOPAlgo_WireSplitter(); -Standard_EXPORT virtual ~BOPAlgo_WireSplitter(); + Standard_EXPORT virtual ~BOPAlgo_WireSplitter(); Standard_EXPORT BOPAlgo_WireSplitter(const BOPCol_BaseAllocator& theAllocator); Standard_EXPORT void SetWES (const BOPAlgo_WireEdgeSet& theWES); Standard_EXPORT BOPAlgo_WireEdgeSet& WES(); - + + //! Sets the context for the algorithm + Standard_EXPORT void SetContext(const Handle(IntTools_Context)& theContext); + + //! Returns the context + Standard_EXPORT const Handle(IntTools_Context)& Context(); + Standard_EXPORT virtual void Perform() Standard_OVERRIDE; - static void MakeWire (BOPCol_ListOfShape& theLE, TopoDS_Wire& theW); + static void MakeWire(BOPCol_ListOfShape& theLE, TopoDS_Wire& theW); - Standard_EXPORT static void SplitBlock (const TopoDS_Face& theF, BOPTools_ConnexityBlock& theCB); - - - + Standard_EXPORT static void SplitBlock (const TopoDS_Face& theF, + BOPTools_ConnexityBlock& theCB, + const Handle(IntTools_Context)& theContext); protected: - Standard_EXPORT virtual void CheckData() Standard_OVERRIDE; Standard_EXPORT void MakeConnexityBlocks(); Standard_EXPORT void MakeWires(); - BOPAlgo_PWireEdgeSet myWES; BOPTools_ListOfConnexityBlock myLCB; - + Handle(IntTools_Context) myContext; private: - - - - }; - #include - - - - #endif // _BOPAlgo_WireSplitter_HeaderFile diff --git a/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx index 316f59660c..185d2dffc6 100644 --- a/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx +++ b/src/BOPAlgo/BOPAlgo_WireSplitter_1.cxx @@ -62,7 +62,8 @@ static const TopoDS_Edge& anEdge, const TopoDS_Face& myFace, const GeomAdaptor_Surface& aGAS, - const Standard_Boolean aFlag); + const Standard_Boolean aFlag, + const Handle(IntTools_Context)& theContext); static void GetNextVertex(const TopoDS_Vertex& aV, @@ -121,14 +122,16 @@ static static void RefineAngles(const TopoDS_Face& myFace, const BOPCol_ListOfShape&, - BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo&); + BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo&, + const Handle(IntTools_Context)&); static void RefineAngles(const TopoDS_Vertex& , const TopoDS_Face& , const BOPCol_MapOfShape& , - BOPAlgo_ListOfEdgeInfo& ); + BOPAlgo_ListOfEdgeInfo&, + const Handle(IntTools_Context)&); static Standard_Boolean RefineAngle2D(const TopoDS_Vertex& , @@ -136,14 +139,16 @@ static const TopoDS_Face& , const Standard_Real , const Standard_Real , - Standard_Real& ); + Standard_Real& , + const Handle(IntTools_Context)& ); //======================================================================= //function : SplitBlock //purpose : //======================================================================= void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace, - BOPTools_ConnexityBlock& aCB) + BOPTools_ConnexityBlock& aCB, + const Handle(IntTools_Context)& theContext) { Standard_Boolean bNothingToDo, bIsClosed, bIsIN; Standard_Integer aIx, aNb, i, aCntIn, aCntOut; @@ -287,7 +292,7 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace, } // // 3. Angles in mySmartMap - BRepAdaptor_Surface aBAS(myFace); + const BRepAdaptor_Surface& aBAS = theContext->SurfaceAdaptor(myFace); const GeomAdaptor_Surface& aGAS=aBAS.Surface(); // for (i=1; i<=aNb; i++) { @@ -302,15 +307,15 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace, bIsIN = aEI.IsIn(); aOr = bIsIN ? TopAbs_REVERSED : TopAbs_FORWARD; aVV.Orientation(aOr); - aAngle = Angle2D(aVV, aE, myFace, aGAS, bIsIN); + aAngle = Angle2D(aVV, aE, myFace, aGAS, bIsIN, theContext); aEI.SetAngle(aAngle); } }// for (i=1; i<=aNb; i++) { // //Theme: The treatment p-curves convergent in node. //The refining the angles of p-curves taking into account - //bounging curves if exist. - RefineAngles(myFace, myEdges, mySmartMap); + //bounding curves if exist. + RefineAngles(myFace, myEdges, mySmartMap, theContext); // // 4. Do // @@ -712,7 +717,8 @@ Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo) const TopoDS_Edge& anEdge, const TopoDS_Face& myFace, const GeomAdaptor_Surface& aGAS, - const Standard_Boolean bIsIN) + const Standard_Boolean bIsIN, + const Handle(IntTools_Context)& theContext) { Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX; gp_Pnt2d aPV, aPV1; @@ -725,7 +731,7 @@ Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo) } // BOPTools_AlgoTools2D::CurveOnSurface (anEdge, myFace, aC2D, - aFirst, aLast, aToler); + aFirst, aLast, aToler, theContext); Standard_Real tol2d =2.*Tolerance2D(aV, aGAS); // GeomAbs_CurveType aType; @@ -849,7 +855,8 @@ Standard_Real VTolerance2D (const TopoDS_Vertex& aV, //======================================================================= void RefineAngles(const TopoDS_Face& myFace, const BOPCol_ListOfShape& myEdges, - BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap) + BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap, + const Handle(IntTools_Context)& theContext) { Standard_Integer aNb, i; BOPCol_IndexedDataMapOfShapeInteger aMSI; @@ -886,7 +893,7 @@ void RefineAngles(const TopoDS_Face& myFace, const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&mySmartMap.FindKey(i)); BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i); // - RefineAngles(aV, myFace, aMBE, aLEI); + RefineAngles(aV, myFace, aMBE, aLEI, theContext); } } //======================================================================= @@ -903,7 +910,8 @@ typedef BOPCol_DataMapOfShapeReal::Iterator \ void RefineAngles(const TopoDS_Vertex& aV, const TopoDS_Face& myFace, const BOPCol_MapOfShape& aMBE, - BOPAlgo_ListOfEdgeInfo& aLEI) + BOPAlgo_ListOfEdgeInfo& aLEI, + const Handle(IntTools_Context)& theContext) { Standard_Boolean bIsIn, bIsBoundary, bRefined; Standard_Integer iCntBnd, iCntInt; @@ -956,7 +964,7 @@ void RefineAngles(const TopoDS_Vertex& aV, continue; } // - bRefined=RefineAngle2D(aV, aE, myFace, aA1, aA2, aA); + bRefined=RefineAngle2D(aV, aE, myFace, aA1, aA2, aA, theContext); if (bRefined) { aDMSR.Bind(aE, aA); } @@ -999,7 +1007,8 @@ Standard_Boolean RefineAngle2D(const TopoDS_Vertex& aV, const TopoDS_Face& myFace, const Standard_Real aA1, const Standard_Real aA2, - Standard_Real& aA) + Standard_Real& aA, + const Handle(IntTools_Context)& theContext) { Standard_Boolean bRet; Standard_Integer i, j, aNbP; @@ -1016,7 +1025,7 @@ Standard_Boolean RefineAngle2D(const TopoDS_Vertex& aV, aCf=0.01; aTolInt=1.e-10; // - BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aT1, aT2, aTol); + BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aT1, aT2, aTol, theContext); aGAC1.Load(aC2D, aT1, aT2); // aTV=BRep_Tool::Parameter (aV, aE, myFace); diff --git a/src/BOPTools/BOPTools_AlgoTools.cxx b/src/BOPTools/BOPTools_AlgoTools.cxx index fffb11c4be..d695831fe7 100644 --- a/src/BOPTools/BOPTools_AlgoTools.cxx +++ b/src/BOPTools/BOPTools_AlgoTools.cxx @@ -1002,7 +1002,8 @@ Standard_Boolean BOPTools_AlgoTools::CheckSameGeom // purpose: //======================================================================= Standard_Integer BOPTools_AlgoTools::Sense (const TopoDS_Face& theF1, - const TopoDS_Face& theF2) + const TopoDS_Face& theF2, + const Handle(IntTools_Context)& theContext) { Standard_Integer iSense=0; gp_Dir aDNF1, aDNF2; @@ -1036,8 +1037,8 @@ Standard_Integer BOPTools_AlgoTools::Sense (const TopoDS_Face& theF1, return iSense; } // - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE1, theF1, aDNF1); - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE2, theF2, aDNF2); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE1, theF1, aDNF1, theContext); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE2, theF2, aDNF2, theContext); // iSense=BOPTools_AlgoTools3D::SenseFlag(aDNF1, aDNF2); // @@ -1357,7 +1358,8 @@ void BOPTools_AlgoTools::MakePCurve(const TopoDS_Edge& aE, const TopoDS_Face& aF2, const IntTools_Curve& aIC, const Standard_Boolean bPC1, - const Standard_Boolean bPC2) + const Standard_Boolean bPC2, + const Handle(IntTools_Context)& theContext) { Standard_Integer i; @@ -1392,19 +1394,19 @@ void BOPTools_AlgoTools::MakePCurve(const TopoDS_Edge& aE, // aC2D=aC2Dx1; if (aC2D.IsNull()) { - BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aFFWD); + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aE, aFFWD, theContext); BOPTools_AlgoTools2D::CurveOnSurface(aE, aFFWD, aC2D, aOutFirst, aOutLast, - aOutTol); + aOutTol, theContext); } // if (aC3DE->IsPeriodic()) { BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, - aC2DA); + aC2DA, theContext); } else { BOPTools_AlgoTools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, - aC2DA); + aC2DA, theContext); } // aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolE); @@ -1809,7 +1811,7 @@ void GetFaceDir(const TopoDS_Edge& aE, Standard_Real aTolE; gp_Pnt aPx; // - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE, aF, aT, aDN); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE, aF, aT, aDN, theContext); if (aF.Orientation()==TopAbs_REVERSED){ aDN.Reverse(); } diff --git a/src/BOPTools/BOPTools_AlgoTools.hxx b/src/BOPTools/BOPTools_AlgoTools.hxx index 033105c0a1..feaf2509f8 100644 --- a/src/BOPTools/BOPTools_AlgoTools.hxx +++ b/src/BOPTools/BOPTools_AlgoTools.hxx @@ -62,7 +62,15 @@ public: Standard_EXPORT static void MakeEdge (const IntTools_Curve& theCurve, const TopoDS_Vertex& theV1, const Standard_Real theT1, const TopoDS_Vertex& theV2, const Standard_Real theT2, const Standard_Real theTolR3D, TopoDS_Edge& theE); - Standard_EXPORT static void MakePCurve (const TopoDS_Edge& theE, const TopoDS_Face& theF1, const TopoDS_Face& theF2, const IntTools_Curve& theCurve, const Standard_Boolean thePC1, const Standard_Boolean thePC2); + //! Makes 2d curve of the edge on the faces and .
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void MakePCurve (const TopoDS_Edge& theE, + const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + const IntTools_Curve& theCurve, + const Standard_Boolean thePC1, + const Standard_Boolean thePC2, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); Standard_EXPORT static void MakeContainer (const TopAbs_ShapeEnum theType, TopoDS_Shape& theShape); @@ -88,7 +96,12 @@ public: Standard_EXPORT static Standard_Boolean CheckSameGeom (const TopoDS_Face& theF1, const TopoDS_Face& theF2, Handle(IntTools_Context)& theContext); - Standard_EXPORT static Standard_Integer Sense (const TopoDS_Face& theF1, const TopoDS_Face& theF2); + //! Basing on the normals directions of the faces the method + //! Defines whether to reverse the second face or not.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static Standard_Integer Sense (const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Returns True if the face theFace contains //! the edge theEdge but with opposite orientation. diff --git a/src/BOPTools/BOPTools_AlgoTools2D.cxx b/src/BOPTools/BOPTools_AlgoTools2D.cxx index 90bd350ddf..8b249f817b 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.cxx @@ -89,7 +89,8 @@ static //purpose : //======================================================================= void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, - const TopoDS_Face& aF) + const TopoDS_Face& aF, + const Handle(IntTools_Context)& theContext) { BRep_Builder aBB; Handle(Geom2d_Curve) aC2D; @@ -104,7 +105,7 @@ void BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, } - BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC); + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aTolPC, theContext); aTolEdge=BRep_Tool::Tolerance(aE); @@ -159,14 +160,14 @@ void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, const Standard_Real aParameter, Standard_Real& U, - Standard_Real& V) + Standard_Real& V, + const Handle(IntTools_Context)& theContext) { gp_Pnt2d aP2D; Handle(Geom2d_Curve) aC2D; Standard_Real aToler, aFirst, aLast; - BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, - aFirst, aLast, aToler); + BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, aFirst, aLast, aToler, theContext); aC2D->D0(aParameter, aP2D); U=aP2D.X(); V=aP2D.Y(); @@ -180,12 +181,12 @@ void BOPTools_AlgoTools2D::PointOnSurface (const TopoDS_Edge& aE, void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, Handle(Geom2d_Curve)& aC2D, - Standard_Real& aToler) + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext) { Standard_Real aFirst, aLast; // - BOPTools_AlgoTools2D::CurveOnSurface (aE, aF, aC2D, - aFirst, aLast, aToler); + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF, aC2D, aFirst, aLast, aToler, theContext); // return; } @@ -198,7 +199,8 @@ void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE, Handle(Geom2d_Curve)& aC2D, Standard_Real& aFirst, Standard_Real& aLast, - Standard_Real& aToler) + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext) { Standard_Boolean aHasOld; Handle(Geom2d_Curve) C2D; @@ -211,7 +213,7 @@ void BOPTools_AlgoTools2D::CurveOnSurface (const TopoDS_Edge& aE, return; } - BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler); + BOPTools_AlgoTools2D::Make2D(aE, aF, C2D, aFirst, aLast, aToler, theContext); aC2D=C2D; return; } @@ -247,7 +249,6 @@ Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF) - { Standard_Boolean bHasOld; Handle(Geom2d_Curve) aC2D; @@ -268,45 +269,51 @@ Standard_Boolean BOPTools_AlgoTools2D::HasCurveOnSurface //function : AdjustPCurveOnFace //purpose : //======================================================================= -void BOPTools_AlgoTools2D::AdjustPCurveOnFace - (const TopoDS_Face& aF, - const Handle(Geom_Curve)& aC3D, - const Handle(Geom2d_Curve)& aC2D, - Handle(Geom2d_Curve)& aC2DA) +void BOPTools_AlgoTools2D::AdjustPCurveOnFace + (const TopoDS_Face& theF, + const Handle(Geom_Curve)& theC3D, + const Handle(Geom2d_Curve)& theC2D, + Handle(Geom2d_Curve)& theC2DA, + const Handle(IntTools_Context)& theContext) { - Standard_Real aT1, aT2; + Standard_Real aT1 = theC3D->FirstParameter(); + Standard_Real aT2 = theC3D->LastParameter(); // - aT1=aC3D->FirstParameter(); - aT2=aC3D->LastParameter(); - // - BOPTools_AlgoTools2D::AdjustPCurveOnFace (aF, aT1, aT2, aC2D, aC2DA); + BOPTools_AlgoTools2D::AdjustPCurveOnFace (theF, aT1, aT2, theC2D, theC2DA, theContext); } //======================================================================= //function : AdjustPCurveOnFace //purpose : //======================================================================= void BOPTools_AlgoTools2D::AdjustPCurveOnFace - (const TopoDS_Face& aF, - const Standard_Real aT1, - const Standard_Real aT2, - const Handle(Geom2d_Curve)& aC2D, - Handle(Geom2d_Curve)& aC2DA) + (const TopoDS_Face& theF, + const Standard_Real theFirst, + const Standard_Real theLast, + const Handle(Geom2d_Curve)& theC2D, + Handle(Geom2d_Curve)& theC2DA, + const Handle(IntTools_Context)& theContext) { - BRepAdaptor_Surface aBAS(aF, Standard_True); + BRepAdaptor_Surface aBASTmp; + const BRepAdaptor_Surface* pBAS; + if (!theContext.IsNull()) { + pBAS = &theContext->SurfaceAdaptor(theF); + } + else { + aBASTmp.Initialize(theF, Standard_True); + pBAS = &aBASTmp; + } // - BOPTools_AlgoTools2D::AdjustPCurveOnFace(aBAS, aT1, aT2, - aC2D, aC2DA); + BOPTools_AlgoTools2D::AdjustPCurveOnSurf(*pBAS, theFirst, theLast, theC2D, theC2DA); } - //======================================================================= //function : AdjustPCurveOnFace //purpose : //======================================================================= -void BOPTools_AlgoTools2D::AdjustPCurveOnFace +void BOPTools_AlgoTools2D::AdjustPCurveOnSurf (const BRepAdaptor_Surface& aBAS, const Standard_Real aFirst, const Standard_Real aLast, - const Handle(Geom2d_Curve)& aC2D, + const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA) { Standard_Boolean mincond, maxcond; @@ -319,9 +326,6 @@ void BOPTools_AlgoTools2D::AdjustPCurveOnFace VMin=aBAS.FirstVParameter(); VMax=aBAS.LastVParameter(); // - //BRepAdaptor_Surface aBAS(aF, Standard_False); - //BRepTools::UVBounds(aF, UMin, UMax, VMin, VMax); - // aDelta=Precision::PConfusion(); aT =.5*(aFirst+aLast); @@ -534,7 +538,8 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE, Handle(Geom2d_Curve)& aC2D, Standard_Real& aFirst, Standard_Real& aLast, - Standard_Real& aToler) + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext) { Standard_Boolean aLocIdentity; Standard_Real f3d, l3d; @@ -569,7 +574,7 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE, // aToler = BRep_Tool::Tolerance(aE); - BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler); + BOPTools_AlgoTools2D::MakePCurveOnFace(aF, C3D2, f3d, l3d, aC2D, aToler, theContext); // aFirst = f3d; aLast = l3d; @@ -582,7 +587,8 @@ void BOPTools_AlgoTools2D::Make2D (const TopoDS_Edge& aE, void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF, const Handle(Geom_Curve)& aC3D, Handle(Geom2d_Curve)& aC2D, //-> - Standard_Real& TolReached2d) + Standard_Real& TolReached2d, + const Handle(IntTools_Context)& theContext) { Standard_Real aFirst, aLast; @@ -591,43 +597,39 @@ void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF, // TolReached2d=0.; // - BOPTools_AlgoTools2D::MakePCurveOnFace (aF, aC3D, aFirst, - aLast, aC2D, TolReached2d); + BOPTools_AlgoTools2D::MakePCurveOnFace + (aF, aC3D, aFirst, aLast, aC2D, TolReached2d, theContext); } //======================================================================= //function : MakePCurveOnFace //purpose : //======================================================================= -void BOPTools_AlgoTools2D::MakePCurveOnFace +void BOPTools_AlgoTools2D::MakePCurveOnFace (const TopoDS_Face& aF, const Handle(Geom_Curve)& aC3D, const Standard_Real aT1, const Standard_Real aT2, - Handle(Geom2d_Curve)& aC2D, - Standard_Real& TolReached2d) + Handle(Geom2d_Curve)& aC2D, + Standard_Real& TolReached2d, + const Handle(IntTools_Context)& theContext) { - Standard_Real aTolR, aT; - Standard_Real aUMin, aUMax, aVMin, aVMax; - Handle(Geom2d_Curve) aC2DA; - Handle(GeomAdaptor_HSurface) aBAHS; - Handle(GeomAdaptor_HCurve) aBAHC; - Handle(Geom_Surface) aS; + BRepAdaptor_Surface aBASTmp; + const BRepAdaptor_Surface* pBAS; + if (!theContext.IsNull()) { + pBAS = &theContext->SurfaceAdaptor(aF); + } + else { + aBASTmp.Initialize(aF, Standard_True); + pBAS = &aBASTmp; + } // - BRepAdaptor_Surface aBAS(aF, Standard_True); - aUMin=aBAS.FirstUParameter(); - aUMax=aBAS.LastUParameter(); - aVMin=aBAS.FirstVParameter(); - aVMax=aBAS.LastVParameter(); - aS=aBAS.Surface().Surface(); - aS=Handle(Geom_Surface)::DownCast(aS->Transformed(aBAS.Trsf())); - GeomAdaptor_Surface aGAS(aS, aUMin, aUMax, aVMin, aVMax); - // - aBAHS=new GeomAdaptor_HSurface(aGAS); - aBAHC=new GeomAdaptor_HCurve(aC3D, aT1, aT2); + Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(*pBAS); + Handle(GeomAdaptor_HCurve) aBAHC = new GeomAdaptor_HCurve(aC3D, aT1, aT2); // + Standard_Real aTolR; //when the type of surface is GeomAbs_SurfaceOfRevolution - if (aGAS.GetType() == GeomAbs_SurfaceOfRevolution) { + if (pBAS->GetType() == GeomAbs_SurfaceOfRevolution) { Standard_Real aTR; // aTR=Precision::Confusion();//1.e-7; @@ -664,12 +666,17 @@ void BOPTools_AlgoTools2D::MakePCurveOnFace } // TolReached2d=aTolR; - BOPTools_AlgoTools2D::AdjustPCurveOnFace (aBAS, aT1, aT2, - aC2D, aC2DA); + // + Handle(Geom2d_Curve) aC2DA; + BOPTools_AlgoTools2D::AdjustPCurveOnSurf (*pBAS, aT1, aT2, aC2D, aC2DA); // aC2D=aC2DA; // // compute the appropriate tolerance for the edge + Handle(Geom_Surface) aS = pBAS->Surface().Surface(); + aS = Handle(Geom_Surface)::DownCast(aS->Transformed(pBAS->Trsf())); + // + Standard_Real aT; if (IntTools_Tools::ComputeTolerance (aC3D, aC2D, aS, aT1, aT2, aTolR, aT)) { if (aTolR > TolReached2d) { diff --git a/src/BOPTools/BOPTools_AlgoTools2D.hxx b/src/BOPTools/BOPTools_AlgoTools2D.hxx index 7af73538f5..6407253570 100644 --- a/src/BOPTools/BOPTools_AlgoTools2D.hxx +++ b/src/BOPTools/BOPTools_AlgoTools2D.hxx @@ -45,9 +45,12 @@ public: - //! Compute P-Curve for the edge on the face - //! Raises exception Standard_ConstructionError if projection algorithm fails - Standard_EXPORT static void BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, const TopoDS_Face& aF); + //! Compute P-Curve for the edge on the face .
+ //! Raises exception Standard_ConstructionError if projection algorithm fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void BuildPCurveForEdgeOnFace (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Compute tangent for the edge [in 3D] at parameter @@ -55,26 +58,43 @@ public: //! Compute surface parameters of the face - //! for the point from the edge at parameter . + //! for the point from the edge at parameter .
//! If has't pcurve on surface, algorithm tries to get it by //! projection and can - //! raise exception Standard_ConstructionError if projection algorithm fails - Standard_EXPORT static void PointOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, const Standard_Real aT, Standard_Real& U, Standard_Real& V); + //! raise exception Standard_ConstructionError if projection algorithm fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void PointOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + Standard_Real& U, + Standard_Real& V, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); - //! Get P-Curve for the edge on surface . - //! If the P-Curve does not exist, build it using Make2D(). + //! Get P-Curve for the edge on surface .
+ //! If the P-Curve does not exist, build it using Make2D().
//! [aToler] - reached tolerance - //! Raises exception Standard_ConstructionError if algorithm Make2D() fails - Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, Handle(Geom2d_Curve)& aC, Standard_Real& aToler); - + //! Raises exception Standard_ConstructionError if algorithm Make2D() fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC, + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); - //! Get P-Curve for the edge on surface . - //! If the P-Curve does not exist, build it using Make2D(). - //! [aFirst, aLast] - range of the P-Curve - //! [aToler] - reached tolerance - //! Raises exception Standard_ConstructionError if algorithm Make2D() fails - Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF, Handle(Geom2d_Curve)& aC, Standard_Real& aFirst, Standard_Real& aLast, Standard_Real& aToler); + //! Get P-Curve for the edge on surface .
+ //! If the P-Curve does not exist, build it using Make2D().
+ //! [aFirst, aLast] - range of the P-Curve
+ //! [aToler] - reached tolerance
+ //! Raises exception Standard_ConstructionError if algorithm Make2D() fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void CurveOnSurface (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Returns TRUE if the edge has P-Curve @@ -91,18 +111,28 @@ public: Standard_EXPORT static Standard_Boolean HasCurveOnSurface (const TopoDS_Edge& aE, const TopoDS_Face& aF); - //! Adjust P-Curve (3D-curve ) on surface . - Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& aF, const Handle(Geom_Curve)& C3D, const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA); + //! Adjust P-Curve (3D-curve ) on surface of the face .
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& theF, + const Handle(Geom_Curve)& theC3D, + const Handle(Geom2d_Curve)& theC2D, + Handle(Geom2d_Curve)& theC2DA, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); + //! Adjust P-Curve (3D-curve ) on surface .
+ //! [aT1, aT2] - range to adjust
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& theF, + const Standard_Real theFirst, + const Standard_Real theLast, + const Handle(Geom2d_Curve)& theC2D, + Handle(Geom2d_Curve)& theC2DA, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); + //! Adjust P-Curve (3D-curve ) on surface . //! [aT1, aT2] - range to adjust - Standard_EXPORT static void AdjustPCurveOnFace (const TopoDS_Face& aF, const Standard_Real aT1, const Standard_Real aT2, const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA); - - - //! Adjust P-Curve (3D-curve ) on surface . - //! [aT1, aT2] - range to adjust - Standard_EXPORT static void AdjustPCurveOnFace (const BRepAdaptor_Surface& aF, const Standard_Real aT1, const Standard_Real aT2, const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA); + Standard_EXPORT static void AdjustPCurveOnSurf (const BRepAdaptor_Surface& aF, const Standard_Real aT1, const Standard_Real aT2, const Handle(Geom2d_Curve)& aC2D, Handle(Geom2d_Curve)& aC2DA); //! Compute intermediate value in between [aFirst, aLast] . @@ -123,24 +153,43 @@ public: Standard_EXPORT static void BuildPCurveForEdgesOnPlane (const BOPCol_ListOfShape& theLE, const TopoDS_Face& theF); - //! Make P-Curve for the edge on surface . - //! [aFirst, aLast] - range of the P-Curve - //! [aToler] - reached tolerance - //! Raises exception Standard_ConstructionError if algorithm fails - Standard_EXPORT static void Make2D (const TopoDS_Edge& aE, const TopoDS_Face& aF, Handle(Geom2d_Curve)& aC, Standard_Real& aFirst, Standard_Real& aLast, Standard_Real& aToler); + //! Make P-Curve for the edge on surface .
+ //! [aFirst, aLast] - range of the P-Curve
+ //! [aToler] - reached tolerance
+ //! Raises exception Standard_ConstructionError if algorithm fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void Make2D (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Handle(Geom2d_Curve)& aC, + Standard_Real& aFirst, + Standard_Real& aLast, + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); - //! Make P-Curve for the 3D-curve on surface . - //! [aToler] - reached tolerance - //! Raises exception Standard_ConstructionError if projection algorithm fails - Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF, const Handle(Geom_Curve)& C3D, Handle(Geom2d_Curve)& aC, Standard_Real& aToler); + //! Make P-Curve for the 3D-curve on surface .
+ //! [aToler] - reached tolerance
+ //! Raises exception Standard_ConstructionError if projection algorithm fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF, + const Handle(Geom_Curve)& C3D, + Handle(Geom2d_Curve)& aC, + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); - //! Make P-Curve for the 3D-curve on surface . - //! [aT1, aT2] - range to build - //! [aToler] - reached tolerance - //! Raises exception Standard_ConstructionError if projection algorithm fails - Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF, const Handle(Geom_Curve)& C3D, const Standard_Real aT1, const Standard_Real aT2, Handle(Geom2d_Curve)& aC, Standard_Real& aToler); + //! Make P-Curve for the 3D-curve on surface .
+ //! [aT1, aT2] - range to build
+ //! [aToler] - reached tolerance
+ //! Raises exception Standard_ConstructionError if projection algorithm fails.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void MakePCurveOnFace (const TopoDS_Face& aF, + const Handle(Geom_Curve)& C3D, + const Standard_Real aT1, + const Standard_Real aT2, + Handle(Geom2d_Curve)& aC, + Standard_Real& aToler, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Make empty P-Curve of relevant to type diff --git a/src/BOPTools/BOPTools_AlgoTools3D.cxx b/src/BOPTools/BOPTools_AlgoTools3D.cxx index 8c7a46c113..bb1a3d19b9 100644 --- a/src/BOPTools/BOPTools_AlgoTools3D.cxx +++ b/src/BOPTools/BOPTools_AlgoTools3D.cxx @@ -231,14 +231,15 @@ void BOPTools_AlgoTools3D::DoSplitSEAMOnFace (const TopoDS_Edge& aSplit, //======================================================================= void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, const TopoDS_Face& aF, - gp_Dir& aDNF) + gp_Dir& aDNF, + const Handle(IntTools_Context)& theContext) { Standard_Real aT, aT1, aT2; BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); aT=BOPTools_AlgoTools2D::IntermediatePoint(aT1, aT2); - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF, theContext); if (aF.Orientation()==TopAbs_REVERSED){ aDNF.Reverse(); @@ -251,7 +252,8 @@ void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, const TopoDS_Face& aF1, const Standard_Real aT, - gp_Dir& aDNF1) + gp_Dir& aDNF1, + const Handle(IntTools_Context)& theContext) { Standard_Real U, V, aTolPC; gp_Pnt2d aP2D; @@ -261,7 +263,7 @@ void BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (const TopoDS_Edge& aE, Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); Handle(Geom2d_Curve)aC2D1; - BOPTools_AlgoTools2D::CurveOnSurface(aE, aF1, aC2D1, aTolPC); + BOPTools_AlgoTools2D::CurveOnSurface(aE, aF1, aC2D1, aTolPC, theContext); aC2D1->D0(aT, aP2D); U=aP2D.X(); @@ -511,7 +513,12 @@ void BOPTools_AlgoTools3D::PointNearEdge gp_Pnt aP; gp_Pnt2d aP2d; // - BRepTools::UVBounds(aF, aU1, aU2, aV1, aV2); + if (theContext.IsNull()) { + BRepTools::UVBounds(aF, aU1, aU2, aV1, aV2); + } + else { + theContext->UVBounds(aF, aU1, aU2, aV1, aV2); + } // dU=aU2-aU1; dV=aV2-aV1; @@ -750,7 +757,12 @@ Standard_Integer BOPTools_AlgoTools3D::PointInFace aFF.Orientation (TopAbs_FORWARD); // aS=BRep_Tool::Surface(aFF); - BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax); + if (theContext.IsNull()) { + BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax); + } + else { + theContext->UVBounds(aFF, aUMin, aUMax, aVMin, aVMax); + } // aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax); Standard_Integer i; diff --git a/src/BOPTools/BOPTools_AlgoTools3D.hxx b/src/BOPTools/BOPTools_AlgoTools3D.hxx index f5945fcd56..c57a2722fc 100644 --- a/src/BOPTools/BOPTools_AlgoTools3D.hxx +++ b/src/BOPTools/BOPTools_AlgoTools3D.hxx @@ -49,13 +49,22 @@ public: //! Computes normal to the face for the point on the edge - //! at parameter - Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE, const TopoDS_Face& aF, const Standard_Real aT, gp_Dir& aD); + //! at parameter .
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aT, + gp_Dir& aD, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Computes normal to the face for the point on the edge - //! at arbitrary intermediate parameter - Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE, const TopoDS_Face& aF, gp_Dir& aD); + //! at arbitrary intermediate parameter.
+ //! - storage for caching the geometrical tools + Standard_EXPORT static void GetNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + gp_Dir& aD, + const Handle(IntTools_Context)& theContext = Handle(IntTools_Context)()); //! Returns 1 if scalar product aNF1* aNF2>0. diff --git a/src/BRepFeat/BRepFeat_Builder.cxx b/src/BRepFeat/BRepFeat_Builder.cxx index 280d8ca9b7..36f766ce93 100644 --- a/src/BRepFeat/BRepFeat_Builder.cxx +++ b/src/BRepFeat/BRepFeat_Builder.cxx @@ -641,8 +641,8 @@ aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2))); aV2.Orientation(TopAbs_REVERSED); // - BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp); - BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF); + BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp); + BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF, myContext); // aSI.SetShape(aSp); // diff --git a/src/BRepOffset/BRepOffset_Tool.cxx b/src/BRepOffset/BRepOffset_Tool.cxx index 0874a2310c..4b0c432a5c 100644 --- a/src/BRepOffset/BRepOffset_Tool.cxx +++ b/src/BRepOffset/BRepOffset_Tool.cxx @@ -1608,7 +1608,9 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, // Store Result L1.Clear(); L2.Clear(); TopAbs_Orientation O1,O2; - + // + const Handle(IntTools_Context)& aContext = pPF->Context(); + // for (i = 0; i < aNb; i++) { BOPDS_InterfFF& aFFi=aFFs(i); const BOPDS_VectorOfCurve& aBCurves=aFFi.Curves(); @@ -1645,10 +1647,10 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, Handle(Geom2d_Curve) aC2dNew; if(aC3DE->IsPeriodic()) { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, f, l, aC2d, aC2dNew); + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, f, l, aC2d, aC2dNew, aContext); } else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, aC3DETrim, aC2d, aC2dNew); + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF1, aC3DETrim, aC2d, aC2dNew, aContext); } aC2d = aC2dNew; } @@ -1661,10 +1663,10 @@ void BRepOffset_Tool::Inter3D(const TopoDS_Face& F1, Handle(Geom2d_Curve) aC2dNew; if(aC3DE->IsPeriodic()) { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, f, l, aC2d, aC2dNew); + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, f, l, aC2d, aC2dNew, aContext); } else { - BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, aC3DETrim, aC2d, aC2dNew); + BOPTools_AlgoTools2D::AdjustPCurveOnFace(cpF2, aC3DETrim, aC2d, aC2dNew, aContext); } aC2d = aC2dNew; } diff --git a/src/IntTools/IntTools_BeanFaceIntersector.cxx b/src/IntTools/IntTools_BeanFaceIntersector.cxx index f92bec12b8..3839ac7b77 100644 --- a/src/IntTools/IntTools_BeanFaceIntersector.cxx +++ b/src/IntTools/IntTools_BeanFaceIntersector.cxx @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -214,8 +214,12 @@ IntTools_BeanFaceIntersector::IntTools_BeanFaceIntersector(const BRepAdaptor_Cur void IntTools_BeanFaceIntersector::Init(const TopoDS_Edge& theEdge, const TopoDS_Face& theFace) { + if (myContext.IsNull()) { + myContext = new IntTools_Context; + } + // myCurve.Initialize(theEdge); - mySurface.Initialize(theFace); + mySurface = myContext->SurfaceAdaptor(theFace); myTrsfSurface = Handle(Geom_Surface)::DownCast(mySurface.Surface().Surface()->Transformed(mySurface.Trsf())); myBeanTolerance = BRep_Tool::Tolerance(theEdge); myFaceTolerance = BRep_Tool::Tolerance(theFace); diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx index a4d26b8e2f..c8c8a73b6a 100644 --- a/src/IntTools/IntTools_Context.cxx +++ b/src/IntTools/IntTools_Context.cxx @@ -46,7 +46,7 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(IntTools_Context,MMgt_TShared) +IMPLEMENT_STANDARD_RTTIEXT(IntTools_Context,Standard_Transient) // //======================================================================= @@ -64,6 +64,7 @@ IntTools_Context::IntTools_Context() myHatcherMap(100, myAllocator), myProjSDataMap(100, myAllocator), myBndBoxDataMap(100, myAllocator), + mySurfAdaptorMap(100, myAllocator), myCreateFlag(0), myPOnSTolerance(1.e-12) { @@ -84,6 +85,7 @@ IntTools_Context::IntTools_Context myHatcherMap(100, myAllocator), myProjSDataMap(100, myAllocator), myBndBoxDataMap(100, myAllocator), + mySurfAdaptorMap(100, myAllocator), myCreateFlag(1), myPOnSTolerance(1.e-12) { @@ -171,6 +173,16 @@ IntTools_Context::~IntTools_Context() myAllocator->Free(anAdr); } myBndBoxDataMap.Clear(); + // + BRepAdaptor_Surface* pSurfAdaptor; + aIt.Initialize(mySurfAdaptorMap); + for (; aIt.More(); aIt.Next()) { + anAdr=aIt.Value(); + pSurfAdaptor=(BRepAdaptor_Surface*)anAdr; + (*pSurfAdaptor).~BRepAdaptor_Surface(); + myAllocator->Free(anAdr); + } + mySurfAdaptorMap.Clear(); } //======================================================================= //function : BndBox @@ -265,15 +277,8 @@ GeomAPI_ProjectPointOnSurf& IntTools_Context::ProjPS(const TopoDS_Face& aF) if (!myProjPSMap.IsBound(aF)) { Standard_Real Umin, Usup, Vmin, Vsup; - BRepAdaptor_Surface aBAS; - // + UVBounds(aF, Umin, Usup, Vmin, Vsup); const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF); - aBAS.Initialize (aF, Standard_True); - // - Umin=aBAS.FirstUParameter(); - Usup=aBAS.LastUParameter (); - Vmin=aBAS.FirstVParameter(); - Vsup=aBAS.LastVParameter (); // pProjPS=(GeomAPI_ProjectPointOnSurf*)myAllocator->Allocate(sizeof(GeomAPI_ProjectPointOnSurf)); new (pProjPS) GeomAPI_ProjectPointOnSurf(); @@ -376,6 +381,32 @@ BRepClass3d_SolidClassifier& IntTools_Context::SolidClassifier return *pSC; } +//======================================================================= +//function : SurfaceAdaptor +//purpose : +//======================================================================= +BRepAdaptor_Surface& IntTools_Context::SurfaceAdaptor + (const TopoDS_Face& theFace) +{ + Standard_Address anAdr; + BRepAdaptor_Surface* pBAS; + + if (!mySurfAdaptorMap.IsBound(theFace)) { + // + pBAS=(BRepAdaptor_Surface*)myAllocator->Allocate(sizeof(BRepAdaptor_Surface)); + new (pBAS) BRepAdaptor_Surface(theFace, Standard_True); + // + anAdr=(Standard_Address)pBAS; + mySurfAdaptorMap.Bind(theFace, anAdr); + } + + else { + anAdr=mySurfAdaptorMap.Find(theFace); + pBAS =(BRepAdaptor_Surface*)anAdr; + } + return *pBAS; +} + //======================================================================= //function : Hatcher //purpose : @@ -1042,3 +1073,20 @@ void IntTools_Context::clearCachedPOnSProjectors() } myProjPSMap.Clear(); } + +//======================================================================= +//function : UVBounds +//purpose : +//======================================================================= +void IntTools_Context::UVBounds(const TopoDS_Face& theFace, + Standard_Real& UMin, + Standard_Real& UMax, + Standard_Real& VMin, + Standard_Real& VMax) +{ + const BRepAdaptor_Surface& aBAS = SurfaceAdaptor(theFace); + UMin = aBAS.FirstUParameter(); + UMax = aBAS.LastUParameter (); + VMin = aBAS.FirstVParameter(); + VMax = aBAS.LastVParameter (); +} \ No newline at end of file diff --git a/src/IntTools/IntTools_Context.hxx b/src/IntTools/IntTools_Context.hxx index 03a1e2389a..213a790907 100644 --- a/src/IntTools/IntTools_Context.hxx +++ b/src/IntTools/IntTools_Context.hxx @@ -27,6 +27,7 @@ #include #include #include +#include class IntTools_FClass2d; class TopoDS_Face; class GeomAPI_ProjectPointOnSurf; @@ -45,17 +46,12 @@ class Bnd_Box; class TopoDS_Shape; -class IntTools_Context; -DEFINE_STANDARD_HANDLE(IntTools_Context, MMgt_TShared) - - //! The intersection Context contains geometrical //! and topological toolkit (classifiers, projectors, etc). //! The intersection Context is for caching the tools //! to increase the performance. -class IntTools_Context : public MMgt_TShared +class IntTools_Context : public Standard_Transient { - public: @@ -99,6 +95,15 @@ Standard_EXPORT virtual ~IntTools_Context(); //! for given face Standard_EXPORT Geom2dHatch_Hatcher& Hatcher (const TopoDS_Face& aF); + //! Returns a reference to surface adaptor for given face + Standard_EXPORT BRepAdaptor_Surface& SurfaceAdaptor (const TopoDS_Face& theFace); + + //! Computes the boundaries of the face using surface adaptor + Standard_EXPORT void UVBounds (const TopoDS_Face& theFace, + Standard_Real& UMin, + Standard_Real& UMax, + Standard_Real& VMin, + Standard_Real& VMax); //! Computes parameter of the Point theP on //! the edge aE. @@ -230,7 +235,7 @@ Standard_EXPORT virtual ~IntTools_Context(); - DEFINE_STANDARD_RTTIEXT(IntTools_Context,MMgt_TShared) + DEFINE_STANDARD_RTTIEXT(IntTools_Context,Standard_Transient) protected: @@ -244,6 +249,7 @@ protected: BOPCol_DataMapOfShapeAddress myHatcherMap; BOPCol_DataMapOfShapeAddress myProjSDataMap; BOPCol_DataMapOfShapeAddress myBndBoxDataMap; + BOPCol_DataMapOfShapeAddress mySurfAdaptorMap; Standard_Integer myCreateFlag; Standard_Real myPOnSTolerance; @@ -256,4 +262,6 @@ private: }; +DEFINE_STANDARD_HANDLE(IntTools_Context, Standard_Transient) + #endif // _IntTools_Context_HeaderFile diff --git a/src/IntTools/IntTools_EdgeFace.cxx b/src/IntTools/IntTools_EdgeFace.cxx index 323ea0e344..24401c3af2 100644 --- a/src/IntTools/IntTools_EdgeFace.cxx +++ b/src/IntTools/IntTools_EdgeFace.cxx @@ -39,13 +39,12 @@ #include #include #include -#include #include #include -#include #include #include #include +#include #include #include #include @@ -61,10 +60,6 @@ static Standard_Boolean IsRadius (const BRepAdaptor_Curve& aCurve , const BRepAdaptor_Surface& aSurface, const Standard_Real aCriteria); -static - Standard_Integer AdaptiveDiscret (const Standard_Integer iDiscret, - const BRepAdaptor_Curve& aCurve , - const BRepAdaptor_Surface& aSurface); //======================================================================= //function : IntTools_EdgeFace::IntTools_EdgeFace @@ -303,170 +298,7 @@ void IntTools_EdgeFace::CheckData() myErrorStatus=3; } } -//======================================================================= -//function : Prepare -//purpose : -//======================================================================= -void IntTools_EdgeFace::Prepare() -{ - Standard_Integer pri; - Standard_Real aTmin, aTmax; - IntTools_CArray1OfReal aPars; - - // - // 1.Prepare Curve's data and Surface's data - myC.Initialize(myEdge); - GeomAbs_CurveType aCurveType; - aCurveType=myC.GetType(); - // - // 2.Prepare myCriteria - Standard_Real aFuzz = myFuzzyValue / 2.; - Standard_Real aTolF = BRep_Tool::Tolerance(myFace) + aFuzz; - Standard_Real aTolE = BRep_Tool::Tolerance(myEdge) + aFuzz; - if (aCurveType == GeomAbs_BSplineCurve || - aCurveType == GeomAbs_BezierCurve) { - myCriteria = 1.5*aTolE + aTolF; - } - else { - myCriteria = aTolE + aTolF; - } - // 2.a myTmin, myTmax - aTmin=myRange.First(); - aTmax=myRange.Last(); - // 2.b myFClass2d - myS.Initialize (myFace,Standard_True); - myFClass2d.Init(myFace, 1.e-6); - // - // 2.c Prepare adaptive myDiscret - myDiscret=AdaptiveDiscret(myDiscret, myC, myS); - // - // - // 3.Prepare myPars - pri = IntTools::PrepareArgs(myC, aTmax, aTmin, - myDiscret, myDeflection, aPars); - if (pri) { - myErrorStatus=6; - return; - } - // 4. - //ProjectableRanges - Standard_Integer i, iProj, aNb, aNbProj, ind0, ind1; - Standard_Real t0, t1, tRoot; - - // - // Table of Projection's function values - aNb=aPars.Length(); - IntTools_CArray1OfInteger anArrProjectability; - anArrProjectability.Resize(aNb); - - for (iProj=0, i=0; iSurfaceAdaptor(myFace); - if(myContext.IsNull()) { - myFClass2d.Init(myFace, 1.e-6); - } - // if (myQuickCoincidenceCheck) { if (IsCoincident()) { aCommonPrt.SetType(TopAbs_EDGE); diff --git a/src/IntTools/IntTools_EdgeFace.hxx b/src/IntTools/IntTools_EdgeFace.hxx index e7cbd85f05..53970cfb87 100644 --- a/src/IntTools/IntTools_EdgeFace.hxx +++ b/src/IntTools/IntTools_EdgeFace.hxx @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include class IntTools_Context; @@ -38,7 +36,6 @@ class TopoDS_Face; class IntTools_Range; class gp_Pnt; class BRepAdaptor_Surface; -class IntTools_CArray1OfReal; class IntTools_CommonPrt; @@ -151,12 +148,8 @@ protected: Standard_EXPORT static Standard_Boolean IsEqDistance (const gp_Pnt& aP, const BRepAdaptor_Surface& aS, const Standard_Real aT, Standard_Real& aD); Standard_EXPORT void CheckData(); - Standard_EXPORT void Prepare(); - Standard_EXPORT Standard_Boolean IsProjectable (const Standard_Real t) const; - Standard_EXPORT void FindProjectableRoot (const Standard_Real t1, const Standard_Real t2, const Standard_Integer f1, const Standard_Integer f2, Standard_Real& tRoot); - Standard_EXPORT Standard_Real DistanceFunction (const Standard_Real t); Standard_EXPORT Standard_Integer MakeType (IntTools_CommonPrt& aCP); @@ -186,8 +179,6 @@ private: Standard_Boolean myIsDone; Standard_Integer myErrorStatus; Handle(IntTools_Context) myContext; - IntTools_SequenceOfRanges myProjectableRanges; - IntTools_FClass2d myFClass2d; IntTools_SequenceOfCommonPrts mySeqOfCommonPrts; IntTools_Range myRange; diff --git a/src/IntTools/IntTools_FaceFace.cxx b/src/IntTools/IntTools_FaceFace.cxx index e3a2aed910..c366ddc36b 100644 --- a/src/IntTools/IntTools_FaceFace.cxx +++ b/src/IntTools/IntTools_FaceFace.cxx @@ -134,7 +134,8 @@ static // static Standard_Boolean CheckPCurve(const Handle(Geom2d_Curve)& aPC, - const TopoDS_Face& aFace); + const TopoDS_Face& aFace, + const Handle(IntTools_Context)& theCtx); static Standard_Real MaxDistance(const Handle(Geom_Curve)& theC, @@ -313,26 +314,25 @@ void IntTools_FaceFace::SetList(IntSurf_ListOfPntOn2S& aListOfPnts) } -static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1, - const TopoDS_Face& theF2, +static Standard_Boolean isTreatAnalityc(const BRepAdaptor_Surface& theBAS1, + const BRepAdaptor_Surface& theBAS2, const Standard_Real theTol) { const Standard_Real Tolang = 1.e-8; Standard_Real aHigh = 0.0; - const BRepAdaptor_Surface aBAS1(theF1), aBAS2(theF2); - const GeomAbs_SurfaceType aType1=aBAS1.GetType(); - const GeomAbs_SurfaceType aType2=aBAS2.GetType(); + const GeomAbs_SurfaceType aType1=theBAS1.GetType(); + const GeomAbs_SurfaceType aType2=theBAS2.GetType(); gp_Pln aS1; gp_Cylinder aS2; if(aType1 == GeomAbs_Plane) { - aS1=aBAS1.Plane(); + aS1=theBAS1.Plane(); } else if(aType2 == GeomAbs_Plane) { - aS1=aBAS2.Plane(); + aS1=theBAS2.Plane(); } else { @@ -341,9 +341,9 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1, if(aType1 == GeomAbs_Cylinder) { - aS2=aBAS1.Cylinder(); - const Standard_Real VMin = aBAS1.FirstVParameter(); - const Standard_Real VMax = aBAS1.LastVParameter(); + aS2=theBAS1.Cylinder(); + const Standard_Real VMin = theBAS1.FirstVParameter(); + const Standard_Real VMax = theBAS1.LastVParameter(); if( Precision::IsNegativeInfinite(VMin) || Precision::IsPositiveInfinite(VMax)) @@ -353,10 +353,10 @@ static Standard_Boolean isTreatAnalityc(const TopoDS_Face& theF1, } else if(aType2 == GeomAbs_Cylinder) { - aS2=aBAS2.Cylinder(); + aS2=theBAS2.Cylinder(); - const Standard_Real VMin = aBAS2.FirstVParameter(); - const Standard_Real VMax = aBAS2.LastVParameter(); + const Standard_Real VMin = theBAS2.FirstVParameter(); + const Standard_Real VMax = theBAS2.LastVParameter(); if( Precision::IsNegativeInfinite(VMin) || Precision::IsPositiveInfinite(VMax)) @@ -407,8 +407,8 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, myFace1=aF1; myFace2=aF2; - const BRepAdaptor_Surface aBAS1(myFace1, Standard_False); - const BRepAdaptor_Surface aBAS2(myFace2, Standard_False); + const BRepAdaptor_Surface& aBAS1 = myContext->SurfaceAdaptor(myFace1); + const BRepAdaptor_Surface& aBAS2 = myContext->SurfaceAdaptor(myFace2); GeomAbs_SurfaceType aType1=aBAS1.GetType(); GeomAbs_SurfaceType aType2=aBAS2.GetType(); @@ -462,11 +462,11 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, if(aType1==GeomAbs_Plane && aType2==GeomAbs_Plane) { Standard_Real umin, umax, vmin, vmax; // - BRepTools::UVBounds(myFace1, umin, umax, vmin, vmax); + myContext->UVBounds(myFace1, umin, umax, vmin, vmax); CorrectPlaneBoundaries(umin, umax, vmin, vmax); myHS1->ChangeSurface().Load(S1, umin, umax, vmin, vmax); // - BRepTools::UVBounds(myFace2, umin, umax, vmin, vmax); + myContext->UVBounds(myFace2, umin, umax, vmin, vmax); CorrectPlaneBoundaries(umin, umax, vmin, vmax); myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax); // @@ -514,11 +514,11 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, { Standard_Real umin, umax, vmin, vmax; // F1 - BRepTools::UVBounds(myFace1, umin, umax, vmin, vmax); + myContext->UVBounds(myFace1, umin, umax, vmin, vmax); CorrectPlaneBoundaries(umin, umax, vmin, vmax); myHS1->ChangeSurface().Load(S1, umin, umax, vmin, vmax); // F2 - BRepTools::UVBounds(myFace2, umin, umax, vmin, vmax); + myContext->UVBounds(myFace2, umin, umax, vmin, vmax); CorrectSurfaceBoundaries(myFace2, myTol * 2., umin, umax, vmin, vmax); myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax); } @@ -526,21 +526,21 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, { Standard_Real umin, umax, vmin, vmax; //F1 - BRepTools::UVBounds(myFace1, umin, umax, vmin, vmax); + myContext->UVBounds(myFace1, umin, umax, vmin, vmax); CorrectSurfaceBoundaries(myFace1, myTol * 2., umin, umax, vmin, vmax); myHS1->ChangeSurface().Load(S1, umin, umax, vmin, vmax); // F2 - BRepTools::UVBounds(myFace2, umin, umax, vmin, vmax); + myContext->UVBounds(myFace2, umin, umax, vmin, vmax); CorrectPlaneBoundaries(umin, umax, vmin, vmax); myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax); } else { Standard_Real umin, umax, vmin, vmax; - BRepTools::UVBounds(myFace1, umin, umax, vmin, vmax); + myContext->UVBounds(myFace1, umin, umax, vmin, vmax); CorrectSurfaceBoundaries(myFace1, myTol * 2., umin, umax, vmin, vmax); myHS1->ChangeSurface().Load(S1, umin, umax, vmin, vmax); - BRepTools::UVBounds(myFace2, umin, umax, vmin, vmax); + myContext->UVBounds(myFace2, umin, umax, vmin, vmax); CorrectSurfaceBoundaries(myFace2, myTol * 2., umin, umax, vmin, vmax); myHS2->ChangeSurface().Load(S2, umin, umax, vmin, vmax); } @@ -626,7 +626,7 @@ void IntTools_FaceFace::Perform(const TopoDS_Face& aF1, } #endif - const Standard_Boolean isGeomInt = isTreatAnalityc(aF1, aF2, myTol); + const Standard_Boolean isGeomInt = isTreatAnalityc(aBAS1, aBAS2, myTol); myIntersector.Perform(myHS1, dom1, myHS2, dom2, TolArc, TolTang, myListOfPnts, RestrictLine, isGeomInt); @@ -1648,7 +1648,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, } } // ########################################### - bPCurvesOk = CheckPCurve(BS1, myFace2); + bPCurvesOk = CheckPCurve(BS1, myFace2, myContext); aCurve.SetSecondCurve2d(BS1); } else { @@ -1674,7 +1674,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, } } // ########################################### - bPCurvesOk = bPCurvesOk && CheckPCurve(BS2, myFace1); + bPCurvesOk = bPCurvesOk && CheckPCurve(BS2, myFace1, myContext); aCurve.SetFirstCurve2d(BS2); } else { @@ -1693,12 +1693,12 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, if(myApprox1) { H1 = GeomInt_IntSS::MakeBSpline2d(WL, ifprm, ilprm, Standard_True); - bPCurvesOk = CheckPCurve(H1, myFace1); + bPCurvesOk = CheckPCurve(H1, myFace1, myContext); } if(myApprox2) { H2 = GeomInt_IntSS::MakeBSpline2d(WL, ifprm, ilprm, Standard_False); - bPCurvesOk = bPCurvesOk && CheckPCurve(H2, myFace2); + bPCurvesOk = bPCurvesOk && CheckPCurve(H2, myFace2, myContext); } // //if pcurves created without approximation are out of the @@ -1753,7 +1753,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, newCheck.FixTangent(Standard_True,Standard_True); // if (!reApprox) { - bIsValid1=CheckPCurve(BS1, myFace1); + bIsValid1=CheckPCurve(BS1, myFace1, myContext); } // aCurve.SetFirstCurve2d(BS1); @@ -1785,7 +1785,7 @@ void IntTools_FaceFace::MakeCurve(const Standard_Integer Index, newCheck.FixTangent(Standard_True,Standard_True); // if (!reApprox) { - bIsValid2=CheckPCurve(BS2, myFace2); + bIsValid2=CheckPCurve(BS2, myFace2, myContext); } aCurve.SetSecondCurve2d(BS2); } @@ -2961,14 +2961,15 @@ Standard_Real MaxDistance(const Handle(Geom_Curve)& theC, //function : CheckPCurve //purpose : Checks if points of the pcurve are out of the face bounds. //======================================================================= - Standard_Boolean CheckPCurve(const Handle(Geom2d_Curve)& aPC, - const TopoDS_Face& aFace) + Standard_Boolean CheckPCurve(const Handle(Geom2d_Curve)& aPC, + const TopoDS_Face& aFace, + const Handle(IntTools_Context)& theCtx) { const Standard_Integer NPoints = 23; Standard_Integer i; Standard_Real umin,umax,vmin,vmax; - BRepTools::UVBounds(aFace, umin, umax, vmin, vmax); + theCtx->UVBounds(aFace, umin, umax, vmin, vmax); Standard_Real tolU = Max ((umax-umin)*0.01, Precision::Confusion()); Standard_Real tolV = Max ((vmax-vmin)*0.01, Precision::Confusion()); Standard_Real fp = aPC->FirstParameter(); diff --git a/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx b/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx index 2ae26cbc78..eb05ed3d6b 100644 --- a/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx +++ b/src/QANewModTopOpe/QANewModTopOpe_Tools.cxx @@ -554,6 +554,8 @@ Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, return Standard_True; } + const Handle(IntTools_Context)& aContext = aDSFiller.Context(); + // IsCommonFound = Standard_True; TopExp::MapShapes(aCommon.Shape(), TopAbs_VERTEX, aMapV); // fill edge history.begin @@ -586,8 +588,8 @@ Standard_Boolean QANewModTopOpe_Tools::BoolOpe(const TopoDS_Shape& theFace1, Standard_Integer nE = aLSE.First(); const TopoDS_Edge& aSpE = *(TopoDS_Edge*)(&pDS->Shape(nE)); - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); - BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1, aContext); + BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2, aContext); iSenseFlag=BOPTools_AlgoTools3D::SenseFlag (aDNF1, aDNF2); if(iSenseFlag == 1) { diff --git a/tests/bugs/modalg_6/bug28165_1 b/tests/bugs/modalg_6/bug28165_1 new file mode 100644 index 0000000000..f70e3f446c --- /dev/null +++ b/tests/bugs/modalg_6/bug28165_1 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC28165" +puts "========" +puts "" +################################################# +# Improve performance of Boolean Operations +################################################# + +restore [locate_data_file bug28165_shapes1.brep] c + +explode c +# c_1 is a face +# c_2 is a set of edges + +# split the face with the edges +bclearobjects +bcleartools +baddobjects c_1 +baddctools c_2 +bfillds +bbuild result + +checknbshapes result -face 1600 + +checkview -display result -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug28165_2 b/tests/bugs/modalg_6/bug28165_2 new file mode 100644 index 0000000000..440d8d11c7 --- /dev/null +++ b/tests/bugs/modalg_6/bug28165_2 @@ -0,0 +1,28 @@ +puts "========" +puts "OCC28165" +puts "========" +puts "" +################################################# +# Improve performance of Boolean Operations +################################################# + +restore [locate_data_file bug28165_shapes1.brep] c + +explode c +# c_1 is a face +# c_2 is a set of edges + +# rotate the shapes to make no intersections at all +ttranslate c_2 0 0 0.1 +trotate c_1 c_2 0 0 0 1 1 0 45 + +bclearobjects +bcleartools +baddobjects c_1 +baddctools c_2 +bfillds +bbuild result + +checknbshapes result -edge 5074 -face 1 + +checkview -display result -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug28165_3 b/tests/bugs/modalg_6/bug28165_3 new file mode 100644 index 0000000000..b0e2a6bdf3 --- /dev/null +++ b/tests/bugs/modalg_6/bug28165_3 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC28165" +puts "========" +puts "" +################################################# +# Improve performance of Boolean Operations +################################################# + +restore [locate_data_file bug28165_shapes2.brep] c + +# fuse the boxes +bclearobjects +bcleartools +baddobjects {*}[explode c so] +bfillds + +# remove all internal faces to make only one solid +bcbuild rx +bcaddall result -m 1 -u + +checkshape result +checknbshapes result -edge 816 -face 378 -solid 1 +checkprops result -v 343 + +checkview -display result -2d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug28165_4 b/tests/bugs/modalg_6/bug28165_4 new file mode 100644 index 0000000000..f11defb9fd --- /dev/null +++ b/tests/bugs/modalg_6/bug28165_4 @@ -0,0 +1,25 @@ +puts "========" +puts "OCC28165" +puts "========" +puts "" +################################################# +# Improve performance of Boolean Operations +################################################# + +restore [locate_data_file bug28165_shapes3.brep] c + +# fuse the shapes +bclearobjects +bcleartools +baddobjects {*}[explode c so] +bfillds + +# remove all internal faces to make only one solid +bcbuild rx +bcaddall result -m 1 -u + +checkshape result +checknbshapes result -edge 1400 -face 506 -solid 1 +checkprops result -v 4.69342e+007 -s 1.38778e+006 + +checkview -display result -2d -path ${imagedir}/${test_image}.png \ No newline at end of file