0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / MeshVS / MeshVS_CommonSensitiveEntity.hxx
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.
25 class MeshVS_CommonSensitiveEntity : public Select3D_SensitiveSet
26 {
27   DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
28 public:
29
30   //! Default constructor.
31   Standard_EXPORT MeshVS_CommonSensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwner,
32                                                 const Handle(MeshVS_Mesh)& theParentMesh,
33                                                 const MeshVS_MeshSelectionMethod theSelMethod);
34
35   //! Destructor.
36   Standard_EXPORT virtual ~MeshVS_CommonSensitiveEntity();
37
38   //! Number of elements.
39   Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
40
41   //! Returns the amount of sub-entities of the complex entity
42   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
43
44   //! Returns bounding box of sub-entity with index theIdx in sub-entity list
45   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
46
47   //! Returns geometry center of sensitive entity index theIdx along the given axis theAxis
48   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
49                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
50
51   //! Swaps items with indexes theIdx1 and theIdx2
52   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
53                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
54
55   //! Returns bounding box of the triangulation. If location
56   //! transformation is set, it will be applied
57   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
58
59   //! Returns center of a mesh
60   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
61
62   //! Create a copy.
63   virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE { return new MeshVS_CommonSensitiveEntity (*this); }
64
65 protected:
66
67   //! Checks whether the entity with index theIdx overlaps the current selecting volume
68   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
69                                                             SelectBasics_SelectingVolumeManager& theMgr,
70                                                             Standard_Integer theElemIdx,
71                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
72
73   //! Checks whether the entity with index theIdx is inside the current selecting volume
74   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
75                                                             Standard_Integer theElemIdx,
76                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
77
78   //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
79   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
80
81   //! Protected copy constructor.
82   Standard_EXPORT MeshVS_CommonSensitiveEntity (const MeshVS_CommonSensitiveEntity& theOther);
83
84 private:
85
86   //! Return point for specified index.
87   gp_Pnt getVertexByIndex (const Standard_Integer theNodeIdx) const;
88
89 private:
90
91   Handle(MeshVS_DataSource)            myDataSource;   //!< mesh data source
92   NCollection_Vector<Standard_Integer> myItemIndexes;  //!< indices for BVH tree reordering
93   MeshVS_MeshSelectionMethod           mySelMethod;    //!< selection mode
94   Standard_Integer                     myMaxFaceNodes; //!< maximum nodes within the element in mesh
95   gp_Pnt                               myCOG;          //!< center of gravity
96   Select3D_BndBox3d                    myBndBox;       //!< bounding box
97
98 };
99
100 DEFINE_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
101
102 #endif // _MeshVS_CommonSensitiveEntity_Header