1 // Created on: 2016-02-18
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2016 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _MeshVS_CommonSensitiveEntity_Header
17 #define _MeshVS_CommonSensitiveEntity_Header
19 #include <MeshVS_DataSource.hxx>
20 #include <MeshVS_Mesh.hxx>
21 #include <MeshVS_MeshSelectionMethod.hxx>
22 #include <Select3D_SensitiveSet.hxx>
24 //! Sensitive entity covering entire mesh for global selection.
25 class MeshVS_CommonSensitiveEntity : public Select3D_SensitiveSet
29 //! Default constructor.
30 Standard_EXPORT MeshVS_CommonSensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwner,
31 const Handle(MeshVS_Mesh)& theParentMesh,
32 const MeshVS_MeshSelectionMethod theSelMethod);
35 Standard_EXPORT virtual ~MeshVS_CommonSensitiveEntity();
37 //! Number of elements.
38 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
40 //! Returns the amount of sub-entities of the complex entity
41 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
43 //! Returns bounding box of sub-entity with index theIdx in sub-entity list
44 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
46 //! Returns geometry center of sensitive entity index theIdx along the given axis theAxis
47 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
48 const Standard_Integer theAxis) const Standard_OVERRIDE;
50 //! Swaps items with indexes theIdx1 and theIdx2
51 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
52 const Standard_Integer theIdx2) Standard_OVERRIDE;
54 //! Returns bounding box of the triangulation. If location
55 //! transformation is set, it will be applied
56 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
60 DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
64 //! Checks whether the entity with index theIdx overlaps the current selecting volume
65 Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
66 Standard_Integer theElemIdx,
67 Standard_Real& theMatchDepth) Standard_OVERRIDE;
69 //! Checks whether the entity with index theIdx is inside the current selecting volume
70 Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
71 const Standard_Integer theElemIdx) Standard_OVERRIDE;
73 //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
74 Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
78 //! Return point for specified index.
79 gp_Pnt getVertexByIndex (const Standard_Integer theNodeIdx) const;
83 Handle(MeshVS_DataSource) myDataSource; //!< mesh data source
84 NCollection_Vector<Standard_Integer> myItemIndexes; //!< indices for BVH tree reordering
85 MeshVS_MeshSelectionMethod mySelMethod; //!< selection mode
86 Standard_Integer myMaxFaceNodes; //!< maximum nodes within the element in mesh
87 gp_Pnt myCOG; //!< center of gravity
88 Select3D_BndBox3d myBndBox; //!< bounding box
92 DEFINE_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
94 #endif // _MeshVS_CommonSensitiveEntity_Header