f751596e |
1 | // Created on: 1995-03-13 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1995-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_SensitiveEntity_HeaderFile |
18 | #define _Select3D_SensitiveEntity_HeaderFile |
19 | |
0ef04197 |
20 | #include <gp_GTrsf.hxx> |
21 | #include <gp_Trsf.hxx> |
22 | #include <Standard_Assert.hxx> |
23 | #include <Standard_Transient.hxx> |
24 | #include <Select3D_BndBox3d.hxx> |
25 | #include <SelectBasics_SelectingVolumeManager.hxx> |
26 | #include <SelectBasics_PickResult.hxx> |
f751596e |
27 | #include <SelectBasics_SensitiveEntity.hxx> |
f751596e |
28 | #include <SelectMgr_SelectingVolumeManager.hxx> |
f751596e |
29 | #include <TopLoc_Location.hxx> |
30 | |
0ef04197 |
31 | class SelectMgr_EntityOwner; |
f751596e |
32 | |
0ef04197 |
33 | //! Abstract framework to define 3D sensitive entities. |
34 | class Select3D_SensitiveEntity : public Standard_Transient |
f751596e |
35 | { |
0ef04197 |
36 | DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveEntity, Standard_Transient) |
f751596e |
37 | public: |
38 | |
0ef04197 |
39 | //! Returns pointer to owner of the entity |
40 | const Handle(SelectMgr_EntityOwner)& OwnerId() const { return myOwnerId; } |
41 | |
42 | //! Sets owner of the entity |
43 | virtual void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId) |
44 | { |
45 | myOwnerId = theOwnerId; |
46 | } |
47 | |
48 | //! allows a better sensitivity for a specific entity in selection algorithms useful for small sized entities. |
49 | Standard_Integer SensitivityFactor() const { return mySFactor; } |
50 | |
51 | //! Allows to manage sensitivity of a particular sensitive entity |
52 | void SetSensitivityFactor (const Standard_Integer theNewSens) |
53 | { |
54 | Standard_ASSERT_RAISE (theNewSens > 0, "Error! Selection sensitivity have positive value."); |
55 | mySFactor = theNewSens; |
56 | } |
57 | |
58 | //! Originally this method intended to return sensitive entity with new location aLocation, |
59 | //! but currently sensitive entities do not hold a location, |
60 | //! instead HasLocation() and Location() methods call corresponding entity owner's methods. |
61 | //! Thus all entities returned by GetConnected() share the same location propagated from corresponding selectable object. |
62 | //! You must redefine this function for any type of sensitive entity which can accept another connected sensitive entity. |
63 | virtual Handle(Select3D_SensitiveEntity) GetConnected() { return Handle(Select3D_SensitiveEntity)(); } |
f751596e |
64 | |
65 | //! Checks whether sensitive overlaps current selecting volume. |
0ef04197 |
66 | //! Stores minimum depth, distance to center of geometry and closest point detected into thePickResult |
67 | virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, |
68 | SelectBasics_PickResult& thePickResult) = 0; |
69 | |
70 | //! Returns the number of sub-entities or elements in sensitive entity. |
71 | //! Is used to determine if entity is complex and needs to pre-build BVH at the creation of sensitive entity step |
72 | //! or is light-weighted so the tree can be build on demand with unnoticeable delay. |
fe758dbe |
73 | virtual Standard_Integer NbSubElements() const = 0; |
f751596e |
74 | |
75 | //! Returns bounding box of a sensitive with transformation applied |
0ef04197 |
76 | virtual Select3D_BndBox3d BoundingBox() = 0; |
f751596e |
77 | |
78 | //! Returns center of a sensitive with transformation applied |
79 | virtual gp_Pnt CenterOfGeometry() const = 0; |
80 | |
81 | //! Builds BVH tree for a sensitive if needed |
0ef04197 |
82 | virtual void BVH() {} |
f751596e |
83 | |
84 | //! Clears up all resources and memory |
0ef04197 |
85 | virtual void Clear() { Set (Handle(SelectMgr_EntityOwner)()); } |
f751596e |
86 | |
3bf9a45f |
87 | //! Returns true if the shape corresponding to the entity has init location |
0ef04197 |
88 | virtual Standard_Boolean HasInitLocation() const { return Standard_False; } |
3bf9a45f |
89 | |
0ef04197 |
90 | //! Returns inversed location transformation matrix if the shape corresponding to this entity has init location set. |
91 | //! Otherwise, returns identity matrix. |
92 | virtual gp_GTrsf InvInitLocation() const { return gp_GTrsf(); } |
3bf9a45f |
93 | |
bc73b006 |
94 | //! Dumps the content of me into the stream |
95 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; |
96 | |
0ef04197 |
97 | protected: |
98 | |
99 | Standard_EXPORT Select3D_SensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwnerId); |
f751596e |
100 | |
101 | protected: |
102 | |
0ef04197 |
103 | Handle(SelectMgr_EntityOwner) myOwnerId; |
104 | Standard_Integer mySFactor; |
105 | |
f751596e |
106 | }; |
107 | |
0ef04197 |
108 | DEFINE_STANDARD_HANDLE(Select3D_SensitiveEntity, Standard_Transient) |
109 | |
110 | // for porting old code |
111 | typedef Select3D_SensitiveEntity SelectBasics_SensitiveEntity; |
f751596e |
112 | |
113 | #endif // _Select3D_SensitiveEntity_HeaderFile |