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