Salome HOME
Fix regression: storeViewParameters() does not work for OCC view
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_Builder_1.cxx
index 5ee7ddaf48a7913238d268e72965cfb304f7bed7..2c9f3d66e46f2dc75e6ff37a11640af2b10efa73 100755 (executable)
@@ -1,26 +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-2010  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:       GEOMAlgo_Builder_1.cxx
-// Created:    
-// Author:     Peter KURNEV 
 
+// File:        GEOMAlgo_Builder_1.cxx
+// Created:     
+// Author:      Peter KURNEV 
+//
 #include <GEOMAlgo_Builder.hxx>
 //
 #include <TColStd_ListOfInteger.hxx>
 
 static
   void FillImagesCompounds(const TopTools_MapOfShape& ,
-                          BRepAlgo_Image& );
+                           BRepAlgo_Image& );
 
 static
   void FillImagesCompound(const TopoDS_Shape& ,
-                       BRepAlgo_Image& ,
-                       TopTools_MapOfShape& );
+                        BRepAlgo_Image& ,
+                        TopTools_MapOfShape& );
 
 //=======================================================================
 //function : FillImagesVertices
@@ -88,12 +91,12 @@ static
     if (aV.ShapeType()==TopAbs_VERTEX) {
       iV=pPF->FindSDVertex(i);
       if (iV) {
-       const TopoDS_Shape& aVSD=aDS.Shape(iV);
-       if (!myImages.HasImage(aV)) {
-         myImages.Bind(aV, aVSD);
-         //
-         mySameDomainShapes.Add(aV, aVSD);
-       }
+        const TopoDS_Shape& aVSD=aDS.Shape(iV);
+        if (!myImages.HasImage(aV)) {
+          myImages.Bind(aV, aVSD);
+          //
+          mySameDomainShapes.Add(aV, aVSD);
+        }
       }
     }
   }
@@ -113,7 +116,7 @@ static
   IntTools_Context& aCtx=pPF->ChangeContext();
   //
   Standard_Boolean bToReverse;
-  Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB;
+  Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB, aNbLB;
   TColStd_ListIteratorOfListOfInteger aItLB;
   TColStd_ListOfInteger aLB;
   TopoDS_Edge aEE, aESpR;
@@ -147,31 +150,32 @@ static
       nSp=aPB.Edge();
       const TopoDS_Shape& aSp=aDS.Shape(nSp);
       //
-      //modified by NIZNHY-PKV Fri Nov 30 10:40:36 2007 f
-      //const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB);
       const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB);
-      //modified by NIZNHY-PKV Fri Nov 30 10:40:48 2007t
+      //modified by NIZNHY-PKV Wed Oct 27 11:19:30 2010f
+      aNbLB=aLB.Extent();
+      if (aIsCB && aNbLB<2) {
+       aIsCB=0;
+      }
+      //modified by NIZNHY-PKV Wed Oct 27 11:19:34 2010t
+      //
       nSpR=aPBR.Edge();
       const TopoDS_Shape& aSpR=aDS.Shape(nSpR);
-      //modified by NIZNHY-PKV Fri Nov 30 10:41:39 2007f
-      //if (aSpR.IsSame(aSp) && aSpR.IsSame(aE)) {
       if (aSpR.IsSame(aSp) && aSpR.IsSame(aE) && !aIsCB) {
-       //modified by NIZNHY-PKV Fri Nov 30 10:41:46 2007t
-       continue;
+        continue;
       }
       //
       aESpR=TopoDS::Edge(aSpR);
       bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx);
       if (bToReverse) {
-       aESpR.Reverse();
+        aESpR.Reverse();
       }
       aLSp.Append(aESpR);
       //
       aItLB.Initialize(aLB);
       for (; aItLB.More(); aItLB.Next()) {
-       nSpx=aItLB.Value();
-       const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
-       mySameDomainShapes.Add(aSpx ,aSpR);
+        nSpx=aItLB.Value();
+        const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
+        mySameDomainShapes.Add(aSpx ,aSpR);
       }
       //
       //
@@ -179,28 +183,24 @@ static
     else {
       aIt.Initialize(aLPB);
       for (; aIt.More(); aIt.Next()) {
-       const BOPTools_PaveBlock& aPB=aIt.Value();
-       //modified by NIZNHY-PKV Fri Nov 30 10:42:15 2007f
-       //const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB);
-       const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB);
-       //modified by NIZNHY-PKV Fri Nov 30 10:42:20 2007t
-       nSpR=aPBR.Edge();
-       const TopoDS_Shape& aSpR=aDS.Shape(nSpR);
-       //
-       aESpR=TopoDS::Edge(aSpR);
-       bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx);
-       if (bToReverse) {
-         aESpR.Reverse();
-       }
-       aLSp.Append(aESpR);
-       //
-       aItLB.Initialize(aLB);
-       for (; aItLB.More(); aItLB.Next()) {
-         nSpx=aItLB.Value();
-         const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
-         mySameDomainShapes.Add(aSpx ,aSpR);
-       }
-       //
+        const BOPTools_PaveBlock& aPB=aIt.Value();
+        const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB);
+        nSpR=aPBR.Edge();
+        const TopoDS_Shape& aSpR=aDS.Shape(nSpR);
+        //
+        aESpR=TopoDS::Edge(aSpR);
+        bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx);
+        if (bToReverse) {
+          aESpR.Reverse();
+        }
+        aLSp.Append(aESpR);
+        //
+        aItLB.Initialize(aLB);
+        for (; aItLB.More(); aItLB.Next()) {
+          nSpx=aItLB.Value();
+          const TopoDS_Shape& aSpx=aDS.Shape(nSpx);
+          mySameDomainShapes.Add(aSpx ,aSpR);
+        }
       }
     }
     //
@@ -252,8 +252,8 @@ static
     for (; aIt.More(); aIt.Next()) {
       const TopoDS_Shape& aF=aIt.Value();
       if (myImages.HasImage(aF)) {
-       bInterferred=!bInterferred;
-       break;
+        bInterferred=!bInterferred;
+        break;
       }
     }
     if (!bInterferred){
@@ -267,20 +267,20 @@ static
     for (; aIt.More(); aIt.Next()) {
       const TopoDS_Shape& aF=aIt.Value();
       if (myImages.HasImage(aF)) {
-       const TopTools_ListOfShape& aLFIm=myImages.Image(aF);
-       aItIm.Initialize(aLFIm);
-       for (; aItIm.More(); aItIm.Next()) {
-         TopoDS_Shape aFIm=aItIm.Value();
-         //
-         bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFIm, aF, aCtx);
-         if (bToReverse) {
-           aFIm.Reverse();
-         }
-         aBB.Add(aCIm, aFIm);
-       }
+        const TopTools_ListOfShape& aLFIm=myImages.Image(aF);
+        aItIm.Initialize(aLFIm);
+        for (; aItIm.More(); aItIm.Next()) {
+          TopoDS_Shape aFIm=aItIm.Value();
+          //
+          bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFIm, aF, aCtx);
+          if (bToReverse) {
+            aFIm.Reverse();
+          }
+          aBB.Add(aCIm, aFIm);
+        }
       }
       else {
-       aBB.Add(aCIm, aF);
+        aBB.Add(aCIm, aF);
       }
     }
     myImages.Bind(aC, aCIm); 
@@ -291,7 +291,7 @@ static
 // purpose: 
 //=======================================================================
 void FillImagesCompounds(const TopTools_MapOfShape& theMS,
-                        BRepAlgo_Image& theImages)
+                         BRepAlgo_Image& theImages)
 {
   TopTools_MapOfShape aMFP;
   TopTools_MapIteratorOfMapOfShape aItS;
@@ -307,8 +307,8 @@ void FillImagesCompounds(const TopTools_MapOfShape& theMS,
 //purpose  : 
 //=======================================================================
 void FillImagesCompound(const TopoDS_Shape& theS,
-                       BRepAlgo_Image& theImages,
-                       TopTools_MapOfShape& theMFP)
+                        BRepAlgo_Image& theImages,
+                        TopTools_MapOfShape& theMFP)
 { 
   Standard_Boolean bInterferred;
   TopAbs_ShapeEnum aTypeX;
@@ -348,9 +348,9 @@ void FillImagesCompound(const TopoDS_Shape& theS,
       const TopTools_ListOfShape& aLFIm=theImages.Image(aSX);
       aItIm.Initialize(aLFIm);
       for (; aItIm.More(); aItIm.Next()) {
-       TopoDS_Shape aSXIm=aItIm.Value();
-       aSXIm.Orientation(aOrX);
-       aBB.Add(aCIm, aSXIm);
+        TopoDS_Shape aSXIm=aItIm.Value();
+        aSXIm.Orientation(aOrX);
+        aBB.Add(aCIm, aSXIm);
       }
     }
     else {