00001 // Copyright (C) 2007-2011 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 00023 // SMESH SMDS : implementaion of Salome mesh data structure 00024 // File : SMDS_VolumeTool.hxx 00025 // Module : SMESH 00026 // Created : Tue Jul 13 11:27:17 2004 00027 // Author : Edward AGAPOV (eap) 00028 // 00029 #ifndef SMDS_VolumeTool_HeaderFile 00030 #define SMDS_VolumeTool_HeaderFile 00031 00032 #include "SMESH_SMDS.hxx" 00033 00034 class SMDS_MeshElement; 00035 class SMDS_MeshNode; 00036 class SMDS_VtkVolume; 00037 class SMDS_MeshVolume; 00038 00039 #include <vector> 00040 #include <set> 00041 00042 // ========================================================================= 00043 // 00044 // Class providing topological and other information about SMDS_MeshVolume: 00045 // allows iteration on faces or, to be precise, on nodes of volume sides; 00046 // provides info on nodes connection etc. 00047 // 00048 // ========================================================================= 00049 00050 class SMDS_EXPORT SMDS_VolumeTool 00051 { 00052 public: 00053 00054 enum VolumeType { UNKNOWN = -1, TETRA = 0, PYRAM, PENTA, HEXA, QUAD_TETRA, 00055 QUAD_PYRAM, QUAD_PENTA, QUAD_HEXA, POLYHEDA }; 00056 00057 SMDS_VolumeTool (); 00058 ~SMDS_VolumeTool (); 00059 SMDS_VolumeTool (const SMDS_MeshElement* theVolume); 00060 00061 bool Set (const SMDS_MeshElement* theVolume); 00062 // Set volume. 00063 // Return false if theVolume is not of type SMDSAbs_Volume 00064 00065 const SMDS_MeshVolume* Element() const; 00066 // return element 00067 00068 int ID() const; 00069 // return element ID 00070 00071 // ----------------------- 00072 // general info 00073 // ----------------------- 00074 00075 VolumeType GetVolumeType() const; 00076 00077 bool IsForward() const { return myVolForward; } 00078 // Check volume orientation. can be changed by Inverse(). 00079 // See node order of forward volumes at the file bottom 00080 00081 void Inverse(); 00082 // Change nodes order as if the volume changes its orientation: 00083 // top and bottom faces are reversed. 00084 // Result of IsForward() and methods returning nodes change 00085 00086 const SMDS_MeshNode** GetNodes() { return myVolumeNodes; } 00087 // Return array of volume nodes 00088 00089 int NbNodes() { return myVolumeNbNodes; } 00090 // Return array of volume nodes 00091 00092 double GetSize() const; 00093 // Return element volume 00094 00095 bool GetBaryCenter (double & X, double & Y, double & Z) const; 00096 00097 bool IsOut(double X, double Y, double Z, double tol); 00098 // Classify a point 00099 00100 // ----------------------- 00101 // info on node connection 00102 // ----------------------- 00103 00104 bool IsLinked (const SMDS_MeshNode* theNode1, 00105 const SMDS_MeshNode* theNode2, 00106 const bool theIgnoreMediumNodes=false) const; 00107 // Return true if theNode1 is linked with theNode2. 00108 // If theIgnoreMediumNodes then corner nodes of quadratic cell are considered linked as well 00109 00110 bool IsLinked (const int theNode1Index, 00111 const int theNode2Index, 00112 bool theIgnoreMediumNodes=false) const; 00113 // Return true if the node with theNode1Index is linked 00114 // with the node with theNode2Index 00115 // If theIgnoreMediumNodes then corner nodes of quadratic cell are considered linked as well 00116 00117 int GetNodeIndex(const SMDS_MeshNode* theNode) const; 00118 // Return an index of theNode 00119 00120 int GetAllExistingEdges(std::vector<const SMDS_MeshElement*> & edges) const; 00121 // Fill vector with boundary edges existing in the mesh 00122 00123 // ------------- 00124 // info on faces 00125 // ------------- 00126 00127 void SetExternalNormal (); 00128 // Node order in faces will be so that faces normals are external. 00129 00130 int NbFaces() const { return myNbFaces; } 00131 // Return number of faces of the volume. In the following 00132 // methods 0 <= faceIndex < NbFaces() 00133 00134 int NbFaceNodes( int faceIndex ); 00135 // Return number of nodes in the array of face nodes 00136 00137 const int* GetFaceNodesIndices( int faceIndex ); 00138 // Return the array of face nodes indices 00139 // To comfort link iteration, the array 00140 // length == NbFaceNodes( faceIndex ) + 1 and 00141 // the last node index == the first one. 00142 // NOTE: for the quadratic volume, node indoces are in the order the nodes encounter 00143 // in face boundary and not the order they are in the mesh face 00144 00145 const SMDS_MeshNode** GetFaceNodes( int faceIndex ); 00146 // Return the array of face nodes. 00147 // To comfort link iteration, the array 00148 // length == NbFaceNodes( faceIndex ) + 1 and 00149 // the last node == the first one. 00150 // NOTE: for the quadratic volume, nodes are in the order they encounter in face boundary 00151 // and not the order they are in the mesh face 00152 // WARNING: do not modify the array, some methods 00153 // work basing on its contents 00154 00155 bool GetFaceNodes (int faceIndex, 00156 std::set<const SMDS_MeshNode*>& theFaceNodes ); 00157 // Return a set of face nodes. 00158 00159 bool IsFaceExternal( int faceIndex ); 00160 // Check normal orientation of a face. 00161 // SetExternalNormal() is taken into account. 00162 00163 bool IsFreeFace( int faceIndex, const SMDS_MeshElement** otherVol=0 ); 00164 // Check that all volumes built on the face nodes lays on one side 00165 // otherVol returns another volume sharing the given facet 00166 00167 bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z); 00168 // Return a normal to a face 00169 00170 bool GetFaceBaryCenter (int faceIndex, double & X, double & Y, double & Z); 00171 // Return barycenter of a face 00172 00173 double GetFaceArea( int faceIndex ); 00174 // Return face area 00175 00176 int GetOppFaceIndex( int faceIndex ) const; 00177 // Return index of the opposite face if it exists, else -1. 00178 00179 int GetFaceIndex( const std::set<const SMDS_MeshNode*>& theFaceNodes ); 00180 // Return index of a face formed by theFaceNodes. 00181 // Return -1 if a face not found 00182 00183 //int GetFaceIndex( const std::set<int>& theFaceNodesIndices ); 00184 // Return index of a face formed by theFaceNodesIndices 00185 // Return -1 if a face not found 00186 00187 int GetAllExistingFaces(std::vector<const SMDS_MeshElement*> & faces); 00188 // Fill vector with boundary faces existing in the mesh 00189 00190 // ------------------------ 00191 // static methods for faces 00192 // ------------------------ 00193 00194 static VolumeType GetType(int nbNodes); 00195 // return VolumeType by nb of nodes in a volume 00196 00197 static int NbFaces( VolumeType type ); 00198 // return nb of faces by volume type 00199 00200 static const int* GetFaceNodesIndices(VolumeType type, 00201 int faceIndex, 00202 bool external); 00203 // Return the array of face nodes indices 00204 // To comfort link iteration, the array 00205 // length == NbFaceNodes( faceIndex ) + 1 and 00206 // the last node index == the first one. 00207 00208 static int NbFaceNodes(VolumeType type, 00209 int faceIndex ); 00210 // Return number of nodes in the array of face nodes 00211 00212 static int NbCornerNodes(VolumeType type); 00213 // Useful to know nb of corner nodes of a quadratic volume 00214 00215 private: 00216 00217 bool setFace( int faceIndex ); 00218 00219 const SMDS_MeshElement* myVolume; 00220 const SMDS_VtkVolume* myPolyedre; 00221 00222 bool myVolForward; 00223 int myNbFaces; 00224 int myVolumeNbNodes; 00225 const SMDS_MeshNode** myVolumeNodes; 00226 std::vector< int > myPolyIndices; 00227 00228 bool myExternalFaces; 00229 00230 int myCurFace; 00231 int myFaceNbNodes; 00232 int* myFaceNodeIndices; 00233 const SMDS_MeshNode** myFaceNodes; 00234 00235 }; 00236 #endif 00237 00238 00240 // 00241 // ORDER OF NODES OF FORWARD ELEMENT 00242 // 00244 /* 00245 // N3 00246 // + 00247 // /|\ 00248 // / | \ 00249 // / | \ 00250 // N0 +---|---+ N1 TETRAHEDRON 00251 // \ | / 00252 // \ | / 00253 // \ | / 00254 // \|/ 00255 // + 00256 // N2 00257 00258 // + N4 00259 // /|\ 00260 // / | \ 00261 // / | \ 00262 // / | \ 00263 // N3 +---------+ N5 00264 // | | | 00265 // | + N1 | 00266 // | / \ | PENTAHEDRON 00267 // | / \ | 00268 // | / \ | 00269 // |/ \| 00270 // N0 +---------+ N2 00271 00272 // N5+----------+N6 00273 // /| /| 00274 // / | / | 00275 // / | / | 00276 // N4+----------+N7 | 00277 // | | | | HEXAHEDRON 00278 // | | | | 00279 // | | | | 00280 // | N1+------|---+N2 00281 // | / | / 00282 // | / | / 00283 // |/ |/ 00284 // N0+----------+N3 00285 // 00286 */