Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 08:36:31

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