Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:18:52

0001 // Created on: 2021-03-04
0002 // Created by: Maria KRYLOVA
0003 // Copyright (c) 2021 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Select3D_SensitiveSphere_HeaderFile
0017 #define _Select3D_SensitiveSphere_HeaderFile
0018 
0019 #include <Select3D_SensitiveEntity.hxx>
0020 
0021 //! A framework to define selection by a sensitive sphere.
0022 class Select3D_SensitiveSphere : public Select3D_SensitiveEntity
0023 {
0024   DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveSphere, Select3D_SensitiveEntity)
0025 public:
0026   //! Constructs a sensitive sphere object defined by the owner theOwnerId,
0027   //! the center of the sphere and it's radius.
0028   Standard_EXPORT Select3D_SensitiveSphere(const occ::handle<SelectMgr_EntityOwner>& theOwnerId,
0029                                            const gp_Pnt&                             theCenter,
0030                                            const double                              theRadius);
0031 
0032   //! Returns the radius of the sphere
0033   double Radius() const { return myRadius; }
0034 
0035 public:
0036   //! Checks whether the sphere overlaps current selecting volume
0037   Standard_EXPORT bool Matches(SelectBasics_SelectingVolumeManager& theMgr,
0038                                SelectBasics_PickResult&             thePickResult) override;
0039 
0040   //! Returns the copy of this
0041   Standard_EXPORT occ::handle<Select3D_SensitiveEntity> GetConnected() override;
0042 
0043   //! Returns bounding box of the sphere.
0044   //! If location transformation is set, it will be applied
0045   Standard_EXPORT Select3D_BndBox3d BoundingBox() override;
0046 
0047   //! Always returns false
0048   bool ToBuildBVH() const override { return false; }
0049 
0050   //! Returns the amount of points
0051   int NbSubElements() const override { return 1; }
0052 
0053   //! Returns center of the sphere with transformation applied
0054   gp_Pnt CenterOfGeometry() const override { return myCenter; };
0055 
0056   //! Returns the position of detected point on the sphere.
0057   const gp_Pnt& LastDetectedPoint() const { return myLastDetectedPoint; }
0058 
0059   //! Invalidate the position of detected point on the sphere.
0060   void ResetLastDetectedPoint()
0061   {
0062     myLastDetectedPoint = gp_Pnt(RealLast(), RealLast(), RealLast());
0063   }
0064 
0065 protected:
0066   gp_Pnt myCenter;
0067   gp_Pnt myLastDetectedPoint;
0068   double myRadius;
0069 };
0070 
0071 #endif // _Select3D_SensitiveSphere_HeaderFile