0024623: Visualization - improve selection mechanism
[occt.git] / src / Select3D / Select3D_SensitiveTriangle.hxx
1 // Created on: 1997-05-14
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-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_SensitiveTriangle_HeaderFile
18 #define _Select3D_SensitiveTriangle_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineHandle.hxx>
22 #include <Standard_Type.hxx>
23
24 #include <Select3D_TypeOfSensitivity.hxx>
25 #include <Select3D_Pnt.hxx>
26 #include <Select3D_SensitivePoly.hxx>
27 #include <Handle_SelectBasics_EntityOwner.hxx>
28 #include <SelectMgr_SelectingVolumeManager.hxx>
29 #include <Standard_OStream.hxx>
30
31 class Standard_ConstructionError;
32 class Standard_OutOfRange;
33 class SelectBasics_EntityOwner;
34 class gp_Pnt;
35 class TColgp_Array1OfPnt2d;
36 class Select3D_SensitiveEntity;
37 class TopLoc_Location;
38
39
40 //! A framework to define selection of triangles in a view.
41 //! This comes into play in the detection of meshing and triangulation in surfaces.
42 //! In some cases this class can raise Standard_ConstructionError and
43 //! Standard_OutOfRange exceptions. For more details see Select3D_SensitivePoly.
44 class Select3D_SensitiveTriangle : public Select3D_SensitivePoly
45 {
46 public:
47
48   //! Constructs a sensitive triangle object defined by the
49   //! owner theOwnerId, the points P1, P2, P3, and the type of sensitivity Sensitivity.
50   Standard_EXPORT Select3D_SensitiveTriangle (const Handle(SelectBasics_EntityOwner)& theOwnerId,
51                                               const gp_Pnt& thePnt0,
52                                               const gp_Pnt& thePnt1,
53                                               const gp_Pnt& thePnt2,
54                                               const Select3D_TypeOfSensitivity theType = Select3D_TOS_INTERIOR);
55
56   //! Checks whether the triangle overlaps current selecting volume
57   Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
58                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
59
60   //! Returns the 3D points P1, P2, P3 used at the time of construction.
61   Standard_EXPORT void Points3D (gp_Pnt& thePnt0, gp_Pnt& thePnt1, gp_Pnt& thePnt2) const;
62
63   //! Returns the center point of the sensitive triangle created at construction time.
64   Standard_EXPORT gp_Pnt Center3D() const;
65
66   //! Returns the copy of this
67   Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
68
69   //! Returns bounding box of the triangle. If location transformation is set, it
70   //! will be applied
71   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
72
73   //! Returns the amount of points
74   Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
75
76   DEFINE_STANDARD_RTTI(Select3D_SensitiveTriangle)
77
78 private:
79
80   Select3D_TypeOfSensitivity mySensType;     //!< Type of sensitivity: boundary or interior
81   gp_Pnt                     myCentroid;     //!< Center of triangle
82 };
83
84 DEFINE_STANDARD_HANDLE(Select3D_SensitiveTriangle, Select3D_SensitiveEntity)
85
86 #endif