Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:54

0001 // Created on: 2014-08-15
0002 // Created by: Varvara POSKONINA
0003 // Copyright (c) 2005-2014 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 _SelectMgr_SensitiveEntitySet_HeaderFile
0017 #define _SelectMgr_SensitiveEntitySet_HeaderFile
0018 
0019 #include <BVH_PrimitiveSet3d.hxx>
0020 #include <Select3D_BVHBuilder3d.hxx>
0021 #include <SelectMgr_EntityOwner.hxx>
0022 #include <SelectMgr_SensitiveEntity.hxx>
0023 #include <SelectMgr_Selection.hxx>
0024 
0025 typedef NCollection_IndexedMap<Handle(SelectMgr_SensitiveEntity)> SelectMgr_IndexedMapOfHSensitive;
0026 typedef NCollection_DataMap<Handle(SelectMgr_EntityOwner), Standard_Integer> SelectMgr_MapOfOwners;
0027 
0028 //! This class is used to store all calculated sensitive entities of one selectable object.
0029 //! It provides an interface for building BVH tree which is used to speed-up
0030 //! the performance of searching for overlap among sensitives of one selectable object
0031 class SelectMgr_SensitiveEntitySet : public BVH_PrimitiveSet3d
0032 {
0033   DEFINE_STANDARD_RTTIEXT(SelectMgr_SensitiveEntitySet, BVH_PrimitiveSet3d)
0034 public:
0035 
0036   //! Empty constructor.
0037   Standard_EXPORT SelectMgr_SensitiveEntitySet (const Handle(Select3D_BVHBuilder3d)& theBuilder);
0038 
0039   virtual ~SelectMgr_SensitiveEntitySet() {}
0040 
0041   //! Adds new entity to the set and marks BVH tree for rebuild
0042   Standard_EXPORT void Append (const Handle(SelectMgr_SensitiveEntity)& theEntity);
0043 
0044   //! Adds every entity of selection theSelection to the set and marks
0045   //! BVH tree for rebuild
0046   Standard_EXPORT void Append (const Handle(SelectMgr_Selection)& theSelection);
0047 
0048   //! Removes every entity of selection theSelection from the set
0049   //! and marks BVH tree for rebuild
0050   Standard_EXPORT void Remove (const Handle(SelectMgr_Selection)& theSelection);
0051 
0052   //! Returns bounding box of entity with index theIdx
0053   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
0054 
0055   //! Make inherited method Box() visible to avoid CLang warning
0056   using BVH_PrimitiveSet3d::Box;
0057 
0058   //! Returns geometry center of sensitive entity index theIdx
0059   //! along the given axis theAxis
0060   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
0061                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
0062 
0063   //! Swaps items with indexes theIdx1 and theIdx2
0064   Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
0065                                      const Standard_Integer theIndex2) Standard_OVERRIDE;
0066 
0067   //! Returns the amount of entities
0068   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
0069 
0070   //! Returns the entity with index theIndex in the set
0071   Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const;
0072 
0073   //! Returns map of entities.
0074   const SelectMgr_IndexedMapOfHSensitive& Sensitives() const { return mySensitives; }
0075 
0076   //! Returns map of owners.
0077   const SelectMgr_MapOfOwners& Owners() const { return myOwnersMap; }
0078 
0079   //! Returns map of entities.
0080   Standard_Boolean HasEntityWithPersistence() const { return myHasEntityWithPersistence; }
0081 
0082 protected:
0083 
0084   //! Adds entity owner to the map of owners (or increases its counter if it is already there).
0085   Standard_EXPORT void addOwner (const Handle(SelectMgr_EntityOwner)& theOwner);
0086 
0087   //! Decreases counter of owner in the map of owners (or removes it from the map if counter == 0).
0088   Standard_EXPORT void removeOwner (const Handle(SelectMgr_EntityOwner)& theOwner);
0089 
0090 private:
0091 
0092   SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
0093   SelectMgr_MapOfOwners            myOwnersMap;  //!< Map of entity owners and its corresponding number of sensitives
0094   Standard_Boolean  myHasEntityWithPersistence;  //!< flag if some of sensitive entity has own transform persistence
0095 };
0096 
0097 #endif // _SelectMgr_SensitiveEntitySet_HeaderFile