]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_SensitivePoint.cpp
Salome HOME
Porting on SALOME 7.6.0
[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 <Bnd_Box2d.hxx>
11 #include <CSLib_Class2d.hxx>
12 #include <ElCLib.hxx>
13 #include <TopLoc_Location.hxx>
14
15 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
16 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SensitivePoint, Select3D_SensitiveEntity);
17
18 SketcherPrs_SensitivePoint::SketcherPrs_SensitivePoint(const Handle(SelectBasics_EntityOwner)& anOwner,
19                                                         const Handle(Graphic3d_ArrayOfPoints)& thePntArray, 
20                                                         int theId)
21 :Select3D_SensitiveEntity(anOwner), myId(theId), myPntArray(thePntArray)
22 {
23   SetSensitivityFactor(12.);
24 }
25
26 Standard_Boolean SketcherPrs_SensitivePoint::Matches (SelectBasics_SelectingVolumeManager& theMgr,
27                                                    SelectBasics_PickResult& thePickResult)
28 {
29   Standard_Real aDepth      = RealLast();
30   Standard_Real aDistToCOG  = RealLast();
31   gp_Pnt aPnt = myPntArray->Vertice(myId);
32   if (!theMgr.Overlaps (aPnt, aDepth))
33   {
34     thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
35     return Standard_False;
36   }
37
38   aDistToCOG = aDepth;
39   thePickResult = SelectBasics_PickResult (aDepth, aDistToCOG);
40   return Standard_True;
41 }
42
43 gp_Pnt SketcherPrs_SensitivePoint::Point() const
44 {
45   return myPntArray->Vertice(myId);
46 }
47
48 Handle(Select3D_SensitiveEntity) SketcherPrs_SensitivePoint::GetConnected()
49 {
50   Handle(SketcherPrs_SensitivePoint) aNewEntity = new SketcherPrs_SensitivePoint (myOwnerId, myPntArray, myId);
51   return aNewEntity;
52 }
53
54 gp_Pnt SketcherPrs_SensitivePoint::CenterOfGeometry() const
55 {
56   return Point();
57 }
58
59 Select3D_BndBox3d SketcherPrs_SensitivePoint::BoundingBox()
60 {
61   gp_Pnt aPnt = myPntArray->Vertice(myId);
62   return Select3D_BndBox3d (SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()),
63                             SelectMgr_Vec3 (aPnt.X(), aPnt.Y(), aPnt.Z()));
64 }
65
66 Standard_Integer SketcherPrs_SensitivePoint::NbSubElements()
67 {
68   return 1;
69 }