From 791c95dab2dce51561211b209fc2bda31bb24035 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 11 Oct 2007 12:49:17 +0000 Subject: [PATCH] PAL17233: Projection 2D doesn't work (bis) fix SortShapes() for face sharing same edges but having different surfaces --- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 36 ++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 8f698def7..1dac9214c 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -2826,18 +2826,45 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL) // Sorting Standard_Integer aTemp; Standard_Boolean exchange, Sort = Standard_True; + Standard_Real tol = Precision::Confusion(); while (Sort) { Sort = Standard_False; for (Index=1; Index < MaxShapes; Index++) { - if (MidXYZ(OrderInd(Index)) > MidXYZ(OrderInd(Index+1))) + Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); + Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); + if ( dMidXYZ > 0 ) { exchange = Standard_True; - else if (MidXYZ(OrderInd(Index)) == MidXYZ(OrderInd(Index+1)) && - Length(OrderInd(Index)) > Length(OrderInd(Index+1)) ) + } + else if ( Abs(dMidXYZ) < tol && dLength > 0 ) { exchange = Standard_True; - else + } + else if ( Abs(dMidXYZ) < tol && Abs(dLength) < tol && + aShapes(OrderInd(Index)).ShapeType() <= TopAbs_FACE) { + // PAL17233 + // equal values possible on shapes such as two halves of a sphere and + // a membrane inside the sphere + Bnd_Box box1,box2; + BRepBndLib::Add( aShapes( OrderInd(Index) ), box1 ); + if ( box1.IsVoid() ) continue; + BRepBndLib::Add( aShapes( OrderInd(Index+1) ), box2 ); + Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); + if ( dSquareExtent > 0 ) { + exchange = Standard_True; + } + else if ( Abs(dSquareExtent) < tol ) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; + box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val1 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9; + box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val2 = (aXmin+aXmax)*999 + (aYmin+aYmax)*99 + (aZmin+aZmax)*0.9; + exchange = val1 > val2; + } + } + else { exchange = Standard_False; + } if (exchange) { aTemp = OrderInd(Index); @@ -2847,6 +2874,7 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL) } } } + for (Index=1; Index <= MaxShapes; Index++) SL.Append( aShapes( OrderInd(Index) )); } -- 2.39.2