Salome HOME
Update copyright information
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_Tools.cxx
index 97bdbb03e2fe601daf62e86019ec14642b517b21..bad8a3c150eadb738057b169b476a66ee853bb45 100644 (file)
@@ -1,8 +1,29 @@
+//  Copyright (C) 2007-2008  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
+//
+//  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_Tools.cxx
 // Created:    Mon Dec  6 11:35:29 2004
 // Author:     Peter KURNEV
 //             <pkv@irinox>
-
+//
 #include <GEOMAlgo_Tools.ixx>
 
 #include <gp_Pnt.hxx>
@@ -20,6 +41,7 @@
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
 
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <BOPTools_Tools2D.hxx>
 #include <IntTools_Context.hxx>
 
-#include <GEOMAlgo_PassKey.hxx>
-#include <GEOMAlgo_IndexedDataMapOfPassKeyListOfShape.hxx>
-//
+#include <GEOMAlgo_PassKeyShape.hxx>//qft
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>//qft
+
+static 
+  void GetCount(const TopoDS_Shape& aS,
+               Standard_Integer& iCnt);
+
+//=======================================================================
+//function : IsCompositeShape
+//purpose  : 
+//=======================================================================
+Standard_Boolean GEOMAlgo_Tools::IsCompositeShape(const TopoDS_Shape& aS)
+{
+  Standard_Boolean bRet;
+  Standard_Integer iCnt;
+  TopoDS_Iterator aIt;
+  //
+  iCnt=0;
+  GetCount(aS, iCnt);
+  bRet=(iCnt>1);
+  //
+  return bRet;
+}
+
+//=======================================================================
+//function : GetCount
+//purpose  : 
+//=======================================================================
+void GetCount(const TopoDS_Shape& aS,
+             Standard_Integer& iCnt)
+{
+  TopoDS_Iterator aIt;
+  TopAbs_ShapeEnum aTS;
+  //
+  aTS=aS.ShapeType();
+  //
+  if (aTS==TopAbs_SHAPE) {
+    return;
+  }
+  if (aTS!=TopAbs_COMPOUND) {
+    ++iCnt;
+    return;
+  }
+  //
+  aIt.Initialize(aS);
+  for (; aIt.More(); aIt.Next()) {
+    const TopoDS_Shape& aSx=aIt.Value();
+    GetCount(aSx, iCnt); 
+  }
+}
+
 //=======================================================================
 //function : RefineSDShapes
 //purpose  : 
 //=======================================================================
-Standard_Integer GEOMAlgo_Tools::RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyListOfShape &aMPKLE,
-                                               const Standard_Real aTol,
-                                               IntTools_Context& aCtx)
+  Standard_Integer GEOMAlgo_Tools::RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE,
+                                                 const Standard_Real aTol,
+                                                 IntTools_Context& aCtx)
 {
   Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd;
   TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd;
@@ -83,12 +153,15 @@ Standard_Integer GEOMAlgo_Tools::RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKey
   }
   //
   for (i=1; i<=aNbToAdd; ++i) {
-    GEOMAlgo_PassKey aPKE1;
+    GEOMAlgo_PassKeyShape aPKE1;
     //
     const TopoDS_Shape& aE1=aMEToAdd.FindKey(i);
     const TopTools_ListOfShape& aLE=aMEToAdd(i);
     //
-    aPKE1.SetIds(aE1);
+    //qf
+    //aPKE1.SetIds(aE1);
+    aPKE1.SetShapes(aE1);
+    //qt
     aMPKLE.Add(aPKE1, aLE);
   }
   //