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;
42 // =========================================================================
44 // Class providing topological and other information about SMDS_MeshVolume:
45 // allows iteration on faces or, to be precise, on nodes of volume sides;
46 // provides info on nodes connection etc.
48 // =========================================================================
50 class SMDS_EXPORT SMDS_VolumeTool
54 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA,
55 QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA };
59 SMDS_VolumeTool (const SMDS_MeshElement* theVolume);
61 bool Set (const SMDS_MeshElement* theVolume);
63 // Return false if theVolume is not of type SMDSAbs_Volume
65 // -----------------------
67 // -----------------------
69 VolumeType GetVolumeType() const;
71 bool IsForward() const { return myVolForward; }
72 // Check volume orientation. can be changed by Inverse().
73 // See node order of forward volumes at the file bottom
76 // Change nodes order as if the volume changes its orientation:
77 // top and bottom faces are reversed.
78 // Result of IsForward() and methods returning nodes change
80 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
81 // Return array of volume nodes
83 int NbNodes() { return myVolumeNbNodes; }
84 // Return array of volume nodes
86 double GetSize() const;
87 // Return element volume
89 bool GetBaryCenter (double & X, double & Y, double & Z) const;
92 // -----------------------
93 // info on node connection
94 // -----------------------
96 bool IsLinked (const SMDS_MeshNode* theNode1,
97 const SMDS_MeshNode* theNode2) const;
98 // Return true if theNode1 is linked with theNode2.
100 bool IsLinked (const int theNode1Index,
101 const int theNode2Index) const;
102 // Return true if the node with theNode1Index is linked
103 // with the node with theNode2Index
105 int GetNodeIndex(const SMDS_MeshNode* theNode) const;
106 // Return an index of theNode
112 void SetExternalNormal ();
113 // Node order in faces will be so that faces normals are external.
115 int NbFaces() const { return myNbFaces; }
116 // Return number of faces of the volume. In the following
117 // methods 0 <= faceIndex < NbFaces()
119 int NbFaceNodes( int faceIndex );
120 // Return number of nodes in the array of face nodes
122 const int* GetFaceNodesIndices( int faceIndex );
123 // Return the array of face nodes indices
124 // To comfort link iteration, the array
125 // length == NbFaceNodes( faceIndex ) + 1 and
126 // the last node index == the first one.
128 const SMDS_MeshNode** GetFaceNodes( int faceIndex );
129 // Return the array of face nodes.
130 // To comfort link iteration, the array
131 // length == NbFaceNodes( faceIndex ) + 1 and
132 // the last node == the first one.
133 // WARNING: do not modify the array, some methods
134 // work basing on its contents
136 bool GetFaceNodes (int faceIndex,
137 std::set<const SMDS_MeshNode*>& theFaceNodes );
138 // Return a set of face nodes.
140 bool IsFaceExternal( int faceIndex );
141 // Check normal orientation of a face.
142 // SetExternalNormal() is taken into account.
144 bool IsFreeFace( int faceIndex );
145 // Check that all volumes built on the face nodes lays on one side
147 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
148 // Return a normal to a face
150 double GetFaceArea( int faceIndex );
153 int GetOppFaceIndex( int faceIndex ) const;
154 // Return index of the opposite face if it exists, else -1.
156 int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes );
157 // Return index of a face formed by theFaceNodes.
158 // Return -1 if a face not found
160 //int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
161 // Return index of a face formed by theFaceNodesIndices
162 // Return -1 if a face not found
164 // ------------------------
165 // static methods for faces
166 // ------------------------
168 static VolumeType GetType(int nbNodes);
169 // return VolumeType by nb of nodes in a volume
171 static int NbFaces( VolumeType type );
172 // return nb of faces by volume type
174 static const int* GetFaceNodesIndices(VolumeType type,
177 // Return the array of face nodes indices
178 // To comfort link iteration, the array
179 // length == NbFaceNodes( faceIndex ) + 1 and
180 // the last node index == the first one.
182 static int NbFaceNodes(VolumeType type,
184 // Return number of nodes in the array of face nodes
188 bool setFace( int faceIndex );
190 const SMDS_MeshElement* myVolume;
191 const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
196 const SMDS_MeshNode** myVolumeNodes;
198 bool myExternalFaces;
202 int* myFaceNodeIndices;
203 const SMDS_MeshNode** myFaceNodes;
209 ///////////////////////////////////////////////////////////////////////////
211 // ORDER OF NODES OF FORWARD ELEMENT
213 ///////////////////////////////////////////////////////////////////////////
220 // N0 +---|---+ N1 TETRAHEDRON
236 // | / \ | PENTAHEDRON
246 // N4+----------+N7 |
247 // | | | | HEXAHEDRON
250 // | N1+------|---+N2