Salome HOME
Issue #604 Creation of an unexpected line in the Sketcher
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SensitivePoint.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_SensitivePoint.cpp
4 // Created:     24 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7
8 #include "SketcherPrs_SensitivePoint.h"
9
10 #include <Graphic3d_ArrayOfPoints.hxx>
11 #include "SketcherPrs_SymbolPrs.h"
12
13 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
14 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
15
16 SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner,
17                                                        int theId)
18 :Select3D_SensitiveEntity(anOwner), myId(theId)
19 {
20   SetSensitivityFactor(12.);
21 }
22
23 Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
24                                                    SelectBasics_PickResult& thePickResult)
25 {
26   Standard_Real aDepth      = RealLast();
27   Standard_Real aDistToCOG  = RealLast();
28   gp_Pnt aPnt = Point();
29   if (!theMgr.Overlaps (aPnt, aDepth))
30   {
31     thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
32     return Standard_False;
33   }
34
35   aDistToCOG = aDepth;
36   thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
37   return Standard_True;
38 }
39
40 gp_Pnt SketcherPrs_SensitivePoint::Point() const
41 {
42   const Handle(SelectMgr_EntityOwner)& anOwner =
43     Handle(SelectMgr_EntityOwner)::DownCast(OwnerId());
44   const Handle(SketcherPrs_SymbolPrs)& aSymbPrs =
45     Handle(SketcherPrs_SymbolPrs)::DownCast(anOwner->Selectable());
46   return aSymbPrs->pointsArray()->Vertice(myId);
47 }
48
49 Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected()
50 {
51   Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myId);
52   return aNewEntity;
53 }
54
55 gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const
56 {
57   return Point();
58 }
59
60 Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox()
61 {
62   gp_Pnt aPnt = Point();
63   return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()),
64                             SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()));
65 }
66
67 Standard_Integer SketcherPrs_SensitivePoint::NbSubElements()
68 {
69   return 1;
70 }
71
72 void SketcherPrs_SensitivePoint::Clear()
73 {
74   return;
75 }