Select3D_SensitiveSet now stores BVH_PrimitiveSet as class field (no dynamic allocation),
and BVH_PrimitiveSet subclass now stores raw pointer to Select3D_SensitiveSet (no smart pointer).
Select3D_BVHPrimitiveContent definition has been moved into Select3D_SensitiveSet
class definition to avoid confusion.
Unused field Select3D_SensitiveSet::myIsLeftChildQueuedFirst has been removed.
Select3D_BndBox3d.hxx
Select3D_BVHIndexBuffer.hxx
-Select3D_BVHPrimitiveContent.cxx
-Select3D_BVHPrimitiveContent.hxx
Select3D_EntitySequence.hxx
Select3D_InteriorSensitivePointSet.cxx
Select3D_InteriorSensitivePointSet.hxx
+++ /dev/null
-// Created on: 2014-05-30
-// Created by: Varvara POSKONINA
-// Copyright (c) 2005-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <BVH_LinearBuilder.hxx>
-
-#include <Select3D_SensitiveSet.hxx>
-#include <Select3D_BVHPrimitiveContent.hxx>
-
-//=======================================================================
-// function : Select3D_BVHPrimitiveContent
-// purpose : Initializes new linear BVH builder for the set of sensitives
-// theSensitiveSet given
-//=======================================================================
-Select3D_BVHPrimitiveContent::Select3D_BVHPrimitiveContent (const Handle(Select3D_SensitiveSet)& theSensitiveSet)
-{
- mySensitiveSet = theSensitiveSet;
- myBuilder = new BVH_LinearBuilder<Standard_Real, 3> (myLeafNodeSize, 32);
-
- MarkDirty();
-}
-
-//=======================================================================
-// function : Size
-// purpose : Returns the length of set of sensitives
-//=======================================================================
-Standard_Integer Select3D_BVHPrimitiveContent::Size() const
-{
- return mySensitiveSet->Size();
-}
-
-//=======================================================================
-// function : Box
-// purpose : Returns bounding box of sensitive with index theIdx
-//=======================================================================
-Select3D_BndBox3d Select3D_BVHPrimitiveContent::Box (const Standard_Integer theIdx) const
-{
- return mySensitiveSet->Box (theIdx);
-}
-
-//=======================================================================
-// function : Center
-// purpose : Returns center of sensitive with index theIdx in the set
-// along the given axis theAxis
-//=======================================================================
-Standard_Real Select3D_BVHPrimitiveContent::Center (const Standard_Integer theIdx,
- const Standard_Integer theAxis) const
-{
- return mySensitiveSet->Center (theIdx, theAxis);
-}
-
-//=======================================================================
-// function : Swap
-// purpose : Swaps items with indexes theIdx1 and theIdx2 in the set
-//=======================================================================
-void Select3D_BVHPrimitiveContent::Swap (const Standard_Integer theIdx1,
- const Standard_Integer theIdx2)
-{
- mySensitiveSet->Swap (theIdx1, theIdx2);
-}
-
-//=======================================================================
-// function : GetBVH
-// purpose : Returns the tree built for set of sensitives
-//=======================================================================
-const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& Select3D_BVHPrimitiveContent::GetBVH()
-{
- return BVH();
-}
+++ /dev/null
-// Created on: 2014-05-30
-// Created by: Varvara POSKONINA
-// Copyright (c) 2005-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _Select3D_BVHPrimitiveContent_Header
-#define _Select3D_BVHPrimitiveContent_Header
-
-#include <BVH_PrimitiveSet.hxx>
-
-class Select3D_SensitiveSet;
-
-//! The purpose of this class is to provide a link between BVH_PrimitiveSet
-//! and Select3D_SensitiveSet instance to build BVH tree for set of sensitives
-class Select3D_BVHPrimitiveContent : public BVH_PrimitiveSet<Standard_Real, 3>
-{
-public:
-
- //! Initializes new linear BVH builder for the set of sensitives
- //! theSensitiveSet given
- Select3D_BVHPrimitiveContent (const Handle(Select3D_SensitiveSet)& theSensitiveSet);
-
- ~Select3D_BVHPrimitiveContent() {};
-
- //! Returns the length of set of sensitives
- Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
-
- //! Returns bounding box of sensitive with index theIdx
- Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
-
- //! Make inherited method Box() visible to avoid CLang warning
- using BVH_PrimitiveSet<Standard_Real, 3>::Box;
-
- //! Returns center of sensitive with index theIdx in the set along the
- //! given axis theAxis
- Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
- const Standard_Integer theAxis) const Standard_OVERRIDE;
-
- //! Swaps items with indexes theIdx1 and theIdx2 in the set
- Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
- const Standard_Integer theIdx2) Standard_OVERRIDE;
-
- //! Returns the tree built for set of sensitives
- Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& GetBVH();
-
- //! Returns a number of nodes in 1 BVH leaf
- Standard_Integer GetLeafNodeSize() const { return myLeafNodeSize; }
-
-protected:
- Handle(Select3D_SensitiveSet) mySensitiveSet; //!< Set of sensitive entities
-
-private:
- static const Standard_Integer myLeafNodeSize = 8; //!< Number of sub-elements in the leaf
-};
-
-#endif // _Select3D_BVHPrimitiveContent_Header
// commercial license or contractual agreement.
#include <Select3D_SensitiveSet.hxx>
-#include <Select3D_BVHPrimitiveContent.hxx>
+#include <BVH_LinearBuilder.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSet,Select3D_SensitiveEntity)
// purpose : Creates new empty sensitive set and its content
//=======================================================================
Select3D_SensitiveSet::Select3D_SensitiveSet (const Handle(SelectBasics_EntityOwner)& theOwnerId)
-: Select3D_SensitiveEntity (theOwnerId)
+: Select3D_SensitiveEntity (theOwnerId),
+ myDetectedIdx (-1)
{
- myDetectedIdx = -1;
- myIsLeftChildQueuedFirst = Standard_False;
- myContent = new Select3D_BVHPrimitiveContent (this);
+ NCollection_Handle< BVH_Builder<Standard_Real, 3> > aBuilder = new BVH_LinearBuilder<Standard_Real, 3> (myLeafNodeSize, 32);
+ myContent.SetSensitiveSet (this);
+ myContent.SetBuilder (aBuilder);
+ myContent.MarkDirty();
}
//=======================================================================
//=======================================================================
void Select3D_SensitiveSet::BVH()
{
- myContent->GetBVH();
+ myContent.GetBVH();
}
//=======================================================================
Standard_Boolean Select3D_SensitiveSet::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
- const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent->GetBVH().get();
+ const BVH_Tree<Standard_Real, 3, BVH_BinaryTree>* aBVH = myContent.GetBVH().get();
thePickResult = SelectBasics_PickResult (RealLast(), RealLast());
- if (myContent->Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
- aBVH->MaxPoint (0)))
+ if (myContent.Size() < 1 || !theMgr.Overlaps (aBVH->MinPoint (0),
+ aBVH->MaxPoint (0)))
{
return Standard_False;
}
return gp_Pnt (RealLast(), RealLast(), RealLast());
}
-//=======================================================================
-// function : MarkDirty
-// purpose : Marks BVH tree of the set as outdated. It will be rebuild
-// at the next call of BVH()
-//=======================================================================
-void Select3D_SensitiveSet::MarkDirty()
-{
- myContent->MarkDirty();
-}
-
//=======================================================================
// function : Clear
// purpose : Destroys cross-reference to avoid memory leak
//=======================================================================
void Select3D_SensitiveSet::Clear()
{
- myContent.Nullify();
-}
-
-//=======================================================================
-// function : GetLeafNodeSize
-// purpose : Returns a number of nodes in 1 BVH leaf
-//=======================================================================
-Standard_Integer Select3D_SensitiveSet::GetLeafNodeSize() const
-{
- return myContent->GetLeafNodeSize();
+ //
}
#ifndef _Select3D_SensitiveSet_Header
#define _Select3D_SensitiveSet_Header
+#include <BVH_PrimitiveSet.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
-#include <Standard_Type.hxx>
-
-#include <NCollection_Handle.hxx>
-
#include <Select3D_BndBox3d.hxx>
-#include <SelectBasics_EntityOwner.hxx>
#include <Select3D_SensitiveEntity.hxx>
-
-class Select3D_BVHPrimitiveContent;
+#include <SelectBasics_EntityOwner.hxx>
//! This class is base class for handling overlap detection of complex sensitive
//! entities. It provides an interface for building BVH tree for some set of entities.
//! For example of usage see Select3D_SensitiveTriangulation.
class Select3D_SensitiveSet : public Select3D_SensitiveEntity
{
+ static const Standard_Integer myLeafNodeSize = 8; //!< Number of sub-elements in the leaf
+ DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSet, Select3D_SensitiveEntity)
public:
//! Creates new empty sensitive set and its content
Standard_EXPORT Select3D_SensitiveSet (const Handle(SelectBasics_EntityOwner)& theOwnerId);
- ~Select3D_SensitiveSet() {};
+ ~Select3D_SensitiveSet() {}
public:
//! Must be called manually to build BVH tree for any sensitive set
//! in case if its content was initialized not in a constructor,
//! but element by element
- Standard_EXPORT void BVH() Standard_OVERRIDE;
+ Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! Marks BVH tree of the set as outdated. It will be rebuild
//! at the next call of BVH()
- Standard_EXPORT void MarkDirty();
+ void MarkDirty() { myContent.MarkDirty(); }
//! Returns bounding box of the whole set.
//! This method should be redefined in Select3D_SensitiveSet descendants
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Returns a number of nodes in 1 BVH leaf
- Standard_EXPORT Standard_Integer GetLeafNodeSize() const;
-
-public:
- DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSet,Select3D_SensitiveEntity)
+ Standard_Integer GetLeafNodeSize() const { return myLeafNodeSize; }
protected:
virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) = 0;
protected:
- Standard_Integer myDetectedIdx; //!< Index of detected primitive in BVH sorted primitive array
-private:
+ //! The purpose of this class is to provide a link between BVH_PrimitiveSet
+ //! and Select3D_SensitiveSet instance to build BVH tree for set of sensitives.
+ class BvhPrimitiveSet : public BVH_PrimitiveSet<Standard_Real, 3>
+ {
+ public:
+
+ //! Empty constructor.
+ BvhPrimitiveSet() {}
+
+ //! Destructor.
+ ~BvhPrimitiveSet() {}
+
+ //! Setup sensitivity set.
+ void SetSensitiveSet (Select3D_SensitiveSet* theSensitiveSet)
+ {
+ mySensitiveSet = theSensitiveSet;
+ MarkDirty();
+ }
+
+ //! Returns the length of set of sensitives
+ virtual Standard_Integer Size() const Standard_OVERRIDE { return mySensitiveSet->Size(); }
+
+ //! Returns bounding box of sensitive with index theIdx
+ virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE { return mySensitiveSet->Box (theIdx); }
+
+ //! Make inherited method Box() visible to avoid CLang warning
+ using BVH_PrimitiveSet<Standard_Real, 3>::Box;
+
+ //! Returns center of sensitive with index theIdx in the set along the given axis theAxis
+ virtual Standard_Real Center (const Standard_Integer theIdx,
+ const Standard_Integer theAxis) const Standard_OVERRIDE { return mySensitiveSet->Center (theIdx, theAxis); }
+
+ //! Swaps items with indexes theIdx1 and theIdx2 in the set
+ virtual void Swap (const Standard_Integer theIdx1,
+ const Standard_Integer theIdx2) Standard_OVERRIDE { mySensitiveSet->Swap (theIdx1, theIdx2); }
+
+ //! Returns the tree built for set of sensitives
+ const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& GetBVH() { return BVH(); }
+
+ protected:
+ Select3D_SensitiveSet* mySensitiveSet; //!< Set of sensitive entities
+ };
+
+protected:
+
+ BvhPrimitiveSet myContent; //!< A link between sensitive entity and BVH_PrimitiveSet
+ Standard_Integer myDetectedIdx; //!< Index of detected primitive in BVH sorted primitive array
- Standard_Boolean myIsLeftChildQueuedFirst; //!< Flag for slight randomization of BVH traverse
- NCollection_Handle<Select3D_BVHPrimitiveContent> myContent; //!< A link between sensitive entity and BVH_PrimitiveSet
};
DEFINE_STANDARD_HANDLE(Select3D_SensitiveSet, Select3D_SensitiveEntity)