SALOME - SMESH
SMDS_VolumeTool.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMDS : implementaion of Salome mesh data structure
23 // File : SMDS_VolumeTool.hxx
24 // Module : SMESH
25 // Created : Tue Jul 13 11:27:17 2004
26 // Author : Edward AGAPOV (eap)
27 //
28 #ifndef SMDS_VolumeTool_HeaderFile
29 #define SMDS_VolumeTool_HeaderFile
30 
31 #include "SMESH_SMDS.hxx"
32 
33 class SMDS_MeshElement;
34 class SMDS_MeshNode;
36 class SMDS_MeshVolume;
37 
38 #include <vector>
39 #include <set>
40 
41 // =========================================================================
42 //
43 // Class providing topological and other information about SMDS_MeshVolume:
44 // allows iteration on faces or, to be precise, on nodes of volume sides;
45 // provides info on nodes connection etc.
46 //
47 // =========================================================================
48 
50 {
51  public:
52 
53  enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA,
54  QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA };
55 
56  SMDS_VolumeTool ();
57  ~SMDS_VolumeTool ();
58  SMDS_VolumeTool (const SMDS_MeshElement* theVolume);
59 
60  bool Set (const SMDS_MeshElement* theVolume);
61  // Set volume.
62  // Return false if theVolume is not of type SMDSAbs_Volume
63 
64  const SMDS_MeshVolume* Get() const;
65  // return element
66 
67  int ID() const;
68  // return element ID
69 
70  // -----------------------
71  // general info
72  // -----------------------
73 
74  VolumeType GetVolumeType() const;
75 
76  bool IsForward() const { return myVolForward; }
77  // Check volume orientation. can be changed by Inverse().
78  // See node order of forward volumes at the file bottom
79 
80  void Inverse();
81  // Change nodes order as if the volume changes its orientation:
82  // top and bottom faces are reversed.
83  // Result of IsForward() and methods returning nodes change
84 
85  const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
86  // Return array of volume nodes
87 
88  int NbNodes() { return myVolumeNbNodes; }
89  // Return array of volume nodes
90 
91  double GetSize() const;
92  // Return element volume
93 
94  bool GetBaryCenter (double & X, double & Y, double & Z) const;
95 
96  bool IsOut(double X, double Y, double Z, double tol);
97  // Classify a point
98 
99  // -----------------------
100  // info on node connection
101  // -----------------------
102 
103  bool IsLinked (const SMDS_MeshNode* theNode1,
104  const SMDS_MeshNode* theNode2) const;
105  // Return true if theNode1 is linked with theNode2.
106 
107  bool IsLinked (const int theNode1Index,
108  const int theNode2Index) const;
109  // Return true if the node with theNode1Index is linked
110  // with the node with theNode2Index
111 
112  int GetNodeIndex(const SMDS_MeshNode* theNode) const;
113  // Return an index of theNode
114 
115  int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const;
116  // Fill vector with boundary edges existing in the mesh
117 
118  // -------------
119  // info on faces
120  // -------------
121 
122  void SetExternalNormal ();
123  // Node order in faces will be so that faces normals are external.
124 
125  int NbFaces() const { return myNbFaces; }
126  // Return number of faces of the volume. In the following
127  // methods 0 <= faceIndex < NbFaces()
128 
129  int NbFaceNodes( int faceIndex );
130  // Return number of nodes in the array of face nodes
131 
132  const int* GetFaceNodesIndices( int faceIndex );
133  // Return the array of face nodes indices
134  // To comfort link iteration, the array
135  // length == NbFaceNodes( faceIndex ) + 1 and
136  // the last node index == the first one.
137 
138  const SMDS_MeshNode** GetFaceNodes( int faceIndex );
139  // Return the array of face nodes.
140  // To comfort link iteration, the array
141  // length == NbFaceNodes( faceIndex ) + 1 and
142  // the last node == the first one.
143  // WARNING: do not modify the array, some methods
144  // work basing on its contents
145 
146  bool GetFaceNodes (int faceIndex,
147  std::set<const SMDS_MeshNode*>& theFaceNodes );
148  // Return a set of face nodes.
149 
150  bool IsFaceExternal( int faceIndex );
151  // Check normal orientation of a face.
152  // SetExternalNormal() is taken into account.
153 
154  bool IsFreeFace( int faceIndex );
155  // Check that all volumes built on the face nodes lays on one side
156 
157  bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
158  // Return a normal to a face
159 
160  double GetFaceArea( int faceIndex );
161  // Return face area
162 
163  int GetOppFaceIndex( int faceIndex ) const;
164  // Return index of the opposite face if it exists, else -1.
165 
166  int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes );
167  // Return index of a face formed by theFaceNodes.
168  // Return -1 if a face not found
169 
170  //int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
171  // Return index of a face formed by theFaceNodesIndices
172  // Return -1 if a face not found
173 
174  int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces);
175  // Fill vector with boundary faces existing in the mesh
176 
177  // ------------------------
178  // static methods for faces
179  // ------------------------
180 
181  static VolumeType GetType(int nbNodes);
182  // return VolumeType by nb of nodes in a volume
183 
184  static int NbFaces( VolumeType type );
185  // return nb of faces by volume type
186 
187  static const int* GetFaceNodesIndices(VolumeType type,
188  int faceIndex,
189  bool external);
190  // Return the array of face nodes indices
191  // To comfort link iteration, the array
192  // length == NbFaceNodes( faceIndex ) + 1 and
193  // the last node index == the first one.
194 
195  static int NbFaceNodes(VolumeType type,
196  int faceIndex );
197  // Return number of nodes in the array of face nodes
198 
199  static int NbCornerNodes(VolumeType type);
200  // Useful to know nb of corner nodes of a quadratic volume
201 
202 private:
203 
204  bool setFace( int faceIndex );
205 
208 
213 
215 
220 
221 };
222 #endif
223 
224 
226 //
227 // ORDER OF NODES OF FORWARD ELEMENT
228 //
230 /*
231 // N3
232 // +
233 // /|\
234 // / | \
235 // / | \
236 // N0 +---|---+ N1 TETRAHEDRON
237 // \ | /
238 // \ | /
239 // \ | /
240 // \|/
241 // +
242 // N2
243 
244 // + N4
245 // /|\
246 // / | \
247 // / | \
248 // / | \
249 // N3 +---------+ N5
250 // | | |
251 // | + N1 |
252 // | / \ | PENTAHEDRON
253 // | / \ |
254 // | / \ |
255 // |/ \|
256 // N0 +---------+ N2
257 
258 // N5+----------+N6
259 // /| /|
260 // / | / |
261 // / | / |
262 // N4+----------+N7 |
263 // | | | | HEXAHEDRON
264 // | | | |
265 // | | | |
266 // | N1+------|---+N2
267 // | / | /
268 // | / | /
269 // |/ |/
270 // N0+----------+N3
271 //
272 */
#define SMDS_EXPORT
Definition: SMESH_SMDS.hxx:36
const SMDS_MeshNode ** myFaceNodes
const SMDS_MeshNode ** GetNodes()
const SMDS_PolyhedralVolumeOfNodes * myPolyedre
bool IsForward() const
long int Z
Definition: Rn.h:72
Base class for elements.
const SMDS_MeshNode ** myVolumeNodes
const SMDS_MeshElement * myVolume