Back to index

salome-smesh  6.5.0
SMESH_Mesh_i.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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_Mesh_i.hxx
00023 //  Author : Paul RASCLE, EDF
00024 //  Module : SMESH
00025 
00026 #ifndef _SMESH_MESH_I_HXX_
00027 #define _SMESH_MESH_I_HXX_
00028 
00029 #include "SMESH.hxx"
00030 
00031 #include <SALOMEconfig.h>
00032 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00033 #include CORBA_SERVER_HEADER(SMESH_Group)
00034 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00035 #include CORBA_CLIENT_HEADER(GEOM_Gen)
00036 #include CORBA_CLIENT_HEADER(MED)
00037 
00038 #include "SMESH_Hypothesis.hxx"
00039 #include "SMESH_Mesh.hxx"
00040 //#include "SMESH_subMesh_i.hxx"
00041 #include "SMESH_subMesh.hxx"
00042 
00043 #include "SALOME_GenericObj_i.hh"
00044 
00045 class SMESH_Gen_i;
00046 class SMESH_GroupBase_i;
00047 class SMESH_subMesh_i;
00048 class SMESH_PreMeshInfo;
00049 
00050 #include <map>
00051 
00052 class SMESH_I_EXPORT SMESH_Mesh_i:
00053   public virtual POA_SMESH::SMESH_Mesh,
00054   public virtual SALOME::GenericObj_i
00055 {
00056   SMESH_Mesh_i();
00057   SMESH_Mesh_i(const SMESH_Mesh_i&);
00058 public:
00059   SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
00060                 SMESH_Gen_i*            myGen_i,
00061                 CORBA::Long             studyId );
00062 
00063   virtual ~SMESH_Mesh_i();
00064 
00065   // --- CORBA
00066   void SetShape( GEOM::GEOM_Object_ptr theShapeObject )
00067     throw (SALOME::SALOME_Exception);
00068 
00069   CORBA::Boolean HasShapeToMesh()
00070     throw (SALOME::SALOME_Exception);
00071 
00072   GEOM::GEOM_Object_ptr GetShapeToMesh()
00073     throw (SALOME::SALOME_Exception);
00074 
00075   CORBA::Boolean IsLoaded()
00076     throw (SALOME::SALOME_Exception);
00077 
00078   void Load()
00079     throw (SALOME::SALOME_Exception);
00080 
00081   void Clear()
00082     throw (SALOME::SALOME_Exception);
00083 
00084   void ClearSubMesh(CORBA::Long ShapeID)
00085     throw (SALOME::SALOME_Exception);
00086 
00087   SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
00088                                          SMESH::SMESH_Hypothesis_ptr anHyp)
00089     throw (SALOME::SALOME_Exception);
00090 
00091   SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
00092                                             SMESH::SMESH_Hypothesis_ptr anHyp)
00093     throw (SALOME::SALOME_Exception);
00094 
00095   SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
00096     throw (SALOME::SALOME_Exception);
00097 
00098   SMESH::submesh_array* GetSubMeshes()
00099     throw (SALOME::SALOME_Exception);
00100 
00101   SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
00102     throw (SALOME::SALOME_Exception);
00103 
00104   void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
00105     throw (SALOME::SALOME_Exception);
00106 
00107   SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
00108     throw (SALOME::SALOME_Exception);
00109 
00110   SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType    theElemType,
00111                                                    const char*           theName,
00112                                                    GEOM::GEOM_Object_ptr theGeomObj )
00113     throw (SALOME::SALOME_Exception);
00114 
00115   SMESH::SMESH_GroupOnFilter_ptr CreateGroupFromFilter(SMESH::ElementType theElemType,
00116                                                        const char*        theName,
00117                                                        SMESH::Filter_ptr  theFilter )
00118     throw (SALOME::SALOME_Exception);
00119 
00120   void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
00121     throw (SALOME::SALOME_Exception);
00122 
00123   void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
00124     throw (SALOME::SALOME_Exception);
00125 
00126   SMESH::ListOfGroups* GetGroups()
00127     throw (SALOME::SALOME_Exception);
00128 
00129   CORBA::Long NbGroups()
00130     throw (SALOME::SALOME_Exception);
00131 
00132   SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
00133                                       SMESH::SMESH_GroupBase_ptr theGroup2,
00134                                       const char* theName )
00135     throw (SALOME::SALOME_Exception);
00136 
00137   SMESH::SMESH_Group_ptr UnionListOfGroups( const SMESH::ListOfGroups& theGroups,
00138                                             const char* theName)
00139     throw (SALOME::SALOME_Exception);
00140 
00141   SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
00142                                           SMESH::SMESH_GroupBase_ptr theGroup2,
00143                                           const char* theName )
00144     throw (SALOME::SALOME_Exception);
00145 
00146   SMESH::SMESH_Group_ptr IntersectListOfGroups( const SMESH::ListOfGroups&  theGroups,
00147                                                 const char* theName )
00148     throw (SALOME::SALOME_Exception);
00149 
00150   SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
00151                                     SMESH::SMESH_GroupBase_ptr theGroup2,
00152                                     const char* theName )
00153     throw (SALOME::SALOME_Exception);
00154 
00155   SMESH::SMESH_Group_ptr CutListOfGroups( const SMESH::ListOfGroups& theMainGroups,
00156                                           const SMESH::ListOfGroups& theToolGroups,
00157                                           const char* theName )
00158   throw (SALOME::SALOME_Exception);
00159 
00160   SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfGroups& theGroups,
00161                                          SMESH::ElementType theElemType,
00162                                          const char* theName )
00163   throw (SALOME::SALOME_Exception);
00164 
00165 
00166   SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroupOn );
00167 
00168 //    SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
00169 //      throw (SALOME::SALOME_Exception);
00170 
00171   SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
00172     throw (SALOME::SALOME_Exception);
00173 
00174   SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
00175 
00176   SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
00177 
00178   CORBA::Boolean HasModificationsToDiscard() throw (SALOME::SALOME_Exception);
00179 
00180   void ClearLog()
00181     throw (SALOME::SALOME_Exception);
00182 
00183   CORBA::Long GetId()
00184     throw (SALOME::SALOME_Exception);
00185 
00186   CORBA::Long GetStudyId()
00187     throw (SALOME::SALOME_Exception);
00188 
00189   // --- C++ interface
00190   void SetImpl(::SMESH_Mesh* impl);
00191   ::SMESH_Mesh& GetImpl();         // :: force no namespace here
00192 
00193   SMESH_Gen_i* GetGen() { return _gen_i; }
00194 
00195   int ImportUNVFile( const char* theFileName )
00196     throw (SALOME::SALOME_Exception);
00197 
00198   int ImportSTLFile( const char* theFileName )
00199     throw (SALOME::SALOME_Exception);
00200 
00204   SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
00205     throw (SALOME::SALOME_Exception);
00206 
00207   SMESH::DriverMED_ReadStatus ImportCGNSFile( const char*  theFileName,
00208                                               const int    theMeshIndex,
00209                                               std::string& theMeshName)
00210     throw (SALOME::SALOME_Exception);
00211 
00215   void SetAutoColor(CORBA::Boolean theAutoColor)
00216     throw (SALOME::SALOME_Exception);
00217 
00218   CORBA::Boolean GetAutoColor()
00219     throw (SALOME::SALOME_Exception);
00220 
00224   CORBA::Boolean HasDuplicatedGroupNamesMED();
00228   char* GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits);
00229 
00230   void ExportToMEDX( const char*        file,
00231                      CORBA::Boolean     auto_groups,
00232                      SMESH::MED_VERSION version,
00233                      CORBA::Boolean     overwrite ) throw (SALOME::SALOME_Exception);
00234   void ExportToMED ( const char*        file,
00235                      CORBA::Boolean     auto_groups,
00236                      SMESH::MED_VERSION version ) throw (SALOME::SALOME_Exception);
00237   void ExportMED   ( const char*        file,
00238                      CORBA::Boolean     auto_groups ) throw (SALOME::SALOME_Exception);
00239 
00240   void ExportSAUV( const char* file, CORBA::Boolean auto_groups ) throw (SALOME::SALOME_Exception);
00241 
00242   void ExportDAT( const char* file ) throw (SALOME::SALOME_Exception);
00243   void ExportUNV( const char* file ) throw (SALOME::SALOME_Exception);
00244   void ExportSTL( const char* file, bool isascii ) throw (SALOME::SALOME_Exception);
00245   void ExportCGNS(SMESH::SMESH_IDSource_ptr meshPart,
00246                   const char*               file,
00247                   CORBA::Boolean            overwrite) throw (SALOME::SALOME_Exception);
00248 
00249   void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
00250                        const char*               file,
00251                        CORBA::Boolean            auto_groups,
00252                        SMESH::MED_VERSION        version,
00253                        CORBA::Boolean            overwrite) throw (SALOME::SALOME_Exception);
00254   void ExportPartToDAT(SMESH::SMESH_IDSource_ptr meshPart,
00255                        const char*               file) throw (SALOME::SALOME_Exception);
00256   void ExportPartToUNV(SMESH::SMESH_IDSource_ptr meshPart,
00257                        const char*               file) throw (SALOME::SALOME_Exception);
00258   void ExportPartToSTL(SMESH::SMESH_IDSource_ptr meshPart,
00259                        const char*               file,
00260                        CORBA::Boolean            isascii) throw (SALOME::SALOME_Exception);
00261 
00262   SALOME_MED::MESH_ptr GetMEDMesh()
00263     throw (SALOME::SALOME_Exception);
00264 
00265   CORBA::Long NbNodes()
00266     throw (SALOME::SALOME_Exception);
00267 
00268   CORBA::Long NbElements()
00269     throw (SALOME::SALOME_Exception);
00270 
00271   CORBA::Long Nb0DElements()
00272     throw (SALOME::SALOME_Exception);
00273 
00274   CORBA::Long NbEdges()
00275     throw (SALOME::SALOME_Exception);
00276 
00277   CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
00278     throw (SALOME::SALOME_Exception);
00279 
00280   CORBA::Long NbFaces()
00281     throw (SALOME::SALOME_Exception);
00282 
00283   CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
00284     throw (SALOME::SALOME_Exception);
00285 
00286   CORBA::Long NbTriangles()
00287     throw (SALOME::SALOME_Exception);
00288 
00289   CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
00290     throw (SALOME::SALOME_Exception);
00291 
00292   CORBA::Long NbQuadrangles()
00293     throw (SALOME::SALOME_Exception);
00294 
00295   CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
00296     throw (SALOME::SALOME_Exception);
00297 
00298   CORBA::Long NbBiQuadQuadrangles()
00299     throw (SALOME::SALOME_Exception);
00300 
00301   CORBA::Long NbPolygons()
00302     throw (SALOME::SALOME_Exception);
00303 
00304   CORBA::Long NbVolumes()
00305     throw (SALOME::SALOME_Exception);
00306 
00307   CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
00308     throw (SALOME::SALOME_Exception);
00309 
00310   CORBA::Long NbTetras()
00311     throw (SALOME::SALOME_Exception);
00312 
00313   CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
00314     throw (SALOME::SALOME_Exception);
00315 
00316   CORBA::Long NbHexas()
00317     throw (SALOME::SALOME_Exception);
00318 
00319   CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
00320     throw (SALOME::SALOME_Exception);
00321 
00322   CORBA::Long NbTriQuadraticHexas()
00323     throw (SALOME::SALOME_Exception);
00324 
00325   CORBA::Long NbPyramids()
00326     throw (SALOME::SALOME_Exception);
00327 
00328   CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
00329     throw (SALOME::SALOME_Exception);
00330 
00331   CORBA::Long NbPrisms()
00332     throw (SALOME::SALOME_Exception);
00333 
00334   CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
00335     throw (SALOME::SALOME_Exception);
00336 
00337   CORBA::Long NbHexagonalPrisms()
00338     throw (SALOME::SALOME_Exception);
00339 
00340   CORBA::Long NbPolyhedrons()
00341     throw (SALOME::SALOME_Exception);
00342 
00343   CORBA::Long NbSubMesh()
00344     throw (SALOME::SALOME_Exception);
00345 
00346   SMESH::long_array* GetElementsId()
00347     throw (SALOME::SALOME_Exception);
00348 
00349   SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
00350     throw (SALOME::SALOME_Exception);
00351 
00352   SMESH::long_array* GetNodesId()
00353     throw (SALOME::SALOME_Exception);
00354 
00355   SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
00356     throw (SALOME::SALOME_Exception);
00357 
00358   SMESH::EntityType GetElementGeomType( CORBA::Long id )
00359     throw (SALOME::SALOME_Exception);
00360 
00364   SMESH::long_array* GetSubMeshElementsId(CORBA::Long ShapeID)
00365     throw (SALOME::SALOME_Exception);
00366 
00372   SMESH::long_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all)
00373     throw (SALOME::SALOME_Exception);
00374 
00378   SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID)
00379     throw (SALOME::SALOME_Exception);
00380 
00381   char* Dump();
00382 
00383   // Internal methods not available through CORBA
00384   // They are called by corresponding interface methods
00385   SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
00386                                                     SMESH::SMESH_Hypothesis_ptr anHyp);
00387 
00388   SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
00389                                                        SMESH::SMESH_Hypothesis_ptr anHyp);
00390 
00391   static SMESH::Hypothesis_Status
00392   ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
00393 
00394   static void PrepareForWriting (const char* file, bool overwrite = true);
00395 
00396   //int importMEDFile( const char* theFileName, const char* theMeshName );
00397 
00398   SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
00399 
00400   bool removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
00401                      GEOM::GEOM_Object_ptr theSubShapeObject );
00402 
00403   SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType        theElemType,
00404                                          const char*               theName,
00405                                          const TopoDS_Shape&       theShape = TopoDS_Shape(),
00406                                          const SMESH_PredicatePtr& thePred = SMESH_PredicatePtr());
00407 
00408   void removeGroup( const int theId );
00409 
00410   SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
00411   // return an existing subMesh object for the shapeID. shapeID == submeshID.
00412 
00413   const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
00414   // return an existing group object.
00415 
00416   void onHypothesisModified();
00417   // callback from _impl to forget not loaded mesh data (issue 0021208)
00418 
00419   void checkMeshLoaded();
00420 
00426   void CheckGeomGroupModif();
00427 
00428   CORBA::LongLong GetMeshPtr();
00429 
00433   void CreateGroupServants();
00434 
00438   SMESH::ListOfGroups* GetGroups(const std::list<int>& groupIDs) const;
00439 
00444   SMESH::double_array* GetNodeXYZ(CORBA::Long id);
00445 
00450   SMESH::long_array* GetNodeInverseElements(CORBA::Long id);
00451 
00455   SMESH::NodePosition* GetNodePosition(CORBA::Long NodeID);
00456 
00461   CORBA::Long GetShapeID(CORBA::Long id);
00462 
00468   CORBA::Long GetShapeIDForElem(CORBA::Long id);
00469 
00474   CORBA::Long GetElemNbNodes(CORBA::Long id);
00475 
00479   SMESH::long_array* GetElemNodes(CORBA::Long id);
00480 
00486   CORBA::Long GetElemNode(CORBA::Long id, CORBA::Long index);
00487 
00492   CORBA::Boolean IsMediumNode(CORBA::Long ide, CORBA::Long idn);
00493 
00498   CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
00499                                        SMESH::ElementType theElemType);
00500 
00504   CORBA::Long ElemNbEdges(CORBA::Long id);
00505 
00509   CORBA::Long ElemNbFaces(CORBA::Long id);
00513   SMESH::long_array* GetElemFaceNodes(CORBA::Long elemId, CORBA::Short faceIndex);
00514 
00518   CORBA::Long FindElementByNodes(const SMESH::long_array& nodes);
00519 
00523   CORBA::Boolean IsPoly(CORBA::Long id);
00524 
00528   CORBA::Boolean IsQuadratic(CORBA::Long id);
00529 
00533   SMESH::double_array* BaryCenter(CORBA::Long id);
00534 
00538   virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
00539 
00543   void SetParameters (const char* theParameters);
00544 
00548   char* GetParameters();
00549 
00553   SMESH::string_array* GetLastParameters();
00554 
00558   static void CollectMeshInfo(const SMDS_ElemIteratorPtr theItr,
00559                               SMESH::long_array&         theInfo);
00560 
00564   virtual SMESH::submesh_array_array* GetMeshOrder();
00568   virtual ::CORBA::Boolean SetMeshOrder(const SMESH::submesh_array_array& theSubMeshArray);
00569 
00570 
00571   // =========================
00572   // SMESH_IDSource interface
00573   // =========================
00574 
00575   virtual SMESH::long_array* GetIDs();
00581   virtual SMESH::long_array* GetMeshInfo();
00585   virtual SMESH::array_of_ElementType* GetTypes();
00589   virtual SMESH::SMESH_Mesh_ptr GetMesh();
00594   bool IsMeshInfoCorrect();
00595 
00596   std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
00597   std::map<int, ::SMESH_subMesh*> _mapSubMesh;   //NRI
00598 
00599 private:
00600   std::string prepareMeshNameAndGroups( const char* file, CORBA::Boolean overwrite );
00601 
00605   void checkGroupNames();
00606 
00610   void convertMeshOrder(const TListOfListOfInt&     theIdsOrder,
00611                         SMESH::submesh_array_array& theSubMeshOrder,
00612                         const bool                  theIsDump);
00613 
00614 private:
00615 
00616   static int    _idGenerator;
00617   ::SMESH_Mesh* _impl;        // :: force no namespace here
00618   SMESH_Gen_i*  _gen_i;
00619   int           _id;          // id given by creator (unique within the creator instance)
00620   int           _studyId;
00621   std::map<int, SMESH::SMESH_subMesh_ptr>    _mapSubMeshIor;
00622   std::map<int, SMESH::SMESH_GroupBase_ptr>  _mapGroups;
00623   std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
00624   SALOME_MED::MedFileInfo_var _medFileInfo;
00625   SMESH_PreMeshInfo*          _preMeshInfo; // mesh info before full loading from study file
00626 
00627   SMESH_PreMeshInfo* & changePreMeshInfo() { return _preMeshInfo; }
00628   friend class SMESH_PreMeshInfo;
00629 
00630 private:
00631 
00632   // Data used to track changes of GEOM groups
00633   struct TGeomGroupData {
00634     // keep study entry but not ior because GEOM_Object actually changes if
00635     // number of items in a group varies (1) <-> (>1)
00636     std::string       _groupEntry;
00637     std::set<int>     _indices; // indices of group items within group's main shape
00638     CORBA::Object_ptr _smeshObject; // SMESH object depending on GEOM group
00639   };
00640   std::list<TGeomGroupData> _geomGroupData;
00641 
00645   void addGeomGroupData(GEOM::GEOM_Object_ptr theGeomObj,
00646                         CORBA::Object_ptr     theSmeshObj);
00650   void removeGeomGroupData(CORBA::Object_ptr theSmeshObj);
00654   TopoDS_Shape newGroupShape( TGeomGroupData & groupData);
00655 
00656 };
00657 
00658 #endif