| 1 | // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE |
| 2 | // |
| 3 | // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, |
| 4 | // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS |
| 5 | // |
| 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, or (at your option) any later version. |
| 10 | // |
| 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. |
| 15 | // |
| 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 |
| 19 | // |
| 20 | // See http://www.salome-platform.org/ or email : [email protected] |
| 21 | // |
| 22 | |
| 23 | // SMESH StdMeshers : implementation of SMESH idl descriptions |
| 24 | // File : StdMeshers_Penta_3D.hxx |
| 25 | // Module : SMESH |
| 26 | // |
| 27 | #ifndef StdMeshers_Penta_3D_HeaderFile |
| 28 | #define StdMeshers_Penta_3D_HeaderFile |
| 29 | |
| 30 | #include "SMESH_StdMeshers.hxx" |
| 31 | |
| 32 | #include <map> |
| 33 | |
| 34 | //////////////////////////////////////////////////////////////////////// |
| 35 | // |
| 36 | // class StdMeshers_SMESHBlock |
| 37 | // |
| 38 | //////////////////////////////////////////////////////////////////////// |
| 39 | #include <TColStd_MapOfInteger.hxx> |
| 40 | #include <TopTools_IndexedMapOfOrientedShape.hxx> |
| 41 | #include <TopoDS_Shell.hxx> |
| 42 | #include <TopoDS_Vertex.hxx> |
| 43 | #include <gp_Pnt.hxx> |
| 44 | #include <gp_XYZ.hxx> |
| 45 | |
| 46 | #include "SMESH_Algo.hxx" |
| 47 | #include "SMESH_Block.hxx" |
| 48 | #include "SMESH_ComputeError.hxx" |
| 49 | #include "SMESH_MesherHelper.hxx" |
| 50 | |
| 51 | typedef std::map< double, std::vector<const SMDS_MeshNode*> > StdMeshers_IJNodeMap; |
| 52 | |
| 53 | class STDMESHERS_EXPORT StdMeshers_SMESHBlock { |
| 54 | |
| 55 | public: |
| 56 | // |
| 57 | StdMeshers_SMESHBlock(); |
| 58 | |
| 59 | void Load (const TopoDS_Shell& theShell); |
| 60 | |
| 61 | void Load (const TopoDS_Shell& theShell, |
| 62 | const TopoDS_Vertex& theV000, |
| 63 | const TopoDS_Vertex& theV001); |
| 64 | |
| 65 | void ComputeParameters(const gp_Pnt& thePnt, |
| 66 | gp_XYZ& theXYZ); |
| 67 | |
| 68 | void ComputeParameters(const gp_Pnt& thePnt, |
| 69 | const TopoDS_Shape& theShape, |
| 70 | gp_XYZ& theXYZ); |
| 71 | |
| 72 | void ComputeParameters(const double& theU, |
| 73 | const TopoDS_Shape& theShape, |
| 74 | gp_XYZ& theXYZ); |
| 75 | |
| 76 | void Point(const gp_XYZ& theParams, |
| 77 | gp_Pnt& thePnt); |
| 78 | |
| 79 | void Point(const gp_XYZ& theParams, |
| 80 | const TopoDS_Shape& theShape, |
| 81 | gp_Pnt& thePnt); |
| 82 | |
| 83 | int ShapeID(const TopoDS_Shape& theShape); |
| 84 | |
| 85 | const TopoDS_Shape& Shape(const int theID); |
| 86 | |
| 87 | SMESH_Block & Block() { return myTBlock; } |
| 88 | |
| 89 | bool IsForwadEdge(const int theEdgeID); |
| 90 | |
| 91 | int ErrorStatus() const; |
| 92 | |
| 93 | SMESH_ComputeErrorPtr GetError() const; |
| 94 | |
| 95 | |
| 96 | protected: |
| 97 | TopoDS_Shell myShell; |
| 98 | TopTools_IndexedMapOfOrientedShape myShapeIDMap; |
| 99 | SMESH_Block myTBlock; |
| 100 | TopoDS_Shape myEmptyShape; |
| 101 | std::vector<int> myIsEdgeForward; |
| 102 | // |
| 103 | int myErrorStatus; |
| 104 | }; |
| 105 | |
| 106 | //////////////////////////////////////////////////////////////////////// |
| 107 | // |
| 108 | // class StdMeshers_TNode |
| 109 | // |
| 110 | //////////////////////////////////////////////////////////////////////// |
| 111 | #include "SMDS_MeshNode.hxx" |
| 112 | |
| 113 | class STDMESHERS_EXPORT StdMeshers_TNode { |
| 114 | |
| 115 | public: |
| 116 | |
| 117 | StdMeshers_TNode(){ |
| 118 | myNode=NULL; |
| 119 | myXYZ.SetCoord(99., 99., 99.); |
| 120 | myShapeSupportID=-1; |
| 121 | myBaseNodeID=-1; |
| 122 | } |
| 123 | |
| 124 | void SetNode(const SMDS_MeshNode* theNode) { |
| 125 | myNode=(SMDS_MeshNode*) theNode; |
| 126 | } |
| 127 | |
| 128 | const SMDS_MeshNode* Node()const { |
| 129 | return myNode; |
| 130 | } |
| 131 | |
| 132 | void SetShapeSupportID (const int theID) { |
| 133 | myShapeSupportID=theID; |
| 134 | } |
| 135 | |
| 136 | int ShapeSupportID()const { |
| 137 | return myShapeSupportID; |
| 138 | } |
| 139 | |
| 140 | void SetNormCoord (const gp_XYZ& theXYZ) { |
| 141 | myXYZ=theXYZ; |
| 142 | } |
| 143 | |
| 144 | const gp_XYZ& NormCoord ()const{ |
| 145 | return myXYZ; |
| 146 | } |
| 147 | |
| 148 | void SetBaseNodeID (const int theID) { |
| 149 | myBaseNodeID=theID; |
| 150 | } |
| 151 | |
| 152 | int BaseNodeID ()const{ |
| 153 | return myBaseNodeID; |
| 154 | } |
| 155 | |
| 156 | private: |
| 157 | SMDS_MeshNode* myNode; |
| 158 | int myShapeSupportID; |
| 159 | gp_XYZ myXYZ; |
| 160 | int myBaseNodeID; |
| 161 | }; |
| 162 | |
| 163 | //////////////////////////////////////////////////////////////////////// |
| 164 | // |
| 165 | // class StdMeshers_Penta_3D |
| 166 | // |
| 167 | //////////////////////////////////////////////////////////////////////// |
| 168 | #include "SMESH_Mesh.hxx" |
| 169 | #include <TopoDS_Shape.hxx> |
| 170 | // |
| 171 | class STDMESHERS_EXPORT StdMeshers_Penta_3D { |
| 172 | // |
| 173 | public: // methods |
| 174 | StdMeshers_Penta_3D(); |
| 175 | |
| 176 | ~StdMeshers_Penta_3D(); |
| 177 | |
| 178 | bool Compute(SMESH_Mesh& , const TopoDS_Shape& ); |
| 179 | |
| 180 | int ErrorStatus() const { |
| 181 | if (myErrorStatus->IsOK()) |
| 182 | return 0; |
| 183 | return myErrorStatus->myName; |
| 184 | } |
| 185 | |
| 186 | SMESH_ComputeErrorPtr GetComputeError() const { |
| 187 | return myErrorStatus; |
| 188 | } |
| 189 | |
| 190 | void SetTolerance(const double theTol3D) { |
| 191 | myTol3D=theTol3D; |
| 192 | } |
| 193 | |
| 194 | double Tolerance() const { |
| 195 | return myTol3D; |
| 196 | } |
| 197 | |
| 198 | bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, |
| 199 | const TopoDS_Face& theFace, |
| 200 | const TopoDS_Edge& theBaseEdge, |
| 201 | SMESHDS_Mesh* theMesh); |
| 202 | // Load nodes bound to theFace into column (vectors) and rows |
| 203 | // of theIJNodes. |
| 204 | // The value of theIJNodes map is a vector of ordered nodes so |
| 205 | // that the 0-the one lies on theBaseEdge. |
| 206 | // The key of theIJNodes map is a normalized parameter of each |
| 207 | // 0-the node on theBaseEdge. |
| 208 | |
| 209 | bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, |
| 210 | MapShapeNbElems& aResMap); |
| 211 | |
| 212 | |
| 213 | protected: // methods |
| 214 | |
| 215 | void CheckData(); |
| 216 | |
| 217 | void MakeBlock(); |
| 218 | |
| 219 | void MakeNodes(); |
| 220 | |
| 221 | double SetHorizEdgeXYZ(const gp_XYZ& aBNXYZ, |
| 222 | const int aFaceID, |
| 223 | std::vector<const SMDS_MeshNode*>*& aCol1, |
| 224 | std::vector<const SMDS_MeshNode*>*& aCol2); |
| 225 | |
| 226 | void ShapeSupportID(const bool theIsUpperLayer, |
| 227 | const SMESH_Block::TShapeID theBNSSID, |
| 228 | SMESH_Block::TShapeID& theSSID); |
| 229 | |
| 230 | void FindNodeOnShape(const TopoDS_Shape& aS, |
| 231 | const gp_XYZ& aParams, |
| 232 | const int z, |
| 233 | StdMeshers_TNode& aTN); |
| 234 | |
| 235 | void CreateNode(const bool theIsUpperLayer, |
| 236 | const gp_XYZ& aParams, |
| 237 | StdMeshers_TNode& aTN); |
| 238 | |
| 239 | void ClearMeshOnFxy1(); |
| 240 | |
| 241 | void MakeMeshOnFxy1(); |
| 242 | |
| 243 | void MakeConnectingMap(); |
| 244 | |
| 245 | int GetIndexOnLayer(const int aID); |
| 246 | |
| 247 | void MakeVolumeMesh(); |
| 248 | |
| 249 | void SetMesh(SMESH_Mesh& theMesh) { |
| 250 | myMesh=(void *)&theMesh; |
| 251 | } |
| 252 | |
| 253 | SMESH_Mesh* GetMesh()const { |
| 254 | return (SMESH_Mesh*)myMesh; |
| 255 | } |
| 256 | |
| 257 | protected: // fields |
| 258 | TopoDS_Shape myShape; |
| 259 | StdMeshers_SMESHBlock myBlock; |
| 260 | void * myMesh; |
| 261 | SMESH_ComputeErrorPtr myErrorStatus; |
| 262 | // |
| 263 | std::vector <StdMeshers_TNode> myTNodes; |
| 264 | int myISize; |
| 265 | int myJSize; |
| 266 | double myTol3D; // Tolerance value |
| 267 | std::map < int, int > myConnectingMap; |
| 268 | // |
| 269 | std::vector<StdMeshers_IJNodeMap> myWallNodesMaps; // nodes on a face |
| 270 | std::vector<gp_XYZ> myShapeXYZ; // point on each sub-shape |
| 271 | |
| 272 | bool myCreateQuadratic; |
| 273 | SMESH_MesherHelper* myTool; // tool building quadratic elements |
| 274 | }; |
| 275 | |
| 276 | #endif |