Salome HOME
test integration for 0019050: EDF 521 GEOM SMESH : Improve selection process in the...
[modules/geom.git] / src / NMTDS / NMTDS_ShapesDataStructure.cxx
index 229f3c5436ced0ecc40af286bcaae831f44b7018..a9a0e7370c65e3b5b0201ec41e137b1cab3cd2b6 100644 (file)
 #include <BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx>
 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
 #include <TColStd_MapOfInteger.hxx>
+#include <NMTDS_Tools.hxx>
+
+
+static
+  void ComputeBoxExS(const Standard_Integer aIx,
+                    const NMTDS_ShapesDataStructure* pDS,
+                    Bnd_Box& aBoxEx);
+static
+  void GetAllSuccessorsS(const Standard_Integer nS,
+                        const NMTDS_ShapesDataStructure* myDS,
+                        TColStd_IndexedMapOfInteger& aMA);
 
 //===========================================================================
 //function : NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure
   NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors aLx;
   NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors aLit;
   TopoDS_Iterator anIt;
-  // Modified  Thu Sep 14 14:35:18 2006 
-  // Contribution of Samtech www.samcef.com BEGIN
   BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMSA;
-  // Contribution of Samtech www.samcef.com END
   //
   anIt.Initialize(myCompositeShape);
-  for (i=0; anIt.More(); anIt.Next(), ++i) {
-    // Modified  Thu Sep 14 14:35:18 2006 
-    // Contribution of Samtech www.samcef.com BEGIN
+  for (; anIt.More(); anIt.Next()) {
     const TopoDS_Shape& aSx=anIt.Value(); 
     BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMS;
-    FillMap(aSx, aMSA, aMS);
-    aLx.Append(aMS);
-    // Contribution of Samtech www.samcef.com END
+    //modified by NIZNHY-PKV Tue Feb 27 17:05:47 2007f
+    //FillMap(aSx, aMSA, aMS);
+    //aLx.Append(aMS);
+    //
+    if (!aMSA.Contains(aSx)) {
+      FillMap(aSx, aMSA, aMS);
+      aLx.Append(aMS);
+    }
+    //modified by NIZNHY-PKV Tue Feb 27 17:06:03 2007t
   }
-  // Modified  Thu Sep 14 14:35:18 2006 
-  // Contribution of Samtech www.samcef.com BEGIN
   aNbS=aMSA.Extent(); 
-  // Contribution of Samtech www.samcef.com END
   //
   // Fill myRanges
+  //modified by NIZNHY-PKV Tue Feb 27 17:10:07 2007f
+  i=aLx.Extent();
+  //modified by NIZNHY-PKV Tue Feb 27 17:10:10 2007t
   myRanges.Resize(i);
   aLit.Initialize(aLx);
   for (i=1; aLit.More(); aLit.Next(), ++i) {
   // Contribution of Samtech www.samcef.com BEGIN
   //
   // Fill the table
-  //modified by NIZNHY-PKV Tue May 16 11:47:28 2006f
-  
+    
   //aShift=0;
   //for (i=0; i<2; ++i) {
   //  if (i) {
   // Contribution of Samtech www.samcef.com END
   return aIndex;
 }
+
+//=======================================================================
+//function : ComputeBoxEx
+//purpose  : 
+//=======================================================================
+  void NMTDS_ShapesDataStructure::ComputeBoxEx (const Standard_Integer aIx,
+                                               Bnd_Box& aBoxEx)const
+{
+  ComputeBoxExS(aIx, this, aBoxEx);
+}
+//=======================================================================
+//function : GetAllSuccessors
+//purpose  : 
+//=======================================================================
+  void NMTDS_ShapesDataStructure::GetAllSuccessors(const Standard_Integer nS,
+                                                  TColStd_IndexedMapOfInteger& aMA)const
+{
+  GetAllSuccessorsS(nS, this, aMA);
+}
+//=======================================================================
+//function : GetAllSuccessorsS
+//purpose  : 
+//=======================================================================
+void GetAllSuccessorsS(const Standard_Integer nS,
+                      const NMTDS_ShapesDataStructure* myDS,
+                      TColStd_IndexedMapOfInteger& aMA)
+{
+  TopAbs_ShapeEnum aT;
+  Standard_Integer i, nSx, aNbSuccessors, *pSuccessors;
+  Standard_Address xSuccessors;
+  //
+  const TopoDS_Shape& aS=myDS->Shape(nS);
+  aT=aS.ShapeType();
+  if(NMTDS_Tools::HasBRep(aT)) {
+    aMA.Add(nS);
+    //
+    if (aT==TopAbs_VERTEX) {
+      return;
+    }
+  }
+  //
+  myDS->GetSuccessors(nS, xSuccessors, aNbSuccessors);
+  pSuccessors=(Standard_Integer*)xSuccessors;
+  for (i=0; i<aNbSuccessors; ++i) {
+    nSx=pSuccessors[i];
+    GetAllSuccessorsS(nSx, myDS, aMA);
+  }
+}
+//=======================================================================
+// function: ComputeBoxExS
+// purpose: 
+//=======================================================================
+  void ComputeBoxExS(const Standard_Integer aIx,
+                    const NMTDS_ShapesDataStructure* pDS,
+                    Bnd_Box& aBoxEx)
+{
+  Standard_Integer i, aNbS, iS;
+  //
+  const Bnd_Box& aBox=pDS->GetBoundingBox(aIx);
+  aBoxEx.Add(aBox);
+  //
+  aNbS=pDS->NumberOfSuccessors(aIx);
+  for (i=1; i<=aNbS; ++i) {
+    Bnd_Box aBoxS;
+    iS=pDS->GetSuccessor(aIx, i);
+    ComputeBoxExS(iS, pDS, aBoxS);
+    aBoxEx.Add(aBoxS);
+  }
+}