42cf5bc1 |
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_DataSource_HeaderFile |
17 | #define _MeshVS_DataSource_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
25e59720 |
22 | #include <Standard_Transient.hxx> |
42cf5bc1 |
23 | #include <Standard_Boolean.hxx> |
24 | #include <Standard_Integer.hxx> |
25 | #include <TColStd_Array1OfReal.hxx> |
26 | #include <MeshVS_EntityType.hxx> |
27 | #include <MeshVS_HArray1OfSequenceOfInteger.hxx> |
28 | #include <Standard_Address.hxx> |
29 | #include <TColStd_Array1OfInteger.hxx> |
30 | #include <TColStd_PackedMapOfInteger.hxx> |
31 | #include <Standard_Real.hxx> |
32 | #include <TColStd_HArray1OfReal.hxx> |
33 | #include <TColgp_Array1OfPnt2d.hxx> |
34 | class Bnd_Box; |
35 | class MeshVS_Mesh; |
36 | class TColStd_HPackedMapOfInteger; |
37 | class Bnd_Box2d; |
38 | |
39 | |
40 | class MeshVS_DataSource; |
25e59720 |
41 | DEFINE_STANDARD_HANDLE(MeshVS_DataSource, Standard_Transient) |
42cf5bc1 |
42 | |
43 | //! The deferred class using for the following tasks: |
44 | //! 1) Receiving geometry data about single element of node by its number; |
45 | //! 2) Receiving type of element or node by its number; |
46 | //! 3) Receiving topological information about links between element and nodes it consist of; |
47 | //! 4) Receiving information about what element cover this node; |
48 | //! 5) Receiving information about all nodes and elements the object consist of |
49 | //! 6) Activation of advanced mesh selection. In the advanced mesh selection mode there is created: |
50 | //! - one owner for the whole mesh and for all selection modes |
51 | //! - one sensitive entity for the whole mesh and for each selection mode |
52 | //! Receiving of IDs of detected entities (nodes and elements) in a viewer is achieved by |
53 | //! implementation of a group of methods GetDetectedEntities. |
25e59720 |
54 | class MeshVS_DataSource : public Standard_Transient |
42cf5bc1 |
55 | { |
56 | |
57 | public: |
58 | |
59 | |
60 | //! Returns geometry information about node or element |
61 | //! ID is the numerical identificator of node or element |
62 | //! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True ) |
63 | //! Coords is an array of co-ordinates of node(s). |
64 | //! For node it is only 3 numbers: X, Y, Z in the strict order |
65 | //! For element it is 3*n numbers, where n is number of this element vertices |
66 | //! The order is strict also: X1, Y1, Z1, X2,...., where Xi, Yi, Zi are co-ordinates of vertices |
67 | //! NbNodes is number of nodes. It is recommended this parameter to be set to 1 for node. |
68 | //! Type is type of node or element (from enumeration). It is recommended this parameter to be set to |
69 | //! MeshVS_ET_Node for node. |
70 | Standard_EXPORT virtual Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const = 0; |
71 | |
72 | //! This method is similar to GetGeom, but returns only element or node type. |
73 | Standard_EXPORT virtual Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const = 0; |
74 | |
75 | //! This method returns topology information about 3D-element |
76 | //! Returns false if element with ID isn't 3D or because other troubles |
77 | Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer ID, Standard_Integer& NbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& Data) const; |
78 | |
79 | //! This method returns pointer which represents element or node data structure. |
80 | //! This address will be saved in MeshVS_MeshEntityOwner, so that you can access to data structure fast |
81 | //! by the method Owner(). In the redefined method you can return NULL. |
82 | //! ID is the numerical identificator of node or element |
83 | //! IsElement indicates this ID describe node ( if Standard_False ) or element ( if Standard_True ) |
84 | Standard_EXPORT virtual Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const = 0; |
85 | |
86 | //! This method returns information about nodes this element consist of. |
87 | //! ID is the numerical identificator of element. |
88 | //! NodeIDs is the output array of nodes IDs in correct order, |
89 | //! the same as coordinates returned by GetGeom(). |
90 | //! NbNodes is number of nodes (number of items set in NodeIDs). |
91 | //! Returns False if element does not exist |
92 | Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const = 0; |
93 | |
94 | //! This method returns map of all nodes the object consist of. |
95 | Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllNodes() const = 0; |
96 | |
97 | //! This method returns map of all elements the object consist of. |
98 | Standard_EXPORT virtual const TColStd_PackedMapOfInteger& GetAllElements() const = 0; |
99 | |
100 | //! This method calculates normal of face, which is using for correct reflection presentation. |
101 | //! There is default method, for advance reflection this method can be redefined. |
102 | //! Id is the numerical identificator of only element! |
103 | //! Max is maximal number of nodes an element can consist of |
104 | //! nx, ny, nz are values whose represent co-ordinates of normal (will be returned) |
105 | //! In the redefined method you can return normal with length more then 1, but in this case |
106 | //! the appearance of element will be more bright than usual. For ordinary brightness you must return |
107 | //! normal with length 1 |
108 | Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const; |
109 | |
110 | //! This method return normal of node ranknode of face Id, |
111 | //! which is using for smooth shading presentation. |
112 | //! Returns false if normal isn't defined. |
113 | Standard_EXPORT virtual Standard_Boolean GetNodeNormal (const Standard_Integer ranknode, const Standard_Integer ElementId, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const; |
114 | |
115 | //! This method puts components of normal vectors at each node of a mesh face (at each face of a mesh volume) |
116 | //! into the output array. |
117 | //! Returns false if some problem was detected during calculation of normals. |
118 | //! Id is an identifier of the mesh element. |
119 | //! IsNodal, when true, means that normals at mesh element nodes are needed. If nodal normals |
120 | //! are not available, or IsNodal is false, or the mesh element is a volume, then the output array contents |
121 | //! depend on the element type: |
122 | //! face: a normal calculated by GetNormal() is duplicated for each node of the face; |
123 | //! volume: normals to all faces of the volume are computed (not for each node!). |
124 | //! MaxNodes is maximal number of nodes an element can consist of. |
125 | //! Normals contains the result. |
126 | Standard_EXPORT virtual Standard_Boolean GetNormalsByElement (const Standard_Integer Id, const Standard_Boolean IsNodal, const Standard_Integer MaxNodes, Handle(TColStd_HArray1OfReal)& Normals) const; |
127 | |
128 | //! This method returns map of all groups the object contains. |
129 | Standard_EXPORT virtual void GetAllGroups (TColStd_PackedMapOfInteger& Ids) const; |
130 | |
131 | //! This method returns map of all group elements. |
132 | Standard_EXPORT virtual Standard_Boolean GetGroup (const Standard_Integer Id, MeshVS_EntityType& Type, TColStd_PackedMapOfInteger& Ids) const; |
133 | |
134 | //! This method returns pointer which represents group data structure. |
135 | //! This address will be saved in MeshVS_MeshOwner, so that you can access to data structure fast |
136 | //! by the method Owner(). In the redefined method you can return NULL. |
137 | //! ID is the numerical identificator of group |
138 | Standard_EXPORT virtual Standard_Address GetGroupAddr (const Standard_Integer ID) const; |
139 | |
140 | //! Returns True if advanced mesh selection is enabled. |
141 | //! Default implementation returns False. |
142 | //! It should be redefined to return True for advanced |
143 | //! mesh selection activation. |
144 | Standard_EXPORT virtual Standard_Boolean IsAdvancedSelectionEnabled() const; |
145 | |
146 | //! Returns the bounding box of the whole mesh. |
147 | //! It is used in advanced selection mode to define roughly |
148 | //! the sensitive area of the mesh. |
149 | //! It can be redefined to get access to a box computed in advance. |
150 | Standard_EXPORT virtual Bnd_Box GetBoundingBox() const; |
151 | |
152 | //! Returns maps of entities (nodes and elements) detected |
153 | //! by mouse click at the point (X,Y) on the current view plane, |
154 | //! with the tolerance aTol. |
155 | //! DMin - is out argument should return actual detection tolerance. |
156 | //! Returns True if something is detected. |
157 | //! It should be redefined if the advanced mesh selection is |
158 | //! activated. Default implementation returns False. |
159 | Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const Standard_Real X, const Standard_Real Y, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements, Standard_Real& DMin); |
160 | |
161 | //! Returns maps of entities (nodes and elements) detected |
162 | //! by mouse selection with rectangular box (XMin, YMin, XMax, YMax) |
163 | //! on the current veiw plane, with the tolerance aTol. |
164 | //! Returns True if something is detected. |
165 | //! It should be redefined if the advanced mesh selection is |
166 | //! activated. Default implementation returns False. |
167 | Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const Standard_Real XMin, const Standard_Real YMin, const Standard_Real XMax, const Standard_Real YMax, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements); |
168 | |
169 | //! Returns maps of entities (nodes and elements) detected |
170 | //! by mouse selection with the polyline <Polyline> |
171 | //! on the current veiw plane, with the tolerance aTol. |
172 | //! Returns True if something is detected. |
173 | //! It should be redefined if the advanced mesh selection is |
174 | //! activated. Default implementation returns False. |
175 | Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, const TColgp_Array1OfPnt2d& Polyline, const Bnd_Box2d& aBox, const Standard_Real aTol, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements); |
176 | |
177 | //! Filter out the maps of mesh entities so as to keep |
178 | //! only the entities that are allowed to be selected |
179 | //! according to the current context. |
180 | //! Returns True if any of the maps has been changed. |
181 | //! It should be redefined if the advanced mesh selection is |
182 | //! activated. Default implementation returns False. |
183 | Standard_EXPORT virtual Standard_Boolean GetDetectedEntities (const Handle(MeshVS_Mesh)& Prs, Handle(TColStd_HPackedMapOfInteger)& Nodes, Handle(TColStd_HPackedMapOfInteger)& Elements); |
184 | |
185 | |
186 | |
187 | |
25e59720 |
188 | DEFINE_STANDARD_RTTIEXT(MeshVS_DataSource,Standard_Transient) |
42cf5bc1 |
189 | |
190 | protected: |
191 | |
192 | |
193 | |
194 | |
195 | private: |
196 | |
197 | |
198 | |
199 | |
200 | }; |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | #endif // _MeshVS_DataSource_HeaderFile |