Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-17 08:36:09

0001 // Created on: 1996-10-17
0002 // Created by: Odile OLIVIER
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Select3D_SensitiveWire_HeaderFile
0018 #define _Select3D_SensitiveWire_HeaderFile
0019 
0020 #include <Select3D_SensitiveSet.hxx>
0021 
0022 //! A framework to define selection of a wire owner by an
0023 //! elastic wire band.
0024 class Select3D_SensitiveWire : public Select3D_SensitiveSet
0025 {
0026 public:
0027   //! Constructs a sensitive wire object defined by the
0028   //! owner theOwnerId
0029   Standard_EXPORT Select3D_SensitiveWire(const Handle(SelectMgr_EntityOwner)& theOwnerId);
0030 
0031   //! Adds the sensitive entity theSensitive to this framework.
0032   Standard_EXPORT void Add(const Handle(Select3D_SensitiveEntity)& theSensitive);
0033 
0034   //! Returns the amount of sub-entities
0035   Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
0036 
0037   Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
0038 
0039   //! returns the sensitive edges stored in this wire
0040   Standard_EXPORT const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& GetEdges();
0041 
0042   //! Sets the owner for all entities in wire
0043   Standard_EXPORT virtual void Set(const Handle(SelectMgr_EntityOwner)& theOwnerId)
0044     Standard_OVERRIDE;
0045 
0046   Standard_EXPORT Handle(Select3D_SensitiveEntity) GetLastDetected() const;
0047 
0048   //! Returns bounding box of the wire. If location
0049   //! transformation is set, it will be applied
0050   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
0051 
0052   //! Returns center of the wire. If location transformation
0053   //! is set, it will be applied
0054   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
0055 
0056   //! Returns the length of vector of sensitive entities
0057   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
0058 
0059   //! Returns bounding box of sensitive entity with index theIdx
0060   Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
0061     Standard_OVERRIDE;
0062 
0063   //! Returns geometry center of sensitive entity index theIdx in
0064   //! the vector along the given axis theAxis
0065   Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
0066                                                const Standard_Integer theAxis) const
0067     Standard_OVERRIDE;
0068 
0069   //! Swaps items with indexes theIdx1 and theIdx2 in the vector
0070   Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
0071                                     const Standard_Integer theIdx2) Standard_OVERRIDE;
0072 
0073   //! Dumps the content of me into the stream
0074   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0075                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0076 
0077   DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveWire, Select3D_SensitiveSet)
0078 
0079 protected:
0080   //! Checks whether the entity with index theIdx overlaps the current selecting volume
0081   Standard_EXPORT virtual Standard_Boolean overlapsElement(
0082     SelectBasics_PickResult&             thePickResult,
0083     SelectBasics_SelectingVolumeManager& theMgr,
0084     Standard_Integer                     theElemIdx,
0085     Standard_Boolean                     theIsFullInside) Standard_OVERRIDE;
0086 
0087   //! Checks whether the entity with index theIdx is inside the current selecting volume
0088   Standard_EXPORT virtual Standard_Boolean elementIsInside(
0089     SelectBasics_SelectingVolumeManager& theMgr,
0090     Standard_Integer                     theElemIdx,
0091     Standard_Boolean                     theIsFullInside) Standard_OVERRIDE;
0092 
0093   //! Calculates distance from the 3d projection of used-picked screen point to center of the
0094   //! geometry
0095   Standard_EXPORT virtual Standard_Real distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
0096     Standard_OVERRIDE;
0097 
0098 private:
0099   // clang-format off
0100   NCollection_Vector<Handle(Select3D_SensitiveEntity)> myEntities;          //!< Vector of sub-entities
0101   NCollection_Vector<Standard_Integer>                 myEntityIndexes;     //!< Indexes of entities for BVH build
0102   gp_Pnt                                               myCenter;            //!< Center of the whole wire
0103   mutable Select3D_BndBox3d                            myBndBox;            //!< Bounding box of the whole wire
0104   // clang-format on
0105 };
0106 
0107 DEFINE_STANDARD_HANDLE(Select3D_SensitiveWire, Select3D_SensitiveEntity)
0108 
0109 #endif // _Select3D_SensitiveWire_HeaderFile