Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2016-02-18
0002 // Created by: Varvara POSKONINA
0003 // Copyright (c) 2016 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 _MeshVS_CommonSensitiveEntity_Header
0017 #define _MeshVS_CommonSensitiveEntity_Header
0018 
0019 #include <MeshVS_DataSource.hxx>
0020 #include <MeshVS_Mesh.hxx>
0021 #include <MeshVS_MeshSelectionMethod.hxx>
0022 #include <Select3D_SensitiveSet.hxx>
0023 
0024 //! Sensitive entity covering entire mesh for global selection.
0025 class MeshVS_CommonSensitiveEntity : public Select3D_SensitiveSet
0026 {
0027   DEFINE_STANDARD_RTTIEXT (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
0028 public:
0029 
0030   //! Default constructor.
0031   Standard_EXPORT MeshVS_CommonSensitiveEntity (const Handle(SelectMgr_EntityOwner)& theOwner,
0032                                                 const Handle(MeshVS_Mesh)& theParentMesh,
0033                                                 const MeshVS_MeshSelectionMethod theSelMethod);
0034 
0035   //! Destructor.
0036   Standard_EXPORT virtual ~MeshVS_CommonSensitiveEntity();
0037 
0038   //! Number of elements.
0039   Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
0040 
0041   //! Returns the amount of sub-entities of the complex entity
0042   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
0043 
0044   //! Returns bounding box of sub-entity with index theIdx in sub-entity list
0045   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
0046 
0047   //! Returns geometry center of sensitive entity index theIdx along the given axis theAxis
0048   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
0049                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
0050 
0051   //! Swaps items with indexes theIdx1 and theIdx2
0052   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
0053                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
0054 
0055   //! Returns bounding box of the triangulation. If location
0056   //! transformation is set, it will be applied
0057   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
0058 
0059   //! Returns center of a mesh
0060   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
0061 
0062   //! Create a copy.
0063   virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE { return new MeshVS_CommonSensitiveEntity (*this); }
0064 
0065 protected:
0066 
0067   //! Checks whether the entity with index theIdx overlaps the current selecting volume
0068   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
0069                                                             SelectBasics_SelectingVolumeManager& theMgr,
0070                                                             Standard_Integer theElemIdx,
0071                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
0072 
0073   //! Checks whether the entity with index theIdx is inside the current selecting volume
0074   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
0075                                                             Standard_Integer theElemIdx,
0076                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
0077 
0078   //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
0079   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
0080 
0081   //! Protected copy constructor.
0082   Standard_EXPORT MeshVS_CommonSensitiveEntity (const MeshVS_CommonSensitiveEntity& theOther);
0083 
0084 private:
0085 
0086   //! Return point for specified index.
0087   gp_Pnt getVertexByIndex (const Standard_Integer theNodeIdx) const;
0088 
0089 private:
0090 
0091   Handle(MeshVS_DataSource)            myDataSource;   //!< mesh data source
0092   NCollection_Vector<Standard_Integer> myItemIndexes;  //!< indices for BVH tree reordering
0093   MeshVS_MeshSelectionMethod           mySelMethod;    //!< selection mode
0094   Standard_Integer                     myMaxFaceNodes; //!< maximum nodes within the element in mesh
0095   gp_Pnt                               myCOG;          //!< center of gravity
0096   Select3D_BndBox3d                    myBndBox;       //!< bounding box
0097 
0098 };
0099 
0100 DEFINE_STANDARD_HANDLE (MeshVS_CommonSensitiveEntity, Select3D_SensitiveSet)
0101 
0102 #endif // _MeshVS_CommonSensitiveEntity_Header