Salome HOME
0020598: EDF 1191 GEOM : Creation of hexa block from two faces
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_4.cxx
index 2c1d50e26251bb01820c5f7ea09065b805e1bf2e..0beae6670a37e5d874d64c61066875f4b010901b 100644 (file)
@@ -1,28 +1,29 @@
-// Copyright (C) 2005  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 
-// 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 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// 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
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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
+//  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
+//  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
+//  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_4.cxx
 // Created:    Mon Dec  8 17:08:58 2003
 // Author:     Peter KURNEV
 //             <pkv@irinox>
-
-
+//
 #include <NMTTools_PaveFiller.ixx>
 //
 #include <stdio.h>
 #include <NMTTools_CommonBlock.hxx>
 #include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
 
-// Modified  Thu Sep 14 14:35:18 2006 
-// Contribution of Samtech www.samcef.com BEGIN
+
 #include <TColStd_ListOfInteger.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <BRepBndLib.hxx>
 #include <BOPTools_CArray1OfVSInterference.hxx>
 #include <BOPTools_VSInterference.hxx>
-// Contribution of Samtech www.samcef.com END
-//
-//
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
 
 
 static
@@ -293,7 +292,6 @@ static
                //
                BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex);
                //
-               //modified by NIZNHY-PKV Mon Jun 19 11:40:09 2007f
                {
                  Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound;
                  Standard_Real aTolVx, aTolVnew, aD2, aDT2;
@@ -339,7 +337,6 @@ static
                    continue;
                  }
                }
-               //modified by NIZNHY-PKV Mon Jun 19 11:40:16 2007t
                //
                // Add Interference to the Pool
                BOPTools_EEInterference anInterf (aWhat, aWith, aCPart);
@@ -408,14 +405,107 @@ static
     } // for (; anIt1.More(); anIt1.Next()) 
   }// for (; myDSIt.More(); myDSIt.Next()) 
   //
-  EENewVertices (aMapVI);
-  EECommonBlocks(aMapCB);
-  // Modified to invoke new nethod Thu Sep 14 14:35:18 2006 
-  // Contribution of Samtech www.samcef.com BEGIN
+  //modified by NIZNHY-PKV Thu Mar 19 14:13:34 2009f
+  //
+  //EENewVertices (aMapVI);
+  //EECommonBlocks(aMapCB);
+  
+  {
+    NMTTools_ListOfCommonBlock aLCB;
+    //
+    FindChains(aMapCB, aLCB);
+    EENewVertices (aMapVI);
+    //TreatPaveBlocks(*this, aLCB);
+    TreatPaveBlocks(aLCB);
+    ReplaceCommonBlocks(aLCB);
+  }
+  //modified by NIZNHY-PKV Thu Mar 19 14:13:42 2009t
+  //
   PerformVF1();
-  // Contribution of Samtech www.samcef.com BEGIN
+  //
   myIsDone=Standard_True;
 }
+//modified by NIZNHY-PKV Thu Mar 19 14:13:52 2009f
+//=======================================================================
+// function:TreatPaveBlocks
+// purpose: 
+//=======================================================================
+  void NMTTools_PaveFiller::TreatPaveBlocks (NMTTools_ListOfCommonBlock& theLCB)
+{
+  Standard_Boolean bFound;
+  Standard_Integer nE, nV, nVp, iFlag;
+  Standard_Real aT;
+  TColStd_MapOfInteger aMI;
+  TColStd_MapIteratorOfMapOfInteger aItMI;
+  NMTTools_ListIteratorOfListOfCommonBlock aItLCB;
+  BOPTools_ListIteratorOfListOfPaveBlock aItLPB;
+  BOPTools_ListIteratorOfListOfPave aItLP;
+  //
+  aItLCB.Initialize(theLCB);
+  for (; aItLCB.More(); aItLCB.Next()) {
+    const NMTTools_CommonBlock& aCB=aItLCB.Value();
+    //
+    aMI.Clear();
+    const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks();
+    //
+    // 1 -> aMI
+    aItLPB.Initialize(aLPB);
+    for (; aItLPB.More(); aItLPB.Next()) {
+      const BOPTools_PaveBlock& aPB=aItLPB.Value();
+      nE=aPB.OriginalEdge();
+      BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
+      BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
+      //
+      aItLP.Initialize(aLP);
+      for (; aItLP.More(); aItLP.Next()) {
+       const BOPTools_Pave& aPave=aItLP.Value();
+       nV=aPave.Index();
+       aMI.Add(nV);
+      }
+    }//for (; anItLPB.More(); anItLPB.Next()) {
+    //
+    // 2
+    aItLPB.Initialize(aLPB);
+    for (; aItLPB.More(); aItLPB.Next()) {
+      const BOPTools_PaveBlock& aPB=aItLPB.Value();
+      nE=aPB.OriginalEdge();
+      BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE));
+      BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet();
+      //
+      aItMI.Initialize(aMI);
+      for (; aItMI.More(); aItMI.Next()) {
+       nV=aItMI.Key();
+       bFound=Standard_False;
+       aItLP.Initialize(aLP);
+       for (; aItLP.More(); aItLP.Next()) {
+         const BOPTools_Pave& aPave=aItLP.Value();
+         nVp=aPave.Index();
+         if (nVp==nV) {
+           bFound=!bFound;
+           break;
+         }
+       }
+       //
+       if (!bFound) {
+         // Append Pave of nV to rhe edge nE
+         const TopoDS_Edge& aE=*(TopoDS_Edge*)(&myDS->Shape(nE));
+         const TopoDS_Vertex& aV= *(TopoDS_Vertex*)(&myDS->Shape(nV));
+         iFlag=myContext.ComputeVE (aV, aE, aT);
+         if (!iFlag) {
+           BOPTools_Pave aPave;
+           //
+           aPave.SetInterference(-1);
+           aPave.SetType (BooleanOperations_EdgeEdge);
+           aPave.SetIndex(nV);
+           aPave.SetParam(aT);
+           aPaveSet.Append(aPave);
+         }
+       }
+      }//for (; aItMI.More(); aItMI.Next()) {
+    }//for (; anItLPB.More(); anItLPB.Next()) {
+  }
+}
+//modified by NIZNHY-PKV Thu Mar 19 14:14:13 2009t
 //=======================================================================
 // function:EECommonBlocks
 // purpose: 
@@ -970,10 +1060,7 @@ void MakeNewVertex(const TopTools_ListOfShape& aLV,
       tNV=tV+aCoeff*(tNV-tV);
       aNewRange.SetFirst(tNV);
       aNewRange.SetLast (aSR.Last());
-      //modified by NIZNHY-PKV Tue Jan 23 14:07:55 2007f
-      //if(aNewRange.First() > aNewRange.Last()) {
       if(aNewRange.First() < aNewRange.Last()) {
-      //modified by NIZNHY-PKV Tue Jan 23 14:08:02 2007t
        aShrunkRange.SetShrunkRange(aNewRange);
       }
     }