From: eap Date: Tue, 18 Feb 2014 13:06:53 +0000 (+0400) Subject: 0022458: [CEA 1039] Regressions on NETGEN_1D2D3D and "GetInPlaceByHistory" X-Git-Tag: V7_4_0a1~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=383c7fe63a07a737bf457414cb55b6b79ac25bea;p=modules%2Fgeom.git 0022458: [CEA 1039] Regressions on NETGEN_1D2D3D and "GetInPlaceByHistory" Re-fix 22448. Remove sub-shapes inappropriate for group creation when it's clear that a group will be created, i.e. that nb of found sub-shapes > 1 --- diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index f71fb3b2e..05b67b46e 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -3643,11 +3643,7 @@ static bool GetInPlaceOfShape (const Handle(GEOM_Function)& theWhereFunction, { if (theWhereFunction.IsNull() || theWhat.IsNull()) return false; - if(theWhereIndices.Contains( theWhat ) && - (theWhat.ShapeType() == TopAbs_VERTEX || theWhat.ShapeType() == TopAbs_EDGE || - theWhat.ShapeType() == TopAbs_FACE || theWhat.ShapeType() == TopAbs_SOLID)) { - // It is possible to add a shape only next type: vertex, edge, face or solid - // to create after a group on these elements + if (theWhereIndices.Contains(theWhat)) { // entity was not changed by the operation Standard_Integer aWhatIndex = theWhereIndices.FindIndex(theWhat); theModifiedList.Append(aWhatIndex); @@ -3702,10 +3698,7 @@ static bool GetInPlaceOfShape (const Handle(GEOM_Function)& theWhereFunction, isGood = Standard_True; Standard_Integer imod, aModifLen = anIntegerArray->Array()->Length(); for (imod = 1; imod <= aModifLen; imod++) { - TopoDS_Shape curShape = theWhereIndices.FindKey(anIntegerArray->Array()->Value(imod)); - if(curShape.ShapeType() == TopAbs_VERTEX || curShape.ShapeType() == TopAbs_EDGE || - curShape.ShapeType() == TopAbs_FACE || curShape.ShapeType() == TopAbs_SOLID) - theModifiedList.Append(anIntegerArray->Array()->Value(imod)); + theModifiedList.Append(anIntegerArray->Array()->Value(imod)); } } } @@ -4290,13 +4283,40 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory return NULL; } - Handle(TColStd_HArray1OfInteger) aModifiedArray = - new TColStd_HArray1OfInteger (1, aModifiedList.Extent()); + Standard_Integer nbFound = aModifiedList.Extent(); TColStd_ListIteratorOfListOfInteger anIterModif (aModifiedList); - for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++) { - aModifiedArray->SetValue(imod, anIterModif.Value()); + if ( nbFound > 1 ) + { + // remove sub-shapes inappropriate for group creation + TopAbs_ShapeEnum subType = TopAbs_SHAPE; + while ( anIterModif.More() ) { + TopAbs_ShapeEnum type = aWhereIndices( 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; + } } + 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, anIterModif.Value()); + //Add a new object Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray); if (aResult.IsNull()) { @@ -4320,7 +4340,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory Handle(GEOM_Function) aFunction = aResult->GetFunction(1); GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetInPlaceByHistory(" - << theShapeWhere << ", " << theShapeWhat << ")"; + << theShapeWhere << ", " << theShapeWhat << ")"; SetErrorCode(OK); return aResult;