1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMDS : implementaion of Salome mesh data structure
23 // File : SMDS_VolumeTool.hxx
25 // Created : Tue Jul 13 11:27:17 2004
26 // Author : Edward AGAPOV (eap)
28 #ifndef SMDS_VolumeTool_HeaderFile
29 #define SMDS_VolumeTool_HeaderFile
31 #include "SMESH_SMDS.hxx"
33 class SMDS_MeshElement;
35 class SMDS_PolyhedralVolumeOfNodes;
36 class SMDS_MeshVolume;
41 // =========================================================================
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.
47 // =========================================================================
49 class SMDS_EXPORT SMDS_VolumeTool
53 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA,
54 QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA };
58 SMDS_VolumeTool (const SMDS_MeshElement* theVolume);
60 bool Set (const SMDS_MeshElement* theVolume);
62 // Return false if theVolume is not of type SMDSAbs_Volume
64 const SMDS_MeshVolume* Get() const;
70 // -----------------------
72 // -----------------------
74 VolumeType GetVolumeType() const;
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
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
85 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
86 // Return array of volume nodes
88 int NbNodes() { return myVolumeNbNodes; }
89 // Return array of volume nodes
91 double GetSize() const;
92 // Return element volume
94 bool GetBaryCenter (double & X, double & Y, double & Z) const;
97 // -----------------------
98 // info on node connection
99 // -----------------------
101 bool IsLinked (const SMDS_MeshNode* theNode1,
102 const SMDS_MeshNode* theNode2) const;
103 // Return true if theNode1 is linked with theNode2.
105 bool IsLinked (const int theNode1Index,
106 const int theNode2Index) const;
107 // Return true if the node with theNode1Index is linked
108 // with the node with theNode2Index
110 int GetNodeIndex(const SMDS_MeshNode* theNode) const;
111 // Return an index of theNode
113 int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const;
114 // Fill vector with boundary edges existing in the mesh
120 void SetExternalNormal ();
121 // Node order in faces will be so that faces normals are external.
123 int NbFaces() const { return myNbFaces; }
124 // Return number of faces of the volume. In the following
125 // methods 0 <= faceIndex < NbFaces()
127 int NbFaceNodes( int faceIndex );
128 // Return number of nodes in the array of face nodes
130 const int* GetFaceNodesIndices( int faceIndex );
131 // Return the array of face nodes indices
132 // To comfort link iteration, the array
133 // length == NbFaceNodes( faceIndex ) + 1 and
134 // the last node index == the first one.
136 const SMDS_MeshNode** GetFaceNodes( int faceIndex );
137 // Return the array of face nodes.
138 // To comfort link iteration, the array
139 // length == NbFaceNodes( faceIndex ) + 1 and
140 // the last node == the first one.
141 // WARNING: do not modify the array, some methods
142 // work basing on its contents
144 bool GetFaceNodes (int faceIndex,
145 std::set<const SMDS_MeshNode*>& theFaceNodes );
146 // Return a set of face nodes.
148 bool IsFaceExternal( int faceIndex );
149 // Check normal orientation of a face.
150 // SetExternalNormal() is taken into account.
152 bool IsFreeFace( int faceIndex );
153 // Check that all volumes built on the face nodes lays on one side
155 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
156 // Return a normal to a face
158 double GetFaceArea( int faceIndex );
161 int GetOppFaceIndex( int faceIndex ) const;
162 // Return index of the opposite face if it exists, else -1.
164 int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes );
165 // Return index of a face formed by theFaceNodes.
166 // Return -1 if a face not found
168 //int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
169 // Return index of a face formed by theFaceNodesIndices
170 // Return -1 if a face not found
172 int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces);
173 // Fill vector with boundary faces existing in the mesh
175 // ------------------------
176 // static methods for faces
177 // ------------------------
179 static VolumeType GetType(int nbNodes);
180 // return VolumeType by nb of nodes in a volume
182 static int NbFaces( VolumeType type );
183 // return nb of faces by volume type
185 static const int* GetFaceNodesIndices(VolumeType type,
188 // Return the array of face nodes indices
189 // To comfort link iteration, the array
190 // length == NbFaceNodes( faceIndex ) + 1 and
191 // the last node index == the first one.
193 static int NbFaceNodes(VolumeType type,
195 // Return number of nodes in the array of face nodes
197 static int NbCornerNodes(VolumeType type);
198 // Useful to know nb of corner nodes of a quadratic volume
202 bool setFace( int faceIndex );
204 const SMDS_MeshElement* myVolume;
205 const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
210 const SMDS_MeshNode** myVolumeNodes;
212 bool myExternalFaces;
216 int* myFaceNodeIndices;
217 const SMDS_MeshNode** myFaceNodes;
223 ///////////////////////////////////////////////////////////////////////////
225 // ORDER OF NODES OF FORWARD ELEMENT
227 ///////////////////////////////////////////////////////////////////////////
234 // N0 +---|---+ N1 TETRAHEDRON
250 // | / \ | PENTAHEDRON
260 // N4+----------+N7 |
261 // | | | | HEXAHEDRON
264 // | N1+------|---+N2