0027536: Visualization - incorrect behavior of zoom persisted objects
[occt.git] / src / MeshVS / MeshVS_CommonSensitiveEntity.hxx
CommitLineData
114b7bf1 1// Created on: 2016-02-18
2// Created by: Varvara POSKONINA
3// Copyright (c) 2016 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _MeshVS_CommonSensitiveEntity_Header
17#define _MeshVS_CommonSensitiveEntity_Header
18
19#include <MeshVS_DataSource.hxx>
20#include <MeshVS_Mesh.hxx>
21#include <MeshVS_MeshSelectionMethod.hxx>
22#include <Select3D_SensitiveSet.hxx>
23
24//! Sensitive entity covering entire mesh for global selection.
25class MeshVS_CommonSensitiveEntity : public Select3D_SensitiveSet
26{
27public:
28
29 //! Default constructor.
30 Standard_EXPORT MeshVS_CommonSensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwner,
31 const Handle(MeshVS_Mesh)& theParentMesh,
32 const MeshVS_MeshSelectionMethod theSelMethod);
33
34 //! Destructor.
35 Standard_EXPORT virtual ~MeshVS_CommonSensitiveEntity();
36
37 //! Number of elements.
38 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
39
40 //! Returns the amount of sub-entities of the complex entity
41 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
42
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;
45
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;
49
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;
53
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;
57
41e08b4d 58 //! Returns center of a mesh
59 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
60
114b7bf1 61public:
62
63 DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
64
65protected:
66
67 //! Checks whether the entity with index theIdx overlaps the current selecting volume
68 Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
69 Standard_Integer theElemIdx,
70 Standard_Real& theMatchDepth) Standard_OVERRIDE;
71
72 //! Checks whether the entity with index theIdx is inside the current selecting volume
73 Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
74 const Standard_Integer theElemIdx) Standard_OVERRIDE;
75
76 //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
77 Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
78
79private:
80
81 //! Return point for specified index.
82 gp_Pnt getVertexByIndex (const Standard_Integer theNodeIdx) const;
83
84private:
85
86 Handle(MeshVS_DataSource) myDataSource; //!< mesh data source
87 NCollection_Vector<Standard_Integer> myItemIndexes; //!< indices for BVH tree reordering
88 MeshVS_MeshSelectionMethod mySelMethod; //!< selection mode
89 Standard_Integer myMaxFaceNodes; //!< maximum nodes within the element in mesh
90 gp_Pnt myCOG; //!< center of gravity
91 Select3D_BndBox3d myBndBox; //!< bounding box
92
93};
94
95DEFINE_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
96
97#endif // _MeshVS_CommonSensitiveEntity_Header