- // compare lists of indices one by one to find chich list indices are lower
- NCollection_Array1<int>::Iterator aFirstList(theAreaToIndex.ChangeFind(theFirst));
- NCollection_Array1<int>::Iterator aSecondList(theAreaToIndex.ChangeFind(theSecond));
- for(; aFirstList.More() && aSecondList.More(); aFirstList.Next(), aSecondList.Next()) {
- if (aFirstList.Value() < aSecondList.Value()) return true;
- if (aFirstList.Value() > aSecondList.Value()) return false;
+ bool isFirst;
+ bool aGeomCompare = !theAreaToIndex.IsBound(theFirst) || !theAreaToIndex.IsBound(theSecond);
+ if (!aGeomCompare) {
+ // compare lists of indices one by one to find chich list indices are lower
+ NCollection_Array1<int>::Iterator aFirstList(theAreaToIndex.ChangeFind(theFirst));
+ NCollection_Array1<int>::Iterator aSecondList(theAreaToIndex.ChangeFind(theSecond));
+ for (; aFirstList.More() && aSecondList.More(); aFirstList.Next(), aSecondList.Next()) {
+ if (aFirstList.Value() < aSecondList.Value()) return true;
+ if (aFirstList.Value() > aSecondList.Value()) return false;
+ }
+ aGeomCompare = !aFirstList.More() && !aSecondList.More();
+ isFirst = !aFirstList.More();
+ } else {
+ isFirst = !theAreaToIndex.IsBound(theFirst);