|
||||
File indexing completed on 2025-01-18 10:04:54
0001 // Copyright (c) 2016 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _SelectMgr_ToleranceMap_HeaderFile 0015 #define _SelectMgr_ToleranceMap_HeaderFile 0016 0017 #include <NCollection_DataMap.hxx> 0018 0019 //! An internal class for calculation of current largest tolerance value which will be applied for creation of selecting frustum by default. 0020 //! Each time the selection set is deactivated, maximum tolerance value will be recalculated. 0021 //! If a user enables custom precision using StdSelect_ViewerSelector3d::SetPixelTolerance, it will be applied to all sensitive entities without any checks. 0022 class SelectMgr_ToleranceMap 0023 { 0024 public: 0025 0026 //! Sets tolerance values to -1.0 0027 Standard_EXPORT SelectMgr_ToleranceMap(); 0028 0029 Standard_EXPORT ~SelectMgr_ToleranceMap(); 0030 0031 //! Adds the value given to map, checks if the current tolerance value 0032 //! should be replaced by theTolerance 0033 Standard_EXPORT void Add (const Standard_Integer& theTolerance); 0034 0035 //! Decrements a counter of the tolerance given, checks if the current tolerance value 0036 //! should be recalculated 0037 Standard_EXPORT void Decrement (const Standard_Integer& theTolerance); 0038 0039 //! Returns a current tolerance that must be applied 0040 Standard_Integer Tolerance() const 0041 { 0042 if (myLargestKey < 0) 0043 { 0044 return 2; // default tolerance value 0045 } 0046 return myCustomTolerance < 0 0047 ? myLargestKey 0048 : myLargestKey + myCustomTolerance; 0049 } 0050 0051 //! Sets tolerance to the given one and disables adaptive checks 0052 void SetCustomTolerance (const Standard_Integer theTolerance) { myCustomTolerance = theTolerance; } 0053 0054 //! Unsets a custom tolerance and enables adaptive checks 0055 void ResetDefaults() { myCustomTolerance = -1; } 0056 0057 //! Returns the value of custom tolerance regardless of it validity 0058 Standard_Integer CustomTolerance() const { return myCustomTolerance; } 0059 0060 //! Returns true if custom tolerance value is greater than zero 0061 Standard_Boolean IsCustomTolSet() const { return myCustomTolerance > 0; } 0062 0063 private: 0064 NCollection_DataMap<Standard_Integer, Standard_Integer> myTolerances; 0065 Standard_Integer myLargestKey; 0066 Standard_Integer myCustomTolerance; 0067 }; 0068 0069 #endif // _SelectMgr_ToleranceMap_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |