1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0026146: Visualization, Select3D_ISensitivePointSet - eliminate crash when clearing selections [only with TBB]

Remove classes Select3D_ISensitivePointSet and Select3D_BoundarySensitivePointSet; use Select3D_SensitivePoly directly for boundary selection.
Make last argument in Select3D_SensitiveFace non-default to ensure that value is always explicitly specified by the caller.
Inherit SelectMgr_FrustumBuilder from Standard_Transient to use normal Handle instead of NCollection_Handle.

Add test case bugs/vis/bug26146.
This commit is contained in:
abv
2015-05-07 08:53:38 +03:00
parent 2157d6ac63
commit bf3977c9f9
18 changed files with 64 additions and 287 deletions

View File

@@ -1,14 +1,11 @@
Select3D_Pnt.hxx
Select3D_Macro.hxx
Select3D_PointData.hxx
Select3D_BoundarySensitivePointSet.hxx
Select3D_BoundarySensitivePointSet.cxx
Select3D_BndBox3d.hxx
Select3D_BVHPrimitiveContent.hxx
Select3D_BVHPrimitiveContent.cxx
Select3D_InteriorSensitivePointSet.hxx
Select3D_InteriorSensitivePointSet.cxx
Select3D_ISensitivePointSet.hxx
Select3D_EntitySequence.hxx
Select3D_SensitiveBox.hxx
Select3D_SensitiveBox.cxx

View File

@@ -44,10 +44,8 @@ uses
is
imported BndBox3d;
imported BoundarySensitivePointSet;
imported BVHPrimitiveContent;
imported InteriorSensitivePointSet;
imported ISensitivePointSet;
imported EntitySequence;
imported Pnt;
imported PointData;

View File

@@ -1,85 +0,0 @@
// Created on: 2014-11-10
// 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 <Select3D_BoundarySensitivePointSet.hxx>
//=======================================================================
// function : Select3D_BoundarySensitivePointSet
// purpose : Creates new instance of Select3D_SensitivePoly with BVH tree
// required and initializes it with the given array of points
//=======================================================================
Select3D_BoundarySensitivePointSet::Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints)
: Select3D_SensitivePoly (OwnerId, ThePoints, Standard_True)
{}
//=======================================================================
// function : Matches
// purpose : Checks whether the point set overlaps current selecting
// volume
//=======================================================================
Standard_Boolean Select3D_BoundarySensitivePointSet::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
return Select3D_SensitivePoly::Matches (theMgr, thePickResult);
}
//=======================================================================
// function : GetPoints
// purpose : Initializes the given array theHArrayOfPnt by 3d
// coordinates of vertices of the point set
//=======================================================================
void Select3D_BoundarySensitivePointSet::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
{
Points3D (theHArrayOfPnt);
}
//=======================================================================
// function : BoundingBox
// purpose : Returns bounding box of the point set. If location transformation
// is set, it will be applied
//=======================================================================
Select3D_BndBox3d Select3D_BoundarySensitivePointSet::BoundingBox()
{
return Select3D_SensitivePoly::BoundingBox();
}
//=======================================================================
// function : CenterOfGeometry
// purpose : Returns center of the point set. If location transformation
// is set, it will be applied
//=======================================================================
gp_Pnt Select3D_BoundarySensitivePointSet::CenterOfGeometry() const
{
return Select3D_SensitivePoly::CenterOfGeometry();
}
//=======================================================================
// function : BVH
// purpose : Builds BVH tree for the point set
//=======================================================================
void Select3D_BoundarySensitivePointSet::BVH()
{
Select3D_SensitivePoly::BVH();
}
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of points in set
//=======================================================================
Standard_Integer Select3D_BoundarySensitivePointSet::NbSubElements()
{
return Select3D_SensitivePoly::NbSubElements();
}

View File

@@ -1,62 +0,0 @@
// Created on: 2014-08-15
// 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_BoundarySensitivePointSet_HeaderFile
#define _Select3D_BoundarySensitivePointSet_HeaderFile
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Select3D_ISensitivePointSet.hxx>
#include <Select3D_SensitivePoly.hxx>
class SelectBasics_EntityOwner;
class TColgp_Array1OfPnt;
class TColgp_HArray1OfPnt;
//! This class handles the selection of arbitrary point set with boundary type of sensitivity.
class Select3D_BoundarySensitivePointSet : public Select3D_ISensitivePointSet, public Select3D_SensitivePoly
{
public:
//! Creates new instance of Select3D_SensitivePoly with BVH tree
//! required and initializes it with the given array of points
Standard_EXPORT Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints);
//! Checks whether the point set overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Initializes the given array theHArrayOfPnt by 3d coordinates
//! of vertices of the point set
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) Standard_OVERRIDE;
//! Returns bounding box of the point set. If there is a
//! location transformation set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Returns center of the point set. If there is a
//! location transformation set, it will be applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Builds BVH tree for the point set
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! Returns the amount of points in set
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
};
#endif // _Select3D_BoundarySensitivePointSet_HeaderFile

View File

@@ -1,70 +0,0 @@
// Created on: 2014-08-15
// 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_ISensitivePointSet_HeaderFile
#define _Select3D_ISensitivePointSet_HeaderFile
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Real.hxx>
#include <Select3D_BndBox3d.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <SelectBasics_PickResult.hxx>
#include <SelectBasics_SelectingVolumeManager.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
class gp_Pnt;
class Standard_ConstructionError;
class Standard_OutOfRange;
class TColgp_Array1OfPnt;
class TColgp_HArray1OfPnt;
class TColgp_Array1OfPnt2d;
class TopLoc_Location;
//! Interface class to unify the work with both internal and boundary
//! sensitive sets of points.
class Select3D_ISensitivePointSet
{
public:
//! Checks whether the point set overlaps current selecting volume
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) = 0;
//! Initializes the given array theHArrayOfPnt by 3d coordinates
//! of vertices of the point set
virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) = 0;
//! Returns bounding box of the point set. If location
//! transformation is set, it will be applied
virtual Select3D_BndBox3d BoundingBox() = 0;
//! Returns center of the point set. If location
//! transformation is set, it will be applied
virtual gp_Pnt CenterOfGeometry() const = 0;
//! Builds BVH tree for the point set
virtual void BVH() = 0;
//! Returns the amount of points in set
virtual Standard_Integer NbSubElements() = 0;
};
#endif // _Select3D_ISensitivePointSet_HeaderFile

View File

@@ -21,6 +21,8 @@
#include <Select3D_InteriorSensitivePointSet.hxx>
namespace {
// Internal class for creation of planar polygons
class Select3D_Plane
{
@@ -74,6 +76,11 @@ private:
Standard_Boolean myIsInitialized;
};
} // anonymous namespace
IMPLEMENT_STANDARD_HANDLE (Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
IMPLEMENT_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
// =======================================================================
// function : Select3D_InteriorSensitivePointSet
// purpose : Splits the given point set thePoints onto planar convex
@@ -171,17 +178,6 @@ Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Ha
}
}
// =======================================================================
// function : Matches
// purpose : Checks whether the point set overlaps current selecting
// volume
// =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
}
// =======================================================================
// function : GetPoints
// purpose : Initializes the given array theHArrayOfPnt by 3d
@@ -320,15 +316,6 @@ gp_Pnt Select3D_InteriorSensitivePointSet::CenterOfGeometry() const
return myCOG;
}
//=======================================================================
// function : BVH
// purpose : Builds BVH tree for the point set
//=======================================================================
void Select3D_InteriorSensitivePointSet::BVH()
{
BVH();
}
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of points in set

View File

@@ -22,7 +22,6 @@
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Handle_TColStd_HArray1OfInteger.hxx>
#include <Select3D_ISensitivePointSet.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_SensitiveSet.hxx>
@@ -37,7 +36,7 @@ typedef NCollection_Vector<Handle(Select3D_SensitivePoly)> Select3D_VectorOfHPol
//! This class handles the selection of arbitrary point set with internal type of sensitivity.
//! The main principle is to split the point set given onto planar convex polygons and search
//! for the overlap with one or more of them through traverse of BVH tree.
class Select3D_InteriorSensitivePointSet : public Select3D_ISensitivePointSet, public Select3D_SensitiveSet
class Select3D_InteriorSensitivePointSet : public Select3D_SensitiveSet
{
public:
@@ -45,13 +44,9 @@ public:
Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePoints);
//! Checks whether the point set overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Initializes the given array theHArrayOfPnt by 3d coordinates of vertices of the
//! whole point set
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) Standard_OVERRIDE;
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
//! Returns the length of vector of planar convex polygons
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
@@ -76,12 +71,11 @@ public:
//! transformation is set, it will be applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Builds BVH tree for the point set
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! Returns the amount of points in set
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
DEFINE_STANDARD_RTTI(Select3D_InteriorSensitivePointSet)
protected:
//! Checks whether the planar convex polygon with index theIdx
@@ -106,4 +100,6 @@ protected:
Select3D_BndBox3d myBndBox; //!< Bounding box of the point set
};
DEFINE_STANDARD_HANDLE(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
#endif // _Select3D_InteriorSensitivePointSet_HeaderFile

View File

@@ -19,6 +19,9 @@
//Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
#include <Select3D_SensitiveFace.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_InteriorSensitivePointSet.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
@@ -41,7 +44,7 @@ Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_Entity
}
else
{
myFacePoints = new Select3D_BoundarySensitivePointSet (theOwnerId, thePoints);
myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
}
}
@@ -61,7 +64,7 @@ Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_Entity
}
else
{
myFacePoints = new Select3D_BoundarySensitivePointSet (theOwnerId, thePoints->Array1());
myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
}
}
@@ -72,7 +75,15 @@ Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_Entity
//=======================================================================
void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
{
myFacePoints->GetPoints (theHArrayOfPnt);
if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
{
Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
}
else
{
Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
}
}
//=======================================================================
@@ -102,7 +113,7 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
{
// Create a copy of this
Handle(TColgp_HArray1OfPnt) aPoints;
myFacePoints->GetPoints (aPoints);
GetPoints (aPoints);
Handle(Select3D_SensitiveEntity) aNewEntity =
new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);

View File

@@ -21,14 +21,10 @@
#ifndef _Select3D_SensitiveFace_HeaderFile
#define _Select3D_SensitiveFace_HeaderFile
#include <NCollection_Handle.hxx>
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Type.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_SensitiveSet.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Standard_Boolean.hxx>
@@ -36,10 +32,6 @@
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>
#include <Select3D_ISensitivePointSet.hxx>
#include <Select3D_BoundarySensitivePointSet.hxx>
#include <Select3D_InteriorSensitivePointSet.hxx>
class Standard_ConstructionError;
class Standard_OutOfRange;
class SelectBasics_EntityOwner;
@@ -61,7 +53,7 @@ public:
//! The array of points is the outer polygon of the geometric face.
Standard_EXPORT Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePoints,
const Select3D_TypeOfSensitivity theType = Select3D_TOS_INTERIOR);
const Select3D_TypeOfSensitivity theType);
//! Constructs a sensitive face object defined by the
//! owner theOwnerId, the array of points thePoints, and
@@ -69,7 +61,7 @@ public:
//! The array of points is the outer polygon of the geometric face.
Standard_EXPORT Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const Handle(TColgp_HArray1OfPnt)& thePoints,
const Select3D_TypeOfSensitivity theType = Select3D_TOS_INTERIOR);
const Select3D_TypeOfSensitivity theType);
//! Initializes the given array theHArrayOfPnt by 3d
//! coordinates of vertices of the face
@@ -99,8 +91,8 @@ public:
private:
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: interior or boundary
NCollection_Handle<Select3D_ISensitivePointSet> myFacePoints; //!< Wrapper for overlap detection created depending on sensitivity type
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: interior or boundary
Handle(Select3D_SensitiveSet) myFacePoints; //!< Wrapper for overlap detection created depending on sensitivity type
};
DEFINE_STANDARD_HANDLE(Select3D_SensitiveFace, Select3D_SensitiveEntity)