1 // Created on: 2021-03-04
2 // Created by: Maria KRYLOVA
3 // Copyright (c) 2021 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <Select3D_SensitiveSphere.hxx>
18 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveSphere, Select3D_SensitiveEntity)
20 // ==================================================
21 // Function: Select3D_SensitiveSphere
23 // ==================================================
24 Select3D_SensitiveSphere::Select3D_SensitiveSphere (const Handle(SelectMgr_EntityOwner)& theOwnerId,
25 const gp_Pnt& theCenter,
26 const Standard_Real theRadius)
27 : Select3D_SensitiveEntity (theOwnerId),
29 myLastDetectedPoint (RealLast(), RealLast(), RealLast()),
34 // ==================================================
37 // ==================================================
38 Standard_Boolean Select3D_SensitiveSphere::Matches (SelectBasics_SelectingVolumeManager& theMgr,
39 SelectBasics_PickResult& thePickResult)
41 myLastDetectedPoint = gp_Pnt (RealLast(), RealLast(), RealLast());
42 if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
44 if (!theMgr.IsOverlapAllowed())
46 Standard_Boolean isInside = Standard_True;
47 return theMgr.OverlapsSphere (myCenter, myRadius, &isInside) && isInside;
51 return theMgr.OverlapsSphere (myCenter, myRadius, NULL);
54 if (!theMgr.OverlapsSphere (myCenter, myRadius, thePickResult))
56 return Standard_False;
58 myLastDetectedPoint = thePickResult.PickedPoint();
59 thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (myCenter));
63 // ==================================================
64 // Function: GetConnected
66 // ==================================================
67 Handle(Select3D_SensitiveEntity) Select3D_SensitiveSphere::GetConnected()
69 Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveSphere (myOwnerId, myCenter, myRadius);
73 // ==================================================
74 // Function: BoundingBox
76 // ==================================================
77 Select3D_BndBox3d Select3D_SensitiveSphere::BoundingBox()
79 const SelectMgr_Vec3 aMinPnt = SelectMgr_Vec3 (myCenter.X() - myRadius, myCenter.Y() - myRadius, myCenter.Z() - myRadius);
80 const SelectMgr_Vec3 aMaxPnt = SelectMgr_Vec3 (myCenter.X() + myRadius, myCenter.Y() + myRadius, myCenter.Z() + myRadius);
81 return Select3D_BndBox3d (aMinPnt, aMaxPnt);