1 // Copyright (c) 2016 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <SelectMgr_ToleranceMap.hxx>
16 //=======================================================================
17 // function: SelectMgr_ToleranceMap
19 //=======================================================================
20 SelectMgr_ToleranceMap::SelectMgr_ToleranceMap()
22 myCustomTolerance (-1)
27 //=======================================================================
28 // function: ~SelectMgr_ToleranceMap
30 //=======================================================================
31 SelectMgr_ToleranceMap::~SelectMgr_ToleranceMap()
36 //=======================================================================
39 //=======================================================================
40 void SelectMgr_ToleranceMap::Add (const Standard_Integer& theTolerance)
42 if (Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance))
45 if (*aFreq == 1 && theTolerance != myLargestKey)
47 myLargestKey = Max (theTolerance, myLargestKey);
52 myTolerances.Bind (theTolerance, 1);
53 if (myTolerances.Extent() == 1)
55 myLargestKey = theTolerance;
59 myLargestKey = Max (theTolerance, myLargestKey);
63 //=======================================================================
64 // function: Decrement
66 //=======================================================================
67 void SelectMgr_ToleranceMap::Decrement (const Standard_Integer& theTolerance)
69 Standard_Integer* aFreq = myTolerances.ChangeSeek (theTolerance);
75 Standard_ProgramError_Raise_if (*aFreq == 0, "SelectMgr_ToleranceMap::Decrement() - internal error");
78 if (theTolerance == myLargestKey
82 for (NCollection_DataMap<Standard_Integer, Standard_Integer>::Iterator anIter (myTolerances); anIter.More(); anIter.Next())
84 if (anIter.Value() != 0)
86 myLargestKey = Max (myLargestKey, anIter.Key());