X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNMTTools%2FNMTTools_PaveFiller_6.cxx;h=3f897dedd64dbd544f1acccd5f85bb69e0c7980a;hb=08a90cb03f6d2befe6f0b923bd690182ded48378;hp=90b631205ef0d6783a4fdd8d53c666afe7073424;hpb=239f8109c64fa0c5a2e1d87a420bad5529b57f48;p=modules%2Fgeom.git diff --git a/src/NMTTools/NMTTools_PaveFiller_6.cxx b/src/NMTTools/NMTTools_PaveFiller_6.cxx index 90b631205..3f897dedd 100644 --- a/src/NMTTools/NMTTools_PaveFiller_6.cxx +++ b/src/NMTTools/NMTTools_PaveFiller_6.cxx @@ -1,31 +1,31 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// IMPROVED by NIZNHY-PKV Thu Oct 12 16:03:33 2006 -// -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either +// License as published by the Free Software Foundation; either // version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: NMTTools_PaveFiller_6.cxx -// Created: Fri Dec 19 10:27:31 2003 -// Author: Peter KURNEV -// +// File: NMTTools_PaveFiller_6.cxx +// Created: Fri Dec 19 10:27:31 2003 +// Author: Peter KURNEV + +#include -#include +#include #include @@ -34,13 +34,16 @@ #include #include #include -#include #include +#include + #include #include #include #include +#include +#include #include @@ -75,14 +78,11 @@ #include #include #include +#include #include -//#include -//#include -//#include -//#include -//#include - +#include +#include #include #include #include @@ -91,6 +91,8 @@ #include #include #include +#include +#include #include #include @@ -98,44 +100,38 @@ #include #include +#include #include +#include +#include #include #include - #include #include +#include +#include +#include -// Modified Thu Sep 14 14:35:18 2006 -// Contribution of Samtech www.samcef.com BEGIN static - void SharedEdges1(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - TopTools_ListOfShape& aLS); -// Contribution of Samtech www.samcef.com END - -//modified by NIZNHY-PKV Mon Dec 4 12:56:04 2006f -static - Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, - IntTools_Context& aCtx); -//modified by NIZNHY-PKV Mon Dec 4 12:56:08 2006t + Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(IntTools_Context)& aCtx); //======================================================================= // function: PerformFF -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::PerformFF() + void NMTTools_PaveFiller::PerformFF() { myIsDone=Standard_False; // - Standard_Boolean bJustAdd;//, bIsComputed, bIsFound; - Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs; Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone; + Standard_Boolean bJustAdd, bToSplit; + Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs; Standard_Integer aNbCurves, aNbPoints; Standard_Real anApproxTol, aTolR3D, aTolR2D; BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith; IntTools_SequenceOfPntOn2Faces aPnts; IntTools_SequenceOfCurves aCvs; - BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface; // BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); // @@ -149,14 +145,13 @@ static aFFs.SetBlockLength(aNbFFs); } // + //modified by NIZNHY-PKV Thu Sep 15 08:02:52 2011f + bToSplit=Standard_False; + //modified by NIZNHY-PKV Thu Sep 15 08:02:55 2011t + // for (; myDSIt->More(); myDSIt->Next()) { myDSIt->Current(n1, n2, bJustAdd); // - //bIsComputed=myIntrPool->IsComputed(n1, n2); - //if (bIsComputed) { - // continue; - //} - // nF1 = n2; nF2 = n1; if(n1 < n2) { @@ -167,21 +162,6 @@ static aPnts.Clear(); aCvs.Clear(); // - /* - bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith); - if (bJustAdd) { - if (!bIsFound) { - myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); - } - else{ - BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); - anIndexIn=aFFs.Append(anInterf); - myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); - } - continue; - } - */ - // const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv // @@ -194,25 +174,16 @@ static // IntTools_FaceFace aFF; // - aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1, - bToApproxC2dOnS2, anApproxTol); + aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1, + bToApproxC2dOnS2, anApproxTol); // aFF.Perform(aF1, aF2); // bIsDone=aFF.IsDone(); // - if (!bIsDone) { - /* - if (!bIsFound) { - myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); - } - else { - BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); - anIndexIn=aFFs.Append(anInterf); - myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); - } - */ + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); continue; } // @@ -220,9 +191,15 @@ static aTolR2D=aFF.TolReached2d(); if (aTolR3D < 1.e-7){ aTolR3D=1.e-7; - } + } // + //modified by NIZNHY-PKV Thu Sep 15 08:03:02 2011f +#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + aFF.PrepareLines3D(bToSplit); +#else aFF.PrepareLines3D(); +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + //modified by NIZNHY-PKV Thu Sep 15 08:03:04 2011t // const IntTools_SequenceOfCurves& aCvsX=aFF.Lines(); const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points(); @@ -233,177 +210,129 @@ static if (!aNbCurves && !aNbPoints) { BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); anIndexIn=aFFs.Append(anInterf); - //myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); continue; } // { BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX); anIndexIn=aFFs.Append(anInterf); - //myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); } // - }// for (; myDSIt.More(); myDSIt.Next()) + }// for (; myDSIt.More(); myDSIt.Next()) // myIsDone=Standard_True; } + //======================================================================= // function: MakeBlocks -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::MakeBlocks() +void NMTTools_PaveFiller::MakeBlocks() { myIsDone=Standard_False; // - // Modified Thu Sep 14 14:35:18 2006 - // Contribution of Samtech www.samcef.com BEGIN Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided; - // Contribution of Samtech www.samcef.com END - // Standard_Boolean bIsMicroEdge, bHasES; - Standard_Integer i, aNbFFs, nF1, nF2, aBid=0; + Standard_Integer i, aNbFFs, nF1, nF2; Standard_Integer nV1, nV2, j, aNbCurves; Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion(); + TopoDS_Face aF1, aF2; NMTTools_IndexedDataMapOfShapePaveBlock aMEPB; BooleanOperations_IndexedDataMapOfShapeInteger aMapEI; - BOPTools_ListIteratorOfListOfPaveBlock anIt; + BOPTools_ListIteratorOfListOfPaveBlock anIt; // BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); // - aNbFFs=aFFs.Extent(); - // - NMTTools_DataMapOfIntegerListOfPaveBlock aMFInOn; - NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock aItMF; - //--- - { - Standard_Integer aNbS, aNbF, nF, aNbOn, nSp; - TopAbs_ShapeEnum aType; - BOPTools_ListIteratorOfListOfPaveBlock anItPB; - NMTTools_ListIteratorOfListOfCommonBlock aItCB; - TColStd_ListIteratorOfListOfInteger aItF; - // - aNbS=myDS->NumberOfShapesOfTheObject(); - for (i=1; i<=aNbS; ++i) { - const TopoDS_Shape& aS=myDS->Shape(i); - aType=aS.ShapeType(); - // - if (aType==TopAbs_EDGE) { - const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i)); - aItCB.Initialize(aLCB); - for (; aItCB.More(); aItCB.Next()) { - const NMTTools_CommonBlock& aCB=aItCB.Value(); - const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1(); - // - const TColStd_ListOfInteger& aLF=aCB.Faces(); - aNbF=aLF.Extent(); - if (aNbF) { - aItF.Initialize(aLF); - for (; aItF.More(); aItF.Next()) { - nF=aItF.Value(); - if (aMFInOn.IsBound(nF)) { - BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF); - aLPB.Append(aPB1); - } - else { - BOPTools_ListOfPaveBlock aLPB; - aLPB.Append(aPB1); - aMFInOn.Bind(nF, aLPB); - } - } - }// if (aNbF) { - } // for (; aItCB.More(); aItCB.Next()) { - }//if (aS.ShapeType()==TopAbs_EDGE) { - // - else if (aType==TopAbs_FACE) { - BOPTools_ListOfPaveBlock aLPBOn; - // - nF=i; - RealSplitsFace(nF, aLPBOn); - // - aNbOn=aLPBOn.Extent(); - if (aNbOn) { - if (aMFInOn.IsBound(nF)) { - BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF); - aLPB.Append(aLPBOn); - } - else { - aMFInOn.Bind(nF, aLPBOn); - } - } - } - } // for (i=1; i<=aNbS; ++i) { - // - // Refine ListOfPaveBlocks - aItMF.Initialize(aMFInOn); - for(; aItMF.More(); aItMF.Next()) { - TColStd_MapOfInteger aMTmp; - BOPTools_ListOfPaveBlock aLPBX; - // - nF=aItMF.Key(); - BOPTools_ListOfPaveBlock& aLPB=aMFInOn.ChangeFind(nF); - anItPB.Initialize(aLPB); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - nSp=aPB.Edge(); - if (aMTmp.Add(nSp)) { - aLPBX.Append(aPB); - } - } - aLPB.Clear(); - aLPB.Append(aLPBX); - } - } - //--- + // - // 1. Produce Section Edges from intersection curves + // 1. Make Section Edges from intersection curves // between each pair of faces aNbFFs=aFFs.Extent(); + if (!aNbFFs) { + return; + } + // + FillFaceInfo(); // for (i=1; i<=aNbFFs; ++i) { + BOPTools_ListOfPaveBlock aLPB; + TColStd_MapOfInteger aMVStick; + TopTools_ListOfShape aLSE; + TColStd_ListOfInteger aLNE; + BOPTools_PaveSet aPSF; + NMTTools_MapOfPaveBlock aMPBX; + TColStd_MapIteratorOfMapOfInteger aItMI; + NMTTools_MapIteratorOfMapOfPaveBlock aItMPB; + // BOPTools_SSInterference& aFFi=aFFs(i); - // + // // Faces aFFi.Indices(nF1, nF2); - const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv - const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv + aF1=*((TopoDS_Face*)(&myDS->Shape(nF1))); + aF2=*((TopoDS_Face*)(&myDS->Shape(nF2))); // - BOPTools_ListOfPaveBlock aLPB; + SharedEdges(nF1, nF2, aLNE, aLSE); + aFFi.SetSharedEdges(aLNE); // - //--- - { - BOPTools_ListIteratorOfListOfPaveBlock anItPB; - NMTTools_MapOfPaveBlock aMPB; - // - if (aMFInOn.IsBound(nF1)) { - const BOPTools_ListOfPaveBlock& aLPBF1=aMFInOn.Find(nF1); - anItPB.Initialize(aLPBF1); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - if (aMPB.Add(aPB)) { - aLPB.Append(aPB); - } + // aMVStick + const NMTTools_FaceInfo& aFI1=myFaceInfo.Find(nF1); + const NMTTools_FaceInfo& aFI2=myFaceInfo.Find(nF2); + // + const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn(); + const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn(); + const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn(); + const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn(); + // + for (j=0; j<2; ++j) { + const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 :aMVIn1; + aItMI.Initialize(aMV1); + for (; aItMI.More(); aItMI.Next()) { + nV1=aItMI.Key(); + if (aMVOn2.Contains(nV1) || aMVIn2.Contains(nV1)) { + aMVStick.Add(nV1); } } - if (aMFInOn.IsBound(nF2)) { - const BOPTools_ListOfPaveBlock& aLPBF2=aMFInOn.Find(nF2); - anItPB.Initialize(aLPBF2); - for (; anItPB.More(); anItPB.Next()) { - const BOPTools_PaveBlock& aPB=anItPB.Value(); - if (aMPB.Contains(aPB)) { + } + // + // aLPB + const NMTTools_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn(); + const NMTTools_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn(); + const NMTTools_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn(); + const NMTTools_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn(); + // + aMPBX.Clear(); + for (j=0; j<4; ++j) { + NMTTools_MapOfPaveBlock *pMPB; + // + if (!j) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn1); + } + else if (j==1) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn1); + } + else if (j==2) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn2); + } + else if (j==3) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn2); + } + // + const NMTTools_MapOfPaveBlock& aMPB=*pMPB; + aItMPB.Initialize(aMPB); + for (; aItMPB.More(); aItMPB.Next()) { + const BOPTools_PaveBlock& aPB=aItMPB.Key(); + if (aMPBX.Add(aPB)) { + aLPB.Append(aPB); + } + // + else { + if (j>1) { aFFi.AppendBlock(aPB); } - else { - aLPB.Append(aPB); - } } + // } } - //--- - // - TopTools_ListOfShape aLSE; - TColStd_ListOfInteger aLNE; - SharedEdges(nF1, nF2, aLNE, aLSE); - aFFi.SetSharedEdges(aLNE); // BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); aNbCurves=aSCvs.Length(); @@ -411,21 +340,20 @@ static continue; } // - // Contribution of Samtech www.samcef.com END aTolR3D=aFFi.TolR3D(); aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D; // - BOPTools_PaveSet aPSF; + CorrectTolR3D(aFFi, aMVStick, aTolR3D); // PrepareSetForFace (nF1, nF2, aLPB, aPSF); // // Put Paves On Curves for (j=1; j<=aNbCurves; ++j) { BOPTools_Curve& aBC=aSCvs(j); - // DEBUG const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - // + // DEBUG f + Handle(Geom_Curve) aC3D = aC.Curve(); + // DEBUG t PutPaveOnCurve (aPSF, aTolR3D, aBC); } // @@ -434,6 +362,16 @@ static BOPTools_Curve& aBC=aSCvs(j); PutBoundPaveOnCurve (aBC, aFFi); } + //modified by NIZNHY-PKV Wed Sep 14 13:12:14 2011f +#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + // + // Put closing pave if needded + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + PutClosingPaveOnCurve (aBC, aFFi); + } +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + //modified by NIZNHY-PKV Wed Sep 14 13:12:17 2011t // // Pave Blocks on Curves bHasES=Standard_False; @@ -444,80 +382,83 @@ static // BOPTools_PaveBlockIterator aPBIter(0, aPaveSet); for (; aPBIter.More(); aPBIter.Next()) { - BOPTools_PaveBlock& aPBNew=aPBIter.Value(); - aPBNew.SetCurve(aIC); - aPBNew.SetFace1(nF1); - aPBNew.SetFace2(nF2); - // - nV1=aPBNew.Pave1().Index(); - nV2=aPBNew.Pave2().Index(); - aT1=aPBNew.Pave1().Param(); - aT2=aPBNew.Pave2().Param(); - // - if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) { - continue;// mkk ft ??? - } - // - // 1 - bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D); - if (bIsExistingPaveBlock) { - continue; - } - // - bIsCoincided=CheckCoincidence(aPBNew, aLPB); - if(bIsCoincided) { - continue; - } - // - // Modified - // to provide checking whether aPBNew already exists in list - // of section edges aLSE - // Thu Sep 14 14:35:18 2006 - // Contribution of Samtech www.samcef.com BEGIN - // 2 - bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D); - if (bIsExistingPaveBlock) { - continue; - } - // Contribution of Samtech www.samcef.com END - // - // Checking of validity in 2D - // - bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D); - if (!bIsValidIn2D) { - continue; - } - // - // - // Make Section Edge - TopoDS_Edge aES; - // - const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1));//mpv - const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2));//mpv - // - BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES); - // - NMTTools_Tools::UpdateEdge (aES, aTolR3D); - bIsMicroEdge=IsMicroEdge(aES, myContext); - if (bIsMicroEdge) { - continue; - } - // - - { - Handle(Geom2d_Curve) aC2D1, aC2D2; - // - aC2D1=aIC.FirstCurve2d(); - aC2D2=aIC.SecondCurve2d(); - // - NMTTools_Tools::MakePCurve(aES, aF1, aC2D1); - NMTTools_Tools::MakePCurve(aES, aF2, aC2D2); - } - // - aMEPB.Add(aES, aPBNew); - aMapEI.Add(aES, i); + BOPTools_PaveBlock& aPBNew=aPBIter.Value(); + aPBNew.SetCurve(aIC); + aPBNew.SetFace1(nF1); + aPBNew.SetFace2(nF2); + // + nV1=aPBNew.Pave1().Index(); + nV2=aPBNew.Pave2().Index(); + aT1=aPBNew.Pave1().Param(); + aT2=aPBNew.Pave2().Param(); + // + if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) { + continue;// mkk ft ??? + } + // + // 1 + bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D); + if (bIsExistingPaveBlock) { + continue; + } + // + bIsCoincided=CheckCoincidence(aPBNew, aLPB); + if(bIsCoincided) { + continue; + } + // + // 2 + bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D); + if (bIsExistingPaveBlock) { + continue; + } // - bHasES=Standard_True; + // Checking of validity in 2D + // + bIsValidIn2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D); + if (!bIsValidIn2D) { + continue; + } + // + // + // Make Section Edge + TopoDS_Edge aES; + // + const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1)); + const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2)); + // + { + Standard_Real aT; + // + myContext->IsVertexOnLine(aV1, aIC, aTolR3D, aT); + BOPTools_Tools::UpdateVertex (aIC, aT, aV1); + // + myContext->IsVertexOnLine(aV2, aIC, aTolR3D, aT); + BOPTools_Tools::UpdateVertex (aIC, aT, aV2); + } + // + BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES); + // + NMTTools_Tools::UpdateEdge (aES, aTolR3D); + bIsMicroEdge=IsMicroEdge(aES, myContext); + if (bIsMicroEdge) { + continue; + } + // + { + Handle(Geom2d_Curve) aC2D1, aC2D2; + // + aC2D1=aIC.FirstCurve2d(); + aC2D2=aIC.SecondCurve2d(); + // + NMTTools_Tools::MakePCurve(aES, aF1, aC2D1); + NMTTools_Tools::MakePCurve(aES, aF2, aC2D2); + } + // + aMEPB.Add(aES, aPBNew); + aMapEI.Add(aES, i); + // + bHasES=Standard_True; }// for (; aPBIter.More(); aPBIter.Next()) } // end of for (j=1; j<=aNbCurves; ++j) // qqf @@ -528,7 +469,7 @@ static }// for (i=1; i<=aNbFFs; ++i) //============================================================= // - // II. Post treatment + // II. Post treatment // // Input data: aMEPB, aMapEI // Result : section edges in myDS @@ -539,7 +480,7 @@ static if (!aNbSE) { // there is nothing to do here return; - } + } // BRep_Builder aBB; TopoDS_Compound aCompound; @@ -560,7 +501,6 @@ static // 2.1.VV tPF.Init(); tPF.PerformVV(); - //tPF.PerformNewVertices(); qq // // 2.2.VE tPF.myPavePool.Resize (tPF.myNbEdges); @@ -574,7 +514,7 @@ static tPF.myCommonBlockPool.Resize (tPF.myNbEdges); tPF.mySplitShapesPool.Resize (tPF.myNbEdges); tPF.myPavePoolNew .Resize (tPF.myNbEdges); - + tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); // @@ -600,7 +540,7 @@ static // aNbLines=tDS.NumberOfInsertedShapes(); aNbOld=tDS.NumberOfShapesOfTheObject(); - // + // // 3.1 Links between indices in tDS and DS (kept in aMNewOld) // // 3.1.1.Old vertices [ links ] @@ -616,14 +556,14 @@ static nV1=aPBSE.Pave1().Index(); const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv if (aV1.IsSame(aV)) { - aMNewOld.Add(i, nV1); - break; + aMNewOld.Add(i, nV1); + break; } nV2=aPBSE.Pave2().Index(); const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv if (aV2.IsSame(aV)) { - aMNewOld.Add(i, nV2); - break; + aMNewOld.Add(i, nV2); + break; } } } @@ -661,7 +601,7 @@ static BOPTools_SSInterference& aFFi=aFFs(iFF); BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); // - BOPTools_Curve& aBC=aSCvs(1); + BOPTools_Curve& aBC=aSCvs(1); // const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i)); aNbPB=aLPB.Extent(); @@ -703,27 +643,27 @@ static const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2)); // if (aCBAPI.IsCommonBlock(aPB)) { - // it can be Common Block - Standard_Real aTolEx; - Handle(Geom2d_Curve) aC2D1, aC2D2; - TopoDS_Face aF1FWD, aF2FWD; - // - NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); - const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); - // - aPB=aCB.PaveBlock1(); - mE=aPB.Edge(); // index of edge in tDS - const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE)); - aTolEx=BRep_Tool::Tolerance(aEx); + // it can be Common Block + Standard_Real aTolEx; + Handle(Geom2d_Curve) aC2D1, aC2D2; + TopoDS_Face aF1FWD, aF2FWD; // - aF1FWD=aF1; - aF1FWD.Orientation(TopAbs_FORWARD); - aF2FWD=aF2; - aF2FWD.Orientation(TopAbs_FORWARD); - // - NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1); - NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2); - NMTTools_Tools::UpdateEdge (aEx, aTolEx); + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + //const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + // + aPB=aCB.PaveBlock1(); + mE=aPB.Edge(); // index of edge in tDS + const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE)); + aTolEx=BRep_Tool::Tolerance(aEx); + // + aF1FWD=aF1; + aF1FWD.Orientation(TopAbs_FORWARD); + aF2FWD=aF2; + aF2FWD.Orientation(TopAbs_FORWARD); + // + NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1); + NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2); + NMTTools_Tools::UpdateEdge (aEx, aTolEx); } //if (aCBAPI.IsCommonBlock(aPB)) // // new SE @@ -743,22 +683,22 @@ static const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv // if (!aMNewOld.Contains(mE)) { - // add new SE to the myDS - BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; - // - anASSeq.SetNewSuccessor(nV1); - anASSeq.SetNewOrientation(aV1.Orientation()); + // add new SE to the myDS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); - anASSeq.SetNewSuccessor(nV2); - anASSeq.SetNewOrientation(aV2.Orientation()); - - myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq); - nE=myDS->NumberOfInsertedShapes(); - // - aMNewOld.Add(mE, nE); + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + + myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq); + nE=myDS->NumberOfInsertedShapes(); + // + aMNewOld.Add(mE, nE); } else { - nE=aMNewOld.FindFromKey(mE); + nE=aMNewOld.FindFromKey(mE); } // Form PaveBlock; BOPTools_PaveBlock aPBx; @@ -779,16 +719,17 @@ static aPBx.SetEdge(nE); // aBC.AppendNewBlock(aPBx); - }// for (; aIt.More(); aIt.Next()) - }// for (i=1; i<=aNbOld; ++i) + }// for (; aIt.More(); aIt.Next()) + }// for (i=1; i<=aNbOld; ++i) // myIsDone=Standard_True; } + //======================================================================= // function: MakePCurves -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::MakePCurves() +void NMTTools_PaveFiller::MakePCurves() { Standard_Integer i, aNb, nF1, nF2, nE; Standard_Integer aNbCB, aNbF, nSp, nF; @@ -821,17 +762,14 @@ static const BOPTools_PaveBlock& aPB=anIt.Value(); nE=aPB.Edge(); const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv - + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); } - } - // - //modified by NIZNHY-PKV Fri Mar 23 10:35:02 2007f + } // Check common blocks between edges and faces // Build P-Curves if they were not built in previos block. - // - // The main case is :arguments for e.g aEdge, aFace -> no FFs, + // The main case is :arguments for e.g aEdge, aFace -> no FFs, // but p-curves are needed. // aNb=myDS->NumberOfShapesOfTheObject(); @@ -861,8 +799,8 @@ static // const TColStd_ListOfInteger& aLF=aCB.Faces(); aNbF=aLF.Extent(); - if (!aNbF) { - continue; + if (!aNbF) { + continue; } // nSp=aPB1.Edge(); @@ -870,23 +808,23 @@ static // aItF.Initialize(aLF); for (; aItF.More(); aItF.Next()) { - nF=aItF.Value(); - aF1FWD=TopoDS::Face(myDS->Shape(nF)); - aF1FWD.Orientation(TopAbs_FORWARD); - // - BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD); + nF=aItF.Value(); + aF1FWD=TopoDS::Face(myDS->Shape(nF)); + aF1FWD.Orientation(TopAbs_FORWARD); + // + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD); } // for (; aItCB.More(); aItCB.Next()) { }//if (aS.ShapeType()==TopAbs_EDGE) { - } - //modified by NIZNHY-PKV Fri Mar 23 10:35:13 2007t + } } + //======================================================================= // function: IsExistingPaveBlock -// purpose: +// purpose: //======================================================================= - Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, - const BOPTools_ListOfPaveBlock& aLPBR, - const Standard_Real aTolR3D) +Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, + const BOPTools_ListOfPaveBlock& aLPBR, + const Standard_Real aTolR3D) { Standard_Boolean bFlag; Standard_Integer nVNew1, nVNew2, nV1, nV2, iC; @@ -905,22 +843,24 @@ static // iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D); if (!iC) { - return !bFlag; + return !bFlag; } } } return bFlag; } + //======================================================================= // function: IsExistingPaveBlock -// purpose: +// purpose: //======================================================================= - Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, - const TopTools_ListOfShape& aLSE, - const Standard_Real aTolR3D) +Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, + const TopTools_ListOfShape& aLSE, + const Standard_Real aTolR3D) { Standard_Boolean bFlag; Standard_Integer aNbSE, iC; + Standard_Real aTolE, aTol; TopTools_ListIteratorOfListOfShape anIt; // bFlag=Standard_False; @@ -933,21 +873,26 @@ static anIt.Initialize(aLSE); for (; anIt.More(); anIt.Next()) { const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); - iC=CheckIntermediatePoint(aPBNew, aE, aTolR3D); + aTolE=BRep_Tool::Tolerance(aE); + aTol=aTolR3D; + if (aTolE>aTol) { + aTol=aTolE; + } + iC=CheckIntermediatePoint(aPBNew, aE, aTol); if (!iC) { return !bFlag; } } return bFlag; } + //======================================================================= // function: CheckIntermediatePoint -// purpose: +// purpose: //======================================================================= - Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, - const BOPTools_PaveBlock& aPBR, - const Standard_Real aTolC) - +Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const BOPTools_PaveBlock& aPBR, + const Standard_Real aTolC) { Standard_Integer iVM, nE2; // @@ -957,24 +902,25 @@ static // return iVM; } + //======================================================================= // function: CheckIntermediatePoint -// purpose: +// purpose: //======================================================================= - Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, - const TopoDS_Edge& aE2, - const Standard_Real aTolC) +Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const TopoDS_Edge& aE2, + const Standard_Real aTolC) { Standard_Real aT11, aT12, aTM, aTmp; Standard_Integer iVM; gp_Pnt aPM; BRep_Builder aBB; TopoDS_Vertex aVM; - // + // // Vertex const BOPTools_Pave& aPave11=aPB.Pave1(); aT11=aPave11.Param(); - // + // const BOPTools_Pave& aPave12=aPB.Pave2(); aT12=aPave12.Param(); // @@ -985,17 +931,18 @@ static // aBB.MakeVertex (aVM, aPM, aTolC); // - iVM=myContext.ComputeVE(aVM, aE2, aTmp); + iVM=myContext->ComputeVE(aVM, aE2, aTmp); // return iVM; } + //======================================================================= // function: PutBoundPaveOnCurve -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ +void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ Standard_Boolean bHasBounds, bVF; Standard_Integer nF1, nF2; Standard_Real aT1, aT2, aTolR3D; @@ -1017,25 +964,26 @@ static const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv // - bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); + bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); if (bVF) { PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi); } // - bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); + bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); if (bVF) { PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi); } } + //======================================================================= // function: PutBoundPaveOnCurve -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP, - const Standard_Real aT, - BOPTools_Curve& aBC, - BOPTools_SSInterference& aFFi) -{ +void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP, + const Standard_Real aT, + BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ Standard_Boolean bFound1, bFound2; Standard_Integer nV; Standard_Real aTolV=aFFi.TolR3D(); @@ -1074,7 +1022,7 @@ static const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv BOPTools_Tools::UpdateVertex (aIC, aT, aV); } - + if (!bFound1 && bFound2) { nV=aPave2.Index(); aPave.SetIndex(nV); @@ -1085,18 +1033,19 @@ static BOPTools_Tools::UpdateVertex (aIC, aT, aV); } } + //======================================================================= // function: FindPave -// purpose: +// purpose: //======================================================================= - Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP, - const Standard_Real aTolPV, - const BOPTools_PaveSet& aPS, - BOPTools_Pave& aPave) +Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP, + const Standard_Real aTolPV, + const BOPTools_PaveSet& aPS, + BOPTools_Pave& aPave) { Standard_Integer nV; Standard_Boolean bIsVertex=Standard_False; - + const BOPTools_ListOfPave& aLP=aPS.Set(); BOPTools_ListIteratorOfListOfPave anIt(aLP); for (; anIt.More(); anIt.Next()) { @@ -1111,16 +1060,17 @@ static } return bIsVertex; } + //======================================================================= // function: PrepareSetForFace -// purpose: +// purpose: //======================================================================= - void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1, - const Standard_Integer ,//nF2, - const BOPTools_ListOfPaveBlock& aLPBC, - BOPTools_PaveSet& aPSF) +void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1, + const Standard_Integer ,//nF2, + const BOPTools_ListOfPaveBlock& aLPBC, + BOPTools_PaveSet& aPSF) { - Standard_Integer nV1, nV2; + Standard_Integer nV1, nV2; TColStd_MapOfInteger aMap; BOPTools_ListIteratorOfListOfPaveBlock anIt; // @@ -1141,95 +1091,13 @@ static } } } -//======================================================================= -// function: PutPaveOnCurve -// purpose: -//======================================================================= - void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet, - const Standard_Real aTolR3D, - BOPTools_Curve& aBC) -{ - Standard_Integer nV; - Standard_Boolean bIsVertexOnLine; - Standard_Real aT; - BOPTools_ListIteratorOfListOfPave anIt; - Bnd_Box aBBC; - GeomAdaptor_Curve aGAC; - // - const IntTools_Curve& aC=aBC.Curve(); - Handle (Geom_Curve) aC3D= aC.Curve(); - aGAC.Load(aC3D); - BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC); - // - const BOPTools_ListOfPave& aLP=aPaveSet.Set(); - anIt.Initialize(aLP); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Pave& aPave=anIt.Value(); - // - nV=aPave.Index(); - const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv - // - Bnd_Box aBBV; - BRepBndLib::Add(aV, aBBV); - if (aBBC.IsOut(aBBV)){ - continue; - } - // - bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT); - // - if (bIsVertexOnLine) { - BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface); - BOPTools_PaveSet& aPS=aBC.Set(); - aPS.Append(aPaveNew); - //<-B - BOPTools_Tools::UpdateVertex (aC, aT, aV); - } - } -} -///////////// - - -// Modified Thu Sep 14 14:35:18 2006 -// Contribution of Samtech www.samcef.com BEGIN -//======================================================================= -//function : SharedEdges1 -//purpose : -//======================================================================= -void SharedEdges1(const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - TopTools_ListOfShape& aLS) -{ - Standard_Integer i, aNbE, aNbF;; - TopTools_IndexedDataMapOfShapeListOfShape aMEF; - // - TopExp::MapShapesAndAncestors(aF1, TopAbs_EDGE, TopAbs_FACE, aMEF); - TopExp::MapShapesAndAncestors(aF2, TopAbs_EDGE, TopAbs_FACE, aMEF); - // - aNbE=aMEF.Extent(); - for (i=1; i<=aNbE; ++i) { - const TopTools_ListOfShape& aLF=aMEF.FindFromIndex(i); - aNbF=aLF.Extent(); - if (aNbF>1) { - if (aNbF==2) { - const TopoDS_Shape& aF1x=aLF.First(); - const TopoDS_Shape& aF2x=aLF.Last(); - if (aF1x.IsSame(aF2x)) { - continue; - } - } - const TopoDS_Shape& aE=aMEF.FindKey(i); - aLS.Append (aE); - } - } -} //======================================================================= // function: CheckCoincidence -// purpose: +// purpose: //======================================================================= - Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew, - const BOPTools_ListOfPaveBlock& aLPBFF) - +Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew, + const BOPTools_ListOfPaveBlock& aLPBFF) { Standard_Boolean bRet; Standard_Real aTE; @@ -1240,7 +1108,7 @@ void SharedEdges1(const TopoDS_Face& aF1, const BOPTools_Pave& aPave11=aPBNew.Pave1(); nV11=aPave11.Index(); const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11)); - + // V12 const BOPTools_Pave& aPave12=aPBNew.Pave2(); nV12=aPave12.Index(); @@ -1256,7 +1124,7 @@ void SharedEdges1(const TopoDS_Face& aF1, // V21 const BOPTools_Pave& aPave21=aPBR.Pave1(); nV21=aPave21.Index(); - + // V22 const BOPTools_Pave& aPave22=aPBR.Pave2(); nV22=aPave22.Index(); @@ -1279,7 +1147,7 @@ void SharedEdges1(const TopoDS_Face& aF1, iCount++; iV++; if (iCount>iCountExt) { - break; + break; } } // @@ -1288,17 +1156,17 @@ void SharedEdges1(const TopoDS_Face& aF1, iCount++; iV++; if (iCount>iCountExt) { - break; + break; } } // VE if (!iV) { - iVE=myContext.ComputeVE (aV11, aE2, aTE); + iVE=myContext->ComputeVE (aV11, aE2, aTE); if (!iVE) { - iCount++; - if (iCount>iCountExt) { - break; - } + iCount++; + if (iCount>iCountExt) { + break; + } } } // VV @@ -1308,7 +1176,7 @@ void SharedEdges1(const TopoDS_Face& aF1, iCount++; iV++; if (iCount>iCountExt) { - break; + break; } } // @@ -1317,33 +1185,30 @@ void SharedEdges1(const TopoDS_Face& aF1, iCount++; iV++; if (iCount>iCountExt) { - break; + break; } } // VE if (!iV) { - iVE=myContext.ComputeVE (aV12, aE2, aTE); + iVE=myContext->ComputeVE (aV12, aE2, aTE); if (!iVE) { - iCount++; - if (iCount>iCountExt) { - break; - } + iCount++; + if (iCount>iCountExt) { + break; + } } } } // next aPBR bRet=(Standard_Boolean)(iCount>iCountExt); return bRet; } -// -// Contribution of Samtech www.samcef.com END -//modified by NIZNHY-PKV Mon Dec 4 12:30:38 2006f use_01 //======================================================================= //function : IsMicroEdge -//purpose : +//purpose : //======================================================================= -Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, - IntTools_Context& aCtx) +Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(IntTools_Context)& aCtx) { Standard_Boolean bRet; Standard_Integer iErr; @@ -1352,15 +1217,15 @@ Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, TopoDS_Vertex aV1, aV2; IntTools_Range aR; // - bRet=(BRep_Tool::Degenerated(aE) || - !BRep_Tool::IsGeometric(aE)); + bRet=(BRep_Tool::Degenerated(aE) || + !BRep_Tool::IsGeometric(aE)); if (bRet) { return bRet; } // aC3D=BRep_Tool::Curve(aE, aT1, aT2); TopExp::Vertices(aE, aV1, aV2); - aT1=BRep_Tool::Parameter(aV1, aE); + aT1=BRep_Tool::Parameter(aV1, aE); aT2=BRep_Tool::Parameter(aV2, aE); if (aT2Shape(nV)); + // + Bnd_Box aBBV; + BRepBndLib::Add(aV, aBBV); + if (aBBC.IsOut(aBBV)){ + continue; + } + // + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aC, aTolR3D, aT); + // + // + if (bIsVertexOnLine) { + BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface); + BOPTools_PaveSet& aPS=aBC.Set(); + aPS.Append(aPaveNew); + //<-B + } } - // - const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1); - const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2); - // - bIsFound=IsFound(aMWht, aMWit); - // - return bIsFound; } +// //======================================================================= -// function: FMapWhat -// purpose: +//function : FillFaceInfo +//purpose : //======================================================================= -void FMapWhat(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWhat) - +void NMTTools_PaveFiller::FillFaceInfo() { - Standard_Integer nE, nV; + Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF; + TopAbs_ShapeEnum aType; + TopoDS_Shape aS; + TColStd_ListIteratorOfListOfInteger aItF; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI; + NMTTools_ListIteratorOfListOfCommonBlock aItCB; // - BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS(); - BooleanOperations_OnceExplorer aExp(*myDS); + myFaceInfo.Clear(); // - // What - aMapWhat.Add(nF); - aExp.Init(nF, TopAbs_VERTEX); - for (; aExp.More(); aExp.Next()) { - nV=aExp.Current(); - aMapWhat.Add(nV); + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + BOPTools_CArray1OfVSInterference& aVFs=myIP->VSInterferences(); + BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); + // + aNbFFs=aFFs.Extent(); + if (!aNbFFs) { + return; } // - aExp.Init(nF, TopAbs_EDGE); - for (; aExp.More(); aExp.Next()) { - nE=aExp.Current(); - aMapWhat.Add(nE); + // 0. + for (i=1; i<=aNbFFs; ++i) { + NMTTools_FaceInfo aFI; + // + BOPTools_SSInterference& aFFi=aFFs(i); + aFFi.Indices(n1, n2); + myFaceInfo.Bind(n1, aFI); + myFaceInfo.Bind(n2, aFI); } + // + // 1. + aNbS=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + aS=myDS->Shape(i); + aType=aS.ShapeType(); + if (aType==TopAbs_EDGE) { + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i)); + aItCB.Initialize(aLCB); + for (; aItCB.More(); aItCB.Next()) { + const NMTTools_CommonBlock& aCB=aItCB.Value(); + const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1(); + const TColStd_ListOfInteger& aLF=aCB.Faces(); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + nF=aItF.Value(); + if (!myFaceInfo.IsBound(nF)) { + continue; + } + // + NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF); + aFI.ChangePaveBlocksIn().Add(aPB1); + // + n1=aPB1.Pave1().Index(); + n2=aPB1.Pave2().Index(); + aFI.ChangeVerticesIn().Add(n1); + aFI.ChangeVerticesIn().Add(n2); + } + } + }// if (aType==TopAbs_EDGE) { + else if (aType==TopAbs_FACE) { + if (!myFaceInfo.IsBound(i)) { + continue; + } + // + BOPTools_ListOfPaveBlock aLPBOn; + // + nF=i; + NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF); + // + RealSplitsFace(nF, aLPBOn); + // + anItPB.Initialize(aLPBOn); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock &aPB=anItPB.Value(); + aFI.ChangePaveBlocksOn().Add(aPB); + // + n1=aPB.Pave1().Index(); + n2=aPB.Pave2().Index(); + aFI.ChangeVerticesOn().Add(n1); + aFI.ChangeVerticesOn().Add(n2); + } + // + }// else if (aType==TopAbs_FACE) { + }// for (i=1; i<=aNbS; ++i) { + // + // 2. + aItMFI.Initialize(myFaceInfo); + for (; aItMFI.More(); aItMFI.Next()) { + nF=aItMFI.Key(); + NMTTools_FaceInfo& aFI=*((NMTTools_FaceInfo*)&aItMFI.Value()); + // + aFI.SetIndex(nF); + // + // + // 2.1 aVFs + aNbVFs=aVFs.Extent(); + for (j=1; j<=aNbVFs; ++j) { + BOPTools_VSInterference& aVFj=aVFs(j); + aVFj.Indices(n1, n2); + if (nF==n1) { + aFI.ChangeVerticesIn().Add(n2); + } + else if (nF==n2){ + aFI.ChangeVerticesIn().Add(n1); + } + }// for (j=1; j<=aNbVFs; ++j) { + // + // 2.2 aEFs + aNbEFs=aEFs.Extent(); + for (j=1; j<=aNbEFs; ++j) { + BOPTools_ESInterference& aEFj=aEFs(j); + aEFj.Indices(n1, n2); + if (!(nF==n1 || nF==n2)) { + continue; + } + // + nX=aEFj.NewShape(); + if (nX<1) { + continue; + } + // + aS=myDS->Shape(nX); + aType=aS.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + aFI.ChangeVerticesIn().Add(nX); + }// for (j=1; j<=aNbEFs; ++j) { + }// for (; aItMFI.More(); aItMFI.Next()) { } + + +#include +#include +#include +#include //======================================================================= -// function: FMapWith -// purpose: +//function : CorrectTolR3D +//purpose : Attempt to correct the value of tolerance aTolR3D for +// the intersection curve in order to +// compel it to pass through the sticks. +// Prerequisites: +// 2. The are based on B-Spline surfaces; +// 1. There is at least the one intersection curve; +// 2. The faces have stick vertices to catch the curve; +// 3. The intersection angle is rather small (0.7-7 deg) +// //======================================================================= -void FMapWith(const Standard_Integer nF, - BOPTools_InterferencePool* myIntrPool, - TColStd_IndexedMapOfInteger& aMapWith) -{ - TColStd_IndexedMapOfInteger aMapWhat; - - FMapWhat(nF, myIntrPool, aMapWhat); - // - // With - Standard_Integer i, aNb, anIndex, aWhat, aWith; - BOPTools_ListIteratorOfListOfInterference anIt; - - const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable(); +void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF, + const TColStd_MapOfInteger& aMVStick, + Standard_Real& aTolR3D) - aNb=aMapWhat.Extent(); - for (i=1; i<=aNb; i++) { - aWhat=aMapWhat(i); - - const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat); - - const BOPTools_ListOfInterference& aLI=aWithLine.List(); - anIt.Initialize(aLI); - for (; anIt.More(); anIt.Next()) { - const BOPTools_Interference& anIntf=anIt.Value(); - anIndex=anIntf.Index(); - if (anIndex) { - aWith=anIntf.With(); - aMapWith.Add(aWith); - } +{ + Standard_Boolean bHasBounds; + Standard_Integer i, nF[2], nV, aNbCurves; + Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax; + Standard_Real aTolR, aTolTresh, aAmin, aAmax; + TColStd_MapIteratorOfMapOfInteger aIt; + gp_Pnt aP, aP1, aP2; + gp_Dir aDN[2]; + gp_Vec aVT; + Handle(Geom_Surface) aS[2]; + Handle(Geom_Curve) aC3D; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aType; + TopoDS_Face aF[2]; + // + aTolTresh=0.0005; + aAmin=0.012;// 0.7-7 deg + aAmax=0.12; + // + if (!aMVStick.Extent()) { + return; + } + // + BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF); + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + aNbCurves=aSCvs.Length(); + if (aNbCurves!=1){ + return; + } + // + aFFi.Indices(nF[0], nF[1]); + for (i=0; i<2; ++i) { + aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i]))); + aS[i]=BRep_Tool::Surface(aF[i]); + aGAS.Load(aS[i]); + aType=aGAS.GetType(); + if (aType!=GeomAbs_BSplineSurface) { + return; } } + // + BOPTools_Curve& aBC=aSCvs(1); + const IntTools_Curve& aIC=aBC.Curve(); + bHasBounds=aIC.HasBounds(); + if (!bHasBounds){ + return; + } + // + aIC.Bounds (aT1, aT2, aP1, aP2); + aT=IntTools_Tools::IntermediatePoint(aT1, aT2); + aC3D=aIC.Curve(); + aC3D->D0(aT, aP); + // + for (i=0; i<2; ++i) { + GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]); + aPPS.Perform(aP); + aPPS.LowerDistanceParameters(aU, aV); + BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]); + } + // + aA=aDN[0].Angle(aDN[1]); + aA=fabs(aA); + if (aA > 0.5*M_PI) { + aA = M_PI - aA; + } + // + if (aAaAmax) { + return; + } + // + aTolVmax=-1.; + aIt.Initialize(aMVStick); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Key(); + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV))); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + + aTolR=aTolVmax/aA; + if (aTolR 0x06050100 // For OCCT6.5.2 and higher //======================================================================= -// function: IsFound -// purpose: +// function: PutClosingPaveOnCurve +// purpose: //======================================================================= -Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat, - const TColStd_IndexedMapOfInteger& aMapWith) +void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) { - Standard_Boolean bFlag=Standard_False; - Standard_Integer i, aNb, aWhat; - - aNb=aMapWhat.Extent(); - for (i=1; i<=aNb; i++) { - aWhat=aMapWhat(i); - if (aMapWith.Contains(aWhat)) { - return !bFlag; + Standard_Boolean bIsClosed, bHasBounds, bAdded; + Standard_Integer nVC, j; + Standard_Real aT[2], aTolR3D, aTC, dT, aTx; + gp_Pnt aP[2] ; + BOPTools_Pave aPVx; + BOPTools_ListIteratorOfListOfPave aItLP; + // + const IntTools_Curve& aIC=aBC.Curve(); + const Handle (Geom_Curve)& aC3D=aIC.Curve(); + if(aC3D.IsNull()) { + return; + } + // + bIsClosed=IntTools_Tools::IsClosed(aC3D); + if (!bIsClosed) { + return; + } + // + bHasBounds=aIC.HasBounds (); + if (!bHasBounds){ + return; + } + // + bAdded=Standard_False; + dT=Precision::PConfusion(); + aTolR3D=aFFi.TolR3D(); + aIC.Bounds (aT[0], aT[1], aP[0], aP[1]); + // + BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); + BOPTools_PaveSet& aCPS=aBC.Set(); + // + const BOPTools_ListOfPave& aLP=aCPS.Set(); + aItLP.Initialize(aLP); + for (; aItLP.More() && !bAdded; aItLP.Next()) { + const BOPTools_Pave& aPC=aItLP.Value(); + nVC=aPC.Index(); + const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC)); + aTC=aPC.Param(); + // + for (j=0; j<2; ++j) { + if (fabs(aTC-aT[j]) < dT) { + aTx=(!j) ? aT[1] : aT[0]; + aPVx.SetIndex(nVC); + aPVx.SetParam(aTx); + // + aCPS.Append(aPVx); + aFFiPS.Append(aPVx); + // + bAdded=Standard_True; + break; + } } } - return bFlag; } -*/ +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher +//modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t