|
|
|||
File indexing completed on 2026-05-19 08:16:11
0001 // Created by: Eugeny MALTCHIKOV 0002 // Created on: 2019-04-17 0003 // Copyright (c) 2019 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _BVH_Distance_Header 0017 #define _BVH_Distance_Header 0018 0019 #include <BVH_Traverse.hxx> 0020 0021 //! Abstract class for computation of the min distance between some 0022 //! Object and elements of BVH tree. 0023 //! To use this class it is required to define two methods: 0024 //! - *RejectNode* to compute distance from the object to bounding box 0025 //! - *Accept* to compute distance from the object to the element of tree 0026 //! 0027 //! \tparam NumType Numeric data type 0028 //! \tparam Dimension Vector dimension 0029 //! \tparam ObjectType Type of the object to which the distance is required 0030 //! \tparam BVHSetType Type of the set on which BVH is built 0031 template <class NumType, int Dimension, class ObjectType, class BVHSetType> 0032 class BVH_Distance : public BVH_Traverse<NumType, Dimension, BVHSetType, NumType> 0033 { 0034 public: //! @name Constructor 0035 //! Constructor 0036 BVH_Distance() 0037 : BVH_Traverse<NumType, Dimension, BVHSetType, NumType>(), 0038 myDistance(std::numeric_limits<NumType>::max()), 0039 myIsDone(Standard_False) 0040 { 0041 } 0042 0043 public: //! @name Setting object for distance computation 0044 //! Sets the object to which the distance is required 0045 void SetObject(const ObjectType& theObject) { myObject = theObject; } 0046 0047 public: //! @name Compute the distance 0048 //! Computes the distance between object and BVH tree 0049 NumType ComputeDistance() 0050 { 0051 myIsDone = this->Select() > 0; 0052 return myDistance; 0053 } 0054 0055 public: //! @name Accessing the results 0056 //! Returns IsDone flag 0057 Standard_Boolean IsDone() const { return myIsDone; } 0058 0059 //! Returns the computed distance 0060 NumType Distance() const { return myDistance; } 0061 0062 public: //! @name Definition of the rules for tree descend 0063 //! Compares the two metrics and chooses the best one 0064 virtual Standard_Boolean IsMetricBetter(const NumType& theLeft, 0065 const NumType& theRight) const Standard_OVERRIDE 0066 { 0067 return theLeft < theRight; 0068 } 0069 0070 //! Rejects the branch by the metric 0071 virtual Standard_Boolean RejectMetric(const NumType& theMetric) const Standard_OVERRIDE 0072 { 0073 return theMetric > myDistance; 0074 } 0075 0076 //! Returns the flag controlling the tree descend 0077 virtual Standard_Boolean Stop() const Standard_OVERRIDE 0078 { 0079 return myDistance == static_cast<NumType>(0); 0080 } 0081 0082 protected: //! @name Fields 0083 NumType myDistance; //!< Distance 0084 Standard_Boolean myIsDone; //!< State of the algorithm 0085 ObjectType myObject; //!< Object to compute the distance to 0086 }; 0087 0088 #endif // _BVH_Distance_Header
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|