Salome HOME
Added help page and revert some changes for a better ergonomy
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_8.cxx
index fed900e3519edf2226ae6611fa11873bb09a3e8f..b4c21b10e9504feaf5bc3234459a6d05acbf17c9 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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
-//  version 2.1 of the License.
+// 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File:        NMTTools_PaveFiller_8.cxx
 // Created:     Fri Dec 19 11:15:53 2003
 // Author:      Peter KURNEV
 {
   Standard_Integer nE1;
   //
-  BooleanOperations_ShapesDataStructure *pDS=myDS;
+//   BooleanOperations_ShapesDataStructure *pDS=myDS;
   BooleanOperations_OnceExplorer aExp(*myDS);
   aExp.Init(nF1, TopAbs_EDGE);
   for (; aExp.More(); aExp.Next()) {
   if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) {
     return 1; // Type mismatch
   }
-  BooleanOperations_ShapesDataStructure *pDS=myDS;
+//   BooleanOperations_ShapesDataStructure *pDS=myDS;
   BooleanOperations_OnceExplorer aExp(*myDS);
   aExp.Init(nF1, TopAbs_EDGE);
   for (; aExp.More(); aExp.Next()) {
   }
   return 0; //Ok
 }
+//modified by NIZNHY-PKV Mon Oct 17 12:07:48 2011f
+static 
+  void SortPaveBlocks(BOPTools_ListOfPaveBlock &);
+static
+  void SortShell(const Standard_Integer, 
+                BOPTools_PaveBlock *);
+static
+  Standard_Boolean Less(const BOPTools_PaveBlock &, 
+                       const BOPTools_PaveBlock &);
+
+//=======================================================================
+// function: RealSplitsInFace
+// purpose:
+//=======================================================================
+  void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nF,
+                                             BOPTools_ListOfPaveBlock& aLPBIn)
+{
+  Standard_Integer j, aNbCBP, nSpIn;
+  TColStd_MapOfInteger aMFence; 
+  BOPTools_ListOfPaveBlock aLPB;
+  BOPTools_ListIteratorOfListOfPaveBlock aItPB;
+  NMTTools_ListIteratorOfListOfCommonBlock aItCB;
+  //
+  NMTTools_CommonBlockPool& aCBP=ChangeCommonBlockPool();
+  //
+  aNbCBP=aCBP.Extent();
+  for (j=1; j<=aNbCBP; ++j) {
+    NMTTools_ListOfCommonBlock& aLCB=aCBP(j);
+    aItCB.Initialize(aLCB);
+    for (; aItCB.More(); aItCB.Next()) {
+      NMTTools_CommonBlock& aCB=aItCB.Value();
+      if (aCB.IsPaveBlockOnFace(nF)) {
+       const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1();
+       nSpIn=aPB1.Edge();
+       if (aMFence.Add(nSpIn)){
+         aLPB.Append(aPB1);
+       }
+      }
+    }
+  }
+  //
+  SortPaveBlocks(aLPB);
+  //
+  aItPB.Initialize(aLPB);
+  for (; aItPB.More(); aItPB.Next()) {
+    const BOPTools_PaveBlock& aPB=aItPB.Value();
+    aLPBIn.Append(aPB);
+  }
+}
+//=======================================================================
+// function: SortPaveBlocks
+// purpose:
+//=======================================================================
+void SortPaveBlocks(BOPTools_ListOfPaveBlock &aLPBIn)
+{
+  Standard_Integer i, aNbPBIn;
+  BOPTools_ListIteratorOfListOfPaveBlock aItPB;
+  BOPTools_PaveBlock *pPB;
+  //
+  aNbPBIn=aLPBIn.Extent();
+  if (aNbPBIn<2) {
+    return;
+  }
+  //
+  pPB=new BOPTools_PaveBlock[aNbPBIn];
+  //
+  aItPB.Initialize(aLPBIn);
+  for (i=0; aItPB.More(); aItPB.Next(), ++i) {
+    const BOPTools_PaveBlock& aPB=aItPB.Value();
+    pPB[i]=aPB;
+  }
+  //
+  SortShell(aNbPBIn, pPB);
+  //
+  aLPBIn.Clear();
+  for (i=0; i<aNbPBIn; ++i) {
+    aLPBIn.Append(pPB[i]);
+  }
+  //
+  delete [] (BOPTools_PaveBlock*)pPB;
+}
+//=======================================================================
+//function : SortShell
+//purpose  : 
+//=======================================================================
+void SortShell(const Standard_Integer n, 
+              BOPTools_PaveBlock *a) 
+{
+  Standard_Integer nd, i, j, l, d=1;
+  BOPTools_PaveBlock x;
+  //
+  while(d<=n) {
+    d*=2;
+  }
+  //
+  while (d) {
+    d=(d-1)/2;
+    //
+    nd=n-d;
+    for (i=0; i<nd; ++i) {
+      j=i;
+    m30:;
+      l=j+d;
+      if (Less(a[l], a[j])) {
+      //if (a[l] < a[j]){
+       x=a[j];
+       a[j]=a[l];
+       a[l]=x;
+       j-=d;
+       if (j > -1) goto m30;
+      }//if (a[l] < a[j]){
+    }//for (i=0; i<nd; ++i) 
+  }//while (1)
+}
+
+//=======================================================================
+//function : Less
+//purpose  : 
+//=======================================================================
+Standard_Boolean Less(const BOPTools_PaveBlock &aPB1, 
+                     const BOPTools_PaveBlock &aPB2)
+{
+  Standard_Boolean bRet;
+  Standard_Integer iE1, iE2;
+  Standard_Real aT11, aT12, aT21, aT22;
+  //
+  iE1=aPB1.OriginalEdge();
+  iE2=aPB2.OriginalEdge();
+  if (iE1!=iE2) {
+    bRet=(iE1<iE2);
+    return bRet;
+  }
+  //
+  aPB1.Parameters(aT11, aT12);
+  aPB2.Parameters(aT21, aT22);
+  bRet=(aT11<aT21);
+  return bRet;
+}
+//modified by NIZNHY-PKV Mon Oct 17 11:44:45 2011t