+ TopTools_SequenceOfShape aShapeFaces;
+ HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces );
+ if ( aShapeFaces.Length() == 1 ) //it should be either face or compound of faces (?)
+ {
+ const TopoDS_Face& CF = TopoDS::Face( aShapeFaces.Value( 1 ));
+ aResShape = CF;
+ }
+ else
+ {
+ TopTools_SequenceOfShape aShapeShells;
+ HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_SHELL, aShapeShells );
+ if (aShapeShells.Length() == 1)
+ aResShape = TopoDS::Shell(aShapeShells(1));
+ else
+ aResShape = anUnitedShape;
+ }
+
+ // Update the sequence of groups
+ if ( theSeqOfGroups )
+ {
+ HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator aUsedIter( aSeqOfUsedGroups );
+ for ( ; aUsedIter.More(); aUsedIter.Next() )
+ {
+ const HYDROData_ShapesGroup::GroupDefinition& aUsedGroupDef = aUsedIter.Value();
+ if ( aUsedGroupDef.Shapes.IsEmpty() )
+ continue;