]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Some changes.
authorapo <apo@opencascade.com>
Tue, 22 Nov 2005 09:22:42 +0000 (09:22 +0000)
committerapo <apo@opencascade.com>
Tue, 22 Nov 2005 09:22:42 +0000 (09:22 +0000)
1. MinMax calculation now starts only after MED fields parsing completetion
2. Improve BuildEntites in case of publication many meshes.

src/VISU_I/VISU_Result_i.cc

index 9a8c86036be8573c1093fa52eb50f4c4f9bc0b09..415ad9dc165899f79c27798131ceb82b113659be 100644 (file)
@@ -270,104 +270,103 @@ VISU::Result_i
   aStudyBuilder->NewCommand();  // There is a transaction
 
   QString aComment;
-  myInput->BuildEntities();
   string aRefFatherEntry = GetRefFatherEntry();
+
+  mySComponent = FindOrCreateVisuComponent(myStudyDocument);
+  CORBA::String_var aSComponentEntry = mySComponent->GetID();
+  CORBA::String_var anIOR(GetID());
+  aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
+                  GetComment(),
+                  VISU::TRESULT,
+                  myFileInfo.filePath().latin1(),
+                  myInitFileName.c_str()); // Restoring of Python dump
+  string aResultEntry =
+    CreateAttributes(myStudyDocument,
+                    aSComponentEntry,
+                    aRefFatherEntry.c_str(),
+                    anIOR,
+                    myName.c_str(),
+                    "",
+                    aComment.latin1(),
+                    true);
+  mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
+  if(!CORBA::is_nil(theSObject)){
+    CORBA::String_var aString = theSObject->GetID();
+    CreateReference(myStudyDocument,aResultEntry,aString.in());
+  }
+
+  myInput->BuildEntities();
   const TMeshMap& aMeshMap = myInput->GetMeshMap();
   TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
   for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
-    mySComponent = FindOrCreateVisuComponent(myStudyDocument);
-    CORBA::String_var aSComponentEntry = mySComponent->GetID();
-    CORBA::String_var anIOR(GetID());
-    aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
-                    GetComment(),
-                    VISU::TRESULT,
-                    myFileInfo.filePath().latin1(),
-                    myInitFileName.c_str()); // Restoring of Python dump
-    string aResultEntry =
+    const string& aMeshName = aMeshMapIter->first;
+    const PMesh& aMesh = aMeshMapIter->second;
+    const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+    if(aMeshOnEntityMap.empty()) 
+      continue;
+    
+    aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
+                    aMeshName.c_str(),
+                    aMesh->myDim);
+    aMesh->myEntry = 
       CreateAttributes(myStudyDocument,
-                      aSComponentEntry,
+                      aResultEntry.c_str(),
                       aRefFatherEntry.c_str(),
-                      anIOR,
-                      myName.c_str(),
+                      "",
+                      aMeshName.c_str(),
                       "",
                       aComment.latin1(),
                       true);
-    mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
-    if(!CORBA::is_nil(theSObject)){
-      CORBA::String_var aString = theSObject->GetID();
-      CreateReference(myStudyDocument,aResultEntry,aString.in());
-    }
-    TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
-    for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
-      const string& aMeshName = aMeshMapIter->first;
-      const PMesh& aMesh = aMeshMapIter->second;
-      const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
-      if(aMeshOnEntityMap.empty()) 
+    
+    aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
+                    aMeshName.c_str());
+    string aSubMeshesEntry = 
+      CreateAttributes(myStudyDocument,
+                      aMesh->myEntry.c_str(),
+                      aRefFatherEntry.c_str(),
+                      "",
+                      "Families",
+                      "",
+                      aComment.latin1(),
+                      true);
+    //Import entities
+    TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+    for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+      const TEntity& anEntity = aMeshOnEntityMapIter->first;
+      const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
+      
+      string anEntityName;
+      switch(anEntity){
+      case NODE_ENTITY: 
+       anEntityName = "onNodes"; 
+       break;
+      case EDGE_ENTITY: 
+       anEntityName = "onEdges"; 
+       break;
+      case FACE_ENTITY: 
+       anEntityName = "onFaces"; 
+       break;
+      case CELL_ENTITY: 
+       anEntityName = "onCells"; 
+       break;
+      default:
        continue;
-
-      aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
+      }
+      
+      aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
+                      VISU::TENTITY,
                       aMeshName.c_str(),
-                      aMesh->myDim);
-      aMesh->myEntry = 
-       CreateAttributes(myStudyDocument,
-                        aResultEntry.c_str(),
-                        aRefFatherEntry.c_str(),
-                        "",
-                        aMeshName.c_str(),
-                        "",
-                        aComment.latin1(),
-                        true);
-
-      aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
-                      aMeshName.c_str());
-      string aSubMeshesEntry = 
-       CreateAttributes(myStudyDocument,
-                        aMesh->myEntry.c_str(),
+                      anEntity);
+      
+      aMeshOnEntity->myEntry = 
+       CreateAttributes(myStudyDocument, 
+                        aSubMeshesEntry.c_str(), 
                         aRefFatherEntry.c_str(),
-                        "",
-                        "Families",
-                        "",
-                        aComment.latin1(),
+                        "", 
+                        anEntityName.c_str(), 
+                        "", 
+                        aComment.latin1(), 
                         true);
-      //Import entities
-      TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
-      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
-       const TEntity& anEntity = aMeshOnEntityMapIter->first;
-       const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
-
-       string anEntityName;
-       switch(anEntity){
-       case NODE_ENTITY: 
-         anEntityName = "onNodes"; 
-         break;
-       case EDGE_ENTITY: 
-         anEntityName = "onEdges"; 
-         break;
-       case FACE_ENTITY: 
-         anEntityName = "onFaces"; 
-         break;
-       case CELL_ENTITY: 
-         anEntityName = "onCells"; 
-         break;
-       default:
-         continue;
-       }
-
-       aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
-                        VISU::TENTITY,
-                        aMeshName.c_str(),
-                        anEntity);
-
-       aMeshOnEntity->myEntry = 
-         CreateAttributes(myStudyDocument, 
-                          aSubMeshesEntry.c_str(), 
-                          aRefFatherEntry.c_str(),
-                          "", 
-                          anEntityName.c_str(), 
-                          "", 
-                          aComment.latin1(), 
-                          true);
-      }
     }
   }
   
@@ -638,13 +637,35 @@ namespace
   void
   BuildMinMax(VISU::Result_i* theResult,
              VISU_Convertor* theInput,
-             CORBA::Boolean theIsDone)
+             CORBA::Boolean& theIsDone)
   {
     TMemManager aMemManager(theResult);
     
     theInput->BuildMinMax();
     theIsDone = true;
   }
+
+
+  //---------------------------------------------------------------
+  void
+  BuildMinMaxFields(VISU::Result_i* theResult,
+                   VISU_Convertor* theInput,
+                   CORBA::Boolean& theFieldsIsDone,
+                   CORBA::Boolean& theMinMaxIsDone,
+                   SALOMEDS::Study_var theStudyDocument,
+                   const std::string& theRefFatherEntry)
+  {
+    BuildFields(theResult,
+               theInput,
+               theFieldsIsDone,
+               theStudyDocument,
+               theRefFatherEntry);
+
+    BuildMinMax(theResult,
+               theInput,
+               theMinMaxIsDone);
+  }
+  
 }
 
 
@@ -664,28 +685,25 @@ VISU::Result_i
 
     std::string aRefFatherEntry = GetRefFatherEntry();
 
-    // To start build of the fields
-    boost::thread aThread1(boost::bind(&BuildFields,
-                                      this,
-                                      myInput,
-                                      myIsFieldsDone,
-                                      myStudyDocument,
-                                      aRefFatherEntry));
-
-    // To start build of the groups
-    boost::thread aThread2(boost::bind(&BuildGroups,
-                                      this,
-                                      myInput,
-                                      myIsGroupsDone,
-                                      myStudyDocument,
-                                      aRefFatherEntry));
-
-    // To start min/max calculation
-    boost::thread aThread3(boost::bind(&BuildMinMax,
-                                      this,
-                                      myInput,
-                                      myIsMinMaxDone));
-
+    {
+      // To start build of the fields and min/max calculation
+      boost::thread aThread(boost::bind(&BuildMinMaxFields,
+                                       this,
+                                       myInput,
+                                       myIsFieldsDone,
+                                       myIsMinMaxDone,
+                                       myStudyDocument,
+                                       aRefFatherEntry));
+    }
+    {
+      // To start build of the groups
+      boost::thread aThread(boost::bind(&BuildGroups,
+                                       this,
+                                       myInput,
+                                       myIsGroupsDone,
+                                       myStudyDocument,
+                                       aRefFatherEntry));
+    }
     return this;
   }
 }
@@ -708,16 +726,16 @@ VISU::Result_i
                myStudyDocument,
                aRefFatherEntry);
 
+    BuildMinMax(this,
+               myInput,
+               myIsMinMaxDone);
+
     BuildGroups(this,
                myInput,
                myIsGroupsDone,
                myStudyDocument,
                aRefFatherEntry);
 
-    BuildMinMax(this,
-               myInput,
-               myIsMinMaxDone);
-
     BuildAll();
   }catch(std::exception& exc){
     INFOS("Follow exception was occured :\n"<<exc.what());