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 // File: SMESH_MesherHelper.hxx 00023 // Created: 15.02.06 14:48:09 00024 // Author: Sergey KUUL 00025 // 00026 #ifndef SMESH_MesherHelper_HeaderFile 00027 #define SMESH_MesherHelper_HeaderFile 00028 00029 #include "SMESH_SMESH.hxx" 00030 00031 #include "SMESH_MeshEditor.hxx" // needed for many meshers 00032 #include <SMDS_MeshNode.hxx> 00033 #include <SMDS_QuadraticEdge.hxx> 00034 00035 #include <Geom_Surface.hxx> 00036 #include <TopoDS_Face.hxx> 00037 #include <TopoDS_Shape.hxx> 00038 #include <gp_Pnt2d.hxx> 00039 00040 #include <map> 00041 00042 typedef std::map<SMESH_TLink, const SMDS_MeshNode*> TLinkNodeMap; 00043 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode; 00044 00054 typedef std::vector<const SMDS_MeshNode* > TNodeColumn; 00055 typedef std::map< double, TNodeColumn > TParam2ColumnMap; 00056 00057 class SMESH_EXPORT SMESH_MesherHelper 00058 { 00059 public: 00060 // ---------- PUBLIC UTILITIES ---------- 00061 00068 static bool IsMedium(const SMDS_MeshNode* node, 00069 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All); 00070 00084 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap, 00085 const TopoDS_Face& theFace, 00086 const TopoDS_Edge& theBaseEdge, 00087 SMESHDS_Mesh* theMesh); 00094 static TopoDS_Shape GetSubShapeByNode(const SMDS_MeshNode* node, 00095 SMESHDS_Mesh* meshDS); 00096 00103 static int WrapIndex(const int ind, const int nbNodes) { 00104 if ( ind < 0 ) return nbNodes + ind % nbNodes; 00105 if ( ind >= nbNodes ) return ind % nbNodes; 00106 return ind; 00107 } 00108 00112 static int NbAncestors(const TopoDS_Shape& shape, 00113 const SMESH_Mesh& mesh, 00114 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE); 00115 00116 public: 00117 // ---------- PUBLIC INSTANCE METHODS ---------- 00118 00119 // constructor 00120 SMESH_MesherHelper(SMESH_Mesh& theMesh); 00121 00122 SMESH_Mesh* GetMesh() const { return myMesh; } 00123 00124 SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); } 00125 00130 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape); 00134 void SetIsQuadratic(const bool theBuildQuadratic) 00135 { myCreateQuadratic = theBuildQuadratic; } 00139 bool GetIsQuadratic() const { return myCreateQuadratic; } 00140 00145 void FixQuadraticElements(bool volumeOnly=true); 00146 00152 void SetElementsOnShape(bool toSet) { mySetElemOnShape = toSet; } 00153 00157 void SetSubShape(const int subShapeID); 00158 void SetSubShape(const TopoDS_Shape& subShape); 00163 int GetSubShapeID() const { return myShapeID; } 00167 TopoDS_Shape GetSubShape() const { return myShape; } 00168 00172 SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0); 00176 SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1, 00177 const SMDS_MeshNode* n2, 00178 const int id = 0, 00179 const bool force3d = true); 00183 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1, 00184 const SMDS_MeshNode* n2, 00185 const SMDS_MeshNode* n3, 00186 const int id=0, 00187 const bool force3d = false); 00191 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1, 00192 const SMDS_MeshNode* n2, 00193 const SMDS_MeshNode* n3, 00194 const SMDS_MeshNode* n4, 00195 const int id = 0, 00196 const bool force3d = false); 00200 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, 00201 const SMDS_MeshNode* n2, 00202 const SMDS_MeshNode* n3, 00203 const SMDS_MeshNode* n4, 00204 const int id = 0, 00205 const bool force3d = true); 00209 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, 00210 const SMDS_MeshNode* n2, 00211 const SMDS_MeshNode* n3, 00212 const SMDS_MeshNode* n4, 00213 const SMDS_MeshNode* n5, 00214 const int id = 0, 00215 const bool force3d = true); 00219 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, 00220 const SMDS_MeshNode* n2, 00221 const SMDS_MeshNode* n3, 00222 const SMDS_MeshNode* n4, 00223 const SMDS_MeshNode* n5, 00224 const SMDS_MeshNode* n6, 00225 const int id = 0, 00226 const bool force3d = true); 00230 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1, 00231 const SMDS_MeshNode* n2, 00232 const SMDS_MeshNode* n3, 00233 const SMDS_MeshNode* n4, 00234 const SMDS_MeshNode* n5, 00235 const SMDS_MeshNode* n6, 00236 const SMDS_MeshNode* n7, 00237 const SMDS_MeshNode* n8, 00238 const int id = 0, 00239 bool force3d = true); 00243 double GetNodeU(const TopoDS_Edge& theEdge, 00244 const SMDS_MeshNode* theNode, 00245 bool* check=0); 00250 gp_XY GetNodeUV(const TopoDS_Face& F, 00251 const SMDS_MeshNode* n, 00252 const SMDS_MeshNode* inFaceNode=0, 00253 bool* check=0) const; 00258 bool CheckNodeUV(const TopoDS_Face& F, 00259 const SMDS_MeshNode* n, 00260 gp_XY& uv, 00261 const double tol) const; 00265 static gp_XY GetMiddleUV(const Handle(Geom_Surface)& surface, 00266 const gp_XY& uv1, 00267 const gp_XY& uv2); 00275 bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const; 00276 00284 bool IsDegenShape(const int subShape) const 00285 { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); } 00294 bool IsSeamShape(const int subShape) const 00295 { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); } 00304 bool IsSeamShape(const TopoDS_Shape& subShape) const 00305 { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); } 00310 bool IsRealSeam(const int subShape) const 00311 { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); } 00316 bool IsRealSeam(const TopoDS_Shape& subShape) const 00317 { return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); } 00323 bool HasSeam() const { return !mySeamShapeIds.empty(); } 00328 int GetPeriodicIndex() const { return myParIndex; } 00332 double GetOtherParam(const double param) const; 00333 00337 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1, 00338 const SMDS_MeshNode* n2, 00339 const bool force3d); 00343 void AddTLinkNode(const SMDS_MeshNode* n1, 00344 const SMDS_MeshNode* n2, 00345 const SMDS_MeshNode* n12); 00349 void AddTLinkNodeMap(const TLinkNodeMap& aMap) 00350 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); } 00351 00355 const TLinkNodeMap& GetTLinkNodeMap() const { return myTLinkNodeMap; } 00356 00362 enum MType{ LINEAR, QUADRATIC, COMP }; 00363 MType IsQuadraticMesh(); 00364 00365 protected: 00366 00373 gp_Pnt2d GetUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const; 00374 00375 private: 00376 00377 // Forbiden copy constructor 00378 SMESH_MesherHelper (const SMESH_MesherHelper& theOther) {}; 00379 00380 // special map for using during creation of quadratic elements 00381 TLinkNodeMap myTLinkNodeMap; 00382 00383 std::set< int > myDegenShapeIds; 00384 std::set< int > mySeamShapeIds; 00385 double myPar1, myPar2; // bounds of a closed periodic surface 00386 int myParIndex; // bounds' index (1-U, 2-V) 00387 00388 TopoDS_Shape myShape; 00389 SMESH_Mesh* myMesh; 00390 int myShapeID; 00391 00392 // to create quadratic elements 00393 bool myCreateQuadratic; 00394 bool mySetElemOnShape; 00395 std::set< int > myOkNodePosShapes; 00396 00397 }; 00398 00399 00400 #endif