f751596e |
1 | // Created on: 2014-11-14 |
2 | // Created by: Varvara POSKONINA |
3 | // Copyright (c) 2005-2014 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 _SelectBasics_PickResult_HeaderFile |
17 | #define _SelectBasics_PickResult_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <NCollection_Vec4.hxx> |
21 | |
17017555 |
22 | //! This structure provides unified access to the results of Matches() method in all sensitive entities, |
23 | //! so that it defines a Depth (distance to the entity along picking ray) and a closest Point on entity. |
f751596e |
24 | struct SelectBasics_PickResult |
25 | { |
26 | public: |
17017555 |
27 | //! Return closest result between two Pick Results according to Depth value. |
28 | static const SelectBasics_PickResult& Min (const SelectBasics_PickResult& thePickResult1, |
29 | const SelectBasics_PickResult& thePickResult2) |
30 | { |
31 | return thePickResult1.Depth() <= thePickResult2.Depth() ? thePickResult1 : thePickResult2; |
32 | } |
f751596e |
33 | |
17017555 |
34 | public: |
35 | //! Empty constructor defining an invalid result. |
f751596e |
36 | SelectBasics_PickResult() |
17017555 |
37 | : myObjPickedPnt (RealLast(), 0.0, 0.0), |
38 | myDepth (RealLast()), |
39 | myDistToCenter (RealLast()) {} |
f751596e |
40 | |
17017555 |
41 | //! Constructor with initialization. |
42 | SelectBasics_PickResult (Standard_Real theDepth, |
43 | Standard_Real theDistToCenter, |
44 | const gp_Pnt& theObjPickedPnt) |
45 | : myObjPickedPnt (theObjPickedPnt), |
46 | myDepth (theDepth), |
f751596e |
47 | myDistToCenter (theDistToCenter) {} |
48 | |
49 | public: |
f751596e |
50 | |
17017555 |
51 | //! Return TRUE if result was been defined. |
52 | Standard_Boolean IsValid() const { return myDepth != RealLast(); } |
53 | |
54 | //! Reset depth value. |
55 | void Invalidate() |
f751596e |
56 | { |
17017555 |
57 | myDepth = RealLast(); |
58 | myObjPickedPnt = gp_Pnt (RealLast(), 0.0, 0.0); |
f751596e |
59 | } |
60 | |
17017555 |
61 | //! Return depth along picking ray. |
62 | Standard_Real Depth() const { return myDepth; } |
63 | |
64 | //! Set depth along picking ray. |
65 | void SetDepth (Standard_Real theDepth) { myDepth = theDepth; } |
66 | |
67 | //! Return TRUE if Picked Point lying on detected entity was set. |
68 | Standard_Boolean HasPickedPoint() const { return myObjPickedPnt.X() != RealLast(); } |
69 | |
70 | //! Return picked point lying on detected entity. |
71 | //! WARNING! Point is defined in local coordinate system and should be translated into World System before usage! |
72 | const gp_Pnt& PickedPoint() const { return myObjPickedPnt; } |
73 | |
74 | //! Set picked point. |
75 | void SetPickedPoint (const gp_Pnt& theObjPickedPnt) { myObjPickedPnt = theObjPickedPnt; } |
76 | |
77 | //! Return distance to geometry center (auxiliary value for comparing results). |
78 | Standard_Real DistToGeomCenter() const { return myDistToCenter; } |
79 | |
80 | //! Set distance to geometry center. |
81 | void SetDistToGeomCenter (Standard_Real theDistToCenter) { myDistToCenter = theDistToCenter; } |
82 | |
f751596e |
83 | private: |
17017555 |
84 | gp_Pnt myObjPickedPnt; //!< User-picked selection point onto object |
85 | Standard_Real myDepth; //!< Depth to detected point |
86 | Standard_Real myDistToCenter; //!< Distance from 3d projection user-picked selection point to entity's geometry center |
f751596e |
87 | }; |
88 | |
89 | #endif // _SelectBasics_PickResult_HeaderFile |