]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To restore constant order of MED file entities that is published in the VISU
authorapo <apo@opencascade.com>
Mon, 20 Mar 2006 09:00:27 +0000 (09:00 +0000)
committerapo <apo@opencascade.com>
Mon, 20 Mar 2006 09:00:27 +0000 (09:00 +0000)
src/CONVERTOR/VISU_Convertor.hxx
src/VISU_I/VISU_Result_i.cc

index 4a5ac9938b7fbae890518416cf237ed3be38c058..304f7de3ce4f988295df765e3e3b88d998dd02b5 100644 (file)
@@ -79,6 +79,9 @@ namespace VISU
     TName myName; //! Name of the corresponding MED MESH
     int myDim; //! Dimension of the corresponding MED MESH
 
+    std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
+    std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
+
     TMesh(): myDim(0)
     {}
   };
index 9745df0151ee25f8c58b112988c278ff423ef07f..360579fc9fc0c93e173d3c6dc4cd07d7243ee979 100644 (file)
@@ -213,12 +213,11 @@ namespace VISU
     aStudyBuilder->Addreference(aNewObj,aRefSObj);
   }
 
-  string 
+  std::string 
   CreateAttributes(_PTR(Study) theStudyDocument,
                   const string& theFatherEntry, 
                   const string& theIOR, 
                   const string& theName,
-                  const string& thePersistentRef, 
                   const string& theComment,
                   CORBA::Boolean theCreateNew)
   {
@@ -244,11 +243,6 @@ namespace VISU
       _PTR(AttributeName) aName (anAttr);
       aName->SetValue(theName);
     }
-    if (thePersistentRef != "") {
-      anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePersistentRef");
-      _PTR(AttributePersistentRef) aPRef (anAttr);
-      aPRef->SetValue(thePersistentRef);
-    }
     if (theComment != "") {
       anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeComment");
       _PTR(AttributeComment) aCmnt (anAttr);
@@ -257,6 +251,37 @@ namespace VISU
     return aNewObj->GetID();
   }
 
+  void 
+  UpdateAttributes(_PTR(Study) theStudyDocument,
+                  const string& theEntry,
+                  const string& theIOR, 
+                  const string& theName,
+                  const string& theComment)
+  {
+    TLock aLock(myMutex);
+
+    _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
+    _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
+
+    _PTR(GenericAttribute) anAttr;
+    if (theIOR != "") {
+      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
+      _PTR(AttributeIOR) anIOR (anAttr);
+      anIOR->SetValue(theIOR);
+    }
+    if (theName != "") {
+      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
+      _PTR(AttributeName) aName (anAttr);
+      aName->SetValue(theName);
+    }
+    if (theComment != "") {
+      anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeComment");
+      _PTR(AttributeComment) aCmnt (anAttr);
+      aCmnt->SetValue(theComment);
+    }
+  }
+
+
   //---------------------------------------------------------------
   struct TResultManager
   {
@@ -339,6 +364,8 @@ namespace VISU
                VISU_Convertor* theInput,
                CORBA::Boolean* theIsDone,
                std::string theResultEntry,
+               CORBA::Boolean theIsBuildGroups,
+               CORBA::Boolean theIsBuildFields,
                _PTR(Study) theStudy)
   {
     if(*theIsDone)
@@ -371,7 +398,6 @@ namespace VISU
                         theResultEntry,
                         "",
                         aMeshName,
-                        "",
                         aComment.latin1(),
                         true);
     
@@ -382,9 +408,29 @@ namespace VISU
                         aMesh->myEntry,
                         "",
                         "Families",
-                        "",
                         aComment.latin1(),
                         true);
+
+      if(theIsBuildGroups){
+       aMesh->myGroupsEntry =
+         CreateAttributes(theStudy,
+                          aMesh->myEntry,
+                          "",
+                          "",
+                          "",
+                          true);
+      }
+
+      if(theIsBuildFields){
+       aMesh->myFieldsEntry =
+         CreateAttributes(theStudy,
+                          aMesh->myEntry,
+                          "",
+                          "",
+                          "",
+                          true);
+      }
+
       //Import entities
       TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
@@ -419,7 +465,6 @@ namespace VISU
                           aSubMeshesEntry, 
                           "", 
                           anEntityName.c_str(), 
-                          "", 
                           aComment.latin1(), 
                           true);
       }
@@ -479,7 +524,6 @@ namespace VISU
                             aMeshOnEntity->myEntry,
                             "",
                             aFamilyName,
-                            "",
                             aComment.latin1(),
                             true);
        }
@@ -489,14 +533,11 @@ namespace VISU
       if(!aGroupMap.empty()){
        aComment.sprintf("myComment=GROUPS;myMeshName=%s",
                         aMeshName.c_str());
-       string aGroupsEntry =
-         CreateAttributes(theStudy,
-                          aMesh->myEntry,
-                          "",
-                          "Groups",
-                          "",
-                          aComment.latin1(),
-                          true);
+       UpdateAttributes(theStudy,
+                        aMesh->myGroupsEntry,
+                        "",
+                        "Groups",
+                        aComment.latin1());
        TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
        for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
          const string& aGroupName = aGroupMapIter->first;
@@ -505,10 +546,9 @@ namespace VISU
                           TGROUP,aMeshName.c_str(),aGroupName.c_str());
          aGroup->myEntry = 
            CreateAttributes(theStudy,
-                            aGroupsEntry,
+                            aMesh->myGroupsEntry,
                             "",
                             aGroupName,
-                            "",
                             aComment.latin1(),
                             true);
          const TFamilySet& aFamilySet = aGroup->myFamilySet;
@@ -559,8 +599,7 @@ namespace VISU
        continue;
       
       //Import fields
-      string aFieldsEntry;
-      bool anIsFieldsEntryCreated = false;
+      bool anIsFieldsEntryUpdated = false;
       
       TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
       for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
@@ -569,18 +608,15 @@ namespace VISU
        const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
        TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
        for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
-         if(!anIsFieldsEntryCreated){
+         if(!anIsFieldsEntryUpdated){
            aComment.sprintf("myComment=FIELDS;myMeshName=%s",
                             aMeshName.c_str());
-           aFieldsEntry =
-             CreateAttributes(theStudy,
-                              aMesh->myEntry,
-                              "",
-                              "Fields",
-                              "",
-                              aComment.latin1(),
-                              true);
-           anIsFieldsEntryCreated = true;
+           UpdateAttributes(theStudy,
+                            aMesh->myFieldsEntry,
+                            "",
+                            "Fields",
+                            aComment.latin1());
+           anIsFieldsEntryUpdated = true;
          }
          const string& aFieldName = aFieldMapIter->first;
          const PField& aField = aFieldMapIter->second;
@@ -595,10 +631,9 @@ namespace VISU
                           aField->myNbComp);
          aField->myEntry = 
            CreateAttributes(theStudy,
-                            aFieldsEntry,
+                            aMesh->myFieldsEntry,
                             "",
                             aFieldNameWithUnit.latin1(),
-                            "",
                             aComment.latin1(),
                             true);
          CreateReference(theStudy,
@@ -621,7 +656,6 @@ namespace VISU
                               aField->myEntry,
                               "",
                               aTimeStampId,
-                              "",
                               aComment.latin1(),
                               true);
          }
@@ -732,6 +766,8 @@ namespace VISU
                  theBuildArgs.myInput,
                  theBuildArgs.myIsEntitiesDone,
                  theBuildArgs.myResultEntry,
+                 theBuildArgs.myIsBuildGroups,
+                 theBuildArgs.myIsBuildFields,
                  theBuildArgs.myStudy);
     {
       boost::thread aThread(boost::bind(&BuildGroups,
@@ -995,7 +1031,6 @@ VISU::Result_i
                     aSComponentEntry.in(),
                     anIOR.in(),
                     myName,
-                    "",
                     aComment.latin1(),
                     true);
   mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
@@ -1009,6 +1044,8 @@ VISU::Result_i
                  myInput,
                  &myIsEntitiesDone,
                  aResultEntry,
+                 myIsBuildGroups,
+                 myIsBuildFields,
                  myStudy);
     
     BuildGroups(this,