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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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 class SMDS_MeshElement;
35 class SMDS_PolyhedralVolumeOfNodes;
41 //#include <SALOME_WNT.hxx>
43 //#define SALOME_WNT_EXPORT
46 #if defined WNT && defined WIN32 && defined SMDS_EXPORTS
47 #define SMDS_WNT_EXPORT __declspec( dllexport )
49 #define SMDS_WNT_EXPORT
52 // =========================================================================
54 // Class providing topological and other information about SMDS_MeshVolume:
55 // allows iteration on faces or, to be precise, on nodes of volume sides;
56 // provides info on nodes connection etc.
58 // =========================================================================
60 class SMDS_WNT_EXPORT SMDS_VolumeTool
64 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, POLYHEDA };
68 SMDS_VolumeTool (const SMDS_MeshElement* theVolume);
70 bool Set (const SMDS_MeshElement* theVolume);
72 // Return false if theVolume is not of type SMDSAbs_Volume
74 // -----------------------
76 // -----------------------
78 VolumeType GetVolumeType() const;
80 bool IsForward() const { return myVolForward; }
81 // Check volume orientation. can be changed by Inverse().
82 // See node order of forward volumes at the file bottom
85 // Change nodes order as if the volume changes its orientation:
86 // top and bottom faces are reversed.
87 // Result of IsForward() and methods returning nodes change
89 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; }
90 // Return array of volume nodes
92 int NbNodes() { return myVolumeNbNodes; }
93 // Return array of volume nodes
95 double GetSize() const;
96 // Return element volume
98 bool GetBaryCenter (double & X, double & Y, double & Z) const;
101 // -----------------------
102 // info on node connection
103 // -----------------------
105 bool IsLinked (const SMDS_MeshNode* theNode1,
106 const SMDS_MeshNode* theNode2) const;
107 // Return true if theNode1 is linked with theNode2.
109 bool IsLinked (const int theNode1Index,
110 const int theNode2Index) const;
111 // Return true if the node with theNode1Index is linked
112 // with the node with theNode2Index
114 int GetNodeIndex(const SMDS_MeshNode* theNode) const;
115 // Return an index of theNode
121 void SetExternalNormal ();
122 // Node order in faces will be so that faces normals are external.
124 int NbFaces() const { return myNbFaces; }
125 // Return number of faces of the volume. In the following
126 // methods 0 <= faceIndex < NbFaces()
128 int NbFaceNodes( int faceIndex );
129 // Return number of nodes in the array of face nodes
131 const int* GetFaceNodesIndices( int faceIndex );
132 // Return the array of face nodes indices
133 // To comfort link iteration, the array
134 // length == NbFaceNodes( faceIndex ) + 1 and
135 // the last node index == the first one.
137 const SMDS_MeshNode** GetFaceNodes( int faceIndex );
138 // Return the array of face nodes.
139 // To comfort link iteration, the array
140 // length == NbFaceNodes( faceIndex ) + 1 and
141 // the last node == the first one.
142 // WARNING: do not modify the array, some methods
143 // work basing on its contents
145 bool GetFaceNodes (int faceIndex,
146 std::set<const SMDS_MeshNode*>& theFaceNodes );
147 // Return a set of face nodes.
149 bool IsFaceExternal( int faceIndex );
150 // Check normal orientation of a face.
151 // SetExternalNormal() is taken into account.
153 bool IsFreeFace( int faceIndex );
154 // Check that all volumes built on the face nodes lays on one side
156 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
157 // Return a normal to a face
159 double GetFaceArea( int faceIndex );
162 int GetOppFaceIndex( int faceIndex ) const;
163 // Return index of the opposite face if it exists, else -1.
165 int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes );
166 // Return index of a face formed by theFaceNodes.
167 // Return -1 if a face not found
169 //int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
170 // Return index of a face formed by theFaceNodesIndices
171 // Return -1 if a face not found
173 // ------------------------
174 // static methods for faces
175 // ------------------------
177 static VolumeType GetType(int nbNodes);
178 // return VolumeType by nb of nodes in a volume
180 static int NbFaces( VolumeType type );
181 // return nb of faces by volume type
183 static const int* GetFaceNodesIndices(VolumeType type,
186 // Return the array of face nodes indices
187 // To comfort link iteration, the array
188 // length == NbFaceNodes( faceIndex ) + 1 and
189 // the last node index == the first one.
191 static int NbFaceNodes(VolumeType type,
193 // Return number of nodes in the array of face nodes
197 bool setFace( int faceIndex );
199 const SMDS_MeshElement* myVolume;
200 const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
205 const SMDS_MeshNode** myVolumeNodes;
207 bool myExternalFaces;
211 int* myFaceNodeIndices;
212 const SMDS_MeshNode** myFaceNodes;
218 ///////////////////////////////////////////////////////////////////////////
220 // ORDER OF NODES OF FORWARD ELEMENT
222 ///////////////////////////////////////////////////////////////////////////
229 // N0 +---|---+ N1 TETRAHEDRON
245 // | / \ | PENTAHEDRON
255 // N4+----------+N7 |
256 // | | | | HEXAHEDRON
259 // | N1+------|---+N2