MeshVS_Mesh selection logic in MeshVS_SMF_Mesh mode (entire mesh) has been optimized.
MeshVS_Mesh::ComputeSelection() now creates single sensitive entity
MeshVS_CommonSensitiveEntity (new class) instead of small sensitive entity on each element.
MeshVS_Buffer.hxx
+MeshVS_CommonSensitiveEntity.hxx
+MeshVS_CommonSensitiveEntity.cxx
MeshVS_EntityType.hxx
MeshVS_DisplayModeFlags.hxx
MeshVS_DummySensitiveEntity.hxx
#define MeshVS_Buffer_HeaderFile
#include <Standard.hxx>
+#include <gp_Pnt.hxx>
/**
* General purpose buffer that is allocated on the stack with a
return * (myDynData ? (Standard_Integer*) myDynData : (Standard_Integer*) myAutoData);
}
+ //! Interpret the buffer as a reference to gp_Pnt
+ operator gp_Pnt& ()
+ {
+ return * (myDynData ? (gp_Pnt*) myDynData : (gp_Pnt*) myAutoData);
+ }
+
private:
//! Deprecate copy constructor
MeshVS_Buffer(const MeshVS_Buffer&) {}
--- /dev/null
+// Created on: 2016-02-18
+// Created by: Varvara POSKONINA
+// Copyright (c) 2016 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 <MeshVS_CommonSensitiveEntity.hxx>
+
+#include <MeshVS_Buffer.hxx>
+#include <MeshVS_Drawer.hxx>
+#include <MeshVS_DrawerAttribute.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_PackedMapOfInteger.hxx>
+#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
+IMPLEMENT_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+MeshVS_CommonSensitiveEntity::MeshVS_CommonSensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwner,
+ const Handle(MeshVS_Mesh)& theParentMesh,
+ const MeshVS_MeshSelectionMethod theSelMethod)
+: Select3D_SensitiveSet (theOwner),
+ myDataSource (theParentMesh->GetDataSource()),
+ mySelMethod (theSelMethod)
+{
+ theParentMesh->GetDrawer()->GetInteger (MeshVS_DA_MaxFaceNodes, myMaxFaceNodes);
+ Standard_ASSERT_RAISE (myMaxFaceNodes > 0,
+ "The maximal amount of nodes in a face must be greater than zero to create sensitive entity");
+ gp_XYZ aCenter (0.0, 0.0, 0.0);
+
+ if (mySelMethod == MeshVS_MSM_NODES)
+ {
+ Standard_Integer aNbSelectableNodes = 0;
+ const TColStd_PackedMapOfInteger& anAllNodesMap = myDataSource->GetAllNodes();
+ for (TColStd_MapIteratorOfPackedMapOfInteger aNodesIter (anAllNodesMap); aNodesIter.More(); aNodesIter.Next())
+ {
+ const Standard_Integer aNodeIdx = aNodesIter.Key();
+ if (theParentMesh->IsSelectableNode (aNodeIdx))
+ {
+ const gp_Pnt aVertex = getVertexByIndex (aNodeIdx);
+ aCenter += aVertex.XYZ();
+ myBndBox.Add (SelectMgr_Vec3 (aVertex.X(), aVertex.Y(), aVertex.Z()));
+ ++aNbSelectableNodes;
+ myItemIndexes.Append (aNodeIdx);
+ }
+ }
+
+ // increase sensitivity for vertices detection
+ SetSensitivityFactor (8);
+ myCOG = aCenter / aNbSelectableNodes;
+ }
+ else if (mySelMethod == MeshVS_MSM_PRECISE)
+ {
+ const TColStd_PackedMapOfInteger& anAllNodesMap = myDataSource->GetAllNodes();
+ for (TColStd_MapIteratorOfPackedMapOfInteger aNodesIter (anAllNodesMap); aNodesIter.More(); aNodesIter.Next())
+ {
+ const Standard_Integer aNodeIdx = aNodesIter.Key();
+ const gp_Pnt aVertex = getVertexByIndex (aNodeIdx);
+ aCenter += aVertex.XYZ();
+ myBndBox.Add (SelectMgr_Vec3 (aVertex.X(), aVertex.Y(), aVertex.Z()));
+ }
+ myCOG = aCenter / anAllNodesMap.Extent();
+
+ const TColStd_PackedMapOfInteger& anAllElementsMap = myDataSource->GetAllElements();
+ MeshVS_EntityType aType;
+ for (TColStd_MapIteratorOfPackedMapOfInteger anElemIter (anAllElementsMap); anElemIter.More(); anElemIter.Next())
+ {
+ const Standard_Integer anElemIdx = anElemIter.Key();
+ if (theParentMesh->IsSelectableElem (anElemIdx)
+ && myDataSource->GetGeomType (anElemIdx, Standard_True, aType)
+ && aType == MeshVS_ET_Face)
+ {
+ myItemIndexes.Append (anElemIdx);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Destructor
+//purpose :
+//=======================================================================
+MeshVS_CommonSensitiveEntity::~MeshVS_CommonSensitiveEntity()
+{
+ myDataSource.Nullify();
+ myItemIndexes.Clear();
+}
+
+//=======================================================================
+//function : NbSubElements
+//purpose :
+//=======================================================================
+Standard_Integer MeshVS_CommonSensitiveEntity::NbSubElements()
+{
+ return myItemIndexes.Size();
+}
+
+//=======================================================================
+//function : Size
+//purpose :
+//=======================================================================
+Standard_Integer MeshVS_CommonSensitiveEntity::Size() const
+{
+ return myItemIndexes.Size();
+}
+
+//=======================================================================
+//function : getVertexByIndex
+//purpose :
+//=======================================================================
+gp_Pnt MeshVS_CommonSensitiveEntity::getVertexByIndex (const Standard_Integer theNodeIdx) const
+{
+ Standard_Real aCoordsBuf[3];
+ TColStd_Array1OfReal aCoords (aCoordsBuf[0], 1, 3);
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aType;
+ if (!myDataSource->GetGeom (theNodeIdx, Standard_False, aCoords, aNbNodes, aType))
+ {
+ return gp_Pnt();
+ }
+ return gp_Pnt (aCoords.Value (1), aCoords.Value (2), aCoords.Value (3));
+}
+
+//=======================================================================
+//function : Box
+//purpose :
+//=======================================================================
+Select3D_BndBox3d MeshVS_CommonSensitiveEntity::Box (const Standard_Integer theIdx) const
+{
+ const Standard_Integer anItemIdx = myItemIndexes.Value (theIdx);
+ Select3D_BndBox3d aBox;
+ if (mySelMethod == MeshVS_MSM_PRECISE)
+ {
+ MeshVS_Buffer aCoordsBuf (3 * myMaxFaceNodes * sizeof (Standard_Real));
+ TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3 * myMaxFaceNodes);
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aType;
+ if (!myDataSource->GetGeom (anItemIdx, Standard_True, aCoords, aNbNodes, aType)
+ || aNbNodes == 0)
+ {
+ return aBox;
+ }
+
+ MeshVS_Buffer aNodesBuf (aNbNodes * sizeof (Standard_Integer));
+ TColStd_Array1OfInteger aElemNodes (aNodesBuf, 1, aNbNodes);
+ if (!myDataSource->GetNodesByElement (anItemIdx, aElemNodes, aNbNodes))
+ {
+ return aBox;
+ }
+
+ for (Standard_Integer aNodeIdx = 1; aNodeIdx <= aNbNodes; aNodeIdx++)
+ {
+ const SelectMgr_Vec3 aPnt (aCoords (3 * aNodeIdx - 2),
+ aCoords (3 * aNodeIdx - 1),
+ aCoords (3 * aNodeIdx));
+ aBox.Add (aPnt);
+ }
+ }
+ else if (mySelMethod == MeshVS_MSM_NODES)
+ {
+ const gp_Pnt aVert = getVertexByIndex (anItemIdx);
+ aBox.Add (SelectMgr_Vec3 (aVert.X(), aVert.Y(), aVert.Z()));
+ }
+
+ return aBox;
+}
+
+//=======================================================================
+//function : Center
+//purpose :
+//=======================================================================
+Standard_Real MeshVS_CommonSensitiveEntity::Center (const Standard_Integer theIdx,
+ const Standard_Integer theAxis) const
+{
+ const Select3D_BndBox3d& aBox = Box (theIdx);
+ SelectMgr_Vec3 aCenter = (aBox.CornerMin () + aBox.CornerMax ()) * 0.5;
+
+ return theAxis == 0 ? aCenter.x() : (theAxis == 1 ? aCenter.y() : aCenter.z());
+}
+
+//=======================================================================
+//function : Swap
+//purpose :
+//=======================================================================
+void MeshVS_CommonSensitiveEntity::Swap (const Standard_Integer theIdx1,
+ const Standard_Integer theIdx2)
+{
+ const Standard_Integer anItem1 = myItemIndexes.Value (theIdx1);
+ const Standard_Integer anItem2 = myItemIndexes.Value (theIdx2);
+ myItemIndexes.ChangeValue (theIdx1) = anItem2;
+ myItemIndexes.ChangeValue (theIdx2) = anItem1;
+}
+
+//=======================================================================
+//function : overlapsElement
+//purpose :
+//=======================================================================
+Standard_Boolean MeshVS_CommonSensitiveEntity::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
+ Standard_Integer theElemIdx,
+ Standard_Real& theMatchDepth)
+{
+ const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx);
+ if (mySelMethod == MeshVS_MSM_PRECISE)
+ {
+ MeshVS_Buffer aCoordsBuf (3 * myMaxFaceNodes * sizeof (Standard_Real));
+ TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3 * myMaxFaceNodes);
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aType;
+ if (!myDataSource->GetGeom (anItemIdx, Standard_True, aCoords, aNbNodes, aType)
+ || aNbNodes == 0)
+ {
+ return Standard_False;
+ }
+
+ MeshVS_Buffer aNodesBuf (aNbNodes * sizeof (Standard_Integer));
+ TColStd_Array1OfInteger aElemNodes (aNodesBuf, 1, aNbNodes);
+ if (!myDataSource->GetNodesByElement (anItemIdx, aElemNodes, aNbNodes))
+ {
+ return Standard_False;
+ }
+ if (aNbNodes == 3)
+ {
+ return theMgr.Overlaps (gp_Pnt (aCoords (1), aCoords (2), aCoords (3)),
+ gp_Pnt (aCoords (4), aCoords (5), aCoords (6)),
+ gp_Pnt (aCoords (7), aCoords (8), aCoords (9)),
+ Select3D_TOS_INTERIOR, theMatchDepth);
+ }
+
+ MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
+ TColgp_Array1OfPnt aFacePnts (aFacePntsBuf, 1, aNbNodes);
+ for (Standard_Integer aNodeIdx = 1; aNodeIdx <= aNbNodes; aNodeIdx++)
+ {
+ aFacePnts.SetValue (aNodeIdx, gp_Pnt (aCoords (3 * aNodeIdx - 2),
+ aCoords (3 * aNodeIdx - 1),
+ aCoords (3 * aNodeIdx)));
+ }
+ return theMgr.Overlaps (aFacePnts, Select3D_TOS_INTERIOR, theMatchDepth);
+ }
+ else if (mySelMethod == MeshVS_MSM_NODES)
+ {
+ const gp_Pnt aVert = getVertexByIndex (anItemIdx);
+ return theMgr.Overlaps (aVert, theMatchDepth);
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : elementIsInside
+//purpose :
+//=======================================================================
+Standard_Boolean MeshVS_CommonSensitiveEntity::elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
+ const Standard_Integer theElemIdx)
+{
+ const Standard_Integer anItemIdx = myItemIndexes.Value (theElemIdx);
+ if (mySelMethod == MeshVS_MSM_PRECISE)
+ {
+ MeshVS_Buffer aCoordsBuf (3 * myMaxFaceNodes * sizeof (Standard_Real));
+ TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3 * myMaxFaceNodes);
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aType;
+ if (!myDataSource->GetGeom (anItemIdx, Standard_True, aCoords, aNbNodes, aType)
+ || aNbNodes == 0)
+ {
+ return Standard_False;
+ }
+
+ MeshVS_Buffer aNodesBuf (aNbNodes * sizeof (Standard_Integer));
+ TColStd_Array1OfInteger aElemNodes (aNodesBuf, 1, aNbNodes);
+ if (!myDataSource->GetNodesByElement (anItemIdx, aElemNodes, aNbNodes))
+ {
+ return Standard_False;
+ }
+
+ MeshVS_Buffer aFacePntsBuf (aNbNodes * 3 * sizeof (Standard_Real));
+ TColgp_Array1OfPnt aFacePnts (aFacePntsBuf, 1, aNbNodes);
+ for (Standard_Integer aNodeIdx = 1; aNodeIdx <= aNbNodes; ++aNodeIdx)
+ {
+ const gp_Pnt aPnt (aCoords (3 * aNodeIdx - 2),
+ aCoords (3 * aNodeIdx - 1),
+ aCoords (3 * aNodeIdx));
+ if (!theMgr.Overlaps (aPnt))
+ {
+ return Standard_False;
+ }
+ }
+ return Standard_True;
+ }
+ else if (mySelMethod == MeshVS_MSM_NODES)
+ {
+ const gp_Pnt aVert = getVertexByIndex (anItemIdx);
+ return theMgr.Overlaps (aVert);
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : distanceToCOG
+//purpose :
+//=======================================================================
+Standard_Real MeshVS_CommonSensitiveEntity::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
+{
+ return theMgr.DistToGeometryCenter (myCOG);
+}
+
+//=======================================================================
+//function : BoundingBox
+//purpose :
+//=======================================================================
+Select3D_BndBox3d MeshVS_CommonSensitiveEntity::BoundingBox()
+{
+ return myBndBox;
+}
--- /dev/null
+// Created on: 2016-02-18
+// Created by: Varvara POSKONINA
+// Copyright (c) 2016 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 _MeshVS_CommonSensitiveEntity_Header
+#define _MeshVS_CommonSensitiveEntity_Header
+
+#include <MeshVS_DataSource.hxx>
+#include <MeshVS_Mesh.hxx>
+#include <MeshVS_MeshSelectionMethod.hxx>
+#include <Select3D_SensitiveSet.hxx>
+
+//! Sensitive entity covering entire mesh for global selection.
+class MeshVS_CommonSensitiveEntity : public Select3D_SensitiveSet
+{
+public:
+
+ //! Default constructor.
+ Standard_EXPORT MeshVS_CommonSensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwner,
+ const Handle(MeshVS_Mesh)& theParentMesh,
+ const MeshVS_MeshSelectionMethod theSelMethod);
+
+ //! Destructor.
+ Standard_EXPORT virtual ~MeshVS_CommonSensitiveEntity();
+
+ //! Number of elements.
+ Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
+
+ //! Returns the amount of sub-entities of the complex entity
+ Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
+
+ //! Returns bounding box of sub-entity with index theIdx in sub-entity list
+ Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
+
+ //! Returns geometry center of sensitive entity index theIdx 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
+ Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
+ const Standard_Integer theIdx2) Standard_OVERRIDE;
+
+ //! Returns bounding box of the triangulation. If location
+ //! transformation is set, it will be applied
+ Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
+
+public:
+
+ DEFINE_STANDARD_RTTI (MeshVS_CommonSensitiveEntity)
+
+protected:
+
+ //! Checks whether the entity with index theIdx overlaps the current selecting volume
+ Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
+ Standard_Integer theElemIdx,
+ Standard_Real& theMatchDepth) Standard_OVERRIDE;
+
+ //! Checks whether the entity with index theIdx is inside the current selecting volume
+ Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
+ const Standard_Integer theElemIdx) Standard_OVERRIDE;
+
+ //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
+ Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
+
+private:
+
+ //! Return point for specified index.
+ gp_Pnt getVertexByIndex (const Standard_Integer theNodeIdx) const;
+
+private:
+
+ Handle(MeshVS_DataSource) myDataSource; //!< mesh data source
+ NCollection_Vector<Standard_Integer> myItemIndexes; //!< indices for BVH tree reordering
+ MeshVS_MeshSelectionMethod mySelMethod; //!< selection mode
+ Standard_Integer myMaxFaceNodes; //!< maximum nodes within the element in mesh
+ gp_Pnt myCOG; //!< center of gravity
+ Select3D_BndBox3d myBndBox; //!< bounding box
+
+};
+
+DEFINE_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
+
+#endif // _MeshVS_CommonSensitiveEntity_Header
#include <SelectMgr_SequenceOfOwner.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitiveBox.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Bnd_Box.hxx>
+#include <MeshVS_CommonSensitiveEntity.hxx>
#include <MeshVS_DataSource.hxx>
#include <MeshVS_MeshEntityOwner.hxx>
#include <MeshVS_MeshOwner.hxx>
if( myWholeMeshOwner.IsNull() )
myWholeMeshOwner = new SelectMgr_EntityOwner( this );
- switch( mySelectionMethod )
+ if (mySelectionMethod == MeshVS_MSM_BOX)
{
- case MeshVS_MSM_BOX:
- {
- Bnd_Box box;
- TColStd_MapIteratorOfPackedMapOfInteger anIterN( anAllNodesMap );
- for( ; anIterN.More(); anIterN.Next() )
- {
- if( myDataSource->GetGeom( anIterN.Key(), Standard_False, aCoords, NbNodes, aType ) ) {
- box.Add (gp_Pnt (aCoords(1), aCoords(2), aCoords(3)));
- }
- }
- if (!box.IsVoid())
- theSelection->Add (new Select3D_SensitiveBox (myWholeMeshOwner, box));
- }
- break;
-
- case MeshVS_MSM_NODES:
- {
- TColStd_MapIteratorOfPackedMapOfInteger anIterN( anAllNodesMap );
- for( ; anIterN.More(); anIterN.Next() )
- if( myDataSource->GetGeom( anIterN.Key(), Standard_False, aCoords, NbNodes, aType ) &&
- IsSelectableNode( anIterN.Key() ) )
- theSelection->Add( new Select3D_SensitivePoint( myWholeMeshOwner, gp_Pnt ( aCoords(1), aCoords(2), aCoords(3) ) ) );
- }
- break;
-
- case MeshVS_MSM_PRECISE:
- {
- Handle( Select3D_SensitiveEntity ) anEnt;
- TColStd_MapIteratorOfPackedMapOfInteger anIterMV( anAllElementsMap );
-
- TColStd_PackedMapOfInteger aSharedNodes;
- for( ; anIterMV.More(); anIterMV.Next() )
- {
- Standard_Integer aKey = anIterMV.Key();
-
- if( IsSelectableElem( aKey ) &&
- myDataSource->GetGeomType( aKey, Standard_True, aType ) &&
- aType==MeshVS_ET_Face )
- {
- myDataSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType );
- if( NbNodes==0 )
- continue;
-
- MeshVS_Buffer aNodesBuf (NbNodes*sizeof(Standard_Integer));
- TColStd_Array1OfInteger aElemNodes(aNodesBuf, 1, NbNodes);
- if ( !myDataSource->GetNodesByElement ( aKey, aElemNodes, NbNodes ) )
- continue;
-
- TColgp_Array1OfPnt Points( 1, NbNodes );
- for ( Standard_Integer i=1; i<=NbNodes; i++ )
- {
- Points (i) = gp_Pnt ( aCoords (3*i-2), aCoords (3*i-1), aCoords (3*i) );
- aSharedNodes.Add( aElemNodes( i ) );
- }
-
- anEnt = new Select3D_SensitiveFace( myWholeMeshOwner, Points, Select3D_TOS_INTERIOR);
- theSelection->Add( anEnt );
- }
- }
- for( anIterMV.Initialize( anAllElementsMap ); anIterMV.More(); anIterMV.Next() )
- {
- Standard_Integer aKey = anIterMV.Key();
-
- if( IsSelectableElem( aKey ) &&
- myDataSource->GetGeomType( aKey, Standard_True, aType ) &&
- aType==MeshVS_ET_Link )
- {
- myDataSource->GetGeom ( aKey, Standard_True, aCoords, NbNodes, aType );
- if( NbNodes==0 )
- continue;
-
- MeshVS_Buffer aNodesBuf (NbNodes*sizeof(Standard_Integer));
- TColStd_Array1OfInteger aElemNodes(aNodesBuf, 1, NbNodes);
- if ( !myDataSource->GetNodesByElement ( aKey, aElemNodes, NbNodes ) )
- continue;
-
- TColgp_Array1OfPnt Points( 1, NbNodes );
- Standard_Boolean all_shared = Standard_True;
- for ( Standard_Integer i=1; i<=NbNodes; i++ )
- {
- Points (i) = gp_Pnt ( aCoords (3*i-2), aCoords (3*i-1), aCoords (3*i) );
- all_shared = all_shared && aSharedNodes.Contains( aElemNodes( i ) );
- aSharedNodes.Add( aElemNodes( i ) );
- }
-
- if( !all_shared )
- {
- anEnt = new Select3D_SensitiveSegment( myWholeMeshOwner, Points.Value( 1 ), Points.Value( 2 ) );
- theSelection->Add( anEnt );
- }
- }
- }
- for( anIterMV.Initialize( anAllNodesMap ); anIterMV.More(); anIterMV.Next() )
- {
- Standard_Integer aKey = anIterMV.Key();
- if( IsSelectableElem( aKey ) &&
- myDataSource->GetGeom ( aKey, Standard_False, aCoords, NbNodes, aType ) &&
- !aSharedNodes.Contains( aKey ) )
- {
- anEnt = new Select3D_SensitivePoint( myWholeMeshOwner, gp_Pnt ( aCoords(1), aCoords(2), aCoords(3) ) ) ;
- theSelection->Add( anEnt );
- }
- }
- }
- break;
+ Bnd_Box aBndBox;
+ BoundingBox (aBndBox);
+ if (!aBndBox.IsVoid())
+ theSelection->Add (new Select3D_SensitiveBox (myWholeMeshOwner, aBndBox));
+ }
+ else
+ {
+ theSelection->Add (new MeshVS_CommonSensitiveEntity (myWholeMeshOwner, this, mySelectionMethod));
}
break;
}
}
+ StdSelect_BRepSelectionTool::PreBuildBVH (theSelection);
+
if ( ShowComputeSelectionTime )
{
Standard_Real sec, cpu;
Standard_Integer theSensType,
Standard_Real& theDepth) = 0;
+ //! Returns true if selecting volume is overlapped by planar convex polygon, which points
+ //! are stored in theArrayOfPts, taking into account sensitivity type theSensType
+ virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
+ Standard_Integer theSensType,
+ Standard_Real& theDepth) = 0;
+
//! Returns true if selecting volume is overlapped by line segment with start point at thePt1
//! and end point at thePt2
virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
// may be considered of interior part or boundary line defined
// by segments depending on given sensitivity type
//=======================================================================
-Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPnts*/,
+Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
Select3D_TypeOfSensitivity /*theSensType*/,
Standard_Real& /*theDepth*/)
{
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
- virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
- Select3D_TypeOfSensitivity theSensType,
- Standard_Real& theDepth);
+ Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
+ Select3D_TypeOfSensitivity theSensType,
+ Standard_Real& theDepth);
//! Checks if line segment overlaps selecting frustum
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2);
//! SAT intersection test between frustum given and planar convex polygon represented as ordered point set
- Standard_Boolean hasOverlap (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
- gp_Vec& theNormal);
+ Standard_EXPORT Standard_Boolean hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts,
+ gp_Vec& theNormal);
//! SAT intersection test between defined volume and given triangle
Standard_Boolean hasOverlap (const gp_Pnt& thePnt1,
// polygon represented as ordered point set
// =======================================================================
template <int N>
-Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
+Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const TColgp_Array1OfPnt& theArrayOfPnts,
gp_Vec& theNormal)
{
- Standard_Integer aStartIdx = theArrayOfPnts->Lower();
- Standard_Integer anEndIdx = theArrayOfPnts->Upper();
+ Standard_Integer aStartIdx = theArrayOfPnts.Lower();
+ Standard_Integer anEndIdx = theArrayOfPnts.Upper();
- const gp_XYZ& aPnt1 = theArrayOfPnts->Value (aStartIdx).XYZ();
- const gp_XYZ& aPnt2 = theArrayOfPnts->Value (aStartIdx + 1).XYZ();
- const gp_XYZ& aPnt3 = theArrayOfPnts->Value (aStartIdx + 2).XYZ();
+ const gp_XYZ& aPnt1 = theArrayOfPnts.Value (aStartIdx).XYZ();
+ const gp_XYZ& aPnt2 = theArrayOfPnts.Value (aStartIdx + 1).XYZ();
+ const gp_XYZ& aPnt3 = theArrayOfPnts.Value (aStartIdx + 2).XYZ();
const gp_XYZ aVec1 = aPnt1 - aPnt2;
const gp_XYZ aVec2 = aPnt3 - aPnt2;
theNormal = aVec2.Crossed (aVec1);
const gp_XYZ& aPlane = myPlanes[aPlaneIdx].XYZ();
for (Standard_Integer aPntIter = aStartIdx; aPntIter <= anEndIdx; ++aPntIter)
{
- Standard_Real aProjection = aPlane.Dot (theArrayOfPnts->Value (aPntIter).XYZ());
+ Standard_Real aProjection = aPlane.Dot (theArrayOfPnts.Value (aPntIter).XYZ());
aMaxPolyg = Max (aMaxPolyg, aProjection);
aMinPolyg = Min (aMinPolyg, aProjection);
}
}
Standard_Integer aDirectionsNb = myIsOrthographic ? 4 : 6;
- for (Standard_Integer aPntsIter = 0, aLastIdx = anEndIdx - aStartIdx, aLen = theArrayOfPnts->Length(); aPntsIter <= aLastIdx; ++aPntsIter)
+ for (Standard_Integer aPntsIter = 0, aLastIdx = anEndIdx - aStartIdx, aLen = theArrayOfPnts.Length(); aPntsIter <= aLastIdx; ++aPntsIter)
{
- const gp_XYZ aSegmDir = theArrayOfPnts->Value ((aPntsIter + 1) % aLen + aStartIdx).XYZ()
- - theArrayOfPnts->Value (aPntsIter + aStartIdx).XYZ();
+ const gp_XYZ aSegmDir = theArrayOfPnts.Value ((aPntsIter + 1) % aLen + aStartIdx).XYZ()
+ - theArrayOfPnts.Value (aPntsIter + aStartIdx).XYZ();
for (Standard_Integer aVolDir = 0; aVolDir < aDirectionsNb; ++aVolDir)
{
Standard_Real aMaxPolyg = RealFirst();
for (Standard_Integer aPntIter = aStartIdx; aPntIter <= anEndIdx; ++aPntIter)
{
- Standard_Real aProjection = aTestDir.Dot (theArrayOfPnts->Value (aPntIter).XYZ());
+ Standard_Real aProjection = aTestDir.Dot (theArrayOfPnts.Value (aPntIter).XYZ());
aMaxPolyg = Max (aMaxPolyg, aProjection);
aMinPolyg = Min (aMinPolyg, aProjection);
}
// may be considered of interior part or boundary line defined
// by segments depending on given sensitivity type
// =======================================================================
-Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
+Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
{
{
Standard_Integer aMatchingSegmentsNb = -1;
theDepth = DBL_MAX;
- Standard_Integer aLower = theArrayOfPnts->Lower();
- Standard_Integer anUpper = theArrayOfPnts->Upper();
-
+ const Standard_Integer aLower = theArrayOfPnts.Lower();
+ const Standard_Integer anUpper = theArrayOfPnts.Upper();
for (Standard_Integer aPntIter = aLower; aPntIter <= anUpper; ++aPntIter)
{
- const gp_Pnt& aStartPnt = theArrayOfPnts->Value (aPntIter);
- const gp_Pnt& aEndPnt = aPntIter == anUpper ? theArrayOfPnts->Value (aLower)
- : theArrayOfPnts->Value (aPntIter + 1);
-
+ const gp_Pnt& aStartPnt = theArrayOfPnts.Value (aPntIter);
+ const gp_Pnt& aEndPnt = theArrayOfPnts.Value (aPntIter == anUpper ? aLower : (aPntIter + 1));
if (hasOverlap (aStartPnt, aEndPnt))
{
aMatchingSegmentsNb++;
return Standard_False;
segmentPlaneIntersection (aPolyNorm,
- theArrayOfPnts->Value (theArrayOfPnts->Lower()),
+ theArrayOfPnts.Value (theArrayOfPnts.Lower()),
theDepth);
}
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
- Handle(TColgp_HArray1OfPnt) aPntsArray = new TColgp_HArray1OfPnt(1, 4);
- aPntsArray->SetValue (1, thePnt1);
- aPntsArray->SetValue (2, thePnt2);
- aPntsArray->SetValue (3, thePnt3);
- aPntsArray->SetValue (4, thePnt1);
+ const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
+ const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 4);
return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
}
else if (theSensType == Select3D_TOS_INTERIOR)
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
- virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
- Select3D_TypeOfSensitivity theSensType,
- Standard_Real& theDepth) Standard_OVERRIDE;
+ Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
+ Select3D_TypeOfSensitivity theSensType,
+ Standard_Real& theDepth) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
if (myActiveSelectionType == Unknown)
return Standard_False;
+ return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts->Array1(),
+ (Select3D_TypeOfSensitivity)theSensType,
+ theDepth);
+}
+
+//=======================================================================
+// function : Overlaps
+// purpose : SAT intersection test between defined volume and given
+// ordered set of points, representing line segments. The test
+// may be considered of interior part or boundary line defined
+// by segments depending on given sensitivity type
+//=======================================================================
+Standard_Boolean SelectMgr_SelectingVolumeManager::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
+ Standard_Integer theSensType,
+ Standard_Real& theDepth)
+{
+ if (myActiveSelectionType == Unknown)
+ return Standard_False;
+
return mySelectingVolumes[myActiveSelectionType / 2]->Overlaps (theArrayOfPnts,
(Select3D_TypeOfSensitivity)theSensType,
theDepth);
Standard_Integer theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
+ //! SAT intersection test between defined volume and given ordered set of points,
+ //! representing line segments. The test may be considered of interior part or
+ //! boundary line defined by segments depending on given sensitivity type
+ Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
+ Standard_Integer theSensType,
+ Standard_Real& theDepth) Standard_OVERRIDE;
+
//! Checks if line segment overlaps selecting frustum
Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
// may be considered of interior part or boundary line defined
// by segments depending on given sensitivity type
// =======================================================================
-Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
+Standard_Boolean SelectMgr_TriangularFrustum::Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& /*theDepth*/)
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
- Standard_Integer aLower = theArrayOfPnts->Lower();
- Standard_Integer anUpper = theArrayOfPnts->Upper();
-
+ const Standard_Integer aLower = theArrayOfPnts.Lower();
+ const Standard_Integer anUpper = theArrayOfPnts.Upper();
for (Standard_Integer aPtIdx = aLower; aPtIdx <= anUpper; ++aPtIdx)
{
- const gp_Pnt& aStartPt = theArrayOfPnts->Value (aPtIdx);
- const gp_Pnt& aEndPt = aPtIdx == anUpper ? theArrayOfPnts->Value (aLower) : theArrayOfPnts->Value (aPtIdx + 1);
-
+ const gp_Pnt& aStartPt = theArrayOfPnts.Value (aPtIdx);
+ const gp_Pnt& aEndPt = theArrayOfPnts.Value (aPtIdx == anUpper ? aLower : (aPtIdx + 1));
if (!hasOverlap (aStartPt, aEndPt))
{
return Standard_False;
{
if (theSensType == Select3D_TOS_BOUNDARY)
{
- Handle(TColgp_HArray1OfPnt) aPtsArray = new TColgp_HArray1OfPnt(1, 4);
- aPtsArray->SetValue (1, thePnt1);
- aPtsArray->SetValue (2, thePnt2);
- aPtsArray->SetValue (3, thePnt3);
- return Overlaps (aPtsArray, Select3D_TOS_BOUNDARY, theDepth);
+ const gp_Pnt aPntsArrayBuf[3] = { thePnt1, thePnt2, thePnt3 };
+ const TColgp_Array1OfPnt aPntsArray (aPntsArrayBuf[0], 1, 3);
+ return Overlaps (aPntsArray, Select3D_TOS_BOUNDARY, theDepth);
}
else if (theSensType == Select3D_TOS_INTERIOR)
{
//! SAT intersection test between defined volume and given ordered set of points,
//! representing line segments. The test may be considered of interior part or
//! boundary line defined by segments depending on given sensitivity type
- virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
- Select3D_TypeOfSensitivity theSensType,
- Standard_Real& theDepth) Standard_OVERRIDE;
+ Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
+ Select3D_TypeOfSensitivity theSensType,
+ Standard_Real& theDepth) Standard_OVERRIDE;
//! Checks if line segment overlaps selecting frustum
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
// function : Overlaps
// purpose :
// =======================================================================
-Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
+Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth)
{
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
Standard_Real& theDepth) Standard_OVERRIDE;
- virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts,
- Select3D_TypeOfSensitivity theSensType,
- Standard_Real& theDepth) Standard_OVERRIDE;
+ Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
+ Select3D_TypeOfSensitivity theSensType,
+ Standard_Real& theDepth) Standard_OVERRIDE;
virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
-- computed for the faces which have none. If it is false,
-- sensitive entities on these faces will be calculated.
- preBuildBVH (myclass;
- theSelection : Selection from SelectMgr)
- is private;
+ PreBuildBVH (myclass;
+ theSelection : Selection from SelectMgr);
---Level: Internal
---Purpose: Traverses the selection given and pre-builds BVH trees for heavyweight
-- sensitive entities containing more than BVH_PRIMITIVE_LIMIT (defined in .cxx file)
#define BVH_PRIMITIVE_LIMIT 800000
//==================================================
-// function: preBuildBVH
+// function: PreBuildBVH
// purpose : Pre-builds BVH tree for heavyweight
// sensitive entities with sub-elements
// amount more than BVH_PRIMITIVE_LIMIT
//==================================================
-void StdSelect_BRepSelectionTool::preBuildBVH (const Handle(SelectMgr_Selection)& theSelection)
+void StdSelect_BRepSelectionTool::PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection)
{
for (theSelection->Init(); theSelection->More(); theSelection->Next())
{
anOwner->Set (theSelectableObj);
}
- preBuildBVH (theSelection);
+ PreBuildBVH (theSelection);
}
//==================================================