Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:28:04

0001 // Created on: 2013-12-25
0002 // Created by: Varvara POSKONINA
0003 // Copyright (c) 1999-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 _Graphic3d_BvhCStructureSet_HeaderFile
0017 #define _Graphic3d_BvhCStructureSet_HeaderFile
0018 
0019 #include <BVH_PrimitiveSet3d.hxx>
0020 #include <Graphic3d_BndBox3d.hxx>
0021 #include <NCollection_IndexedMap.hxx>
0022 
0023 class Graphic3d_CStructure;
0024 
0025 //! Set of OpenGl_Structures for building BVH tree.
0026 class Graphic3d_BvhCStructureSet : public BVH_PrimitiveSet3d
0027 {
0028   DEFINE_STANDARD_RTTIEXT(Graphic3d_BvhCStructureSet, BVH_PrimitiveSet3d)
0029 protected:
0030   using BVH_PrimitiveSet3d::Box;
0031 
0032 public:
0033   //! Creates an empty primitive set for BVH clipping.
0034   Standard_EXPORT Graphic3d_BvhCStructureSet();
0035 
0036   //! Returns total number of structures.
0037   Standard_EXPORT int Size() const override;
0038 
0039   //! Returns AABB of the structure.
0040   Standard_EXPORT Graphic3d_BndBox3d Box(const int theIdx) const override;
0041 
0042   //! Calculates center of the AABB along given axis.
0043   Standard_EXPORT double Center(const int theIdx, const int theAxis) const override;
0044 
0045   //! Swaps structures with the given indices.
0046   Standard_EXPORT void Swap(const int theIdx1, const int theIdx2) override;
0047 
0048   //! Adds structure to the set.
0049   //! @return true if structure added, otherwise returns false (structure already in the set).
0050   Standard_EXPORT bool Add(const Graphic3d_CStructure* theStruct);
0051 
0052   //! Removes the given structure from the set.
0053   //! @return true if structure removed, otherwise returns false (structure is not in the set).
0054   Standard_EXPORT bool Remove(const Graphic3d_CStructure* theStruct);
0055 
0056   //! Cleans the whole primitive set.
0057   Standard_EXPORT void Clear();
0058 
0059   //! Returns the structure corresponding to the given ID.
0060   Standard_EXPORT const Graphic3d_CStructure* GetStructureById(int theId);
0061 
0062   //! Access directly a collection of structures.
0063   const NCollection_IndexedMap<const Graphic3d_CStructure*>& Structures() const
0064   {
0065     return myStructs;
0066   }
0067 
0068 private:
0069   // clang-format off
0070   NCollection_IndexedMap<const Graphic3d_CStructure*> myStructs;    //!< Indexed map of structures.
0071   // clang-format on
0072 };
0073 
0074 #endif // _Graphic3d_BvhCStructureSet_HeaderFile