const TopoDS_Shape &aShapeResult = aGIP.Result();
TopTools_MapOfShape aMFence;
TopTools_IndexedMapOfShape aWhereIndices;
+ Standard_Integer aShapeType = -1;
TopExp::MapShapes(aWhere, aWhereIndices);
if (aShapeResult.IsNull() == Standard_False) {
- TopoDS_Iterator anIt(aShapeResult);
+ TopoDS_Iterator anIt(aShapeResult);
+ Standard_Boolean isFirst = Standard_True;
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape &aPart = anIt.Value();
if(aWhereIndices.Contains(aPart) && aMFence.Add(aPart)) {
+ const TopAbs_ShapeEnum aType = aPart.ShapeType();
+
+ if (aShapeType == -1) {
+ // Initialization.
+ aShapeType = aType;
+ } else if (aShapeType != TopAbs_SHAPE && aShapeType != aType) {
+ // Different types.
+ aShapeType = TopAbs_SHAPE;
+ }
+
aLSA.Append(aPart);
}
}
Handle(TColStd_HArray1OfInteger) aModifiedArray = new TColStd_HArray1OfInteger (1, aLSA.Extent());
TopTools_ListIteratorOfListOfShape anIterModif (aLSA);
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
- if (aWhereIndices.Contains(anIterModif.Value())) {
- aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
- }
- else {
- SetErrorCode("Error: wrong sub-shape returned");
- return NULL;
- }
+ aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
}
//Add a new object
return NULL;
}
- if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
+ const Standard_Boolean isSameType = (aShapeType != TopAbs_SHAPE);
+
+ if ((aModifiedArray->Length() > 1 && isSameType) ||
+ theShapeWhat->GetType() == GEOM_GROUP) {
//Set a GROUP type
aResult->SetType(GEOM_GROUP);
new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
Standard_Integer imod;
+ Standard_Integer aShapeType = -1;
for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
const Standard_Integer anIndex =
aWhereIndices.FindIndex(anIterModif.Value());
+ const TopAbs_ShapeEnum aType = anIterModif.Value().ShapeType();
+
+ if (aShapeType == -1) {
+ // Initialization.
+ aShapeType = aType;
+ } else if (aShapeType != TopAbs_SHAPE && aShapeType != aType) {
+ // Different types.
+ aShapeType = TopAbs_SHAPE;
+ }
aModifiedArray->SetValue(imod, anIndex);
}
return NULL;
}
- if (aModifiedArray->Length() > 1 || theShapeWhat->GetType() == GEOM_GROUP) {
+ const Standard_Boolean isSameType = (aShapeType != TopAbs_SHAPE);
+
+ if ((aModifiedArray->Length() > 1 && isSameType) ||
+ theShapeWhat->GetType() == GEOM_GROUP) {
//Set a GROUP type
aResult->SetType(GEOM_GROUP);
return NULL;
}
- Standard_Integer nbFound = aModifiedList.Extent();
+ Handle(TColStd_HArray1OfInteger) aModifiedArray =
+ new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
- if ( nbFound > 1 )
- {
- // remove sub-shapes inappropriate for group creation
- TopAbs_ShapeEnum subType = TopAbs_SHAPE;
- while ( anIterModif.More() ) {
- TopAbs_ShapeEnum type = anIterModif.Value().ShapeType();
- bool okForGroup = ( type == TopAbs_VERTEX || type == TopAbs_EDGE ||
- type == TopAbs_FACE || type == TopAbs_SOLID );
- if ( okForGroup ) {
- if ( subType == TopAbs_SHAPE )
- subType = type;
- else
- okForGroup = ( subType == type );
- }
- if ( okForGroup )
- anIterModif.Next();
- else
- aModifiedList.Remove( anIterModif );
- nbFound -= ( !okForGroup );
- }
- if ( nbFound == 0 ) {
- SetErrorCode("Error: result found but it's type is inappropriate for group creation.");
- return NULL;
+ Standard_Integer imod;
+ Standard_Integer aShapeType = -1;
+
+ for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
+ const Standard_Integer anIndex =
+ aWhereIndices.FindIndex(anIterModif.Value());
+ const TopAbs_ShapeEnum aType = anIterModif.Value().ShapeType();
+
+ if (aShapeType == -1) {
+ // Initialization.
+ aShapeType = aType;
+ } else if (aShapeType != TopAbs_SHAPE && aShapeType != aType) {
+ // Different types.
+ aShapeType = TopAbs_SHAPE;
}
- }
- Handle(TColStd_HArray1OfInteger) aModifiedArray =
- new TColStd_HArray1OfInteger( 1, nbFound );
- anIterModif.Initialize(aModifiedList);
- for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++)
- aModifiedArray->SetValue
- (imod, aWhereIndices.FindIndex(anIterModif.Value()));
+ aModifiedArray->SetValue(imod, anIndex);
+ }
//Add a new object
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
return NULL;
}
- if (aModifiedArray->Length() > 1) {
+ const Standard_Boolean isSameType = (aShapeType != TopAbs_SHAPE);
+
+ if ((aModifiedArray->Length() > 1 && isSameType) ||
+ theShapeWhat->GetType() == GEOM_GROUP) {
//Set a GROUP type
aResult->SetType(GEOM_GROUP);