- if (!myMap->IsBound(theShape1)) {
- myMap->Bind(theShape1, ShapeToDouble(theShape1, myConvertPoint));
- }
-
- if (!myMap->IsBound(theShape2)) {
- myMap->Bind(theShape2, ShapeToDouble(theShape2, myConvertPoint));
- }
-
- const std::pair<gp_Pnt, double>& val1 = myMap->Find(theShape1);
- const std::pair<gp_Pnt, double>& val2 = myMap->Find(theShape2);
-
- double tol = 10.0 * Precision::Confusion();
- bool exchange = Standard_False;
-
- // compare coordinates of center points
- GeomPointPtr aPnt1(new GeomAPI_Pnt(val1.first.X(), val1.first.Y(), val1.first.Z()));
- GeomPointPtr aPnt2(new GeomAPI_Pnt(val2.first.X(), val2.first.Y(), val2.first.Z()));
- if (aPnt2->isLess(aPnt1, tol)) {
- exchange = Standard_True;
- }
- else if (!aPnt1->isLess(aPnt2, tol)) {
- double dLength = val1.second - val2.second;
- if (dLength >= tol) {
- exchange = Standard_True;
- }
- else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) {
- // equal values possible on shapes such as two halves of a sphere and
- // a membrane inside the sphere
-// LCOV_EXCL_START
- // this part of code is taken from GEOM module, but can not reproduce in SHAPER
- Bnd_Box box1,box2;
- BRepBndLib::Add(theShape1, box1);
- if (!box1.IsVoid()) {
- BRepBndLib::Add(theShape2, box2);
- Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent();
- if (dSquareExtent >= tol) {
- 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.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9;
- box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9;
- if ((val1 - val2) >= tol) {
- exchange = Standard_True;
- }
- }
- }
-// LCOV_EXCL_STOP
- } else // compare addresses if shapes are geometrically equal
- return theShape1.TShape().get() > theShape2.TShape().get();
- }
-
- //return val1 < val2;
- return !exchange;