Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:53

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 
0028   //! Constructs a sensitive wire object defined by the
0029   //! owner theOwnerId
0030   Standard_EXPORT Select3D_SensitiveWire (const Handle(SelectMgr_EntityOwner)& theOwnerId);
0031 
0032   //! Adds the sensitive entity theSensitive to this framework.
0033   Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
0034 
0035   //! Returns the amount of sub-entities
0036   Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
0037 
0038   Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
0039 
0040   //! returns the sensitive edges stored in this wire
0041   Standard_EXPORT const NCollection_Vector<Handle(Select3D_SensitiveEntity)>& GetEdges();
0042 
0043   //! Sets the owner for all entities in wire
0044   Standard_EXPORT virtual void Set (const Handle(SelectMgr_EntityOwner)& theOwnerId) 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 Standard_OVERRIDE;
0061 
0062   //! Returns geometry center of sensitive entity index theIdx in
0063   //! the vector along the given axis theAxis
0064   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
0065                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
0066 
0067   //! Swaps items with indexes theIdx1 and theIdx2 in the vector
0068   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
0069                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
0070 
0071   //! Dumps the content of me into the stream
0072   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0073 
0074   DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveWire,Select3D_SensitiveSet)
0075 
0076 protected:
0077 
0078   //! Checks whether the entity with index theIdx overlaps the current selecting volume
0079   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
0080                                                             SelectBasics_SelectingVolumeManager& theMgr,
0081                                                             Standard_Integer theElemIdx,
0082                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
0083 
0084   //! Checks whether the entity with index theIdx is inside the current selecting volume
0085   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
0086                                                             Standard_Integer theElemIdx,
0087                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
0088 
0089   //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
0090   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
0091 
0092 private:
0093 
0094   NCollection_Vector<Handle(Select3D_SensitiveEntity)> myEntities;          //!< Vector of sub-entities
0095   NCollection_Vector<Standard_Integer>                 myEntityIndexes;     //!< Indexes of entities for BVH build
0096   gp_Pnt                                               myCenter;            //!< Center of the whole wire
0097   mutable Select3D_BndBox3d                            myBndBox;            //!< Bounding box of the whole wire
0098 };
0099 
0100 DEFINE_STANDARD_HANDLE(Select3D_SensitiveWire, Select3D_SensitiveEntity)
0101 
0102 #endif // _Select3D_SensitiveWire_HeaderFile