Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller_6.cxx
index 1dea52d684562ceac6c021d1ea353191a40257ec..3f897dedd64dbd544f1acccd5f85bb69e0c7980a 100644 (file)
@@ -1,29 +1,31 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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_6.cxx
 //  Created:     Fri Dec 19 10:27:31 2003
 //  Author:      Peter KURNEV
 
-#include <NMTTools_PaveFiller.ixx>
+#include <NMTTools_PaveFiller.hxx>
+
+#include <Basics_OCCTVersion.hxx>
 
 #include <Precision.hxx>
 
@@ -90,6 +92,7 @@
 #include <BOPTools_PaveBlockIterator.hxx>
 #include <BOPTools_Tools2D.hxx>
 #include <BOPTools_Tools3D.hxx>
+#include <BOPTools_Curve.hxx>
 
 #include <NMTDS_Iterator.hxx>
 #include <NMTDS_ShapesDataStructure.hxx>
 
 static
   Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
-                               IntTools_Context& aCtx);
+                               const Handle(IntTools_Context)& aCtx);
 
 //=======================================================================
 // function: PerformFF
@@ -122,7 +125,7 @@ static
   myIsDone=Standard_False;
   //
   Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone;
-  Standard_Boolean bJustAdd;
+  Standard_Boolean bJustAdd, bToSplit;
   Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs;
   Standard_Integer aNbCurves, aNbPoints;
   Standard_Real anApproxTol, aTolR3D, aTolR2D;
@@ -142,6 +145,10 @@ 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);
     //
@@ -186,7 +193,13 @@ static
       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();
@@ -230,7 +243,7 @@ void NMTTools_PaveFiller::MakeBlocks()
   //
   BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences();
   //
-  
+
   //
   // 1. Make Section Edges from intersection curves
   //    between each pair of faces
@@ -349,6 +362,16 @@ void NMTTools_PaveFiller::MakeBlocks()
       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;
@@ -392,7 +415,7 @@ void NMTTools_PaveFiller::MakeBlocks()
        //
         // Checking of validity in 2D
         //
-        bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
+        bIsValidIn2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D);
         if (!bIsValidIn2D) {
           continue;
         }
@@ -407,10 +430,10 @@ void NMTTools_PaveFiller::MakeBlocks()
         {
           Standard_Real aT;
           //
-          myContext.IsVertexOnLine(aV1, aIC, aTolR3D, aT);
+          myContext->IsVertexOnLine(aV1, aIC, aTolR3D, aT);
           BOPTools_Tools::UpdateVertex (aIC, aT, aV1);
           //
-          myContext.IsVertexOnLine(aV2, aIC, aTolR3D, aT);
+          myContext->IsVertexOnLine(aV2, aIC, aTolR3D, aT);
           BOPTools_Tools::UpdateVertex (aIC, aT, aV2);
         }
         //
@@ -908,7 +931,7 @@ Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_Pave
   //
   aBB.MakeVertex (aVM, aPM, aTolC);
   //
-  iVM=myContext.ComputeVE(aVM, aE2, aTmp);
+  iVM=myContext->ComputeVE(aVM, aE2, aTmp);
   //
   return iVM;
 }
@@ -941,12 +964,12 @@ void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC,
   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);
   }
@@ -1138,7 +1161,7 @@ Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock&
     }
     // VE
     if (!iV) {
-      iVE=myContext.ComputeVE (aV11, aE2, aTE);
+      iVE=myContext->ComputeVE (aV11, aE2, aTE);
       if (!iVE) {
         iCount++;
         if (iCount>iCountExt) {
@@ -1167,7 +1190,7 @@ Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock&
     }
     // VE
     if (!iV) {
-      iVE=myContext.ComputeVE (aV12, aE2, aTE);
+      iVE=myContext->ComputeVE (aV12, aE2, aTE);
       if (!iVE) {
         iCount++;
         if (iCount>iCountExt) {
@@ -1185,7 +1208,7 @@ Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock&
 //purpose  :
 //=======================================================================
 Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE,
-                             IntTools_Context& aCtx)
+                             const Handle(IntTools_Context)& aCtx)
 {
   Standard_Boolean bRet;
   Standard_Integer iErr;
@@ -1252,7 +1275,7 @@ void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
       continue;
     }
     //
-    bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT);
+    bIsVertexOnLine=myContext->IsVertexOnLine(aV, aC, aTolR3D, aT);
     //
     //
     if (bIsVertexOnLine) {
@@ -1260,24 +1283,20 @@ void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
       BOPTools_PaveSet& aPS=aBC.Set();
       aPS.Append(aPaveNew);
       //<-B
-      //modified by NIZNHY-PKV Thu Apr 22 10:36:45 2010f
-      //BOPTools_Tools::UpdateVertex (aC, aT, aV);
-      //modified by NIZNHY-PKV Thu Apr 22 10:36:48 2010t
     }
   }
 }
-//modified by NIZNHY-PKV Tue Feb 08 12:24:35 2011f
 //
 //=======================================================================
 //function : FillFaceInfo
-//purpose  : 
+//purpose  :
 //=======================================================================
 void NMTTools_PaveFiller::FillFaceInfo()
 {
   Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF;
   TopAbs_ShapeEnum aType;
   TopoDS_Shape aS;
-  TColStd_ListIteratorOfListOfInteger aItF; 
+  TColStd_ListIteratorOfListOfInteger aItF;
   BOPTools_ListIteratorOfListOfPaveBlock anItPB;
   NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI;
   NMTTools_ListIteratorOfListOfCommonBlock aItCB;
@@ -1418,19 +1437,19 @@ void NMTTools_PaveFiller::FillFaceInfo()
 //=======================================================================
 //function : CorrectTolR3D
 //purpose  : Attempt to correct the value of tolerance aTolR3D for
-//           the intersection curve in order to 
+//           the intersection curve in order to
 //           compel it to pass through the sticks.
-//           Prerequisites: 
+//           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 NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
                                        const TColStd_MapOfInteger& aMVStick,
                                        Standard_Real& aTolR3D)
-     
+
 {
   Standard_Boolean bHasBounds;
   Standard_Integer i, nF[2], nV, aNbCurves;
@@ -1485,7 +1504,7 @@ void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
   aC3D->D0(aT, aP);
   //
   for (i=0; i<2; ++i) {
-    GeomAPI_ProjectPointOnSurf& aPPS=myContext.ProjPS(aF[i]);
+    GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]);
     aPPS.Perform(aP);
     aPPS.LowerDistanceParameters(aU, aV);
     BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]);
@@ -1493,8 +1512,8 @@ void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
   //
   aA=aDN[0].Angle(aDN[1]);
   aA=fabs(aA);
-  if (aA>0.5*PI) {
-    aA=PI-aA;
+  if (aA > 0.5*M_PI) {
+    aA = M_PI - aA;
   }
   //
   if (aA<aAmin || aA>aAmax) {
@@ -1512,10 +1531,75 @@ void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF,
     }
   }
   //
-  
+
   aTolR=aTolVmax/aA;
   if (aTolR<aTolTresh) {
     aTolR3D=aTolR;
   }
 }
-//modified by NIZNHY-PKV Tue Feb 08 12:24:56 2011t
+
+//modified by NIZNHY-PKV Wed Sep 14 13:21:13 2011f
+#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
+//=======================================================================
+// function: PutClosingPaveOnCurve
+// purpose:
+//=======================================================================
+void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC,
+                                               BOPTools_SSInterference& aFFi)
+{
+  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;
+      }
+    }
+  }
+}
+#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher
+//modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t