0030682: Configuration, qmake - all warnings are suppressed on macOS target
[occt.git] / src / MeshVS / MeshVS_Mesh.hxx
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   //! Constructor.
51   //! theIsAllowOverlapped is Standard_True, if it is allowed to draw edges overlapped with beams
52   //! Its value is stored in drawer
53   Standard_EXPORT MeshVS_Mesh(const Standard_Boolean theIsAllowOverlapped = Standard_False);
54
55   //! Returns true for supported display modes basing on a list of defined builders.
56   Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE;
57
58   //! Computes presentation using builders added to sequence. Each builder computes
59   //! own part of mesh presentation according to its type.
60   Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& PM, const Handle(Prs3d_Presentation)& Prs, const Standard_Integer DisplayMode) Standard_OVERRIDE;
61   
62   //! Computes selection according to SelectMode
63   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& Sel, const Standard_Integer SelectMode) Standard_OVERRIDE;
64   
65   //! Draw selected owners presentation
66   Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& PM, const SelectMgr_SequenceOfOwner& Owners) Standard_OVERRIDE;
67   
68   //! Draw hilighted owner presentation
69   Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
70                                                       const Handle(Prs3d_Drawer)& theColor,
71                                                       const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
72   
73   //! Clears internal selection presentation
74   Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
75   
76   //! How many builders there are in sequence
77   Standard_EXPORT Standard_Integer GetBuildersCount() const;
78   
79   //! Returns builder by its index in sequence
80   Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilder (const Standard_Integer Index) const;
81   
82   //! Returns builder by its ID
83   Standard_EXPORT Handle(MeshVS_PrsBuilder) GetBuilderById (const Standard_Integer Id) const;
84   
85   //! Returns the smallest positive ID, not occupied by any builder.
86   //! This method using when builder is created with ID = -1
87   Standard_EXPORT Standard_Integer GetFreeId() const;
88   
89   //! Adds builder to tale of sequence.
90   //! PrsBuilder is builder to be added
91   //! If TreatAsHilighter is true, MeshVS_Mesh will use this builder to create
92   //! presentation of hilighted and selected owners.
93   //! Only one builder can be hilighter, so that if you call this method with
94   //! TreatAsHilighter = Standard_True some times, only last builder will be hilighter
95   //! WARNING: As minimum one builder must be added as hilighter, otherwise selection cannot be computed
96   Standard_EXPORT void AddBuilder (const Handle(MeshVS_PrsBuilder)& Builder, const Standard_Boolean TreatAsHilighter = Standard_False);
97   
98   //! Changes hilighter ( see above )
99   Standard_EXPORT void SetHilighter (const Handle(MeshVS_PrsBuilder)& Builder);
100   
101   //! Sets builder with sequence index "Index" as hilighter
102   Standard_EXPORT Standard_Boolean SetHilighter (const Standard_Integer Index);
103   
104   //! Sets builder with identificator "Id" as hilighter
105   Standard_EXPORT Standard_Boolean SetHilighterById (const Standard_Integer Id);
106   
107   //! Returns hilighter
108   Standard_EXPORT Handle(MeshVS_PrsBuilder) GetHilighter() const;
109   
110   //! Removes builder from sequence. If it is hilighter, hilighter will be NULL
111   //! ( Don't remember to set it to other after!!! )
112   Standard_EXPORT void RemoveBuilder (const Standard_Integer Index);
113   
114   //! Removes builder with identificator Id
115   Standard_EXPORT void RemoveBuilderById (const Standard_Integer Id);
116   
117   //! Finds builder by its type the string represents
118   Standard_EXPORT Handle(MeshVS_PrsBuilder) FindBuilder (const Standard_CString TypeString) const;
119   
120   //! Returns map of owners.
121   Standard_EXPORT const MeshVS_DataMapOfIntegerOwner& GetOwnerMaps (const Standard_Boolean IsElement);
122   
123   //! Returns default builders' data source
124   Standard_EXPORT Handle(MeshVS_DataSource) GetDataSource() const;
125   
126   //! Sets default builders' data source
127   Standard_EXPORT void SetDataSource (const Handle(MeshVS_DataSource)& aDataSource);
128   
129   //! Returns default builders' drawer
130   Standard_EXPORT Handle(MeshVS_Drawer) GetDrawer() const;
131   
132   //! Sets default builders' drawer
133   Standard_EXPORT void SetDrawer (const Handle(MeshVS_Drawer)& aDrawer);
134   
135   //! Returns True if specified element is hidden
136   //! By default no elements are hidden
137   Standard_EXPORT Standard_Boolean IsHiddenElem (const Standard_Integer ID) const;
138   
139   //! Returns True if specified node is hidden.
140   //! By default all nodes are hidden
141   Standard_EXPORT Standard_Boolean IsHiddenNode (const Standard_Integer ID) const;
142   
143   //! Returns True if specified element is not hidden
144   Standard_EXPORT Standard_Boolean IsSelectableElem (const Standard_Integer ID) const;
145   
146   //! Returns True if specified node is specified as selectable.
147   Standard_EXPORT Standard_Boolean IsSelectableNode (const Standard_Integer ID) const;
148   
149   //! Returns map of hidden nodes (may be null handle)
150   Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenNodes() const;
151   
152   //! Sets map of hidden nodes, which shall not be displayed individually.
153   //! If nodes shared by some elements shall not be drawn,
154   //! they should be included into that map
155   Standard_EXPORT void SetHiddenNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids);
156   
157   //! Returns map of hidden elements (may be null handle)
158   Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetHiddenElems() const;
159   
160   //! Sets map of hidden elements
161   Standard_EXPORT void SetHiddenElems (const Handle(TColStd_HPackedMapOfInteger)& Ids);
162   
163   //! Returns map of selectable elements (may be null handle)
164   Standard_EXPORT const Handle(TColStd_HPackedMapOfInteger)& GetSelectableNodes() const;
165   
166   //! Sets map of selectable nodes.
167   Standard_EXPORT void SetSelectableNodes (const Handle(TColStd_HPackedMapOfInteger)& Ids);
168   
169   //! Automatically computes selectable nodes; the node is considered
170   //! as being selectable if it is either not hidden, or is hidden
171   //! but referred by at least one non-hidden element.
172   //! Thus all nodes that are visible (either individually, or as ends or
173   //! corners of elements) are selectable by default.
174   Standard_EXPORT void UpdateSelectableNodes();
175   
176   //! Returns set mesh selection method (see MeshVS.cdl)
177   Standard_EXPORT MeshVS_MeshSelectionMethod GetMeshSelMethod() const;
178   
179   //! Sets mesh selection method (see MeshVS.cdl)
180   Standard_EXPORT void SetMeshSelMethod (const MeshVS_MeshSelectionMethod M);
181   
182   //! Returns True if the given owner represents a whole mesh.
183   Standard_EXPORT virtual Standard_Boolean IsWholeMeshOwner (const Handle(SelectMgr_EntityOwner)& theOwner) const;
184
185 friend class MeshVS_PrsBuilder;
186
187
188   DEFINE_STANDARD_RTTIEXT(MeshVS_Mesh,AIS_InteractiveObject)
189
190 protected:
191
192   //! Stores all vertices that belong to one of the faces to the given map
193   //! @param theAllElements [in] the map of all mesh elements
194   //! @param theNbMaxFaceNodes [in] the maximum amount of nodes per face, retrieved from drawer
195   //! @param theSharedNodes [out] the result map of all vertices that belong to one face at least
196   Standard_EXPORT void scanFacesForSharedNodes (const TColStd_PackedMapOfInteger& theAllElements,
197                                                 const Standard_Integer theNbMaxFaceNodes,
198                                                 TColStd_PackedMapOfInteger& theSharedNodes) const;
199
200 protected:
201
202
203   MeshVS_DataMapOfIntegerOwner myNodeOwners;
204   MeshVS_DataMapOfIntegerOwner myElementOwners;
205   MeshVS_DataMapOfIntegerOwner my0DOwners;
206   MeshVS_DataMapOfIntegerOwner myLinkOwners;
207   MeshVS_DataMapOfIntegerOwner myFaceOwners;
208   MeshVS_DataMapOfIntegerOwner myVolumeOwners;
209   MeshVS_DataMapOfIntegerOwner myGroupOwners;
210   MeshVS_DataMapOfIntegerOwner myMeshOwners;
211   Handle(MeshVS_Drawer) myCurrentDrawer;
212   Handle(MeshVS_Drawer) mySelectionDrawer;
213   Handle(MeshVS_Drawer) myHilightDrawer;
214   Handle(SelectMgr_EntityOwner) myWholeMeshOwner;
215
216
217 private:
218
219
220   MeshVS_SequenceOfPrsBuilder myBuilders;
221   Handle(MeshVS_PrsBuilder) myHilighter;
222   Handle(TColStd_HPackedMapOfInteger) myHiddenElements;
223   Handle(TColStd_HPackedMapOfInteger) myHiddenNodes;
224   Handle(TColStd_HPackedMapOfInteger) mySelectableNodes;
225   Handle(MeshVS_DataSource) myDataSource;
226   MeshVS_MeshSelectionMethod mySelectionMethod;
227
228
229 };
230
231
232
233
234
235
236
237 #endif // _MeshVS_Mesh_HeaderFile