f751596e |
1 | // Created on: 1996-10-17 |
2 | // Created by: Odile OLIVIER |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Select3D_SensitiveWire_HeaderFile |
18 | #define _Select3D_SensitiveWire_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
ec357c5c |
21 | #include <Standard_Type.hxx> |
f751596e |
22 | #include <Standard_Type.hxx> |
23 | |
24 | #include <Select3D_SensitiveSet.hxx> |
f751596e |
25 | #include <Standard_OStream.hxx> |
26 | #include <NCollection_Sequence.hxx> |
27 | |
28 | class SelectBasics_EntityOwner; |
29 | class TopLoc_Location; |
30 | class Select3D_SensitiveEntitySequence; |
31 | |
32 | |
33 | //! A framework to define selection of a wire owner by an |
34 | //! elastic wire band. |
35 | class Select3D_SensitiveWire : public Select3D_SensitiveSet |
36 | { |
37 | public: |
38 | |
39 | //! Constructs a sensitive wire object defined by the |
40 | //! owner theOwnerId |
41 | Standard_EXPORT Select3D_SensitiveWire (const Handle(SelectBasics_EntityOwner)& theOwnerId); |
42 | |
43 | //! Adds the sensitive entity theSensitive to this framework. |
44 | Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive); |
45 | |
46 | //! Returns the amount of sub-entities |
47 | Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE; |
48 | |
49 | Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE; |
50 | |
51 | //! returns the sensitive edges stored in this wire |
52 | Standard_EXPORT const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& GetEdges(); |
53 | |
54 | //! Sets the owner for all entities in wire |
79104795 |
55 | Standard_EXPORT void Set (const Handle(SelectBasics_EntityOwner)& theOwnerId) Standard_OVERRIDE; |
f751596e |
56 | |
35c0599a |
57 | Standard_EXPORT Handle(Select3D_SensitiveEntity) GetLastDetected() const; |
f751596e |
58 | |
59 | //! Returns bounding box of the wire. If location |
60 | //! transformation is set, it will be applied |
61 | Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; |
62 | |
63 | //! Returns center of the wire. If location transformation |
64 | //! is set, it will be applied |
65 | Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE; |
66 | |
67 | //! Returns the length of vector of sensitive entities |
68 | Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE; |
69 | |
70 | //! Returns bounding box of sensitive entity with index theIdx |
71 | Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE; |
72 | |
73 | //! Returns geometry center of sensitive entity index theIdx in |
74 | //! the vector along the given axis theAxis |
75 | Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx, |
76 | const Standard_Integer theAxis) const Standard_OVERRIDE; |
77 | |
78 | //! Swaps items with indexes theIdx1 and theIdx2 in the vector |
79 | Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1, |
80 | const Standard_Integer theIdx2) Standard_OVERRIDE; |
81 | |
ec357c5c |
82 | DEFINE_STANDARD_RTTI(Select3D_SensitiveWire, Select3D_SensitiveSet) |
f751596e |
83 | |
84 | protected: |
85 | |
86 | //! Checks whether the entity with index theIdx overlaps the current selecting volume |
87 | Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, |
88 | Standard_Integer theElemIdx, |
89 | Standard_Real& theMatchDepth) Standard_OVERRIDE; |
90 | |
2157d6ac |
91 | //! Checks whether the entity with index theIdx is inside the current selecting volume |
92 | Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, |
93 | const Standard_Integer theElemIdx) Standard_OVERRIDE; |
94 | |
f751596e |
95 | //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry |
96 | Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; |
97 | |
98 | private: |
99 | |
100 | NCollection_Vector<Handle(Select3D_SensitiveEntity)> myEntities; //!< Vector of sub-entities |
101 | NCollection_Vector<Standard_Integer> myEntityIndexes; //!< Indexes of entities for BVH build |
102 | gp_Pnt myCenter; //!< Center of the whole wire |
103 | mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the whole wire |
104 | }; |
105 | |
106 | DEFINE_STANDARD_HANDLE(Select3D_SensitiveWire, Select3D_SensitiveEntity) |
107 | |
108 | #endif // _Select3D_SensitiveWire_HeaderFile |