]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOMAlgo/GEOMAlgo_WESCorrector.cxx
Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_WESCorrector.cxx
index 4ee7d7a69bccffd6372e367ed61e84351eb2c37f..83fea18f76edc7d7d8dd29e979d39673f7f96266 100755 (executable)
@@ -1,30 +1,29 @@
-//  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:        NMTAlgo_WESCorrector.cxx
-// Created:     
 // Author:      Peter KURNEV
-//              <pkv@irinox>
-//
-#include <GEOMAlgo_WESCorrector.ixx>
+
+#include <GEOMAlgo_WESCorrector.hxx>
 
 #include <Geom_Surface.hxx>
 
 #include <GEOMAlgo_WESScaler.hxx>
 
 static
-  void MakeWire(const TopTools_ListOfShape& aLE, 
+  void MakeWire(const TopTools_ListOfShape& aLE,
                 TopoDS_Wire& newWire);
 
 
 static
-  Standard_Boolean IsToScale(const TopoDS_Face& aF, 
-                            Standard_Real& aScale);
+  Standard_Boolean IsToScale(const TopoDS_Face& aF,
+                             Standard_Real& aScale);
 
 //=======================================================================
-// function: 
-// purpose: 
+// function:
+// purpose:
 //=======================================================================
   GEOMAlgo_WESCorrector::GEOMAlgo_WESCorrector()
 :
@@ -79,14 +78,14 @@ static
 }
 //=======================================================================
 // function: ~
-// purpose: 
+// purpose:
 //=======================================================================
   GEOMAlgo_WESCorrector::~GEOMAlgo_WESCorrector()
 {
 }
 //=======================================================================
 // function: SetWES
-// purpose: 
+// purpose:
 //=======================================================================
   void GEOMAlgo_WESCorrector::SetWES (const GEOMAlgo_WireEdgeSet& aWES)
 {
@@ -95,23 +94,23 @@ static
 }
 //=======================================================================
 // function: WES
-// purpose: 
+// purpose:
 //=======================================================================
-  GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::WES () 
+  GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::WES ()
 {
   return *myWES;
 }
 //=======================================================================
 // function: NewWES
-// purpose: 
+// purpose:
 //=======================================================================
-  GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::NewWES () 
+  GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::NewWES ()
 {
   return myNewWES;
 }
 //=======================================================================
 // function: Perform
-// purpose: 
+// purpose:
 //=======================================================================
   void GEOMAlgo_WESCorrector::Perform()
 {
@@ -122,7 +121,7 @@ static
 }
 //=======================================================================
 // function: DoConnexityBlocks
-// purpose: 
+// purpose:
 //=======================================================================
   void GEOMAlgo_WESCorrector::DoConnexityBlocks()
 {
@@ -149,7 +148,7 @@ static
     }
   }
   //
-  // 2. 
+  // 2.
   aNbV=aMVE.Extent();
   for (i=1; i<=aNbV; ++i) {
     const TopoDS_Shape& aV=aMVE.FindKey(i);
@@ -166,7 +165,7 @@ static
     //
     //------------------------------------- goal: aMEC
     aMEC.Clear();    // aMEC - edges of CB
-    aMVP.Clear();    // aMVP - vertices to process right now 
+    aMVP.Clear();    // aMVP - vertices to process right now
     aMVAdd.Clear();  // aMVAdd vertices to process on next step of while(1)
     //
     aMVP.Add(aV);
@@ -193,7 +192,7 @@ static
             }
           }
         }
-      }//for (j=1; j<=aNbVP; ++j) 
+      }//for (j=1; j<=aNbVP; ++j)
       //
       aNbVP=aMVAdd.Extent();
       if (!aNbVP) {
@@ -213,7 +212,7 @@ static
     TopTools_IndexedDataMapOfShapeListOfShape aMVER;
     //
     bRegular=Standard_True;
-   
+    //
     aNbC=aMEC.Extent();
     for (j=1; j<=aNbC; ++j) {
       aER=aMEC(j);
@@ -224,21 +223,17 @@ static
         aER.Orientation(TopAbs_REVERSED);
         aLEC.Append(aER);
         //
-       bRegular=Standard_False;
+        bRegular=Standard_False;
       }
       else {
         aLEC.Append(aER);
       }
       //
       if (bRegular) {
-       //modified by NIZNHY-PKV Wed Oct 20 14:45:52 2010f
-       const  TopoDS_Edge& aEx=*((TopoDS_Edge*)&aER);
-       if (!BRep_Tool::Degenerated(aEx)) {
-         TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
-       }
-       //
-        //TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
-       //modified by NIZNHY-PKV Wed Oct 20 14:46:48 2010t
+        const  TopoDS_Edge& aEx=*((TopoDS_Edge*)&aER);
+        if (!BRep_Tool::Degenerated(aEx)) {
+          TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER);
+        }
       }
     }//for (j=1; j<=aNbC; ++j) {
     //
@@ -273,7 +268,7 @@ static
 
 //=======================================================================
 // function: DoCorrections
-// purpose: 
+// purpose:
 //=======================================================================
   void GEOMAlgo_WESCorrector::DoCorrections()
 {
@@ -315,7 +310,7 @@ static
       aWSC.Perform();
       iErr=aWSC.ErrorStatus();
       if (iErr) {
-       return;
+        return;
       }
       //
       const TopoDS_Face& aFS=aWSC.FaceScaled();
@@ -327,31 +322,31 @@ static
       aWS.Perform();
       iErr=aWS.ErrorStatus();
       if (iErr) {
-       continue;
+        continue;
       }
       //
       bIsNothingToDo=aWS.IsNothingToDo();
       if (bIsNothingToDo) {
-       MakeWire(aLE, aW);
-       myNewWES.AddShape (aW);
-       continue;
+        MakeWire(aLE, aW);
+        myNewWES.AddShape (aW);
+        continue;
       }
       //
       const BOPTColStd_ListOfListOfShape& aLLSS=aWS.Shapes();
       aItLLSS.Initialize(aLLSS);
       for (; aItLLSS.More(); aItLLSS.Next()) {
-       TopTools_ListOfShape aLS;
-       //
-       const TopTools_ListOfShape& aLSS=aItLLSS.Value();
-       aIt.Initialize(aLSS);
-       for (; aIt.More(); aIt.Next()) {
-         const TopoDS_Shape& aES=aIt.Value();
-         aE=aWSC.Origin(aES);
-         aLS.Append(aE);
-       }
-       //
-       MakeWire(aLS, aW);
-       myNewWES.AddShape (aW);
+        TopTools_ListOfShape aLS;
+        //
+        const TopTools_ListOfShape& aLSS=aItLLSS.Value();
+        aIt.Initialize(aLSS);
+        for (; aIt.More(); aIt.Next()) {
+          const TopoDS_Shape& aES=aIt.Value();
+          aE=aWSC.Origin(aES);
+          aLS.Append(aE);
+        }
+        //
+        MakeWire(aLS, aW);
+        myNewWES.AddShape (aW);
       }
     }//if(bToScale)
     //
@@ -362,32 +357,33 @@ static
       aWS.Perform();
       iErr=aWS.ErrorStatus();
       if (iErr) {
-       continue;
+        continue;
       }
       bIsNothingToDo=aWS.IsNothingToDo();
       if (bIsNothingToDo) {
-       MakeWire(aLE, aW);
-       myNewWES.AddShape (aW);
-       continue;
+        MakeWire(aLE, aW);
+        myNewWES.AddShape (aW);
+        continue;
       }
       //
       const BOPTColStd_ListOfListOfShape& aSSS=aWS.Shapes();
-    
+      //
       BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS);
       for (; aWireIt.More(); aWireIt.Next()) {
-       const TopTools_ListOfShape& aLEx=aWireIt.Value();
-       //
-       MakeWire(aLEx, aW);
-       myNewWES.AddShape (aW);
+        const TopTools_ListOfShape& aLEx=aWireIt.Value();
+        //
+        MakeWire(aLEx, aW);
+        myNewWES.AddShape (aW);
       }
     }// else
   }
 }
+
 //=======================================================================
 // function: MakeWire
-// purpose: 
+// purpose:
 //=======================================================================
-  void MakeWire(const TopTools_ListOfShape& aLE, 
+  void MakeWire(const TopTools_ListOfShape& aLE,
                 TopoDS_Wire& newWire)
 {
   BRep_Builder aBB;
@@ -399,15 +395,13 @@ static
     aBB.Add(newWire, aE);
   }
 }
-//
 
 //=======================================================================
 //function : IsToScale
-//purpose  : 
+//purpose  :
 //=======================================================================
-Standard_Boolean IsToScale(const TopoDS_Face& aF, 
-                          Standard_Real& aScale)
+Standard_Boolean IsToScale(const TopoDS_Face& aF,
+                           Standard_Real& aScale)
 {
   Standard_Boolean bRet;
   Standard_Real aV1, aV2, dV, aTr;
@@ -424,11 +418,12 @@ Standard_Boolean IsToScale(const TopoDS_Face& aF,
     aV1=aBAS.FirstVParameter();
     aV2=aBAS.LastVParameter();
     dV=aV2-aV1;
+    //
     if (dV>aTr) {
       bRet=!bRet;
       aScale=1./aTr;
+      return bRet;
     }
   }
   return bRet;
 }
-