]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Minor changes
authorapo <apo@opencascade.com>
Wed, 31 Aug 2005 09:47:21 +0000 (09:47 +0000)
committerapo <apo@opencascade.com>
Wed, 31 Aug 2005 09:47:21 +0000 (09:47 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx

index 0a7cdb976851b4304665dc923cc3f8415f96ef65..a561d57f37c0a10e298e5f067c4e7fe85c7cf01a 100644 (file)
@@ -115,6 +115,13 @@ namespace VISU
     return myFilter;
   }
 
+  TDataSet* 
+  TAppendFilter
+  ::GetDataSet() const
+  {
+    return GetFilter()->GetOutput();
+  }
+
 
   //---------------------------------------------------------------
   TPointCoords
@@ -360,6 +367,22 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
+  vtkIdType
+  TSubMeshImpl
+  ::GetElemVTKID(vtkIdType theID) const
+  {
+    return theID;
+  }
+
+  vtkIdType
+  TSubMeshImpl
+  ::GetElemObjID(vtkIdType theID) const
+  {
+    return theID;
+  }
+
+
   //---------------------------------------------------------------
   vtkIdType
   TMeshOnEntityImpl
@@ -372,7 +395,11 @@ namespace VISU
   TMeshOnEntityImpl
   ::GetElemObjID(vtkIdType theID) const
   {
-    return theID;
+    vtkIdType anInputID;
+    const TVTKAppendFilter& anAppendFilter = GetFilter();
+    vtkIdType aID = anAppendFilter->GetElemObjId(theID,anInputID);
+    const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputID];
+    return aSubMesh->GetElemObjID(aID);
   }
 
 
@@ -618,9 +645,8 @@ namespace
   
 
   //---------------------------------------------------------------
-  void
-  GetPoints(const TVTKSource& theSource, 
-           const PMeshImpl& theMesh) 
+  vtkPoints*
+  GetPoints(const PMeshImpl& theMesh) 
   {
     TVTKPoints& aPoints = theMesh->myPoints;
     const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
@@ -679,10 +705,11 @@ namespace
       }
       
       theMesh->myIsVTKDone = true;
+
       if(MYVTKDEBUG) aPoints->DebugOn();
     }
 
-    theSource->SetPoints(aPoints.GetPointer());
+    return aPoints.GetPointer();
   }
   
   
@@ -704,13 +731,18 @@ namespace
 
   //---------------------------------------------------------------
   void
-  GetCellsOnEntity(const TVTKSource& theSource,
-                  const PMeshOnEntityImpl& theMeshOnEntity) 
+  GetCellsOnSubMesh(const TVTKSource& theSource,
+                   const PSubMeshImpl& theSubMesh,
+                   const vtkIdType theGeom) 
   {
-    INITMSG(MYDEBUG,"GetCellsOnEntity"<<endl);
+    const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
+    vtkIdType aCellsSize = theSubMesh->myCellsSize;
+    vtkIdType aNbCells = theSubMesh->myNbCells;
+    INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
+           "- theGeom = "<<theGeom<<
+           "; aNbCells = "<<aNbCells<<
+           endl);
 
-    vtkIdType aNbCells = theMeshOnEntity->myNbCells;
-    vtkIdType aCellsSize = theMeshOnEntity->myCellsSize;
 
     vtkCellArray* aConnectivity = vtkCellArray::New();
     aConnectivity->Allocate(aCellsSize,0);
@@ -718,20 +750,11 @@ namespace
     aCellTypesArray->SetNumberOfComponents(1);
     aCellTypesArray->SetNumberOfTuples(aNbCells);
 
-    const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
-    VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
-    for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){
-      const vtkIdType& aGeom = anIter->first;
-      const VISU::TSubMeshImpl& aSubMesh = anIter->second;
-      const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
-      INITMSG(MYDEBUG,"aGeom = "<<aGeom<<
-             "; anArray.size() = "<<anArray.size()<<
-             endl);
-      for(vtkIdType k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
-       PrintCells(i,aConnectivity,anArray[k]);
-       aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
-      }
+    for(vtkIdType anID = 0; anID < aNbCells; anID++){
+      PrintCells(anID,aConnectivity,anArray[anID]);
+      aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
     }
+
     vtkIdType *pts = 0, npts = 0;
     vtkIntArray* aCellLocationsArray = vtkIntArray::New();
     aCellLocationsArray->SetNumberOfComponents(1);
@@ -1009,7 +1032,7 @@ namespace
     if(theSubProfile->myIsVTKDone)
       return;
     
-    GetPoints(aSource,theMesh);
+    aSource->SetPoints(GetPoints(theMesh));
     INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
     GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
     BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
@@ -1029,12 +1052,14 @@ namespace
     
     const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
     if(theProfile->myIsAll){
-      const TVTKSource& aSource = theMeshOnEntity->GetSource();
-      anAppendFilter->AddInput(aSource.GetPointer());
+      TDataSet* aDataSet = theMeshOnEntity->GetDataSet();
+      anAppendFilter->AddInput(aDataSet);
     }else{
       const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+      TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
+      aSubProfileArr.resize(aGeom2SubProfile.size());
       TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
-      for(; anIter != aGeom2SubProfile.end(); anIter++){
+      for(vtkIdType anID = 0; anIter != aGeom2SubProfile.end(); anIter++, anID++){
        PSubProfileImpl aSubProfile = anIter->second;
        if(aSubProfile->myStatus == eRemoveAll)
          continue;
@@ -1046,6 +1071,8 @@ namespace
        
        const TVTKSource& aSource = aSubProfile->GetSource();
        anAppendFilter->AddInput(aSource.GetPointer());
+
+       aSubProfileArr[anID] = aSubProfile;
       }
     }
     anAppendFilter->Update(); // Fix on VTK
@@ -1329,21 +1356,33 @@ VISU_Convertor_impl
   //Cheching possibility do the query
   TFindMeshOnEntity aFindMeshOnEntity = 
     FindMeshOnEntity(theMeshName,theEntity);
-
+  
   PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
   PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
-
+  
   //Main part of code
-  const TVTKSource& aSource = aMeshOnEntity->GetSource();
+  const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
 #ifndef _DEXCEPT_
   try{
 #endif
     if(!aMeshOnEntity->myIsVTKDone){
-      if(MYVTKDEBUG) aSource->DebugOn();
+      if(MYVTKDEBUG) anAppendFilter->DebugOn();
 
       LoadMeshOnEntity(aMesh,aMeshOnEntity);
-      GetPoints(aSource,aMesh);
-      GetCellsOnEntity(aSource,aMeshOnEntity);
+      
+      const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+      TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+      TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
+      aSubMeshArr.resize(aGeom2SubMesh.size());
+      for(vtkIdType anID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
+       const vtkIdType& aGeom = anIter->first;
+       PSubMeshImpl aSubMesh = anIter->second;
+       const TVTKSource& aSource = aSubMesh->GetSource();
+       aSource->SetPoints(GetPoints(aMesh));
+       GetCellsOnSubMesh(aSource,aSubMesh,aGeom);
+       anAppendFilter->AddInput(aSource.GetPointer());
+       aSubMeshArr[anID] = aSubMesh;
+      }
 
       aMeshOnEntity->myIsVTKDone = true;
 
@@ -1351,13 +1390,13 @@ VISU_Convertor_impl
        std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
        std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
        aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
-       VISU::WriteToFile(aSource.GetPointer(),aFileName);
+       VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
       }
     }
 
     if(MYVTKDEBUG){
       GetMeshOnEntitySize(theMeshName,theEntity);
-      PrintMemorySize(aSource.GetPointer());
+      PrintMemorySize(anAppendFilter->GetOutput());
     }
 
 #ifndef _DEXCEPT_
@@ -1366,7 +1405,7 @@ VISU_Convertor_impl
   }
 #endif
 
-  return aSource.GetPointer();
+  return anAppendFilter->GetOutput();
 }
 
 
@@ -1402,7 +1441,7 @@ VISU_Convertor_impl
       GetMeshOnEntity(theMeshName,theEntity);
 
       LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
-      GetPoints(aSource,aMesh);
+      aSource->SetPoints(GetPoints(aMesh));
       GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
 
       aFamily->myIsVTKDone = true;
index 15c4bb1c4558e7861649f678e6e0fb9c1ab2a3a3..a655fdbca0ab4f26a124cbf8468e50e860a59916 100644 (file)
@@ -30,8 +30,10 @@ namespace VISU
   using MED::TCSlice;
   using MED::TSlice;
 
+  typedef vtkUnstructuredGrid TDataSet;
+  typedef vtkSmartPointer<TDataSet> TVTKSource;
+
   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
-  typedef vtkSmartPointer<vtkUnstructuredGrid> TVTKSource;
   typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
   typedef float TCoord;
 
@@ -74,6 +76,9 @@ namespace VISU
 
     const TVTKAppendFilter& 
     GetFilter() const;
+
+    TDataSet* 
+    GetDataSet() const;
   };
 
 
@@ -281,17 +286,24 @@ namespace VISU
   struct TSubMeshImpl: virtual TSource
   {
     TCell2Connect myCell2Connect;
+
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
   };
   typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
 
 
   //---------------------------------------------------------------
   typedef std::map<vtkIdType,PSubMeshImpl> TGeom2SubMesh;
+  typedef TVector<PSubMeshImpl> TSubMeshArr;
 
-  struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TSource
+  struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TAppendFilter, virtual TSizeCounter
   {
-    TGeom2SubMesh myGeom2SubMesh;
-
     virtual 
     vtkIdType 
     GetElemVTKID(vtkIdType theID) const;
@@ -300,7 +312,8 @@ namespace VISU
     vtkIdType 
     GetElemObjID(vtkIdType theID) const;
 
-    TObj2VTKID myObj2VTKID;
+    TSubMeshArr mySubMeshArr;
+    TGeom2SubMesh myGeom2SubMesh;
   };
   typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
 
index 5fc96d78cd63598abc4b9f85f0624ad02c13f5fe..f0c24e9825b91e8482ef810c16bf0e9817703d1b 100644 (file)
@@ -243,15 +243,7 @@ namespace
        vtkIdType aVGeom = aSubProfile->myGeom;
        aGeom2SubProfile[aVGeom] = aSubProfile;
       }
-      {
-       TSubProfileArr& aSubProfileArr = aProfile->mySubProfileArr;
-       aSubProfileArr.resize(aGeom2SubProfile.size());
-       TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
-       for(TInt anID = 0; anIter != aGeom2SubProfile.end(); anIter++, anID++){
-         const PSubProfileImpl& aSubProfile = anIter->second;
-         aSubProfileArr[anID] = aSubProfile;
-       }
-      }
+
       aProfileMap[aProfileKey] = aProfile;
       theValForTime.myProfile = aProfile;
     }
@@ -634,10 +626,10 @@ namespace
        const MED::TFamilyTSize& aFamilyTSize = *aFamilyTSizeSetIter;
        const MED::PFamilyInfo& aFamilyInfo = boost::get<0>(aFamilyTSize);
        TInt aSize = boost::get<1>(aFamilyTSize);
-       if(aFamilyInfo->GetId() == 0) 
+       TInt anId = aFamilyInfo->GetId();
+       if(anId == 0) 
          continue;
        
-       TInt anId = aFamilyInfo->GetId();
        std::string aFamilyName = aFamilyInfo->GetName();
 
        PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
@@ -693,7 +685,7 @@ namespace
       MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
       for(; aFamilyIter != aFamilyInfoSet.end(); aFamilyIter++){
        const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
-       const std::string& aFamilyName = aFamilyInfo->GetName();
+       std::string aFamilyName = aFamilyInfo->GetName();
        
        TEntity aVEntity = TEntity(-1);
        PMEDFamily aFamily;
@@ -757,6 +749,33 @@ namespace
     return TGaussPointID(aCellID,aLocalPntID);
   }
   
+
+  //---------------------------------------------------------------
+  vtkIdType
+  TMEDSubMesh
+  ::GetElemObjID(vtkIdType theID) const
+  {
+    if(myIsElemNum)
+      return myElemNum[theID];
+    else
+      return TSubMeshImpl::GetElemObjID(theID);
+  }
+  
+  vtkIdType
+  TMEDSubMesh
+  ::GetElemVTKID(vtkIdType theID) const
+  {
+    if(myIsElemNum){
+      MED::TElemNum::const_iterator anIter = 
+       std::find(myElemNum.begin(),myElemNum.end(),theID);
+      if(anIter != myElemNum.end())
+       return *anIter;
+      else
+       return -1;
+    }else
+      return TSubMeshImpl::GetElemVTKID(theID);
+  }
+  
 }
 
 
@@ -1015,7 +1034,19 @@ VISU_MedConvertor
          
     aSubMesh->myIsElemNum = aNodeInfo->IsElemNum();
     aSubMesh->myElemNum = aNodeInfo->myElemNum;
+    aSubMesh->myNbCells = theMesh->myNbPoints;
+    aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
     
+    {
+      TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
+      aSubMeshArr.resize(aGeom2SubMesh.size());
+      TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+      for(TInt anID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
+       const PSubMeshImpl& aSubMesh = anIter->second;
+       aSubMeshArr[anID] = aSubMesh;
+      }
+    }
+
     TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
     aCell2Connect.resize(aNbElem);
     for (int iElem = 0; iElem < aNbElem; iElem++)
@@ -1123,6 +1154,7 @@ VISU_MedConvertor
          
          aSubMesh->myIsElemNum = aPolygoneInfo->IsElemNum();
          aSubMesh->myElemNum = aPolygoneInfo->myElemNum;
+         aSubMesh->myNbCells = aNbElem;      
 
          TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
          aCell2Connect.resize(aNbElem);
@@ -1130,6 +1162,7 @@ VISU_MedConvertor
          for(TInt iElem = 0; iElem < aNbElem; iElem++) {
            MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
            TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
+           aSubMesh->myCellsSize += aNbConn;
            TConnect& anArray = aCell2Connect[iElem];
            anArray.resize(aNbConn);
            for(TInt iConn = 0; iConn < aNbConn; iConn++)
@@ -1147,6 +1180,7 @@ VISU_MedConvertor
          
          aSubMesh->myIsElemNum = aPolyedreInfo->IsElemNum();
          aSubMesh->myElemNum = aPolyedreInfo->myElemNum;
+         aSubMesh->myNbCells = aNbElem;      
 
          TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
          aCell2Connect.resize(aNbElem);
@@ -1160,6 +1194,7 @@ VISU_MedConvertor
            for(TInt iFace = 0; iFace < aNbFaces; iFace++){
              MED::TCConnSlice aConnSlice = aConnSliceArr[iFace];
              TInt aNbConn = aConnSlice.size();
+             aSubMesh->myCellsSize += aNbConn;
              for(TInt iConn = 0; iConn < aNbConn; iConn++){
                aConnectSet.insert(aConnSlice[iConn]);
              }
@@ -1178,7 +1213,7 @@ VISU_MedConvertor
        break;
       }
       default: {
-       int aVNbNodes = VTKGeom2NbNodes(aVGeom);
+       TInt aVNbNodes = VTKGeom2NbNodes(aVGeom);
        
        MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
        TInt aNbElem = aCellInfo->GetNbElem();
@@ -1188,6 +1223,8 @@ VISU_MedConvertor
          
          aSubMesh->myIsElemNum = aCellInfo->IsElemNum();
          aSubMesh->myElemNum = aCellInfo->myElemNum;
+         aSubMesh->myNbCells = aNbElem;      
+         aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
 
          TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
          aCell2Connect.resize(aNbElem);
index 3ae1891ffd11d4f3bc7f8df5a88e2359cd62095f..74aabc04a60a27702a40d668fc71057cac349c19 100644 (file)
@@ -32,6 +32,10 @@ namespace VISU
   {
     MED::EGeometrieElement myMGeom;
 
+    TMEDSubProfile():
+      myIsElemNum(MED::eFAUX)
+    {}
+
     MED::EBooleen myIsElemNum;
     MED::TElemNum myElemNum;
 
@@ -59,6 +63,10 @@ namespace VISU
   //---------------------------------------------------------------
   struct TMEDGaussSubMesh: virtual TGaussSubMeshImpl
   {
+    TMEDGaussSubMesh():
+      myIsElemNum(MED::eFAUX)
+    {}
+
     MED::EBooleen myIsElemNum;
     MED::TElemNum myElemNum;
 
@@ -78,8 +86,20 @@ namespace VISU
   //---------------------------------------------------------------
   struct TMEDSubMesh: virtual TSubMeshImpl
   {
+    TMEDSubMesh():
+      myIsElemNum(MED::eFAUX)
+    {}
+
     MED::EBooleen myIsElemNum;
     MED::TElemNum myElemNum;
+
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
   };
   typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;