SALOME - SMESH
|
00001 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 // SMESH SMDS : implementaion of Salome mesh data structure 00023 // File : SMDS_VolumeTool.hxx 00024 // Module : SMESH 00025 // Created : Tue Jul 13 11:27:17 2004 00026 // Author : Edward AGAPOV (eap) 00027 // 00028 #ifndef SMDS_VolumeTool_HeaderFile 00029 #define SMDS_VolumeTool_HeaderFile 00030 00031 #include "SMESH_SMDS.hxx" 00032 00033 class SMDS_MeshElement; 00034 class SMDS_MeshNode; 00035 class SMDS_PolyhedralVolumeOfNodes; 00036 class SMDS_MeshVolume; 00037 00038 #include <vector> 00039 #include <set> 00040 00041 // ========================================================================= 00042 // 00043 // Class providing topological and other information about SMDS_MeshVolume: 00044 // allows iteration on faces or, to be precise, on nodes of volume sides; 00045 // provides info on nodes connection etc. 00046 // 00047 // ========================================================================= 00048 00049 class SMDS_EXPORT SMDS_VolumeTool 00050 { 00051 public: 00052 00053 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA, 00054 QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA }; 00055 00056 SMDS_VolumeTool (); 00057 ~SMDS_VolumeTool (); 00058 SMDS_VolumeTool (const SMDS_MeshElement* theVolume); 00059 00060 bool Set (const SMDS_MeshElement* theVolume); 00061 // Set volume. 00062 // Return false if theVolume is not of type SMDSAbs_Volume 00063 00064 const SMDS_MeshVolume* Get() const; 00065 // return element 00066 00067 int ID() const; 00068 // return element ID 00069 00070 // ----------------------- 00071 // general info 00072 // ----------------------- 00073 00074 VolumeType GetVolumeType() const; 00075 00076 bool IsForward() const { return myVolForward; } 00077 // Check volume orientation. can be changed by Inverse(). 00078 // See node order of forward volumes at the file bottom 00079 00080 void Inverse(); 00081 // Change nodes order as if the volume changes its orientation: 00082 // top and bottom faces are reversed. 00083 // Result of IsForward() and methods returning nodes change 00084 00085 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; } 00086 // Return array of volume nodes 00087 00088 int NbNodes() { return myVolumeNbNodes; } 00089 // Return array of volume nodes 00090 00091 double GetSize() const; 00092 // Return element volume 00093 00094 bool GetBaryCenter (double & X, double & Y, double & Z) const; 00095 00096 bool IsOut(double X, double Y, double Z, double tol); 00097 // Classify a point 00098 00099 // ----------------------- 00100 // info on node connection 00101 // ----------------------- 00102 00103 bool IsLinked (const SMDS_MeshNode* theNode1, 00104 const SMDS_MeshNode* theNode2) const; 00105 // Return true if theNode1 is linked with theNode2. 00106 00107 bool IsLinked (const int theNode1Index, 00108 const int theNode2Index) const; 00109 // Return true if the node with theNode1Index is linked 00110 // with the node with theNode2Index 00111 00112 int GetNodeIndex(const SMDS_MeshNode* theNode) const; 00113 // Return an index of theNode 00114 00115 int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const; 00116 // Fill vector with boundary edges existing in the mesh 00117 00118 // ------------- 00119 // info on faces 00120 // ------------- 00121 00122 void SetExternalNormal (); 00123 // Node order in faces will be so that faces normals are external. 00124 00125 int NbFaces() const { return myNbFaces; } 00126 // Return number of faces of the volume. In the following 00127 // methods 0 <= faceIndex < NbFaces() 00128 00129 int NbFaceNodes( int faceIndex ); 00130 // Return number of nodes in the array of face nodes 00131 00132 const int* GetFaceNodesIndices( int faceIndex ); 00133 // Return the array of face nodes indices 00134 // To comfort link iteration, the array 00135 // length == NbFaceNodes( faceIndex ) + 1 and 00136 // the last node index == the first one. 00137 00138 const SMDS_MeshNode** GetFaceNodes( int faceIndex ); 00139 // Return the array of face nodes. 00140 // To comfort link iteration, the array 00141 // length == NbFaceNodes( faceIndex ) + 1 and 00142 // the last node == the first one. 00143 // WARNING: do not modify the array, some methods 00144 // work basing on its contents 00145 00146 bool GetFaceNodes (int faceIndex, 00147 std::set<const SMDS_MeshNode*>& theFaceNodes ); 00148 // Return a set of face nodes. 00149 00150 bool IsFaceExternal( int faceIndex ); 00151 // Check normal orientation of a face. 00152 // SetExternalNormal() is taken into account. 00153 00154 bool IsFreeFace( int faceIndex ); 00155 // Check that all volumes built on the face nodes lays on one side 00156 00157 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z); 00158 // Return a normal to a face 00159 00160 double GetFaceArea( int faceIndex ); 00161 // Return face area 00162 00163 int GetOppFaceIndex( int faceIndex ) const; 00164 // Return index of the opposite face if it exists, else -1. 00165 00166 int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes ); 00167 // Return index of a face formed by theFaceNodes. 00168 // Return -1 if a face not found 00169 00170 //int GetFaceIndex( const std::set<int>& theFaceNodesIndices ); 00171 // Return index of a face formed by theFaceNodesIndices 00172 // Return -1 if a face not found 00173 00174 int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces); 00175 // Fill vector with boundary faces existing in the mesh 00176 00177 // ------------------------ 00178 // static methods for faces 00179 // ------------------------ 00180 00181 static VolumeType GetType(int nbNodes); 00182 // return VolumeType by nb of nodes in a volume 00183 00184 static int NbFaces( VolumeType type ); 00185 // return nb of faces by volume type 00186 00187 static const int* GetFaceNodesIndices(VolumeType type, 00188 int faceIndex, 00189 bool external); 00190 // Return the array of face nodes indices 00191 // To comfort link iteration, the array 00192 // length == NbFaceNodes( faceIndex ) + 1 and 00193 // the last node index == the first one. 00194 00195 static int NbFaceNodes(VolumeType type, 00196 int faceIndex ); 00197 // Return number of nodes in the array of face nodes 00198 00199 static int NbCornerNodes(VolumeType type); 00200 // Useful to know nb of corner nodes of a quadratic volume 00201 00202 private: 00203 00204 bool setFace( int faceIndex ); 00205 00206 const SMDS_MeshElement* myVolume; 00207 const SMDS_PolyhedralVolumeOfNodes* myPolyedre; 00208 00209 bool myVolForward; 00210 int myNbFaces; 00211 int myVolumeNbNodes; 00212 const SMDS_MeshNode** myVolumeNodes; 00213 00214 bool myExternalFaces; 00215 00216 int myCurFace; 00217 int myFaceNbNodes; 00218 int* myFaceNodeIndices; 00219 const SMDS_MeshNode** myFaceNodes; 00220 00221 }; 00222 #endif 00223 00224 00226 // 00227 // ORDER OF NODES OF FORWARD ELEMENT 00228 // 00230 /* 00231 // N3 00232 // + 00233 // /|\ 00234 // / | \ 00235 // / | \ 00236 // N0 +---|---+ N1 TETRAHEDRON 00237 // \ | / 00238 // \ | / 00239 // \ | / 00240 // \|/ 00241 // + 00242 // N2 00243 00244 // + N4 00245 // /|\ 00246 // / | \ 00247 // / | \ 00248 // / | \ 00249 // N3 +---------+ N5 00250 // | | | 00251 // | + N1 | 00252 // | / \ | PENTAHEDRON 00253 // | / \ | 00254 // | / \ | 00255 // |/ \| 00256 // N0 +---------+ N2 00257 00258 // N5+----------+N6 00259 // /| /| 00260 // / | / | 00261 // / | / | 00262 // N4+----------+N7 | 00263 // | | | | HEXAHEDRON 00264 // | | | | 00265 // | | | | 00266 // | N1+------|---+N2 00267 // | / | / 00268 // | / | / 00269 // |/ |/ 00270 // N0+----------+N3 00271 // 00272 */