-// function: SortPaveBlocks
-// purpose:
-//=======================================================================
-void BOPDS_DS::SortPaveBlocks(const Handle(BOPDS_CommonBlock)& aCB)
-{
- Standard_Integer theI;
- Standard_Boolean bToSort;
- bToSort = IsToSort(aCB, theI);
- if (!bToSort) {
- return;
- }
-
- Standard_Integer i(0);
- const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
- BOPDS_ListOfPaveBlock aLPBN = aLPB;
-
- Handle(BOPDS_PaveBlock) aPB;
- BOPDS_ListIteratorOfListOfPaveBlock aIt;
- //
- aIt.Initialize(aLPBN);
- for (aIt.Next(); aIt.More(); ) {
- i++;
- if(i == theI) {
- aPB = aIt.Value();
- aLPBN.Remove(aIt);
- aLPBN.Prepend(aPB);
- break;
- }
- aIt.Next();
- }
- //
- aCB->AddPaveBlocks(aLPBN);
-}
-//=======================================================================
-// function: IsToSort
-// purpose:
-//=======================================================================
-Standard_Boolean BOPDS_DS::IsToSort
- (const Handle(BOPDS_CommonBlock)& aCB,
- Standard_Integer& theI)
-{
- Standard_Boolean bRet;
- bRet = Standard_False;
- const BOPDS_ListOfPaveBlock& aLPB = aCB->PaveBlocks();
- if (aLPB.Extent()==1) {
- return bRet;
- }
-
- Standard_Integer nE;
- Standard_Real aTolMax, aTol;
- Handle(BOPDS_PaveBlock) aPB;
- TopoDS_Edge aE;
- BOPDS_ListIteratorOfListOfPaveBlock aIt;
- //
- aPB = aLPB.First();
- nE = aPB->OriginalEdge();
- aE = (*(TopoDS_Edge *)(&Shape(nE)));
- aTolMax = BRep_Tool::Tolerance(aE);
- //
- theI = 0;
- aIt.Initialize(aLPB);
- for (aIt.Next(); aIt.More(); aIt.Next()) {
- theI++;
- aPB = aIt.Value();
- nE = aPB->OriginalEdge();
- aE = (*(TopoDS_Edge *)(&Shape(nE)));
- aTol = BRep_Tool::Tolerance(aE);
- if (aTolMax < aTol) {
- aTolMax = aTol;
- bRet = Standard_True;
- }
- }
-
- return bRet;
-}
-//=======================================================================