- } 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);