| 1 | // Created on: 2003-10-10 |
| 2 | // Created by: Alexander SOLOVYOV |
| 3 | // Copyright (c) 2003-2014 OPEN CASCADE SAS |
| 4 | // |
| 5 | // This file is part of Open CASCADE Technology software library. |
| 6 | // |
| 7 | // This library is free software; you can redistribute it and/or modify it under |
| 8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 9 | // by the Free Software Foundation, with special exception defined in the file |
| 10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 11 | // distribution for complete text of the license and disclaimer of any warranty. |
| 12 | // |
| 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 14 | // commercial license or contractual agreement. |
| 15 | |
| 16 | #ifndef _MeshVS_Mesh_HeaderFile |
| 17 | #define _MeshVS_Mesh_HeaderFile |
| 18 | |
| 19 | #include <Standard.hxx> |
| 20 | #include <Standard_Type.hxx> |
| 21 | |
| 22 | #include <MeshVS_SequenceOfPrsBuilder.hxx> |
| 23 | #include <MeshVS_DataMapOfIntegerOwner.hxx> |
| 24 | #include <MeshVS_MeshSelectionMethod.hxx> |
| 25 | #include <AIS_InteractiveObject.hxx> |
| 26 | #include <Standard_Boolean.hxx> |
| 27 | #include <PrsMgr_PresentationManager3d.hxx> |
| 28 | #include <Standard_Integer.hxx> |
| 29 | #include <SelectMgr_Selection.hxx> |
| 30 | #include <SelectMgr_SequenceOfOwner.hxx> |
| 31 | #include <Quantity_NameOfColor.hxx> |
| 32 | #include <Standard_CString.hxx> |
| 33 | class MeshVS_PrsBuilder; |
| 34 | class TColStd_HPackedMapOfInteger; |
| 35 | class MeshVS_DataSource; |
| 36 | class MeshVS_Drawer; |
| 37 | class SelectMgr_EntityOwner; |
| 38 | class Prs3d_Presentation; |
| 39 | |
| 40 | |
| 41 | class MeshVS_Mesh; |
| 42 | DEFINE_STANDARD_HANDLE(MeshVS_Mesh, AIS_InteractiveObject) |
| 43 | |
| 44 | //! the main class provides interface to create mesh presentation as a whole |
| 45 | class MeshVS_Mesh : public AIS_InteractiveObject |
| 46 | { |
| 47 | |
| 48 | public: |
| 49 | |
| 50 | |
| 51 | //! Constructor. |
| 52 | //! theIsAllowOverlapped is Standard_True, if it is allowed to draw edges overlapped with beams |
| 53 | //! Its value is stored in drawer |
| 54 | Standard_EXPORT MeshVS_Mesh(const Standard_Boolean theIsAllowOverlapped = Standard_False); |
| 55 | |
| 56 | //! Computes presentation using builders added to sequence. Each builder computes |
| 57 | //! own part of mesh presentation according to its type. |
| 58 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& PM, const Handle(Prs3d_Presentation)& Prs, const Standard_Integer DisplayMode) Standard_OVERRIDE; |
| 59 | |
| 60 | //! Computes selection according to SelectMode |
| 61 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& Sel, const Standard_Integer SelectMode) Standard_OVERRIDE; |
| 62 | |
| 63 | //! Draw selected owners presentation |
| 64 | Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Owners) Standard_OVERRIDE; |
| 65 | |
| 66 | //! Draw hilighted owner presentation |
| 67 | Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, |
| 68 | const Handle(Prs3d_Drawer)& theColor, |
| 69 | const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE; |
| 70 | |
| 71 | //! Clears internal selection presentation |
| 72 | Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE; |
| 73 | |
| 74 | //! How many builders there are in sequence |
| 75 | Standard_EXPORT Standard_Integer GetBuildersCount() const; |
| 76 | |
| 77 | //! Returns builder by its index in sequence |
| 78 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilder (const Standard_Integer Index) const; |
| 79 | |
| 80 | //! Returns builder by its ID |
| 81 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilderById (const Standard_Integer Id) const; |
| 82 | |
| 83 | //! Returns the smallest positive ID, not occupied by any builder. |
| 84 | //! This method using when builder is created with ID = -1 |
| 85 | Standard_EXPORT Standard_Integer GetFreeId() const; |
| 86 | |
| 87 | //! Adds builder to tale of sequence. |
| 88 | //! PrsBuilder is builder to be added |
| 89 | //! If TreatAsHilighter is true, MeshVS_Mesh will use this builder to create |
| 90 | //! presentation of hilighted and selected owners. |
| 91 | //! Only one builder can be hilighter, so that if you call this method with |
| 92 | //! TreatAsHilighter = Standard_True some times, only last builder will be hilighter |
| 93 | //! WARNING: As minimum one builder must be added as hilighter, otherwise selection cannot be computed |
| 94 | Standard_EXPORT void AddBuilder (const Handle(MeshVS_PrsBuilder)& Builder, const Standard_Boolean TreatAsHilighter = Standard_False); |
| 95 | |
| 96 | //! Changes hilighter ( see above ) |
| 97 | Standard_EXPORT void SetHilighter (const Handle(MeshVS_PrsBuilder)& Builder); |
| 98 | |
| 99 | //! Sets builder with sequence index "Index" as hilighter |
| 100 | Standard_EXPORT Standard_Boolean SetHilighter (const Standard_Integer Index); |
| 101 | |
| 102 | //! Sets builder with identificator "Id" as hilighter |
| 103 | Standard_EXPORT Standard_Boolean SetHilighterById (const Standard_Integer Id); |
| 104 | |
| 105 | //! Returns hilighter |
| 106 | Standard_EXPORT Handle(MeshVS_PrsBuilder) GetHilighter() const; |
| 107 | |
| 108 | //! Removes builder from sequence. If it is hilighter, hilighter will be NULL |
| 109 | //! ( Don't remember to set it to other after!!! ) |
| 110 | Standard_EXPORT void RemoveBuilder (const Standard_Integer Index); |
| 111 | |
| 112 | //! Removes builder with identificator Id |
| 113 | Standard_EXPORT void RemoveBuilderById (const Standard_Integer Id); |
| 114 | |
| 115 | //! Finds builder by its type the string represents |
| 116 | Standard_EXPORT Handle(MeshVS_PrsBuilder) FindBuilder (const Standard_CString TypeString) const; |
| 117 | |
| 118 | //! Returns map of owners. |
| 119 | Standard_EXPORT const MeshVS_DataMapOfIntegerOwner& GetOwnerMaps (const Standard_Boolean IsElement); |
| 120 | |
| 121 | //! Returns default builders' data source |
| 122 | Standard_EXPORT Handle(MeshVS_DataSource) GetDataSource() const; |
| 123 | |
| 124 | //! Sets default builders' data source |
| 125 | Standard_EXPORT void SetDataSource (const Handle(MeshVS_DataSource)& aDataSource); |
| 126 | |
| 127 | //! Returns default builders' drawer |
| 128 | Standard_EXPORT Handle(MeshVS_Drawer) GetDrawer() const; |
| 129 | |
| 130 | //! Sets default builders' drawer |
| 131 | Standard_EXPORT void SetDrawer (const Handle(MeshVS_Drawer)& aDrawer); |
| 132 | |
| 133 | //! Returns True if specified element is hidden |
| 134 | //! By default no elements are hidden |
| 135 | Standard_EXPORT Standard_Boolean IsHiddenElem (const Standard_Integer ID) const; |
| 136 | |
| 137 | //! Returns True if specified node is hidden. |
| 138 | //! By default all nodes are hidden |
| 139 | Standard_EXPORT Standard_Boolean IsHiddenNode (const Standard_Integer ID) const; |
| 140 | |
| 141 | //! Returns True if specified element is not hidden |
| 142 | Standard_EXPORT Standard_Boolean IsSelectableElem (const Standard_Integer ID) const; |
| 143 | |
| 144 | //! Returns True if specified node is specified as selectable. |
| 145 | Standard_EXPORT Standard_Boolean IsSelectableNode (const Standard_Integer ID) const; |
| 146 | |
| 147 | //! Returns map of hidden nodes (may be null handle) |
| 148 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenNodes() const; |
| 149 | |
| 150 | //! Sets map of hidden nodes, which shall not be displayed individually. |
| 151 | //! If nodes shared by some elements shall not be drawn, |
| 152 | //! they should be included into that map |
| 153 | Standard_EXPORT void SetHiddenNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
| 154 | |
| 155 | //! Returns map of hidden elements (may be null handle) |
| 156 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenElems() const; |
| 157 | |
| 158 | //! Sets map of hidden elements |
| 159 | Standard_EXPORT void SetHiddenElems (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
| 160 | |
| 161 | //! Returns map of selectable elements (may be null handle) |
| 162 | Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetSelectableNodes() const; |
| 163 | |
| 164 | //! Sets map of selectable nodes. |
| 165 | Standard_EXPORT void SetSelectableNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids); |
| 166 | |
| 167 | //! Automatically computes selectable nodes; the node is considered |
| 168 | //! as being selectable if it is either not hidden, or is hidden |
| 169 | //! but referred by at least one non-hidden element. |
| 170 | //! Thus all nodes that are visible (either individually, or as ends or |
| 171 | //! corners of elements) are selectable by default. |
| 172 | Standard_EXPORT void UpdateSelectableNodes(); |
| 173 | |
| 174 | //! Returns set mesh selection method (see MeshVS.cdl) |
| 175 | Standard_EXPORT MeshVS_MeshSelectionMethod GetMeshSelMethod() const; |
| 176 | |
| 177 | //! Sets mesh selection method (see MeshVS.cdl) |
| 178 | Standard_EXPORT void SetMeshSelMethod (const MeshVS_MeshSelectionMethod M); |
| 179 | |
| 180 | //! Returns True if the given owner represents a whole mesh. |
| 181 | Standard_EXPORT virtual Standard_Boolean IsWholeMeshOwner (const Handle(SelectMgr_EntityOwner)& theOwner) const; |
| 182 | |
| 183 | friend class MeshVS_PrsBuilder; |
| 184 | |
| 185 | |
| 186 | DEFINE_STANDARD_RTTIEXT(MeshVS_Mesh,AIS_InteractiveObject) |
| 187 | |
| 188 | protected: |
| 189 | |
| 190 | //! Stores all vertices that belong to one of the faces to the given map |
| 191 | //! @param theAllElements [in] the map of all mesh elements |
| 192 | //! @param theNbMaxFaceNodes [in] the maximum amount of nodes per face, retrieved from drawer |
| 193 | //! @param theSharedNodes [out] the result map of all vertices that belong to one face at least |
| 194 | Standard_EXPORT void scanFacesForSharedNodes (const TColStd_PackedMapOfInteger& theAllElements, |
| 195 | const Standard_Integer theNbMaxFaceNodes, |
| 196 | TColStd_PackedMapOfInteger& theSharedNodes) const; |
| 197 | |
| 198 | protected: |
| 199 | |
| 200 | |
| 201 | MeshVS_DataMapOfIntegerOwner myNodeOwners; |
| 202 | MeshVS_DataMapOfIntegerOwner myElementOwners; |
| 203 | MeshVS_DataMapOfIntegerOwner my0DOwners; |
| 204 | MeshVS_DataMapOfIntegerOwner myLinkOwners; |
| 205 | MeshVS_DataMapOfIntegerOwner myFaceOwners; |
| 206 | MeshVS_DataMapOfIntegerOwner myVolumeOwners; |
| 207 | MeshVS_DataMapOfIntegerOwner myGroupOwners; |
| 208 | MeshVS_DataMapOfIntegerOwner myMeshOwners; |
| 209 | Handle(MeshVS_Drawer) myCurrentDrawer; |
| 210 | Handle(MeshVS_Drawer) mySelectionDrawer; |
| 211 | Handle(MeshVS_Drawer) myHilightDrawer; |
| 212 | Handle(SelectMgr_EntityOwner) myWholeMeshOwner; |
| 213 | |
| 214 | |
| 215 | private: |
| 216 | |
| 217 | |
| 218 | MeshVS_SequenceOfPrsBuilder myBuilders; |
| 219 | Handle(MeshVS_PrsBuilder) myHilighter; |
| 220 | Handle(TColStd_HPackedMapOfInteger) myHiddenElements; |
| 221 | Handle(TColStd_HPackedMapOfInteger) myHiddenNodes; |
| 222 | Handle(TColStd_HPackedMapOfInteger) mySelectableNodes; |
| 223 | Handle(MeshVS_DataSource) myDataSource; |
| 224 | MeshVS_MeshSelectionMethod mySelectionMethod; |
| 225 | |
| 226 | |
| 227 | }; |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | |
| 234 | |
| 235 | #endif // _MeshVS_Mesh_HeaderFile |