Back to index

salome-geom  6.5.0
Public Types | Public Member Functions | Public Attributes
GEOMImpl_IShapesOperations::CompareShapes Struct Reference

Sort shapes in the list by their coordinates. More...

#include <GEOMImpl_IShapesOperations.hxx>

List of all members.

Public Types

typedef NCollection_DataMap
< TopoDS_Shape, std::pair
< double, double > > 
NCollection_DataMapOfShapeDouble

Public Member Functions

 CompareShapes (bool isOldSorting)
bool operator() (const TopoDS_Shape &lhs, const TopoDS_Shape &rhs)

Public Attributes

NCollection_DataMapOfShapeDouble myMap
bool myIsOldSorting

Detailed Description

Sort shapes in the list by their coordinates.

Parameters:
SLThe list of shapes to sort.

Definition at line 383 of file GEOMImpl_IShapesOperations.hxx.


Member Typedef Documentation

typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > GEOMImpl_IShapesOperations::CompareShapes::NCollection_DataMapOfShapeDouble

Definition at line 390 of file GEOMImpl_IShapesOperations.hxx.


Constructor & Destructor Documentation

Definition at line 385 of file GEOMImpl_IShapesOperations.hxx.

      : myIsOldSorting(isOldSorting) {}

Member Function Documentation

bool GEOMImpl_IShapesOperations::CompareShapes::operator() ( const TopoDS_Shape &  lhs,
const TopoDS_Shape &  rhs 
)

Definition at line 4314 of file GEOMImpl_IShapesOperations.cxx.

{
  if (!myMap.IsBound(theShape1)) {
    myMap.Bind(theShape1, ShapeToDouble(theShape1, myIsOldSorting));
  }

  if (!myMap.IsBound(theShape2)) {
    myMap.Bind(theShape2, ShapeToDouble(theShape2, myIsOldSorting));
  }

  std::pair<double, double> val1 = myMap.Find(theShape1);
  std::pair<double, double> val2 = myMap.Find(theShape2);

  double tol = Precision::Confusion();
  bool exchange = Standard_False;

  double dMidXYZ = val1.first - val2.first;
  if (dMidXYZ >= tol) {
    exchange = Standard_True;
  }
  else if (Abs(dMidXYZ) < tol) {
    double dLength = val1.second - val2.second;
    if (dLength >= tol) {
      exchange = Standard_True;
    }
    else if (Abs(dLength) < tol && theShape1.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(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;
          }
        }
      }
    }
  }

  //return val1 < val2;
  return !exchange;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 392 of file GEOMImpl_IShapesOperations.hxx.

Definition at line 391 of file GEOMImpl_IShapesOperations.hxx.


The documentation for this struct was generated from the following files: