Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-03 10:55:49

0001 // Created on: 2003-10-10
0002 // Created by: Alexander SOLOVYOV
0003 // Copyright (c) 2003-2014 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_Mesh_HeaderFile
0017 #define _MeshVS_Mesh_HeaderFile
0018 
0019 #include <MeshVS_PrsBuilder.hxx>
0020 #include <NCollection_Sequence.hxx>
0021 #include <Standard_Integer.hxx>
0022 #include <SelectMgr_EntityOwner.hxx>
0023 #include <NCollection_DataMap.hxx>
0024 #include <MeshVS_MeshSelectionMethod.hxx>
0025 #include <AIS_InteractiveObject.hxx>
0026 
0027 class MeshVS_PrsBuilder;
0028 class TColStd_HPackedMapOfInteger;
0029 class MeshVS_DataSource;
0030 class MeshVS_Drawer;
0031 class SelectMgr_EntityOwner;
0032 
0033 //! the main class provides interface to create mesh presentation as a whole
0034 class MeshVS_Mesh : public AIS_InteractiveObject
0035 {
0036 
0037 public:
0038   //! Constructor.
0039   //! theIsAllowOverlapped is true, if it is allowed to draw edges overlapped with beams
0040   //! Its value is stored in drawer
0041   Standard_EXPORT MeshVS_Mesh(const bool theIsAllowOverlapped = false);
0042 
0043   //! Returns true for supported display modes basing on a list of defined builders.
0044   Standard_EXPORT bool AcceptDisplayMode(const int theMode) const override;
0045 
0046   //! Computes presentation using builders added to sequence. Each builder computes
0047   //! own part of mesh presentation according to its type.
0048   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0049                                const occ::handle<Prs3d_Presentation>&         thePrs,
0050                                const int                                      theDispMode) override;
0051 
0052   //! Computes selection according to SelectMode
0053   Standard_EXPORT void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSel,
0054                                         const int theSelMode) override;
0055 
0056   //! Draw selected owners presentation
0057   Standard_EXPORT void HilightSelected(
0058     const occ::handle<PrsMgr_PresentationManager>&                  thePrsMgr,
0059     const NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>& theOwners) override;
0060 
0061   //! Draw hilighted owner presentation
0062   Standard_EXPORT void HilightOwnerWithColor(
0063     const occ::handle<PrsMgr_PresentationManager>& thePM,
0064     const occ::handle<Prs3d_Drawer>&               theColor,
0065     const occ::handle<SelectMgr_EntityOwner>&      theOwner) override;
0066 
0067   //! Clears internal selection presentation
0068   Standard_EXPORT void ClearSelected() override;
0069 
0070   //! How many builders there are in sequence
0071   Standard_EXPORT int GetBuildersCount() const;
0072 
0073   //! Returns builder by its index in sequence
0074   Standard_EXPORT occ::handle<MeshVS_PrsBuilder> GetBuilder(const int Index) const;
0075 
0076   //! Returns builder by its ID
0077   Standard_EXPORT occ::handle<MeshVS_PrsBuilder> GetBuilderById(const int Id) const;
0078 
0079   //! Returns the smallest positive ID, not occupied by any builder.
0080   //! This method using when builder is created with ID = -1
0081   Standard_EXPORT int GetFreeId() const;
0082 
0083   //! Adds builder to tale of sequence.
0084   //! PrsBuilder is builder to be added
0085   //! If TreatAsHilighter is true, MeshVS_Mesh will use this builder to create
0086   //! presentation of hilighted and selected owners.
0087   //! Only one builder can be hilighter, so that if you call this method with
0088   //! TreatAsHilighter = true some times, only last builder will be hilighter
0089   //! WARNING: As minimum one builder must be added as hilighter, otherwise selection cannot be
0090   //! computed
0091   Standard_EXPORT void AddBuilder(const occ::handle<MeshVS_PrsBuilder>& Builder,
0092                                   const bool                            TreatAsHilighter = false);
0093 
0094   //! Changes hilighter ( see above )
0095   Standard_EXPORT void SetHilighter(const occ::handle<MeshVS_PrsBuilder>& Builder);
0096 
0097   //! Sets builder with sequence index "Index" as hilighter
0098   Standard_EXPORT bool SetHilighter(const int Index);
0099 
0100   //! Sets builder with identificator "Id" as hilighter
0101   Standard_EXPORT bool SetHilighterById(const int Id);
0102 
0103   //! Returns hilighter
0104   Standard_EXPORT occ::handle<MeshVS_PrsBuilder> GetHilighter() const;
0105 
0106   //! Removes builder from sequence. If it is hilighter, hilighter will be NULL
0107   //! ( Don't remember to set it to other after!!! )
0108   Standard_EXPORT void RemoveBuilder(const int Index);
0109 
0110   //! Removes builder with identificator Id
0111   Standard_EXPORT void RemoveBuilderById(const int Id);
0112 
0113   //! Finds builder by its type the string represents
0114   Standard_DEPRECATED("This method will be removed right after 7.9 release. \
0115 Use FindBuilder(const occ::handle<Standard_Type>&) instead \
0116 or directly iterate under sequence of builders.")
0117   Standard_EXPORT occ::handle<MeshVS_PrsBuilder> FindBuilder(const char* const TypeString) const;
0118 
0119   //! Finds builder by its type the type represents
0120   Standard_EXPORT occ::handle<MeshVS_PrsBuilder> FindBuilder(
0121     const occ::handle<Standard_Type>& TypeString) const;
0122 
0123   //! Returns map of owners.
0124   Standard_EXPORT const NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>>& GetOwnerMaps(
0125     const bool IsElement);
0126 
0127   //! Returns default builders' data source
0128   Standard_EXPORT occ::handle<MeshVS_DataSource> GetDataSource() const;
0129 
0130   //! Sets default builders' data source
0131   Standard_EXPORT void SetDataSource(const occ::handle<MeshVS_DataSource>& aDataSource);
0132 
0133   //! Returns default builders' drawer
0134   Standard_EXPORT occ::handle<MeshVS_Drawer> GetDrawer() const;
0135 
0136   //! Sets default builders' drawer
0137   Standard_EXPORT void SetDrawer(const occ::handle<MeshVS_Drawer>& aDrawer);
0138 
0139   //! Returns True if specified element is hidden
0140   //! By default no elements are hidden
0141   Standard_EXPORT bool IsHiddenElem(const int ID) const;
0142 
0143   //! Returns True if specified node is hidden.
0144   //! By default all nodes are hidden
0145   Standard_EXPORT bool IsHiddenNode(const int ID) const;
0146 
0147   //! Returns True if specified element is not hidden
0148   Standard_EXPORT bool IsSelectableElem(const int ID) const;
0149 
0150   //! Returns True if specified node is specified as selectable.
0151   Standard_EXPORT bool IsSelectableNode(const int ID) const;
0152 
0153   //! Returns map of hidden nodes (may be null handle)
0154   Standard_EXPORT const occ::handle<TColStd_HPackedMapOfInteger>& GetHiddenNodes() const;
0155 
0156   //! Sets map of hidden nodes, which shall not be displayed individually.
0157   //! If nodes shared by some elements shall not be drawn,
0158   //! they should be included into that map
0159   Standard_EXPORT void SetHiddenNodes(const occ::handle<TColStd_HPackedMapOfInteger>& Ids);
0160 
0161   //! Returns map of hidden elements (may be null handle)
0162   Standard_EXPORT const occ::handle<TColStd_HPackedMapOfInteger>& GetHiddenElems() const;
0163 
0164   //! Sets map of hidden elements
0165   Standard_EXPORT void SetHiddenElems(const occ::handle<TColStd_HPackedMapOfInteger>& Ids);
0166 
0167   //! Returns map of selectable elements (may be null handle)
0168   Standard_EXPORT const occ::handle<TColStd_HPackedMapOfInteger>& GetSelectableNodes() const;
0169 
0170   //! Sets map of selectable nodes.
0171   Standard_EXPORT void SetSelectableNodes(const occ::handle<TColStd_HPackedMapOfInteger>& Ids);
0172 
0173   //! Automatically computes selectable nodes; the node is considered
0174   //! as being selectable if it is either not hidden, or is hidden
0175   //! but referred by at least one non-hidden element.
0176   //! Thus all nodes that are visible (either individually, or as ends or
0177   //! corners of elements) are selectable by default.
0178   Standard_EXPORT void UpdateSelectableNodes();
0179 
0180   //! Returns set mesh selection method (see MeshVS.cdl)
0181   Standard_EXPORT MeshVS_MeshSelectionMethod GetMeshSelMethod() const;
0182 
0183   //! Sets mesh selection method (see MeshVS.cdl)
0184   Standard_EXPORT void SetMeshSelMethod(const MeshVS_MeshSelectionMethod M);
0185 
0186   //! Returns True if the given owner represents a whole mesh.
0187   Standard_EXPORT virtual bool IsWholeMeshOwner(
0188     const occ::handle<SelectMgr_EntityOwner>& theOwner) const;
0189 
0190   friend class MeshVS_PrsBuilder;
0191 
0192   DEFINE_STANDARD_RTTIEXT(MeshVS_Mesh, AIS_InteractiveObject)
0193 
0194 protected:
0195   //! Stores all vertices that belong to one of the faces to the given map
0196   //! @param[in] theAllElements  the map of all mesh elements
0197   //! @param[in] theNbMaxFaceNodes  the maximum amount of nodes per face, retrieved from drawer
0198   //! @param[out] theSharedNodes  the result map of all vertices that belong to one face at least
0199   Standard_EXPORT void scanFacesForSharedNodes(const TColStd_PackedMapOfInteger& theAllElements,
0200                                                const int                         theNbMaxFaceNodes,
0201                                                TColStd_PackedMapOfInteger& theSharedNodes) const;
0202 
0203 protected:
0204   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myNodeOwners;
0205   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myElementOwners;
0206   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> my0DOwners;
0207   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myLinkOwners;
0208   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myFaceOwners;
0209   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myVolumeOwners;
0210   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myGroupOwners;
0211   NCollection_DataMap<int, occ::handle<SelectMgr_EntityOwner>> myMeshOwners;
0212   occ::handle<MeshVS_Drawer>                                   myCurrentDrawer;
0213   occ::handle<MeshVS_Drawer>                                   mySelectionDrawer;
0214   occ::handle<MeshVS_Drawer>                                   myHilightDrawer;
0215   occ::handle<SelectMgr_EntityOwner>                           myWholeMeshOwner;
0216 
0217 private:
0218   NCollection_Sequence<occ::handle<MeshVS_PrsBuilder>> myBuilders;
0219   occ::handle<MeshVS_PrsBuilder>                       myHilighter;
0220   occ::handle<TColStd_HPackedMapOfInteger>             myHiddenElements;
0221   occ::handle<TColStd_HPackedMapOfInteger>             myHiddenNodes;
0222   occ::handle<TColStd_HPackedMapOfInteger>             mySelectableNodes;
0223   occ::handle<MeshVS_DataSource>                       myDataSource;
0224   MeshVS_MeshSelectionMethod                           mySelectionMethod;
0225 };
0226 
0227 #endif // _MeshVS_Mesh_HeaderFile