Salome HOME
PAL12867: EDF214 GEOM DifferenceList does not remove the elements of the list. Algori...
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IGroupOperations.cxx
index c74ded4a8678315decd7a8bb57932269d1505c8b..3bc83464cbabe16013a88eeda44d21f794429617 100644 (file)
@@ -15,7 +15,7 @@
 // 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/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 #include <Standard_Stream.hxx>
 
@@ -38,6 +38,7 @@
 #include <TDataStd_Integer.hxx>
 
 #include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopTools_IndexedMapOfShape.hxx>
 
 #include <TColStd_HArray1OfInteger.hxx>
@@ -75,7 +76,7 @@ GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
-       (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum  theShapeType)
+       (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
 {
   SetErrorCode(KO);
 
@@ -94,14 +95,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
 
   //Make a Python command
   Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
-  //TCollection_AsciiString anOldDescr = aFunction->GetDescription();
 
-  //GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t" << aGroup
   GEOM::TPythonDump(aFunction) << aGroup
-    << " = geompy.CreateGroup(" << theMainShape << ", " << (int)theShapeType << ")";
+    << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
 
   SetErrorCode(OK);
-  return aGroup; 
+  return aGroup;
 }
 
 //=============================================================================
@@ -117,7 +116,25 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if(aFunction.IsNull()) return;
 
-  GEOM_ISubShape aSSI(aFunction);
+  GEOM_ISubShape aSSI (aFunction);
+
+  // Check sub-shape index validity
+  TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
+  if (aLabel.IsRoot()) return;
+  Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
+  if (anObj.IsNull()) return;
+  TopoDS_Shape aMainShape = anObj->GetValue();
+  if (aMainShape.IsNull()) return;
+
+  TopTools_IndexedMapOfShape aMapOfShapes;
+  TopExp::MapShapes(aMainShape, aMapOfShapes);
+
+  if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) {
+    SetErrorCode("Invalid sub-shape index: out of range");
+    return;
+  }
+
+  // Add sub-shape index
   Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
   if(aSeq.IsNull()) return;
   if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
@@ -137,14 +154,12 @@ void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theS
     aSSI.SetIndices(aNewSeq);
   }
 
-  //Make a Python command 
-  TCollection_AsciiString anOldDescr = aFunction->GetDescription();
-
-  GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
+  //Make a Python command
+  GEOM::TPythonDump(aFunction, /*append=*/true)
     << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
 
   SetErrorCode(OK);
-  return; 
+  return;
 }
 
 //=============================================================================
@@ -204,9 +219,7 @@ void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int
   }
 
   //Make a Python command 
-  TCollection_AsciiString anOldDescr = aFunction->GetDescription();
-
-  GEOM::TPythonDump(aFunction) << anOldDescr.ToCString() << "\n\t"
+  GEOM::TPythonDump(aFunction, /*append=*/true)
     << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
 
   SetErrorCode(OK);
@@ -224,6 +237,12 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
   SetErrorCode(KO);
   if (theGroup.IsNull()) return;
 
+  Standard_Integer aLen = theSubShapes->Length();
+  if (aLen < 1) {
+    SetErrorCode("The list is empty");
+    return;
+  }
+
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if (aFunction.IsNull()) return;
 
@@ -258,80 +277,68 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
   TopTools_IndexedMapOfShape mapIndices;
   TopExp::MapShapes(aMainShape, mapIndices);
 
+  // Get group type
+  TopAbs_ShapeEnum aType = GetType(theGroup);
+
   // Get IDs of sub-shapes to add
-  Standard_Integer i, new_id, aLen = theSubShapes->Length();
+  Standard_Integer i, new_id;
   for (i = 1; i <= aLen; i++) {
     Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
 
+    TopoDS_Shape aShape_i = anObj_i->GetValue();
+    TopAbs_ShapeEnum aType_i = aShape_i.ShapeType();
+
+    // 1. If aShape_i is sub-shape of aMainShape - add it
     if (anObj_i->IsMainShape()) {
-      TopoDS_Shape aShape_i = anObj_i->GetValue();
-      if (mapIndices.Contains(aShape_i)) {
-        new_id = mapIndices.FindIndex(aShape_i);
-        if (mapIDs.Add(new_id)) {
-          aNewIDs.Append(new_id);
-        }
-      } else {
-        SetErrorCode("One of given objects can not be added to the group, because it is not a sub-shape of the group's main shape");
+      if (aType_i != aType && aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
+        SetErrorCode("Operation aborted: one of given objects has a wrong type");
         return;
       }
-    } else {
-      // Check main shape of sub-shape to add
-      Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
-      if (aFunc_i.IsNull()) return;
-
-      GEOM_ISubShape aSSI_i (aFunc_i);
-
-      Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
-      if (aMainShapeFunc_i.IsNull()) return;
-      TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
-      if (aLabel_i.IsRoot()) return;
-      Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
-      if (aMainObj_i.IsNull()) return;
-      TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
-      if (aMainShape_i.IsNull()) return;
-
-      if (aMainShape_i.IsSame(aMainShape)) {
-        // add all sub-shape IDs to the list
-
-        // Get IDs
-        Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
-        if (aSeq_i.IsNull()) return;
-        Standard_Integer aLength_i = aSeq_i->Length();
-
-        for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
-          new_id = aSeq_i->Value(i_j);
-          if (new_id > 0) {
-            if (mapIDs.Add(new_id)) {
-              aNewIDs.Append(new_id);
-            }
-          }
-        }
-
-      } else if (mapIndices.Contains(aMainShape_i)) {
-        // compute new IDs and add them to the list
-        TopTools_IndexedMapOfShape mapIndices_i;
-        TopExp::MapShapes(aMainShape_i, mapIndices_i);
-
-        // Get IDs
-        Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
-        if (aSeq_i.IsNull()) return;
-        Standard_Integer aLength_i = aSeq_i->Length();
-
-        for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
-          if (aSeq_i->Value(i_j) > 0) {
-            TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
-            new_id = mapIndices.FindIndex(aShape_i_j);
-            if (mapIDs.Add(new_id)) {
-              aNewIDs.Append(new_id);
-            }
+      if (!mapIndices.Contains(aShape_i)) {
+        SetErrorCode("Operation aborted: not a sub-shape given");
+        return;
+      }
+      new_id = mapIndices.FindIndex(aShape_i);
+      if (mapIDs.Add(new_id)) {
+        aNewIDs.Append(new_id);
+      }
+    }
+    // 2. If type of group is not defined - add all sub-shapes of aShape_i
+    else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
+      TopTools_IndexedMapOfShape mapIndices_i;
+      TopExp::MapShapes(aShape_i, mapIndices_i);
+      Standard_Integer ii = 1, nbSubSh = mapIndices_i.Extent();
+      Standard_Boolean someGood = Standard_False;
+      for (; ii <= nbSubSh; ii++) {
+        TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
+        if (mapIndices.Contains(aSubShape_i)) {
+          someGood = Standard_True;
+          new_id = mapIndices.FindIndex(aSubShape_i);
+          if (mapIDs.Add(new_id)) {
+            aNewIDs.Append(new_id);
           }
         }
-
-      } else {
-        SetErrorCode("One of given objects can not be added to the group, because it is not a sub-shape of the group's main shape");
+      }
+      if (!someGood) {
+        SetErrorCode("Operation aborted: not a sub-shape given");
         return;
       }
     }
+    // 3. If type of group is defined - add all sub-shapes of aShape_i of that type
+    else {
+      TopExp_Explorer aSubShapes_i (aShape_i, aType);
+      for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
+        TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
+        if (!mapIndices.Contains(aSubShape_i)) {
+          SetErrorCode("Operation aborted: not a sub-shape given");
+          return;
+        }
+        new_id = mapIndices.FindIndex(aSubShape_i);
+        if (mapIDs.Add(new_id)) {
+          aNewIDs.Append(new_id);
+        }
+      }
+    }
   }
 
   if (aNewIDs.Extent() > 0) {
@@ -345,11 +352,13 @@ void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
     aSSI.SetIndices(aNewSeq);
   }
 
-  //Make a Python command 
-  TCollection_AsciiString anOldDescr = aFunction->GetDescription();
+  //Make a Python command
+  Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
+  aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
+  Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
 
-  GEOM::TPythonDump pd (aFunction);
-  pd << anOldDescr.ToCString() << "\n\t" << "geompy.UnionList(" << theGroup << ", [";
+  GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
+  pd << "geompy.UnionList(" << theGroup << ", [";
 
   for (i = 1; i <= aLen; i++) {
     Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@@ -370,6 +379,12 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
   SetErrorCode(KO);
   if (theGroup.IsNull()) return;
 
+  Standard_Integer aLen = theSubShapes->Length();
+  if (aLen < 1) {
+    SetErrorCode("The list is empty");
+    return;
+  }
+
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if (aFunction.IsNull()) return;
 
@@ -405,78 +420,50 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
   TopTools_IndexedMapOfShape mapIndices;
   TopExp::MapShapes(aMainShape, mapIndices);
 
+  // Get group type
+  TopAbs_ShapeEnum aType = GetType(theGroup);
+
   // Get IDs of sub-shapes to be removed
-  Standard_Integer i, rem_id, aLen = theSubShapes->Length();
+  Standard_Integer i, rem_id;
   for (i = 1; i <= aLen; i++) {
     Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
 
-    if (anObj_i->IsMainShape()) {
-      TopoDS_Shape aShape_i = anObj_i->GetValue();
-      if (mapIndices.Contains(aShape_i)) {
-        rem_id = mapIndices.FindIndex(aShape_i);
-        if (mapIDsCurrent.Contains(rem_id)) {
-          mapIDsToRemove.Add(rem_id);
-        }
-      } else {
-        SetErrorCode("One of given objects can not be removed from the group, because it is not a sub-shape of the group's main shape");
-        return;
+    TopoDS_Shape aShape_i = anObj_i->GetValue();
+
+    // 1. If aShape_i is sub-shape of aMainShape - remove it
+    if (mapIndices.Contains(aShape_i)) {
+      rem_id = mapIndices.FindIndex(aShape_i);
+      if (mapIDsCurrent.Contains(rem_id)) {
+        mapIDsToRemove.Add(rem_id);
       }
-    } else {
-      // Check main shape of sub-shape to be removed
-      Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
-      if (aFunc_i.IsNull()) return;
-
-      GEOM_ISubShape aSSI_i (aFunc_i);
-
-      Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
-      if (aMainShapeFunc_i.IsNull()) return;
-      TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
-      if (aLabel_i.IsRoot()) return;
-      Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
-      if (aMainObj_i.IsNull()) return;
-      TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
-      if (aMainShape_i.IsNull()) return;
-
-      if (aMainShape_i.IsSame(aMainShape)) {
-        // remove all sub-shapes
-
-        // Get IDs
-        Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
-        if (aSeq_i.IsNull()) return;
-        Standard_Integer aLength_i = aSeq_i->Length();
-
-        for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
-          rem_id = aSeq_i->Value(i_j);
-          if (rem_id > 0) {
-            if (mapIDsCurrent.Contains(rem_id)) {
-              mapIDsToRemove.Add(rem_id);
-            }
+    }
+    // 2. If type of group is not defined - remove all sub-shapes of aShape_i
+    else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
+      TopTools_IndexedMapOfShape mapIndices_i;
+      TopExp::MapShapes(aShape_i, mapIndices_i);
+      Standard_Integer nbSubSh = mapIndices_i.Extent();
+      Standard_Integer ii = 1;
+      for (; ii <= nbSubSh; ii++) {
+        TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
+        if (mapIndices.Contains(aSubShape_i)) {
+          rem_id = mapIndices.FindIndex(aSubShape_i);
+          if (mapIDsCurrent.Contains(rem_id)) {
+            mapIDsToRemove.Add(rem_id);
           }
         }
-
-      } else if (mapIndices.Contains(aMainShape_i)) {
-        // compute new IDs and add them to the map of ids to be removed
-        TopTools_IndexedMapOfShape mapIndices_i;
-        TopExp::MapShapes(aMainShape_i, mapIndices_i);
-
-        // Get IDs
-        Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
-        if (aSeq_i.IsNull()) return;
-        Standard_Integer aLength_i = aSeq_i->Length();
-
-        for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
-          if (aSeq_i->Value(i_j) > 0) {
-            TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
-            rem_id = mapIndices.FindIndex(aShape_i_j);
-            if (mapIDsCurrent.Contains(rem_id)) {
-              mapIDsToRemove.Add(rem_id);
-            }
+      }
+    }
+    // 3. If type of group is defined - remove all sub-shapes of aShape_i of that type
+    else {
+      TopExp_Explorer aSubShapes_i (aShape_i, aType);
+      for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
+        TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
+        if (mapIndices.Contains(aSubShape_i)) {
+          rem_id = mapIndices.FindIndex(aSubShape_i);
+          if (mapIDsCurrent.Contains(rem_id)) {
+            mapIDsToRemove.Add(rem_id);
           }
         }
-
-      } else {
-        SetErrorCode("One of given objects can not be removed from the group, because it is not a sub-shape of the group's main shape");
-        return;
       }
     }
   }
@@ -496,10 +483,12 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
   }
 
   //Make a Python command
-  TCollection_AsciiString anOldDescr = aFunction->GetDescription();
+  Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
+  aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
+  Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
 
-  GEOM::TPythonDump pd (aFunction);
-  pd << anOldDescr.ToCString() << "\n\t" << "geompy.DifferenceList(" << theGroup << ", [";
+  GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
+  pd << "geompy.DifferenceList(" << theGroup << ", [";
 
   for (i = 1; i <= aLen; i++) {
     Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
@@ -508,6 +497,7 @@ void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
 
   SetErrorCode(OK);
 }
+
 //=============================================================================
 /*!
  *  UnionIDs
@@ -519,6 +509,12 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
   SetErrorCode(KO);
   if (theGroup.IsNull()) return;
 
+  Standard_Integer aLen = theSubShapes->Length();
+  if (aLen < 1) {
+    SetErrorCode("The list is empty");
+    return;
+  }
+
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if (aFunction.IsNull()) return;
 
@@ -554,7 +550,7 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
   TopExp::MapShapes(aMainShape, mapIndices);
 
   // Get IDs of sub-shapes to add
-  Standard_Integer i, new_id, aLen = theSubShapes->Length();
+  Standard_Integer i, new_id;
   for (i = 1; i <= aLen; i++) {
     new_id = theSubShapes->Value(i);
 
@@ -576,6 +572,13 @@ void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
     aSSI.SetIndices(aNewSeq);
   }
 
+  //Make a Python command
+  GEOM::TPythonDump pd (aFunction, /*append=*/true);
+  pd << "geompy.UnionIDs(" << theGroup << ", [";
+  for (i = 1; i < aLen; i++)
+    pd << theSubShapes->Value(i) << ", ";
+  pd << theSubShapes->Value(aLen) << "])";
+
   SetErrorCode(OK);
 }
 
@@ -590,6 +593,12 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
   SetErrorCode(KO);
   if (theGroup.IsNull()) return;
 
+  Standard_Integer aLen = theSubShapes->Length();
+  if (aLen < 1) {
+    SetErrorCode("The list is empty");
+    return;
+  }
+
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if (aFunction.IsNull()) return;
 
@@ -626,7 +635,7 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
   TopExp::MapShapes(aMainShape, mapIndices);
 
   // Get IDs of sub-shapes to be removed
-  Standard_Integer i, rem_id, aLen = theSubShapes->Length();
+  Standard_Integer i, rem_id;
   for (i = 1; i <= aLen; i++) {
     rem_id = theSubShapes->Value(i);
     if (mapIDsCurrent.Contains(rem_id)) {
@@ -648,6 +657,13 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
     aSSI.SetIndices(aNewSeq);
   }
 
+  //Make a Python command
+  GEOM::TPythonDump pd (aFunction, /*append=*/true);
+  pd << "geompy.DifferenceIDs(" << theGroup << ", [";
+  for (i = 1; i < aLen; i++)
+    pd << theSubShapes->Value(i) << ", ";
+  pd << theSubShapes->Value(aLen) << "])";
+
   SetErrorCode(OK);
 }
 
@@ -663,7 +679,7 @@ TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup
   TDF_Label aFreeLabel = theGroup->GetFreeLabel();
   Handle(TDataStd_Integer) anAttrib;
   if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE;
+
   SetErrorCode(OK);
   return (TopAbs_ShapeEnum) anAttrib->Get(); 
 }
@@ -691,9 +707,7 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object)
   if (aMainShape.IsNull()) return NULL;
 
   //Make a Python command
-  TCollection_AsciiString anOldDescr = aGroupFunction->GetDescription();
-
-  GEOM::TPythonDump(aGroupFunction) << anOldDescr.ToCString() << "\n\t"
+  GEOM::TPythonDump(aGroupFunction, /*append=*/true)
     << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
 
   SetErrorCode(OK);
@@ -708,12 +722,12 @@ Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object)
 Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
 {
   SetErrorCode(KO);
-  
-   if(theGroup.IsNull()) return NULL;
+
+  if(theGroup.IsNull()) return NULL;
 
   Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
   if(aFunction.IsNull()) return NULL;
-  
+
   GEOM_ISubShape aSSI(aFunction);
   Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
   if(aSeq.IsNull()) return NULL;