Salome HOME
Debug
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i_1.cxx
index bb0b0c7052771b4096f744431d1911e538b41a99..2441aa14c69c31f570f5d1778631f8d3435121a0 100644 (file)
@@ -210,8 +210,10 @@ GEOM::GEOM_Object_ptr SMESH_Gen_i::ShapeToGeomObject (const TopoDS_Shape& theSha
     GEOM_Client* aClient = GetShapeReader();
     TCollection_AsciiString IOR;
     if ( aClient && aClient->Find( theShape, IOR ))
-      aShapeObj = GEOM::GEOM_Object::_narrow
-        ( GetORB()->string_to_object( IOR.ToCString() ) );
+    {
+      CORBA::Object_var obj = GetORB()->string_to_object( IOR.ToCString() );
+      aShapeObj = GEOM::GEOM_Object::_narrow ( obj );
+    }
   }
   return aShapeObj._retn();
 }
@@ -262,7 +264,8 @@ static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr   theStudy,
   }
   if ( thePixMap ) {
     anAttr  = aStudyBuilder->FindOrCreateAttribute( SO, "AttributePixMap" );
-    SALOMEDS::AttributePixMap::_narrow( anAttr )->SetPixMap( thePixMap );
+    SALOMEDS::AttributePixMap_var pm = SALOMEDS::AttributePixMap::_narrow( anAttr );
+    pm->SetPixMap( thePixMap );
   }
   if ( !theSelectable ) {
     anAttr   = aStudyBuilder->FindOrCreateAttribute( SO, "AttributeSelectable" );
@@ -368,9 +371,9 @@ static void addReference (SALOMEDS::Study_ptr   theStudy,
 //=============================================================================
 
 SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr   theStudy,
-                                                 SALOMEDS::SObject_ptr theSObject,
-                                                 CORBA::Object_ptr     theIOR,
-                                                 const char*           theName)
+                                                  SALOMEDS::SObject_ptr theSObject,
+                                                  CORBA::Object_ptr     theIOR,
+                                                  const char*           theName)
      throw (SALOME::SALOME_Exception)
 {
   Unexpect aCatch(SALOME_SalomeException);
@@ -465,9 +468,9 @@ static long findMaxChildTag( SALOMEDS::SObject_ptr theSObject )
     if ( !aStudy->_is_nil() ) {
       SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSObject );
       for ( ; anIter->More(); anIter->Next() ) {
-       long nTag = anIter->Value()->Tag();
-       if ( nTag > aTag )
-         aTag = nTag;
+        long nTag = anIter->Value()->Tag();
+        if ( nTag > aTag )
+          aTag = nTag;
       }
     }
   }
@@ -518,13 +521,12 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr   theStudy,
 
     // Publish global hypotheses
 
-    SMESH::ListOfHypothesis * hypList = theMesh->GetHypothesisList( aShapeObject );
-    if ( hypList )
-      for ( int i = 0; i < hypList->length(); i++ ) {
-        SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( (*hypList)[ i ]);
-        PublishHypothesis( theStudy, aHyp );
-        AddHypothesisToShape( theStudy, theMesh, aShapeObject, aHyp );
-      }
+    SMESH::ListOfHypothesis_var hypList = theMesh->GetHypothesisList( aShapeObject );
+    for ( int i = 0; i < hypList->length(); i++ ) {
+      SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( hypList[ i ]);
+      PublishHypothesis( theStudy, aHyp );
+      AddHypothesisToShape( theStudy, theMesh, aShapeObject, aHyp );
+    }
   }
 
   // Publish submeshes
@@ -558,6 +560,10 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr   theStudy,
     }
   }
 
+  // Update string attribute (to display used variables)
+  if( SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() ) )
+    aServant->UpdateStringAttribute();
+
   if(MYDEBUG) MESSAGE("PublishMesh_END");
   return aMeshSO._retn();
 }
@@ -588,7 +594,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr      theS
     }
     // Find submesh sub-tree tag
     long aRootTag;
-    char* aRootName = "";
+    const char* aRootName = "";
     switch ( theShapeObject->GetShapeType() ) {
     case GEOM::VERTEX:
       aRootTag  = GetSubMeshOnVertexTag();
@@ -674,8 +680,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr    theStudy
     }
     int aType = (int)theGroup->GetType();
     const char* aRootNames[] = {
-      "Compound Groups", "Groups of Nodes",
-      "Groups of Edges", "Groups of Faces", "Groups of Volumes" };
+      "Compound Groups", "Groups of Nodes", "Groups of Edges",
+      "Groups of Faces", "Groups of Volumes", "Groups of 0D Elements" };
 
     // Currently, groups with heterogenous content are not supported
     if ( aType != SMESH::ALL ) {
@@ -684,7 +690,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr    theStudy
       // Find or create groups root
       SALOMEDS::SObject_var aRootSO = publish (theStudy, CORBA::Object::_nil(),
                                                aMeshSO, aRootTag, 0, false );
-      if ( aType < 5 )
+      if ( aType < 6 )
         SetName( aRootSO, aRootNames[aType] );
 
       // Add new group to corresponding sub-tree
@@ -747,6 +753,10 @@ SALOMEDS::SObject_ptr
     SetName( aHypSO, theName, aHypName );
   }
 
+  // Update string attribute (to display used variables)
+  if( SMESH_Hypothesis_i* aServant = dynamic_cast<SMESH_Hypothesis_i*>( GetServant( theHyp ).in() ) )
+    aServant->UpdateStringAttribute();
+
   if(MYDEBUG) MESSAGE("PublishHypothesis--END")
   return aHypSO._retn();
 }
@@ -883,101 +893,3 @@ bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr         theStudy
   }
   return true;
 }
-
-//=======================================================================
-//function : UpdateParameters
-//purpose  : 
-//=======================================================================
-void SMESH_Gen_i::UpdateParameters(CORBA::Object_ptr theObject, const char* theParameters)
-{
-
-  if(VARIABLE_DEBUG)
-    cout<<"UpdateParameters : "<<theParameters<<endl;
-  SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
-  if(aStudy->_is_nil() || CORBA::is_nil(theObject)) 
-    return;
-
-  SALOMEDS::SObject_var aSObj =  ObjectToSObject(aStudy,theObject);
-  if(aSObj->_is_nil())  
-    return;
-  
-  SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-  
-  SALOMEDS::GenericAttribute_var aFindAttr;
-  bool hasAttr = aSObj->FindAttribute(aFindAttr, "AttributeString");
-  if(VARIABLE_DEBUG)
-    cout<<"Find Attribute "<<hasAttr<<endl;
-
-  SALOMEDS::GenericAttribute_var anAttr;
-  anAttr = aStudyBuilder->FindOrCreateAttribute( aSObj, "AttributeString");
-  SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
-
-  TCollection_AsciiString aNewParams;
-  TCollection_AsciiString aOldParameters(aStringAttr->Value());
-  TCollection_AsciiString anInputParams(ParseParameters(theParameters));
-  
-  if(!hasAttr)
-    aNewParams = anInputParams;
-  else 
-    aNewParams = aOldParameters+"|"+anInputParams;
-
-  if(VARIABLE_DEBUG)
-    {
-      cout<<"Input Parameters : "<<anInputParams<<endl;
-      cout<<"Old Parameters : "<<aOldParameters<<endl;
-      cout<<"New Parameters : "<<aNewParams<<endl;
-    }
-  
-  
-  aStringAttr->SetValue( aNewParams.ToCString() );
-}
-
-//=======================================================================
-//function : ParseParameters
-//purpose  : 
-//=======================================================================
-char* SMESH_Gen_i::ParseParameters(const char* theParameters)
-{
-  const char* aParameters = CORBA::string_dup(theParameters);
-  TCollection_AsciiString anInputParams;
-  SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
-  if( !aStudy->_is_nil() ) {
-    SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(aParameters);
-    for(int j=0;j<aSections->length();j++) {
-      SALOMEDS::ListOfStrings aVars= aSections[j];
-      for(int i=0;i<aVars.length();i++ ) {
-        anInputParams += aStudy->IsVariable(aVars[i].in()) ? 
-          TCollection_AsciiString(aVars[i].in()) : TCollection_AsciiString("");
-        if(i != aVars.length()-1)
-          anInputParams+=":";
-      }
-      if(j!=aSections->length()-1)
-        anInputParams+="|";
-    }
-  }
-  return CORBA::string_dup(anInputParams.ToCString());
-}
-
-//=======================================================================
-//function : GetParameters
-//purpose  : 
-//=======================================================================
-char* SMESH_Gen_i::GetParameters(CORBA::Object_ptr theObject)
-{
-  TCollection_AsciiString aResult;
-
-  SALOMEDS::Study_ptr aStudy = GetCurrentStudy();
-  SALOMEDS::SObject_var aSObj =  ObjectToSObject(aStudy,theObject);
-
-  if(!aStudy->_is_nil() && 
-     !CORBA::is_nil(theObject) && 
-     !aSObj->_is_nil()){
-    
-    SALOMEDS::GenericAttribute_var anAttr;
-    if ( aSObj->FindAttribute(anAttr, "AttributeString")) {
-      aResult = TCollection_AsciiString(SALOMEDS::AttributeString::_narrow(anAttr)->Value());
-    }
-  }
-  
-  return CORBA::string_dup( aResult.ToCString() );
-}