SALOME - SMESH
StdMeshers_Penta_3D.hxx
Go to the documentation of this file.
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 StdMeshers : implementaion of SMESH idl descriptions
00023 //  File   : StdMeshers_Penta_3D.hxx
00024 //  Module : SMESH
00025 //
00026 #ifndef StdMeshers_Penta_3D_HeaderFile
00027 #define StdMeshers_Penta_3D_HeaderFile
00028 
00029 #include "SMESH_StdMeshers.hxx"
00030 
00031 #include <map>
00032 
00034 //
00035 //  class StdMeshers_SMESHBlock
00036 //
00038 #include <gp_Pnt.hxx>
00039 #include <gp_XYZ.hxx>
00040 #include <TopoDS_Vertex.hxx>
00041 #include <TopoDS_Shell.hxx>
00042 #include <TopTools_IndexedMapOfOrientedShape.hxx>
00043 #include <TColStd_MapOfInteger.hxx>
00044 
00045 #include "SMESH_Block.hxx"
00046 #include "SMESH_ComputeError.hxx"
00047 #include "SMESH_MesherHelper.hxx"
00048 #include "SMESH_3D_Algo.hxx"
00049 
00050 typedef std::map< double, std::vector<const SMDS_MeshNode*> > StdMeshers_IJNodeMap;
00051 
00052 class STDMESHERS_EXPORT StdMeshers_SMESHBlock {
00053  
00054 public:
00055   //
00056   StdMeshers_SMESHBlock();
00057   
00058   void Load (const TopoDS_Shell& theShell);
00059   
00060   void Load (const TopoDS_Shell& theShell,
00061           const TopoDS_Vertex& theV000,
00062           const TopoDS_Vertex& theV001);
00063   
00064   void ComputeParameters(const gp_Pnt& thePnt, 
00065                 gp_XYZ& theXYZ);
00066   
00067   void ComputeParameters(const gp_Pnt& thePnt,
00068                 const TopoDS_Shape& theShape,
00069                 gp_XYZ& theXYZ);
00070   
00071   void ComputeParameters(const double& theU,
00072                 const TopoDS_Shape& theShape,
00073                 gp_XYZ& theXYZ);
00074   
00075   void Point(const gp_XYZ& theParams, 
00076           gp_Pnt& thePnt);
00077   
00078   void Point(const gp_XYZ& theParams,
00079           const TopoDS_Shape& theShape, 
00080           gp_Pnt& thePnt);
00081   
00082   int ShapeID(const TopoDS_Shape& theShape); 
00083   
00084   const TopoDS_Shape& Shape(const int theID);
00085 
00086   SMESH_Block & Block() { return myTBlock; }
00087 
00088   bool IsForwadEdge(const int theEdgeID);
00089 
00090   int  ErrorStatus() const;
00091 
00092   SMESH_ComputeErrorPtr GetError() const;
00093 
00094 
00095 protected:
00096   TopoDS_Shell                       myShell;
00097   TopTools_IndexedMapOfOrientedShape myShapeIDMap;
00098   SMESH_Block                        myTBlock;
00099   TopoDS_Shape                       myEmptyShape;
00100   std::vector<int>                   myIsEdgeForward;
00101   //
00102   int myErrorStatus;
00103 };
00104 
00106 //
00107 //  class StdMeshers_TNode
00108 //
00110 #include "SMDS_MeshNode.hxx"
00111 
00112 class STDMESHERS_EXPORT StdMeshers_TNode {
00113 
00114 public:
00115   
00116   StdMeshers_TNode(){
00117     myNode=NULL;
00118     myXYZ.SetCoord(99., 99., 99.);
00119     myShapeSupportID=-1;
00120     myBaseNodeID=-1;
00121   }
00122   
00123   void SetNode(const SMDS_MeshNode* theNode) {
00124     myNode=(SMDS_MeshNode*) theNode;
00125   }
00126   
00127   const SMDS_MeshNode* Node()const {
00128     return myNode;
00129   }
00130 
00131   void SetShapeSupportID (const int theID) {
00132     myShapeSupportID=theID;
00133   }
00134   
00135   int ShapeSupportID()const {
00136     return myShapeSupportID;
00137   }
00138   
00139   void SetNormCoord (const gp_XYZ& theXYZ) {
00140     myXYZ=theXYZ;
00141   }
00142 
00143   const gp_XYZ& NormCoord ()const{
00144     return myXYZ;
00145   }
00146   
00147   void SetBaseNodeID (const int theID) {
00148     myBaseNodeID=theID;
00149   }
00150   
00151   int BaseNodeID ()const{
00152     return myBaseNodeID;
00153   }
00154 
00155 private:
00156   SMDS_MeshNode* myNode;
00157   int  myShapeSupportID;
00158   gp_XYZ         myXYZ;
00159   int            myBaseNodeID;
00160 };
00161 
00163 //
00164 //  class StdMeshers_Penta_3D
00165 //
00167 #include "SMESH_Mesh.hxx"
00168 #include <TopoDS_Shape.hxx>
00169 //
00170 class STDMESHERS_EXPORT StdMeshers_Penta_3D {
00171 //
00172   public: // methods
00173     StdMeshers_Penta_3D();
00174     
00175     ~StdMeshers_Penta_3D();
00176     
00177     bool Compute(SMESH_Mesh& , const TopoDS_Shape& );
00178     
00179     int ErrorStatus() const {
00180       if (myErrorStatus->IsOK())
00181         return 0;
00182       return myErrorStatus->myName;
00183     }
00184 
00185     SMESH_ComputeErrorPtr GetComputeError() const {
00186       return myErrorStatus;
00187     }
00188    
00189     void SetTolerance(const double theTol3D) {
00190       myTol3D=theTol3D;
00191     }
00192     
00193     double Tolerance() const {
00194       return myTol3D;
00195     }
00196 
00197     bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
00198                      const TopoDS_Face&     theFace,
00199                      const TopoDS_Edge&     theBaseEdge,
00200                      SMESHDS_Mesh*          theMesh);
00201     // Load nodes bound to theFace into column (vectors) and rows
00202     // of theIJNodes.
00203     // The value of theIJNodes map is a vector of ordered nodes so
00204     // that the 0-the one lies on theBaseEdge.
00205     // The key of theIJNodes map is a normalized parameter of each
00206     // 0-the node on theBaseEdge.
00207 
00208     bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
00209             MapShapeNbElems& aResMap);
00210 
00211 
00212   protected: // methods
00213     
00214     void CheckData();
00215     
00216     void MakeBlock();
00217 
00218     void MakeNodes();
00219 
00220     double SetHorizEdgeXYZ(const gp_XYZ&                  aBNXYZ,
00221                            const int                      aFaceID,
00222                            std::vector<const SMDS_MeshNode*>*& aCol1,
00223                            std::vector<const SMDS_MeshNode*>*& aCol2);
00224 
00225     void ShapeSupportID(const bool theIsUpperLayer,
00226                const SMESH_Block::TShapeID theBNSSID,
00227                SMESH_Block::TShapeID& theSSID);
00228 
00229     void FindNodeOnShape(const TopoDS_Shape& aS,
00230                 const gp_XYZ& aParams,
00231                          const int z,
00232                 StdMeshers_TNode& aTN);
00233 
00234     void CreateNode(const bool theIsUpperLayer,
00235               const gp_XYZ& aParams,
00236               StdMeshers_TNode& aTN);
00237 
00238     void ClearMeshOnFxy1();
00239 
00240     void MakeMeshOnFxy1();
00241 
00242     void MakeConnectingMap();
00243 
00244     int GetIndexOnLayer(const int aID);
00245 
00246     void MakeVolumeMesh();
00247   
00248     void SetMesh(SMESH_Mesh& theMesh) {
00249       myMesh=(void *)&theMesh;
00250     }
00251     
00252     SMESH_Mesh* GetMesh()const {
00253       return (SMESH_Mesh*)myMesh;
00254     }
00255     
00256   protected: // fields
00257     TopoDS_Shape              myShape;
00258     StdMeshers_SMESHBlock     myBlock;
00259     void *                    myMesh;
00260     SMESH_ComputeErrorPtr     myErrorStatus;
00261     //
00262     std::vector <StdMeshers_TNode> myTNodes;
00263     int                       myISize;
00264     int                       myJSize;
00265     double                    myTol3D;        // Tolerance value     
00266     std::map < int, int >     myConnectingMap;
00267     //
00268     std::vector<StdMeshers_IJNodeMap> myWallNodesMaps; // nodes on a face
00269     std::vector<gp_XYZ>               myShapeXYZ; // point on each sub-shape
00270 
00271     bool myCreateQuadratic;
00272     SMESH_MesherHelper* myTool; // tool building quadratic elements
00273 };
00274 
00275 #endif