Back to home page

EIC code displayed by LXR

 
 

    


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

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