1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 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
24 // File : SMDS_VolumeTool.hxx
26 // Created : Tue Jul 13 11:27:17 2004
27 // Author : Edward AGAPOV (eap)
30 #ifndef SMDS_VolumeTool_HeaderFile
31 #define SMDS_VolumeTool_HeaderFile
33 #include "SMESH_SMDS.hxx"
35 class SMDS_MeshElement;
37 class SMDS_PolyhedralVolumeOfNodes;
38 class SMDS_MeshVolume;
43 // =========================================================================
45 // Class providing topological and other information about SMDS_MeshVolume:
46 // allows iteration on faces or, to be precise, on nodes of volume sides;
47 // provides info on nodes connection etc.
49 // =========================================================================
51 class SMDS_EXPORT SMDS_VolumeTool
55 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA,
56 QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA };
60 SMDS_VolumeTool (const SMDS_MeshElement* theVolume);
62 bool Set (const SMDS_MeshElement* theVolume);
64 // Return false if theVolume is not of type SMDSAbs_Volume
66 const SMDS_MeshVolume* Get() const;
72 // -----------------------
74 // -----------------------
76 VolumeType GetVolumeType() const;
78 bool IsForward() const { return myVolForward; }
79 // Check volume orientation. can be changed by Inverse().
80 // See node order of forward volumes at the file bottom
83 // Change nodes order as if the volume changes its orientation:
84 // top and bottom faces are reversed.
85 // Result of IsForward() and methods returning nodes change
87 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
88 // Return array of volume nodes
90 int NbNodes() { return myVolumeNbNodes; }
91 // Return array of volume nodes
93 double GetSize() const;
94 // Return element volume
96 bool GetBaryCenter (double & X, double & Y, double & Z) const;
99 // -----------------------
100 // info on node connection
101 // -----------------------
103 bool IsLinked (const SMDS_MeshNode* theNode1,
104 const SMDS_MeshNode* theNode2) const;
105 // Return true if theNode1 is linked with theNode2.
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
112 int GetNodeIndex(const SMDS_MeshNode* theNode) const;
113 // Return an index of theNode
115 int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const;
116 // Fill vector with boundary edges existing in the mesh
122 void SetExternalNormal ();
123 // Node order in faces will be so that faces normals are external.
125 int NbFaces() const { return myNbFaces; }
126 // Return number of faces of the volume. In the following
127 // methods 0 <= faceIndex < NbFaces()
129 int NbFaceNodes( int faceIndex );
130 // Return number of nodes in the array of face nodes
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.
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
146 bool GetFaceNodes (int faceIndex,
147 std::set<const SMDS_MeshNode*>& theFaceNodes );
148 // Return a set of face nodes.
150 bool IsFaceExternal( int faceIndex );
151 // Check normal orientation of a face.
152 // SetExternalNormal() is taken into account.
154 bool IsFreeFace( int faceIndex );
155 // Check that all volumes built on the face nodes lays on one side
157 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
158 // Return a normal to a face
160 double GetFaceArea( int faceIndex );
163 int GetOppFaceIndex( int faceIndex ) const;
164 // Return index of the opposite face if it exists, else -1.
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
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
174 int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces);
175 // Fill vector with boundary faces existing in the mesh
177 // ------------------------
178 // static methods for faces
179 // ------------------------
181 static VolumeType GetType(int nbNodes);
182 // return VolumeType by nb of nodes in a volume
184 static int NbFaces( VolumeType type );
185 // return nb of faces by volume type
187 static const int* GetFaceNodesIndices(VolumeType type,
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.
195 static int NbFaceNodes(VolumeType type,
197 // Return number of nodes in the array of face nodes
199 static int NbCornerNodes(VolumeType type);
200 // Useful to know nb of corner nodes of a quadratic volume
204 bool setFace( int faceIndex );
206 const SMDS_MeshElement* myVolume;
207 const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
212 const SMDS_MeshNode** myVolumeNodes;
214 bool myExternalFaces;
218 int* myFaceNodeIndices;
219 const SMDS_MeshNode** myFaceNodes;
225 ///////////////////////////////////////////////////////////////////////////
227 // ORDER OF NODES OF FORWARD ELEMENT
229 ///////////////////////////////////////////////////////////////////////////
236 // N0 +---|---+ N1 TETRAHEDRON
252 // | / \ | PENTAHEDRON
262 // N4+----------+N7 |
263 // | | | | HEXAHEDRON
266 // | N1+------|---+N2