26 #ifndef _SMESH_GEN_I_HXX_ 
   27 #define _SMESH_GEN_I_HXX_ 
   31 #include <SALOMEconfig.h> 
   32 #include CORBA_SERVER_HEADER(SMESH_Gen) 
   33 #include CORBA_SERVER_HEADER(SMESH_Mesh) 
   34 #include CORBA_SERVER_HEADER(SMESH_Hypothesis) 
   35 #include CORBA_CLIENT_HEADER(GEOM_Gen) 
   36 #include CORBA_CLIENT_HEADER(SALOMEDS) 
   37 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) 
   43 #include <SALOME_Component_i.hxx> 
   44 #include <SALOME_NamingService.hxx> 
   45 #include <Utils_CorbaException.hxx> 
   47 #include <GEOM_Client.hxx> 
   49 #include <TCollection_AsciiString.hxx> 
   50 #include <Resource_DataMapOfAsciiStringAsciiString.hxx> 
   51 #include <TColStd_HSequenceOfAsciiString.hxx> 
   57 class SALOME_LifeCycleCORBA;
 
   74   int addObject( std::string theIOR )
 
   76     int nextId = getNextId();
 
   77     mapIdToIOR[ nextId ]  = theIOR;
 
   81   int findId( std::string theIOR )
 
   83     std::map<int, std::string>::iterator imap;
 
   84     for ( imap = mapIdToIOR.begin(); imap != mapIdToIOR.end(); ++imap ) {
 
   85       if ( imap->second == theIOR )
 
   91   std::string getIORbyId( 
const int theId )
 
   93     if ( mapIdToIOR.find( theId ) != mapIdToIOR.end() )
 
   94       return mapIdToIOR[ theId ];
 
   95     return std::string( 
"" );
 
   98   std::string getIORbyOldId( 
const int theOldId )
 
  100     if ( mapIdToId.find( theOldId ) != mapIdToId.end() )
 
  101       return getIORbyId( mapIdToId[ theOldId ] );
 
  102     return std::string( 
"" );
 
  106     mapIdToId[ oldId ] = newId;
 
  110     std::map<int, int>::iterator imap;
 
  111     for ( imap = mapIdToId.begin(); imap != mapIdToId.end(); ++imap ) {
 
  112       if ( imap->second == newId )
 
  123     while( mapIdToIOR.find( 
id ) != mapIdToIOR.end() )
 
  136   public virtual POA_SMESH::SMESH_Gen,
 
  143   static CORBA::ORB_var 
GetORB() { 
return myOrb;}
 
  145   static PortableServer::POA_var 
GetPOA() { 
return myPoa;}
 
  147   static SALOME_NamingService* GetNS();
 
  149   static SALOME_LifeCycleCORBA* GetLCC();
 
  151   static GEOM::GEOM_Gen_var GetGeomEngine();
 
  153   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
 
  155   static CORBA::Object_var 
SObjectToObject( SALOMEDS::SObject_ptr theSObject );
 
  157   static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy,
 
  158                                                CORBA::Object_ptr   theObject);
 
  160   GEOM::GEOM_Object_ptr ShapeToGeomObject (
const TopoDS_Shape& theShape );
 
  162   TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
 
  168                PortableServer::POA_ptr   poa,
 
  169                PortableServer::ObjectId* contId,
 
  170                const char*               instanceName,
 
  171                const char*               interfaceName );
 
  179   void SetName(
const char* theIOR,
 
  180                const char* theName);
 
  183   void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
 
  186   void SetEmbeddedMode( CORBA::Boolean theMode );
 
  188   CORBA::Boolean IsEmbeddedMode();
 
  191   void SetCurrentStudy( SALOMEDS::Study_ptr theStudy );
 
  193   SALOMEDS::Study_ptr GetCurrentStudy();
 
  197                                                 const char* theLibName)
 
  198     throw ( SALOME::SALOME_Exception );
 
  201   SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (
const char*           theHypType,
 
  202                                                             const char*           theLibName,
 
  203                                                             SMESH::SMESH_Mesh_ptr theMesh,
 
  204                                                             GEOM::GEOM_Object_ptr theGeom,
 
  205                                                             CORBA::Boolean        byMesh)
 
  206     throw ( SALOME::SALOME_Exception );
 
  211   CORBA::Boolean GetSoleSubMeshUsingHyp( SMESH::SMESH_Hypothesis_ptr theHyp,
 
  212                                          SMESH::SMESH_Mesh_out       theMesh,
 
  213                                          GEOM::GEOM_Object_out       theShape);
 
  221   void SetBoundaryBoxSegmentation( CORBA::Long theNbSegments ) 
throw ( SALOME::SALOME_Exception );
 
  225   void SetDefaultNbSegments(CORBA::Long theNbSegments) 
throw ( SALOME::SALOME_Exception );
 
  230   virtual void  SetOption(
const char*, 
const char*);
 
  234   virtual char* GetOption(
const char*);
 
  243   SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
 
  244     throw ( SALOME::SALOME_Exception );
 
  247   SMESH::SMESH_Mesh_ptr CreateEmptyMesh()
 
  248     throw ( SALOME::SALOME_Exception );
 
  251   SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const 
char* theFileName )
 
  252     throw ( SALOME::SALOME_Exception );
 
  255   SMESH::
mesh_array* CreateMeshesFromMED( const 
char* theFileName,
 
  257     throw ( SALOME::SALOME_Exception );
 
  260   SMESH::
mesh_array* CreateMeshesFromSAUV( const 
char* theFileName,
 
  262     throw ( SALOME::SALOME_Exception );
 
  265   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const 
char* theFileName )
 
  266     throw ( SALOME::SALOME_Exception );
 
  269   SMESH::
mesh_array* CreateMeshesFromCGNS( const 
char* theFileName,
 
  271     throw ( SALOME::SALOME_Exception );
 
  274   SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const 
char*             theFileName,
 
  275                                              CORBA::Boolean          theMakeRequiredGroups,
 
  276                                              SMESH::ComputeError_out theError)
 
  277     throw ( SALOME::SALOME_Exception );
 
  280   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
 
  281                                  const 
char*               meshName,
 
  282                                  CORBA::Boolean            toCopyGroups,
 
  283                                  CORBA::Boolean            toKeepIDs);
 
  286   CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh,
 
  287                           GEOM::GEOM_Object_ptr theShapeObject )
 
  288     throw ( SALOME::SALOME_Exception );
 
  291   void CancelCompute( SMESH::SMESH_Mesh_ptr theMesh,
 
  292                       GEOM::GEOM_Object_ptr theShapeObject );
 
  298                                                GEOM::GEOM_Object_ptr  theShapeObject )
 
  299     throw ( SALOME::SALOME_Exception );
 
  306   SMESH::
long_array* Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
 
  307                               GEOM::GEOM_Object_ptr theShapeObject)
 
  308     throw ( SALOME::SALOME_Exception );
 
  311   CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
 
  312                                    GEOM::GEOM_Object_ptr theShapeObject )
 
  313     throw ( SALOME::SALOME_Exception );
 
  320   SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh,
 
  321                                         GEOM::GEOM_Object_ptr theSubObject,
 
  324     throw ( SALOME::SALOME_Exception );
 
  328                                          GEOM::GEOM_Object_ptr theSubObject )
 
  329       throw ( SALOME::SALOME_Exception );
 
  332   SMESH::MeshPreviewStruct* GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
 
  333                                                  CORBA::Short          theSubShapeID )
 
  334     throw ( SALOME::SALOME_Exception );
 
  337   SMESH::
ListOfGroups* MakeGroupsOfBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
 
  338                                                      CORBA::Short          theSubShapeID,
 
  339                                                      const 
char*           theGroupName)
 
  340     throw ( SALOME::SALOME_Exception );
 
  343   SMESH::
long_array* GetSubShapesId( GEOM::GEOM_Object_ptr      theMainShapeObject,
 
  345     throw ( SALOME::SALOME_Exception );
 
  348   GEOM::GEOM_Object_ptr GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
 
  349                                                   CORBA::Long            theElementID,
 
  350                                                   const 
char*            theGeomName)
 
  351     throw ( SALOME::SALOME_Exception );
 
  354   GEOM::GEOM_Object_ptr FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr  theMesh,
 
  355                                                    CORBA::Long            theElementID)
 
  356     throw ( SALOME::SALOME_Exception );
 
  359   SMESH::SMESH_Mesh_ptr ConcatenateCommon(const SMESH::
ListOfIDSources& meshesArray,
 
  360                                           CORBA::Boolean                uniteIdenticalGroups,
 
  361                                           CORBA::Boolean                mergeNodesAndElements,
 
  362                                           CORBA::Double                 mergeTolerance,
 
  363                                           CORBA::Boolean                commonGroups)
 
  364     throw ( SALOME::SALOME_Exception );
 
  367   SMESH::SMESH_Mesh_ptr Concatenate(const SMESH::
ListOfIDSources& meshesArray,
 
  368                                     CORBA::Boolean                uniteIdenticalGroups,
 
  369                                     CORBA::Boolean                mergeNodesAndElements,
 
  370                                     CORBA::Double                 mergeTolerance)
 
  371     throw ( SALOME::SALOME_Exception );
 
  375   SMESH::SMESH_Mesh_ptr ConcatenateWithGroups(const SMESH::
ListOfIDSources& meshesArray,
 
  376                                               CORBA::Boolean                uniteIdenticalGroups,
 
  377                                               CORBA::Boolean                mergeNodesAndElements,
 
  378                                               CORBA::Double                 mergeTolerance)
 
  379     throw ( SALOME::SALOME_Exception );
 
  382   CORBA::Boolean GetMEDVersion(const 
char* theFileName,
 
  386   SMESH::
string_array* GetMeshNames(const 
char* theFileName);
 
  393   SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
 
  397   bool Load( SALOMEDS::SComponent_ptr theComponent,
 
  398              const SALOMEDS::TMPFile& theStream,
 
  402   SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr theComponent,
 
  406   bool LoadASCII( SALOMEDS::SComponent_ptr theComponent,
 
  407                   const SALOMEDS::TMPFile& theStream,
 
  412   SMESH::FilterManager_ptr CreateFilterManager();
 
  418   SMESH::Measurements_ptr  CreateMeasurements();
 
  421   void Close( SALOMEDS::SComponent_ptr theComponent );
 
  424   char* ComponentDataType();
 
  427   char* IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject,
 
  428                                 const 
char*           IORString,
 
  429                                 CORBA::Boolean        isMultiFile,
 
  430                                 CORBA::Boolean        isASCII );
 
  432   char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject,
 
  433                                 const 
char*           aLocalPersistentID,
 
  434                                 CORBA::Boolean        isMultiFile,
 
  435                                 CORBA::Boolean        isASCII );
 
  438   bool CanPublishInStudy( CORBA::Object_ptr theIOR );
 
  440   SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::Study_ptr   theStudy,
 
  441                                         SALOMEDS::SObject_ptr theSObject,
 
  442                                         CORBA::Object_ptr     theObject,
 
  443                                         const 
char*           theName )
 
  444     throw ( SALOME::SALOME_Exception );
 
  447   CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr theObject ) { 
return false; }
 
  449   SALOMEDS::TMPFile* 
CopyFrom( SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID ) { 
return NULL; }
 
  451   CORBA::Boolean 
CanPaste( 
const char* theComponentName, CORBA::Long theObjectID ) { 
return false; }
 
  453   SALOMEDS::SObject_ptr PasteInto( 
const SALOMEDS::TMPFile& theStream,
 
  454                                    CORBA::Long              theObjectID,
 
  455                                    SALOMEDS::SObject_ptr    theObject ) {
 
  456     SALOMEDS::SObject_var aResultSO;
 
  457     return aResultSO._retn();
 
  464   virtual char* getVersion();
 
  470   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
 
  471                                        CORBA::Boolean isPublished,
 
  472                                        CORBA::Boolean isMultiFile,
 
  473                                        CORBA::Boolean& isValidScript);
 
  475   void AddToPythonScript (
int theStudyID, 
const TCollection_AsciiString& theString);
 
  477   void RemoveLastFromPythonScript (
int theStudyID);
 
  479   void SavePython (SALOMEDS::Study_ptr theStudy);
 
  481   TCollection_AsciiString DumpPython_impl (SALOMEDS::Study_ptr theStudy,
 
  482                                            Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
 
  483                                            Resource_DataMapOfAsciiStringAsciiString& theNames,
 
  486                                            bool isHistoricalDump,
 
  488                                            TCollection_AsciiString& theSavedTrace);
 
  490   TCollection_AsciiString GetNewPythonLines (
int theStudyID);
 
  492   void CleanPythonTrace (
int theStudyID);
 
  499   GEOM_Client* GetShapeReader();
 
  502   static long GetHypothesisRootTag();
 
  503   static long GetAlgorithmsRootTag();
 
  504   static long GetRefOnShapeTag();
 
  505   static long GetRefOnAppliedHypothesisTag();
 
  506   static long GetRefOnAppliedAlgorithmsTag();
 
  507   static long GetSubMeshOnVertexTag();
 
  508   static long GetSubMeshOnEdgeTag();
 
  509   static long GetSubMeshOnFaceTag();
 
  510   static long GetSubMeshOnSolidTag();
 
  511   static long GetSubMeshOnCompoundTag();
 
  512   static long GetSubMeshOnWireTag();
 
  513   static long GetSubMeshOnShellTag();
 
  514   static long GetNodeGroupsTag();
 
  515   static long GetEdgeGroupsTag();
 
  516   static long GetFaceGroupsTag();
 
  517   static long GetVolumeGroupsTag();
 
  518   static long Get0DElementsGroupsTag();
 
  519   static long GetBallElementsGroupsTag();
 
  522   SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy);
 
  523   SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr   theStudy,
 
  524                                      SMESH::SMESH_Mesh_ptr theMesh,
 
  525                                      const char*           theName = 0);
 
  526   SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr         theStudy,
 
  527                                            SMESH::SMESH_Hypothesis_ptr theHyp,
 
  528                                            const char*                 theName = 0);
 
  529   SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr      theStudy,
 
  530                                         SMESH::SMESH_Mesh_ptr    theMesh,
 
  531                                         SMESH::SMESH_subMesh_ptr theSubMesh,
 
  532                                         GEOM::GEOM_Object_ptr    theShapeObject,
 
  533                                         const char*              theName = 0);
 
  534   SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr    theStudy,
 
  535                                       SMESH::SMESH_Mesh_ptr  theMesh,
 
  536                                       SMESH::SMESH_GroupBase_ptr theGroup,
 
  537                                       GEOM::GEOM_Object_ptr  theShapeObject,
 
  538                                       const char*            theName = 0);
 
  539   bool AddHypothesisToShape(SALOMEDS::Study_ptr         theStudy,
 
  540                             SMESH::SMESH_Mesh_ptr       theMesh,
 
  541                             GEOM::GEOM_Object_ptr       theShapeObject,
 
  542                             SMESH::SMESH_Hypothesis_ptr theHyp);
 
  543   bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy,
 
  544                                  SMESH::SMESH_Mesh_ptr       theMesh,
 
  545                                  GEOM::GEOM_Object_ptr       theShapeObject,
 
  546                                  SMESH::SMESH_Hypothesis_ptr theHyp);
 
  547   SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr   theStudy,
 
  548                                                  SMESH::SMESH_Mesh_ptr theMesh,
 
  549                                                  GEOM::GEOM_Object_ptr theShape);
 
  550   static void SetName(SALOMEDS::SObject_ptr theSObject,
 
  552                       const char*           theDefaultName = 0);
 
  554   static void SetPixMap(SALOMEDS::SObject_ptr theSObject,
 
  555                         const char*           thePixMap);
 
  561   int RegisterObject(CORBA::Object_ptr theObject);
 
  564   CORBA::Long GetObjectId(CORBA::Object_ptr theObject);
 
  567   template<
class TInterface>
 
  568   typename TInterface::_var_type GetObjectByOldId( 
const int oldID )
 
  570     if ( 
StudyContext* myStudyContext = GetCurrentStudyContext() ) {
 
  571       std::string ior = myStudyContext->getIORbyOldId( oldID );
 
  573         return TInterface::_narrow(GetORB()->string_to_object( ior.c_str() ));
 
  575     return TInterface::_nil();
 
  579   int GetCurrentStudyID();
 
  584   SALOMEDS::SObject_ptr GetAlgoSO(const ::SMESH_Algo* algo);
 
  586   void UpdateParameters(CORBA::Object_ptr theObject, 
const char* theParameters);
 
  587   char* GetParameters(CORBA::Object_ptr theObject);
 
  592   std::vector< std::string >        GetAllParameters(
const std::string& theObjectEntry) 
const;
 
  596              SALOMEDS::SObject_ptr where,
 
  600                                 const char*           theLibName,
 
  601                                 GEOM::GEOM_Object_ptr theShapeObject,
 
  602                                 CORBA::Boolean        toCheckAll);
 
  618                                    CORBA::Double             theZ2);
 
  629                                         CORBA::Double             theR );
 
  633                                 GEOM::GEOM_Object_ptr     theGeom,
 
  634                                 CORBA::Double             theTolerance );
 
  639                                                     const char*  theLibName,
 
  640                                                     std::string& thePlatformLibName)
 
  641   throw ( SALOME::SALOME_Exception );
 
  643   SMESH::SMESH_Hypothesis_ptr createHypothesis( 
const char* theHypName,
 
  644                                                 const char* theLibName);
 
  646   SMESH::SMESH_Mesh_ptr createMesh()
 
  647     throw ( SALOME::SALOME_Exception );
 
  649   static 
void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
 
  651   SMESH::
mesh_array* CreateMeshesFromMEDorSAUV( const 
char* theFileName,
 
  653                                                 const 
char* theCommandNameForPython,
 
  654                                                 const 
char* theFileNameForPython);
 
  656   void setCurrentStudy( SALOMEDS::Study_ptr theStudy,
 
  657                         bool                theStudyIsBeingClosed=false);
 
  659   std::vector<
long> _GetInside(SMESH::SMESH_IDSource_ptr meshPart,
 
  661                                TopoDS_Shape& aShape,
 
  662                                double* theTolerance = NULL);
 
  665   static GEOM::GEOM_Gen_var      myGeomGen;
 
  666   static CORBA::ORB_var          myOrb;         
 
  667   static PortableServer::POA_var myPoa;         
 
  668   static SALOME_NamingService*   myNS;          
 
  669   static SALOME_LifeCycleCORBA*  myLCC;         
 
  678   GEOM_Client*                   myShapeReader;      
 
  679   SALOMEDS::Study_var            myCurrentStudy;     
 
  680   CORBA::Boolean                 myIsEmbeddedMode;   
 
  683   std::
string myDefaultGroupColor;
 
  686   bool myToForgetMeshDataOnHypModif;
 
  689   std::map < 
int, 
Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts;
 
  690   bool                                                     myIsHistoricalPythonDump;
 
  691   std::vector< 
int >                                       myLastParamIndex;
 
  692   std::vector< std::
string >                               myLastParameters;
 
  693   std::
string                                              myLastObj;
 
  712     THROW_SALOME_CORBA_EXCEPTION( excText, SALOME::INTERNAL_ERROR );