Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:58:41

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   //! Default constructor.
0030   Standard_EXPORT MeshVS_CommonSensitiveEntity(const occ::handle<SelectMgr_EntityOwner>& theOwner,
0031                                                const occ::handle<MeshVS_Mesh>&  theParentMesh,
0032                                                const MeshVS_MeshSelectionMethod theSelMethod);
0033 
0034   //! Destructor.
0035   Standard_EXPORT ~MeshVS_CommonSensitiveEntity() override;
0036 
0037   //! Number of elements.
0038   Standard_EXPORT int NbSubElements() const override;
0039 
0040   //! Returns the amount of sub-entities of the complex entity
0041   Standard_EXPORT int Size() const override;
0042 
0043   //! Returns bounding box of sub-entity with index theIdx in sub-entity list
0044   Standard_EXPORT Select3D_BndBox3d Box(const int theIdx) const override;
0045 
0046   //! Returns geometry center of sensitive entity index theIdx along the given axis theAxis
0047   Standard_EXPORT double Center(const int theIdx, const int theAxis) const override;
0048 
0049   //! Swaps items with indexes theIdx1 and theIdx2
0050   Standard_EXPORT void Swap(const int theIdx1, const int theIdx2) override;
0051 
0052   //! Returns bounding box of the triangulation. If location
0053   //! transformation is set, it will be applied
0054   Standard_EXPORT Select3D_BndBox3d BoundingBox() override;
0055 
0056   //! Returns center of a mesh
0057   Standard_EXPORT gp_Pnt CenterOfGeometry() const override;
0058 
0059   //! Create a copy.
0060   occ::handle<Select3D_SensitiveEntity> GetConnected() override
0061   {
0062     return new MeshVS_CommonSensitiveEntity(*this);
0063   }
0064 
0065 protected:
0066   //! Checks whether the entity with index theIdx overlaps the current selecting volume
0067   Standard_EXPORT bool overlapsElement(SelectBasics_PickResult&             thePickResult,
0068                                        SelectBasics_SelectingVolumeManager& theMgr,
0069                                        int                                  theElemIdx,
0070                                        bool theIsFullInside) override;
0071 
0072   //! Checks whether the entity with index theIdx is inside the current selecting volume
0073   Standard_EXPORT bool elementIsInside(SelectBasics_SelectingVolumeManager& theMgr,
0074                                        int                                  theElemIdx,
0075                                        bool theIsFullInside) override;
0076 
0077   //! Calculates distance from the 3d projection of used-picked screen point to center of the
0078   //! geometry
0079   Standard_EXPORT double distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr) override;
0080 
0081   //! Protected copy constructor.
0082   Standard_EXPORT MeshVS_CommonSensitiveEntity(const MeshVS_CommonSensitiveEntity& theOther);
0083 
0084 private:
0085   //! Return point for specified index.
0086   gp_Pnt getVertexByIndex(const int theNodeIdx) const;
0087 
0088 private:
0089   occ::handle<MeshVS_DataSource> myDataSource;  //!< mesh data source
0090   NCollection_DynamicArray<int>  myItemIndexes; //!< indices for BVH tree reordering
0091   MeshVS_MeshSelectionMethod     mySelMethod;   //!< selection mode
0092                                                 // clang-format off
0093   int                     myMaxFaceNodes; //!< maximum nodes within the element in mesh
0094                                                 // clang-format on
0095   gp_Pnt            myCOG;                      //!< center of gravity
0096   Select3D_BndBox3d myBndBox;                   //!< bounding box
0097 };
0098 
0099 #endif // _MeshVS_CommonSensitiveEntity_Header