mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-26 12:40:34 +05:00
0052774: GetInPlace creates result as a group of sub-shapes of different types
This commit is contained in:
parent
ce07ba70be
commit
c38fbe7a1c
@ -4223,16 +4223,28 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
const TopoDS_Shape &aShapeResult = aGIP.Result();
|
const TopoDS_Shape &aShapeResult = aGIP.Result();
|
||||||
TopTools_MapOfShape aMFence;
|
TopTools_MapOfShape aMFence;
|
||||||
TopTools_IndexedMapOfShape aWhereIndices;
|
TopTools_IndexedMapOfShape aWhereIndices;
|
||||||
|
Standard_Integer aShapeType = -1;
|
||||||
|
|
||||||
TopExp::MapShapes(aWhere, aWhereIndices);
|
TopExp::MapShapes(aWhere, aWhereIndices);
|
||||||
|
|
||||||
if (aShapeResult.IsNull() == Standard_False) {
|
if (aShapeResult.IsNull() == Standard_False) {
|
||||||
TopoDS_Iterator anIt(aShapeResult);
|
TopoDS_Iterator anIt(aShapeResult);
|
||||||
|
Standard_Boolean isFirst = Standard_True;
|
||||||
|
|
||||||
for (; anIt.More(); anIt.Next()) {
|
for (; anIt.More(); anIt.Next()) {
|
||||||
const TopoDS_Shape &aPart = anIt.Value();
|
const TopoDS_Shape &aPart = anIt.Value();
|
||||||
|
|
||||||
if(aWhereIndices.Contains(aPart) && aMFence.Add(aPart)) {
|
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);
|
aLSA.Append(aPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4246,14 +4258,8 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
Handle(TColStd_HArray1OfInteger) aModifiedArray = new TColStd_HArray1OfInteger (1, aLSA.Extent());
|
Handle(TColStd_HArray1OfInteger) aModifiedArray = new TColStd_HArray1OfInteger (1, aLSA.Extent());
|
||||||
TopTools_ListIteratorOfListOfShape anIterModif (aLSA);
|
TopTools_ListIteratorOfListOfShape anIterModif (aLSA);
|
||||||
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
||||||
if (aWhereIndices.Contains(anIterModif.Value())) {
|
|
||||||
aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
|
aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value()));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
SetErrorCode("Error: wrong sub-shape returned");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add a new object
|
//Add a new object
|
||||||
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
||||||
@ -4262,7 +4268,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object)
|
|||||||
return NULL;
|
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
|
//Set a GROUP type
|
||||||
aResult->SetType(GEOM_GROUP);
|
aResult->SetType(GEOM_GROUP);
|
||||||
|
|
||||||
@ -4331,10 +4340,20 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld
|
|||||||
new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
|
new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
|
||||||
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
||||||
Standard_Integer imod;
|
Standard_Integer imod;
|
||||||
|
Standard_Integer aShapeType = -1;
|
||||||
|
|
||||||
for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
||||||
const Standard_Integer anIndex =
|
const Standard_Integer anIndex =
|
||||||
aWhereIndices.FindIndex(anIterModif.Value());
|
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);
|
aModifiedArray->SetValue(imod, anIndex);
|
||||||
}
|
}
|
||||||
@ -4348,7 +4367,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld
|
|||||||
return NULL;
|
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
|
//Set a GROUP type
|
||||||
aResult->SetType(GEOM_GROUP);
|
aResult->SetType(GEOM_GROUP);
|
||||||
|
|
||||||
@ -4406,40 +4428,27 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer nbFound = aModifiedList.Extent();
|
Handle(TColStd_HArray1OfInteger) aModifiedArray =
|
||||||
|
new TColStd_HArray1OfInteger (1, aModifiedList.Extent());
|
||||||
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
TopTools_ListIteratorOfListOfShape anIterModif (aModifiedList);
|
||||||
if ( nbFound > 1 )
|
Standard_Integer imod;
|
||||||
{
|
Standard_Integer aShapeType = -1;
|
||||||
// remove sub-shapes inappropriate for group creation
|
|
||||||
TopAbs_ShapeEnum subType = TopAbs_SHAPE;
|
for (imod = 1; anIterModif.More(); anIterModif.Next(), imod++) {
|
||||||
while ( anIterModif.More() ) {
|
const Standard_Integer anIndex =
|
||||||
TopAbs_ShapeEnum type = anIterModif.Value().ShapeType();
|
aWhereIndices.FindIndex(anIterModif.Value());
|
||||||
bool okForGroup = ( type == TopAbs_VERTEX || type == TopAbs_EDGE ||
|
const TopAbs_ShapeEnum aType = anIterModif.Value().ShapeType();
|
||||||
type == TopAbs_FACE || type == TopAbs_SOLID );
|
|
||||||
if ( okForGroup ) {
|
if (aShapeType == -1) {
|
||||||
if ( subType == TopAbs_SHAPE )
|
// Initialization.
|
||||||
subType = type;
|
aShapeType = aType;
|
||||||
else
|
} else if (aShapeType != TopAbs_SHAPE && aShapeType != aType) {
|
||||||
okForGroup = ( subType == type );
|
// Different types.
|
||||||
}
|
aShapeType = TopAbs_SHAPE;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(TColStd_HArray1OfInteger) aModifiedArray =
|
aModifiedArray->SetValue(imod, anIndex);
|
||||||
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()));
|
|
||||||
|
|
||||||
//Add a new object
|
//Add a new object
|
||||||
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray);
|
||||||
@ -4448,7 +4457,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
|
|||||||
return NULL;
|
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
|
//Set a GROUP type
|
||||||
aResult->SetType(GEOM_GROUP);
|
aResult->SetType(GEOM_GROUP);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user