Back to index

salome-geom  6.5.0
NMTTools_PaveFiller_5.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        NMTTools_PaveFiller_5.cxx
00024 // Created:     Mon Dec 15 11:28:33 2003
00025 // Author:      Peter KURNEV
00026 //              <pkv@irinox>
00027 //
00028 #include <NMTTools_PaveFiller.hxx>
00029 
00030 #include <TColStd_IndexedMapOfInteger.hxx>
00031 
00032 #include <BRep_Tool.hxx>
00033 #include <BRep_Builder.hxx>
00034 
00035 #include <Bnd_Box.hxx>
00036 
00037 #include <TopAbs_ShapeEnum.hxx>
00038 
00039 #include <TopoDS.hxx>
00040 #include <TopoDS_Face.hxx>
00041 #include <TopoDS_Edge.hxx>
00042 #include <TopoDS_Vertex.hxx>
00043 #include <TopoDS_Compound.hxx>
00044 
00045 #include <TopExp.hxx>
00046 
00047 #include <TopTools_IndexedMapOfShape.hxx>
00048 
00049 #include <IntTools_ShrunkRange.hxx>
00050 #include <IntTools_Range.hxx>
00051 #include <IntTools_EdgeFace.hxx>
00052 #include <IntTools_SequenceOfCommonPrts.hxx>
00053 #include <IntTools_CommonPrt.hxx>
00054 #include <IntTools_Tools.hxx>
00055 #include <IntTools_Context.hxx>
00056 
00057 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
00058 #include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
00059 #include <BooleanOperations_OnceExplorer.hxx>
00060 
00061 #include <BOPTools_Tools.hxx>
00062 #include <BOPTools_Pave.hxx>
00063 #include <BOPTools_PaveSet.hxx>
00064 #include <BOPTools_ListOfPave.hxx>
00065 #include <BOPTools_ListIteratorOfListOfPave.hxx>
00066 #include <BOPTools_PaveBlock.hxx>
00067 #include <BOPTools_ListOfPaveBlock.hxx>
00068 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
00069 #include <BOPTools_ESInterference.hxx>
00070 
00071 #include <BOPTools_CArray1OfVVInterference.hxx>
00072 #include <BOPTools_CArray1OfESInterference.hxx>
00073 #include <BOPTools_VVInterference.hxx>
00074 #include <BOPTools_ESInterference.hxx>
00075 #include <BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx>
00076 #include <BOPTools_IMapOfPaveBlock.hxx>
00077 
00078 #include <NMTDS_ShapesDataStructure.hxx>
00079 #include <NMTDS_Iterator.hxx>
00080 #include <NMTDS_InterfPool.hxx>
00081 
00082 #include <NMTTools_ListOfCommonBlock.hxx>
00083 #include <NMTTools_CommonBlockAPI.hxx>
00084 #include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
00085 #include <NMTTools_CommonBlockAPI.hxx>
00086 #include <NMTTools_ListOfCommonBlock.hxx>
00087 
00088 
00089 static
00090   void VertexParameter(const IntTools_CommonPrt& aCPart,
00091                        Standard_Real& aT);
00092 static
00093   Standard_Boolean IsOnPave(const Standard_Real& aTR,
00094                             const IntTools_Range& aCPRange,
00095                             const Standard_Real& aTolerance);
00096 //
00097 //=======================================================================
00098 // function: PerformEF
00099 // purpose:
00100 //=======================================================================
00101   void NMTTools_PaveFiller::PerformEF()
00102 {
00103   Standard_Boolean bJustAdd;
00104   Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength;
00105   Standard_Integer aDiscretize;
00106   Standard_Real aTolE, aTolF, aDeflection;
00107   BooleanOperations_IndexedDataMapOfShapeInteger aMapVI;
00108   BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB;
00109   BOPTools_IMapOfPaveBlock aIMPBx;
00110   //
00111   myIsDone=Standard_False;
00112   aDeflection=0.01;
00113   aDiscretize=35;
00114   //
00115   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
00116   //
00117   myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE);
00118   //
00119   // BlockLength correction
00120   aNbEFs=myDSIt->BlockLength();
00121   aBlockLength=aEFs.BlockLength();
00122   if (aNbEFs > aBlockLength) {
00123     aEFs.SetBlockLength(aNbEFs);
00124   }
00125   //
00126   for (; myDSIt->More(); myDSIt->Next()) {
00127     myDSIt->Current(n1, n2, bJustAdd);
00128     //
00129     if(bJustAdd) {
00130       continue;
00131     }
00132     //
00133     anIndexIn = 0;
00134     //
00135     nE=n1;
00136     nF=n2;
00137     if (myDS->GetShapeType(n2)==TopAbs_EDGE) {
00138       nE=n2;
00139       nF=n1;
00140     }
00141     //
00142     // all Common Blocks for face nF
00143     NMTTools_ListOfCommonBlock aLCBF;
00144     CommonBlocksFace(nF, aLCBF);
00145     NMTTools_CommonBlockAPI aCBAPIF(aLCBF);
00146     //
00147     // Edge
00148     const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));
00149     if (BRep_Tool::Degenerated(aE)){
00150       continue;
00151     }
00152     //
00153     // Face
00154     const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF));
00155     //
00156     TopTools_IndexedMapOfShape aME;
00157     TopExp::MapShapes(aF, TopAbs_EDGE, aME);
00158     if (aME.Contains(aE)) {
00159       continue;
00160     }
00161     //
00162     aTolF=BRep_Tool::Tolerance(aF);
00163     aTolE=BRep_Tool::Tolerance(aE);
00164 
00165     const Bnd_Box& aBBF=myDS->GetBoundingBox(nF);
00166     //
00167     // Process each PaveBlock on edge nE
00168     BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
00169     //
00170     BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB);
00171     for (; anIt.More(); anIt.Next()) {
00172       BOPTools_PaveBlock& aPB=anIt.Value();
00173       if (aCBAPIF.IsCommonBlock(aPB)) {
00174         continue;
00175       }
00176       //
00177       const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange();
00178       const IntTools_Range& aSR =aShrunkRange.ShrunkRange();
00179       const Bnd_Box& aBBE=aShrunkRange.BndBox();
00180       //
00181       if (aBBF.IsOut (aBBE)) {
00182         continue;
00183       }
00184       //
00185       // EF
00186       IntTools_EdgeFace aEF;
00187       aEF.SetEdge (aE);
00188       aEF.SetFace (aF);
00189       aEF.SetTolE (aTolE);
00190       aEF.SetTolF (aTolF);
00191       aEF.SetDiscretize (aDiscretize);
00192       aEF.SetDeflection (aDeflection);
00193       //
00194       aEF.SetContext(myContext);
00195       //
00196       IntTools_Range anewSR = aSR;
00197       //
00198       // Correction of the Shrunk Range
00199       BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR);
00200       aEF.SetRange (anewSR);
00201       //
00202       aEF.Perform();
00203       //
00204       if (aEF.IsDone()) {
00205         Standard_Boolean bCoinsideFlag;
00206         Standard_Integer i, aNbCPrts;
00207         TopAbs_ShapeEnum aType;
00208         //
00209         const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts();
00210         //
00211         aNbCPrts=aCPrts.Length();
00212         for (i=1; i<=aNbCPrts; ++i) {
00213           anIndexIn=0;
00214           //
00215           const IntTools_CommonPrt& aCPart=aCPrts(i);
00216           aType=aCPart.Type();
00217           //
00218           switch (aType) {
00219             //
00220             case TopAbs_VERTEX:  {
00221               Standard_Boolean bIsOnPave1, bIsOnPave2;
00222               Standard_Integer nVF;
00223               Standard_Real aT, aTolToDecide;
00224               TopoDS_Vertex aNewVertex;
00225               //
00226               const IntTools_Range& aR=aCPart.Range1();
00227               //
00228               // New Vertex
00229               VertexParameter(aCPart, aT);
00230               BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex);
00231               //
00232               //decide to add pave or not
00233               aTolToDecide=5.e-8;
00234               bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide);
00235               bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide);
00236               //
00237               if (!bIsOnPave1 && !bIsOnPave2) {
00238                 nVF=CheckFacePaves(aNewVertex, nF);
00239                 if (!nVF) {
00240                   // really new vertex
00241                   // Add Interference to the Pool
00242                   BOPTools_ESInterference anInterf (nE, nF, aCPart);
00243                   anIndexIn=aEFs.Append(anInterf);
00244                   anInterf.SetNewShape(0);
00245                   //
00246                   aMapVI.Add(aNewVertex, anIndexIn);
00247                   aIMPBx.Add(aPB);
00248                   //
00249                   myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
00250                   //
00251                 }// if (!nVF)
00252               }// if (!bIsOnPave1 && !bIsOnPave2)
00253               //
00254               //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f
00255               else {
00256                 const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2();
00257                 nVF=aPave.Index();
00258                 const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF));
00259                 BOPTools_Tools::UpdateVertex (aVF, aNewVertex);
00260               }
00261               //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t
00262               //
00263             }// case TopAbs_VERTEX:
00264               break;
00265             //
00266             case TopAbs_EDGE: {
00267               bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext);
00268               if (!bCoinsideFlag) {
00269                 break;
00270               }
00271               //
00272               // Fill aMapCB
00273               if (aMapCB.Contains(aPB)) {
00274                 TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB);
00275                 aMapF.Add(nF);
00276               }
00277               else {
00278                 TColStd_IndexedMapOfInteger aMapF;
00279                 aMapF.Add(nF);
00280                 aMapCB.Add(aPB, aMapF);
00281               }
00282               //
00283               aIMPBx.Add(aPB);
00284               myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF);
00285             }// case TopAbs_EDGE:
00286               break;
00287 
00288             default:
00289               break;
00290           } // switch (aType)
00291         } // for (i=1; i<=aNbCPrts; i++)
00292       } //if (aEF.IsDone())
00293     } // for (; anIt.More(); anIt.Next())
00294   }// for (; myDSIt.More(); myDSIt.Next())
00295   //
00296   // Treat New vertices
00297   EFNewVertices(aMapVI);
00298   //
00299   // Add draft Common Blocks of EF type
00300   EFCommonBlocks(aMapCB);
00301   //
00302   // Collect all CB we suspected to split by new vertices
00303   NMTTools_ListOfCommonBlock aLCBx;
00304   {
00305     Standard_Integer i, aNbPBx, nEx;
00306     BOPTools_IMapOfPaveBlock aMx;
00307     //
00308     aNbPBx=aIMPBx.Extent();
00309     for (i=1; i<=aNbPBx; ++i) {
00310       const BOPTools_PaveBlock& aPBx=aIMPBx(i);
00311       nEx=aPBx.OriginalEdge();
00312       NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx));
00313       if (aLCB.Extent()) {
00314         NMTTools_CommonBlockAPI aCBAPIx(aLCB);
00315         if (aCBAPIx.IsCommonBlock(aPBx)) {
00316           NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx);
00317           const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1();
00318           if (!aMx.Contains(aPB1)){
00319             aMx.Add(aPB1);
00320             aLCBx.Append(aCBx);
00321           }
00322         }
00323       }
00324     }
00325   }
00326   //
00327   // Split the common blocks above
00328   if (aLCBx.Extent()) {
00329     ReplaceCommonBlocks(aLCBx);
00330   }
00331   //
00332   myIsDone=Standard_True;
00333 }
00334 //=======================================================================
00335 // function:EFCommonBlocks
00336 // purpose:
00337 //=======================================================================
00338   void NMTTools_PaveFiller::EFCommonBlocks
00339     (const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB)
00340 {
00341   Standard_Integer i, aNbPB, nE, j, aNbF, nF;
00342   //
00343   aNbPB=aMapCB.Extent();
00344   for (i=1; i<=aNbPB; ++i) {
00345     const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i);
00346     const TColStd_IndexedMapOfInteger& aMapF=aMapCB.FindFromIndex(i);
00347     aNbF=aMapF.Extent();
00348     //
00349     nE=aPB.OriginalEdge();
00350     //
00351     NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE));
00352     //
00353     NMTTools_CommonBlockAPI aCBAPI(aLCB);
00354     if (aCBAPI.IsCommonBlock(aPB)) {
00355       NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);
00356       for (j=1; j<=aNbF; ++j) {
00357         nF=aMapF(j);
00358         aCB.AddFace(nF);
00359       }
00360     }
00361     else {
00362       NMTTools_CommonBlock aCB;
00363       //
00364       aCB.AddPaveBlock(aPB);
00365       for (j=1; j<=aNbF; ++j) {
00366         nF=aMapF(j);
00367         aCB.AddFace(nF);
00368       }
00369       aLCB.Append(aCB);
00370     }
00371   }
00372 }
00373 //=======================================================================
00374 // function:EFNewVertices
00375 // purpose:
00376 //=======================================================================
00377   void NMTTools_PaveFiller::EFNewVertices
00378     (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
00379 {
00380   Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple;
00381   Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges, iTmp;
00382   Standard_Real aT;
00383   TopoDS_Compound aCompound;
00384   TopoDS_Vertex aNewVertex;
00385   BRep_Builder aBB;
00386   BOPTools_Pave aPave;
00387   NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEF;
00388   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
00389   TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple;
00390   //
00391   aNb=aMapVI.Extent();
00392   if (!aNb) { // no new vertices, no new problems
00393     return;
00394   }
00395   //
00396   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
00397   //
00398   // 0.
00399   if (aNb==1) {
00400     aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1));
00401     EFNewVertices(aNewVertex, aMapVI);
00402     return;
00403   }
00404   //
00405   // 1. Make compound from new vertices
00406   aBB.MakeCompound(aCompound);
00407   for (i=1; i<=aNb; ++i) {
00408     const TopoDS_Shape& aV=aMapVI.FindKey(i);
00409     aBB.Add(aCompound, aV);
00410   }
00411   //
00412   // 2. VV intersection between these vertices
00413   //       using the auxiliary Filler
00414   NMTTools_PaveFiller tPF;
00415   //
00416   tPF.SetCompositeShape(aCompound);
00417   //
00418   tPF.Init();
00419   tPF.PerformVV();
00420   //
00421   NMTDS_ShapesDataStructure& tDS=*(tPF.DS());
00422   NMTDS_InterfPool& tInterfPool=*(tPF.IP());
00423   BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterferences();
00424   //
00425   // 3. Separate Comlex and Simple new vertices
00426   aNbVV=aVVInterfs.Extent();
00427    for (i=1; i<=aNbVV; ++i) {
00428     const BOPTools_VVInterference& aVV=aVVInterfs(i);
00429     aVV.Indices(aWhat, aWith);
00430     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
00431     const TopoDS_Shape& aV2=tDS.Shape(aWith);
00432     aMNVComplex.Add(aV1);
00433     aMNVComplex.Add(aV2);
00434   }
00435   //
00436   for (i=1; i<=aNb; ++i) {
00437     const TopoDS_Shape& aV=aMapVI.FindKey(i);
00438     if (!aMNVComplex.Contains(aV)) {
00439       aMNVSimple.Add(aV);
00440     }
00441   }
00442   //
00443   // 4. Treat Simple new Vertices
00444   aNbSimple=aMNVSimple.Extent();
00445   for (i=1; i<=aNbSimple; ++i) {
00446     const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i));
00447     EFNewVertices(aV, aMapVI);
00448   }
00449   //
00450   // 3. Fill Maps : NewVertex-edges (aMNVE)
00451   //                NewVertex-interferences (aMNVIEE)
00452   aNb=aVVInterfs.Extent();
00453   for (i=1; i<=aNb; ++i) {
00454     const BOPTools_VVInterference& aVV=aVVInterfs(i);
00455     aNewShape=aVV.NewShape();
00456     if (!aNewShape) {
00457       continue;
00458     }
00459     //
00460     if (!aMNVE.Contains(aNewShape)) {
00461       TColStd_IndexedMapOfInteger aMx;
00462       aMNVE.Add(aNewShape, aMx);
00463     }
00464     if (!aMNVIEF.Contains(aNewShape)) {
00465       TColStd_IndexedMapOfInteger aMx;
00466       aMNVIEF.Add(aNewShape, aMx);
00467     }
00468     //
00469     TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape);
00470     TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.ChangeFromKey(aNewShape);
00471     //
00472     aVV.Indices(aWhat, aWith);
00473     //aWhat
00474     const TopoDS_Shape& aV1=tDS.Shape(aWhat);
00475     iX=aMapVI.FindFromKey(aV1);
00476     const BOPTools_ESInterference& aEF1=aEFs(iX);
00477     aEF1.Indices(nE, nF);
00478     //
00479     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
00480       iTmp=nE;
00481       nE=nF;
00482       nF=iTmp;
00483     }
00484     aME.Add(nE);
00485     aMIEF.Add(iX);
00486     //aWith
00487     const TopoDS_Shape& aV2=tDS.Shape(aWith);
00488     iX=aMapVI.FindFromKey(aV2);
00489     const BOPTools_ESInterference& aEF2=aEFs(iX);
00490     aEF2.Indices(nE, nF);
00491     //
00492     if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
00493       iTmp=nE;
00494       nE=nF;
00495       nF=iTmp;
00496     }
00497     aME.Add(nE);
00498     aMIEF.Add(iX);
00499   }// for (i=1; i<=aNb; ++i) {
00500   //
00501   // 4. Process new vertices
00502   aNb=aMNVE.Extent();
00503   for (i=1; i<=aNb; ++i) { // xx
00504     //
00505     //  new Vertex
00506     nV=aMNVE.FindKey(i);
00507     aNewVertex=TopoDS::Vertex(tDS.Shape(nV));
00508     //
00509     // Insert New Vertex in DS;
00510     myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
00511     aNewShape=myDS->NumberOfInsertedShapes();
00512     myDS->SetState (aNewShape, BooleanOperations_ON);
00513     //
00514     // Update index of NewShape in EF interferences
00515     const TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.FindFromKey(nV);
00516     aNbIEF=aMIEF.Extent();
00517     for (j=1; j<=aNbIEF; ++j) {
00518       iX=aMIEF(j);
00519       BOPTools_ESInterference& aEF=aEFs(iX);
00520       aEF.SetNewShape(aNewShape);
00521     }
00522     //
00523     // Update Paves on all edges
00524     const TColStd_IndexedMapOfInteger& aME=aMNVE(i);
00525     aNbEdges=aME.Extent();
00526     for (j=1; j<=aNbEdges; ++j) {
00527       nE=aME(j);
00528       const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv
00529       //
00530       aFlag=myContext->ComputeVE (aNewVertex, aE, aT);
00531       //
00532       if (!aFlag) {
00533         aPave.SetInterference(-1);
00534         aPave.SetType (BooleanOperations_EdgeSurface);
00535         aPave.SetIndex(aNewShape);
00536         aPave.SetParam(aT);
00537         //
00538         BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
00539         aPaveSet.Append(aPave);
00540       }
00541     }
00542   }
00543 }
00544 //=======================================================================
00545 // function:EFNewVertices
00546 // purpose:
00547 //=======================================================================
00548   void NMTTools_PaveFiller::EFNewVertices
00549     (const TopoDS_Vertex& aNewVertex,
00550      const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI)
00551 {
00552   Standard_Integer i, aNewShape, nE, nF;
00553   Standard_Real aT;
00554   BOPTools_Pave aPave;
00555   BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
00556   //
00557   BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences();
00558   //
00559   // Insert New Vertex in DS;
00560   myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq);
00561   aNewShape=myDS->NumberOfInsertedShapes();
00562   myDS->SetState (aNewShape, BooleanOperations_ON);
00563   //
00564   // Insert New Vertex in EFInterference
00565   i=aMapVI.FindFromKey(aNewVertex);
00566   BOPTools_ESInterference& aEFInterf= aEFs(i);
00567   aEFInterf.SetNewShape(aNewShape);
00568   // Extract interference info
00569   aEFInterf.Indices(nE, nF);
00570   if (myDS->GetShapeType(nF)==TopAbs_EDGE) {
00571     nE=nF;
00572   }
00573   const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt();
00574   VertexParameter(aCPart, aT);
00575   //
00576   // Pave for edge nE
00577   aPave.SetInterference(i);
00578   aPave.SetType (BooleanOperations_EdgeSurface);
00579   aPave.SetIndex(aNewShape);
00580   aPave.SetParam(aT);
00581   // Append the Pave to the myPavePoolNew
00582   BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
00583   aPaveSet.Append(aPave);
00584   //
00585 }
00586 //=======================================================================
00587 // function: CheckFacePaves
00588 // purpose:
00589 //=======================================================================
00590   Standard_Integer NMTTools_PaveFiller::CheckFacePaves
00591     (const TopoDS_Vertex& aNewVertex,
00592      const Standard_Integer nF)
00593 {
00594   Standard_Integer nEF, nVF, iFlag, i, aNbV, iRet;
00595   BOPTools_ListIteratorOfListOfPave anIt;
00596   TColStd_IndexedMapOfInteger aMVF;
00597   //
00598   iRet=0;
00599   //
00600   BooleanOperations_OnceExplorer aExp(*myDS);
00601   aExp.Init(nF, TopAbs_EDGE);
00602   for (; aExp.More(); aExp.Next()) {
00603     nEF=aExp.Current();
00604     BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF));
00605     const BOPTools_ListOfPave& aLP=aPaveSet.Set();
00606     anIt.Initialize(aLP);
00607     for (; anIt.More(); anIt.Next()) {
00608       const BOPTools_Pave& aPave=anIt.Value();
00609       nVF=aPave.Index();
00610       aMVF.Add(nVF);
00611     }
00612   }
00613   //
00614   aNbV=aMVF.Extent();
00615   for (i=1; i<=aNbV; ++i) {
00616     nVF=aMVF(i);
00617     const TopoDS_Vertex aVF=TopoDS::Vertex(myDS->Shape(nVF));
00618     iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF);
00619     if (!iFlag) {
00620       return nVF;
00621     }
00622   }
00623   return iRet;
00624 }
00625 //
00626 //=======================================================================
00627 // function: VertexParameter
00628 // purpose:
00629 //=======================================================================
00630 void VertexParameter(const IntTools_CommonPrt& aCPart,
00631                      Standard_Real& aT)
00632 {
00633   const IntTools_Range& aR=aCPart.Range1();
00634   aT=0.5*(aR.First()+aR.Last());
00635   if((aCPart.VertexParameter1() >= aR.First()) &&
00636      (aCPart.VertexParameter1() <= aR.Last())) {
00637     aT = aCPart.VertexParameter1();
00638   }
00639 }
00640 //=======================================================================
00641 // function: IsOnPave
00642 // purpose:
00643 //=======================================================================
00644 Standard_Boolean IsOnPave(const Standard_Real& aTR,
00645                           const IntTools_Range& aCPRange,
00646                           const Standard_Real& aTolerance)
00647 {
00648   Standard_Boolean bIsOnPave;
00649   Standard_Real aT1, aT2, dT1, dT2;
00650   //
00651   aT1=aCPRange.First();
00652   aT2=aCPRange.Last();
00653   bIsOnPave=(aTR>=aT1 && aTR<=aT1);
00654   if (bIsOnPave) {
00655     return bIsOnPave;
00656   }
00657   //
00658   dT1=Abs(aTR-aT1);
00659   dT2=Abs(aTR-aT2);
00660   bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance);
00661   return bIsOnPave;
00662 }