Salome HOME
Fix for the bug IPAL22851: Sub-shapes spelling
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_Gluer.cxx
index a147c90b0f82a11080a583740d067cb136cb0681..a35a31d112c2a0e8aa87fd53c97f34201efa6b58 100755 (executable)
@@ -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:       GEOMAlgo_Gluer.cxx
 // Created:    Sat Dec 04 12:45:53 2004
 // Author:     Peter KURNEV
 #include <GEOMAlgo_PassKeyShape.hxx>
 #include <GEOMAlgo_Tools.hxx>
 //
-
+//modified by NIZNHY-PKV Thu Jan 21 10:02:52 2010f
+#include <NMTDS_BndSphereTree.hxx>
+#include <NMTDS_BndSphere.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBndSphere.hxx>
+//modified by NIZNHY-PKV Thu Jan 21 10:02:56 2010t
+//
 static 
   void GetSubShapes(const TopoDS_Shape& aS,
                    TopTools_IndexedMapOfShape& aMSS);
@@ -138,6 +144,14 @@ void GEOMAlgo_Gluer::SetKeepNonSolids(const Standard_Boolean aFlag)
   myKeepNonSolids=aFlag;
 }
 //=======================================================================
+//function : KeepNonSolids
+//purpose  : 
+//=======================================================================
+//Standard_Boolean GEOMAlgo_Gluer::KeepNonSolids()const 
+//{
+//  return myKeepNonSolids;
+//}
+//=======================================================================
 //function : AloneShapes
 //purpose  : 
 //=======================================================================
@@ -186,6 +200,7 @@ void GEOMAlgo_Gluer::Perform()
     }
   }
 }
+
 //=======================================================================
 //function : MakeVertices
 //purpose  : 
@@ -195,6 +210,8 @@ void GEOMAlgo_Gluer::MakeVertices()
   myErrorStatus=0;
   //
   Standard_Integer j, i, aNbV, aNbVSD;
+  Standard_Real aTolV;
+  gp_Pnt aPV;
   TColStd_ListIteratorOfListOfInteger aIt;
   TopoDS_Shape aVF;
   TopoDS_Vertex aVnew;
@@ -203,12 +220,14 @@ void GEOMAlgo_Gluer::MakeVertices()
   TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
   TopTools_DataMapOfShapeListOfShape aMVV;
   GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
-  GEOMAlgo_IndexedDataMapOfShapeBox aMSB;
-  //
-  NMTDS_BoxBndTreeSelector aSelector;
-  NMTDS_BoxBndTree aBBTree;
-  NCollection_UBTreeFiller <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
+  //modified by NIZNHY-PKV Thu Jan 21 10:03:07 2010f
+  //GEOMAlgo_IndexedDataMapOfShapeBox aMSB;
+  NMTDS_IndexedDataMapOfShapeBndSphere aMSB;
+  //modified by NIZNHY-PKV Thu Jan 21 10:03:10 2010t
   //
+  NMTDS_BndSphereTreeSelector aSelector;
+  NMTDS_BndSphereTree aBBTree;
+  NCollection_UBTreeFiller <Standard_Integer, NMTDS_BndSphere> aTreeFiller(aBBTree);
   //
   TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV);
   aNbV=aMV.Extent();
@@ -218,11 +237,15 @@ void GEOMAlgo_Gluer::MakeVertices()
   }
   //
   for (i=1; i<=aNbV; ++i) {
-    const TopoDS_Shape& aV=aMV(i);
-    Bnd_Box aBox;
+    NMTDS_BndSphere aBox;
+    //
+    const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i));
+    aPV=BRep_Tool::Pnt(aV);
+    aTolV=BRep_Tool::Tolerance(aV);
     //
-    aBox.SetGap(myTol); 
-    BRepBndLib::Add(aV, aBox);
+    aBox.SetGap(myTol);
+    aBox.SetCenter(aPV);
+    aBox.SetRadius(aTolV);
     //
     aTreeFiller.Add(i, aBox);
     //
@@ -235,7 +258,7 @@ void GEOMAlgo_Gluer::MakeVertices()
   //------------------------------
   // Chains
   for (i=1; i<=aNbV; ++i) {
-    const TopoDS_Shape& aV=aMV(i);
+    const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i));
     //
     if (aMVProcessed.Contains(aV)) {
       continue;
@@ -257,7 +280,10 @@ void GEOMAlgo_Gluer::MakeVertices()
        }
        //
        const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
-       const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
+       //modified by NIZNHY-PKV Thu Jan 21 10:04:09 2010f
+       const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP);
+       //const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP);
+       //modified by NIZNHY-PKV Thu Jan 21 10:04:11 2010t
        //
        aSelector.Clear();
        aSelector.SetBox(aBoxVP);
@@ -268,6 +294,7 @@ void GEOMAlgo_Gluer::MakeVertices()
        }
        //
        const TColStd_ListOfInteger& aLI=aSelector.Indices();
+       //
        aIt.Initialize(aLI);
        for (; aIt.More(); aIt.Next()) {
          aIP1=aIt.Value();
@@ -326,7 +353,7 @@ void GEOMAlgo_Gluer::MakeVertices()
   aMV.Clear();
   aItIm.Initialize(myImages);
   for (; aItIm.More(); aItIm.Next()) {
-    const TopoDS_Shape& aV=aItIm.Key();
+    const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aItIm.Key());
     const TopTools_ListOfShape& aLVSD=aItIm.Value();
     aNbVSD=aLVSD.Extent();
     if (aNbVSD>1) {
@@ -381,16 +408,13 @@ void GEOMAlgo_Gluer::MakeSubShapes (const TopoDS_Shape&  theShape,
   theMS.Add(theShape);
   //
   if (theShape.ShapeType() == TopAbs_COMPOUND ||
-      theShape.ShapeType() == TopAbs_COMPSOLID)
-  {
+      theShape.ShapeType() == TopAbs_COMPSOLID)  {
     TopoDS_Iterator It (theShape, Standard_True, Standard_True);
-    for (; It.More(); It.Next())
-    {
+    for (; It.More(); It.Next())    {
       MakeSubShapes(It.Value(), theMS, theResult);
     }
   }
-  else if (theShape.ShapeType() == TopAbs_SOLID)
-  {
+  else if (theShape.ShapeType() == TopAbs_SOLID)  {
     // build a solid
     TopoDS_Solid aNewSolid;
     TopExp_Explorer aExpS, aExp;
@@ -418,13 +442,10 @@ void GEOMAlgo_Gluer::MakeSubShapes (const TopoDS_Shape&  theShape,
     //
     aBB.Add(theResult, aNewSolid);
   }
-  else if (theShape.ShapeType() == TopAbs_WIRE)
-  {
-    if (myKeepNonSolids)
-    {
+  else if (theShape.ShapeType() == TopAbs_WIRE)  {
+    if (myKeepNonSolids)    {
       // just add image
-      if (!myOrigins.IsBound(theShape))
-      {
+      if (!myOrigins.IsBound(theShape))   {
         // build wire
         const TopoDS_Wire& aW=TopoDS::Wire(theShape);
         //
@@ -469,8 +490,7 @@ void GEOMAlgo_Gluer::MakeSubShapes (const TopoDS_Shape&  theShape,
   }
   else
   {
-    if (myKeepNonSolids)
-    {
+    if (myKeepNonSolids)    {
       // just add image
       const TopoDS_Shape& aShapeR = myOrigins.Find(theShape);
       aBB.Add(theResult, aShapeR);
@@ -634,7 +654,7 @@ void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType)
     //
     bHasNewSubShape=Standard_True;
     // prevent creation of a new shape if there are not
-    // new subshapes of aSS among the originals
+    // new sub-shapes of aSS among the originals
     if (aNbSDF==1) {
       bHasNewSubShape=HasNewSubShape(aS1);
       if (!bHasNewSubShape) {
@@ -1134,6 +1154,7 @@ Standard_Boolean GEOMAlgo_Gluer::IsDeleted (const TopoDS_Shape& aS)
   //
   return bRet;
 }
+
 //
 // ErrorStatus
 //