]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To fix a regression with wrong cashing of timestamp's data
authorapo <apo@opencascade.com>
Thu, 29 Sep 2005 15:34:48 +0000 (15:34 +0000)
committerapo <apo@opencascade.com>
Thu, 29 Sep 2005 15:34:48 +0000 (15:34 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_Convertor_impl.hxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 8ea39fb0a45f50076e6f0515b4fa0a12a0ce723c..30f24fedd91864655f77ed67430bc8671f6028d7 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "VISU_Convertor_impl.hxx"
 #include "VISU_ConvertorUtils.hxx"
+#include "VTKViewer_AppendFilter.h"
 
 #include <vtkPoints.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkCellData.h>
 #include <vtkCellLinks.h>
 
-#include <vtkMergeDataObjectFilter.h>
+#include <vtkMergeFilter.h>
 
 #include <qstring.h>
 #include <qfileinfo.h>
 
 #include <valarray>    
 #include <memory>
-#include "VTKViewer_AppendFilter.h"
 
 using namespace std;
 using namespace VISU;
@@ -129,6 +129,30 @@ namespace VISU
   }
 
 
+  //---------------------------------------------------------------
+  TMergeFilter::TMergeFilter()
+  {}
+
+  const TVTKMergeFilter& 
+  TMergeFilter
+  ::GetFilter() const
+  {
+    if(!myFilter.GetPointer()){
+      myFilter = vtkMergeFilter::New();
+      myFilter->Delete();
+    }
+    return myFilter;
+  }
+
+  TVTKOutput* 
+  TMergeFilter
+  ::GetVTKOutput()
+  {
+    GetFilter()->Update();
+    return GetFilter()->GetUnstructuredGridOutput();
+  }
+
+
   //---------------------------------------------------------------
   TPointCoords
   ::TPointCoords():
@@ -342,6 +366,72 @@ namespace VISU
     return mySource.GetVTKOutput();
   }
 
+
+  //---------------------------------------------------------------
+  TVTKOutput* 
+  TProfileMergeFilter
+  ::GetVTKOutput()
+  {
+    if(!myFilter.GetPointer()){
+      const TVTKAppendFilter& anAppendFilter = myProfile.GetFilter();
+      TVTKOutput* aGeometry = anAppendFilter->GetOutput();
+      
+      const TVTKSource& aSource = mySource.GetSource();
+      TDataSet* aDataSet = aSource.GetPointer();
+      aDataSet->ShallowCopy(aGeometry);
+      
+      const TVTKMergeFilter& aFilter = GetFilter();
+      aFilter->SetGeometry(aGeometry);
+      aFilter->SetScalars(aDataSet);
+      aFilter->SetVectors(aDataSet);
+      aFilter->AddField("VISU_FIELD",aDataSet);
+    }
+    return myFilter->GetUnstructuredGridOutput();
+  }
+
+  vtkIdType
+  TProfileMergeFilter
+  ::GetNodeObjID(vtkIdType theID) const
+  {
+    return myProfile.GetNodeObjID(theID);
+  }
+  
+  vtkIdType
+  TProfileMergeFilter
+  ::GetNodeVTKID(vtkIdType theID) const
+  {
+    return myProfile.GetNodeVTKID(theID);
+  }
+
+  float*  
+  TProfileMergeFilter
+  ::GetNodeCoord(vtkIdType theObjID)
+  {
+    return myProfile.GetNodeCoord(theObjID);
+  }
+
+  vtkIdType
+  TProfileMergeFilter
+  ::GetElemObjID(vtkIdType theID) const
+  {
+    return myProfile.GetElemObjID(theID);
+  }
+
+  vtkIdType
+  TProfileMergeFilter
+  ::GetElemVTKID(vtkIdType theID) const
+  {
+    return myProfile.GetElemVTKID(theID);
+  }
+
+  vtkCell* 
+  TProfileMergeFilter
+  ::GetElemCell(vtkIdType theObjID)
+  {
+    return myProfile.GetElemCell(theObjID);
+  }
+  
+
   //---------------------------------------------------------------
   TGaussSubMeshImpl::TGaussSubMeshImpl():
     myStatus(eNone)
@@ -681,6 +771,11 @@ namespace VISU
 
 
   //---------------------------------------------------------------
+  TValForTimeImpl
+  ::TValForTimeImpl():
+    myProfileMergeFilter(new TProfileMergeFilter())
+  {}
+
   const TMeshValue& 
   TValForTimeImpl
   ::GetMeshValue(vtkIdType theGeom) const
@@ -1747,12 +1842,11 @@ VISU_Convertor_impl
   PFieldImpl aField = boost::get<3>(aFindTimeStamp);
 
   //Main part of code
-  PProfileImpl aProfile = aValForTime->myProfile;
-  TSource& aProfileSource = aProfile->mySource;
+  PProfileMergeFilter aProfileMergeFilter = aValForTime->myProfileMergeFilter;
 #ifndef _DEXCEPT_
   try{
 #endif
-    if(!aProfileSource.myIsVTKDone){
+    if(!aProfileMergeFilter->myIsVTKDone){
       LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
 
       try{
@@ -1766,14 +1860,20 @@ VISU_Convertor_impl
       }
 
       GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);     
-      GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
-      
-      const TVTKAppendFilter& anAppendFilter = aProfile->GetFilter();
-      const TVTKSource& aSource = aProfile->mySource.GetSource();
-      aSource->ShallowCopy(anAppendFilter->GetOutput());
+
+      PProfileImpl aProfile = aValForTime->myProfile;
+      TSource& aProfileSource = aProfile->mySource;
+      if(!aProfileSource.myIsVTKDone){
+       GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
+       aProfileSource.myIsVTKDone = true;
+      }
+
+      aProfileMergeFilter->myProfile = aProfile;
+      TVTKOutput* anOutput = aProfileMergeFilter->GetVTKOutput();
+      const TVTKSource& aSource = aProfileMergeFilter->mySource.GetSource();
       GetTimeStampOnProfile(aSource,aField,aValForTime);
 
-      aProfileSource.myIsVTKDone = true;
+      aProfileMergeFilter->myIsVTKDone = true;
 
       if(MYDEBUGWITHFILES){
        string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
@@ -1781,16 +1881,16 @@ VISU_Convertor_impl
        string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
        string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + 
          aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
-       VISU::WriteToFile(aSource.GetPointer(),aFileName);
+       VISU::WriteToFile(anOutput,aFileName);
       }
       if(MYVTKDEBUG){
        GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
-       aSource->Update();
+       anOutput->Update();
        if(theEntity == VISU::NODE_ENTITY)
-         BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(aSource->GetPointData()->GetActualMemorySize()*1000)<<endl);
+         BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
        else
-         BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(aSource->GetCellData()->GetActualMemorySize()*1000)<<endl);
-       BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(aSource->GetActualMemorySize()*1000)<<endl);
+         BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
+       BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(anOutput->GetActualMemorySize()*1000)<<endl);
       }
     }
 #ifndef _DEXCEPT_
@@ -1801,7 +1901,7 @@ VISU_Convertor_impl
   }
 #endif
 
-  return aValForTime->myProfile;
+  return aProfileMergeFilter;
 }
 
 
index f1923dd8dcfb68aff87134f41125d5da260a5b72..6ecb9b6952717d0824e6a0254e80e16e3a170223 100644 (file)
@@ -15,8 +15,9 @@
 
 class vtkCell;
 class vtkPoints;
-class VTKViewer_AppendFilter;
+class vtkMergeFilter;
 class vtkUnstructuredGrid;
+class VTKViewer_AppendFilter;
 
 #include "VISU_Convertor.hxx"
 #include "MED_SliceArray.hxx"
@@ -28,10 +29,13 @@ namespace VISU
   using MED::TSlice;
 
   typedef vtkUnstructuredGrid TDataSet;
-  typedef vtkSmartPointer<TDataSet> TVTKSource;
 
+  typedef vtkSmartPointer<TDataSet> TVTKSource;
   typedef vtkSmartPointer<vtkPoints> TVTKPoints;
+  typedef vtkSmartPointer<vtkMergeFilter> TVTKMergeFilter;
+
   typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
+
   typedef float TCoord;
 
   //---------------------------------------------------------------
@@ -55,6 +59,7 @@ namespace VISU
   //---------------------------------------------------------------
   class TSource: public virtual TSizeCounter
   {
+  protected:
     mutable TVTKSource mySource;
   public:
     TSource();
@@ -72,6 +77,7 @@ namespace VISU
   class TAppendFilter: public virtual TIsVTKDone,
                       public virtual TIDMapper
   {
+  protected:
     mutable TVTKAppendFilter myFilter;
   public:
     TAppendFilter();
@@ -85,6 +91,24 @@ namespace VISU
   };
 
 
+  //---------------------------------------------------------------
+  class TMergeFilter: public virtual TIsVTKDone,
+                     public virtual TIDMapper
+  {
+  protected:
+    mutable TVTKMergeFilter myFilter;
+  public:
+    TMergeFilter();
+
+    const TVTKMergeFilter& 
+    GetFilter() const;
+
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+
+
   //---------------------------------------------------------------
   typedef TVector<TCoord> TCoordArray;
   typedef TSlice<TCoordArray> TCoordSlice;
@@ -92,6 +116,7 @@ namespace VISU
 
   class TPointCoords: public virtual TBaseStructure
   {
+  protected:
     vtkIdType myDim;
     vtkIdType myNbPoints;
 
@@ -132,6 +157,7 @@ namespace VISU
 
   class TNamedPointCoords: public virtual TPointCoords
   {
+  protected:
     typedef TVector<std::string> TPointsDim;
     TPointsDim myPointsDim;
     TVectorID myVectorID;
@@ -253,6 +279,43 @@ namespace VISU
   typedef SharedPtr<TProfileImpl> PProfileImpl;
 
 
+  //---------------------------------------------------------------
+  struct TProfileMergeFilter: virtual TMergeFilter
+  { 
+    TProfileImpl myProfile;
+    TSource mySource;
+
+    virtual 
+    vtkIdType 
+    GetNodeObjID(vtkIdType theID) const;
+
+    virtual 
+    vtkIdType 
+    GetNodeVTKID(vtkIdType theID) const;
+
+    virtual 
+    float*  
+    GetNodeCoord(vtkIdType theObjID);
+
+    virtual 
+    vtkIdType 
+    GetElemObjID(vtkIdType theID) const;
+
+    virtual 
+    vtkIdType 
+    GetElemVTKID(vtkIdType theID) const;
+
+    virtual
+    vtkCell* 
+    GetElemCell(vtkIdType theObjID);
+    
+    virtual
+    TVTKOutput* 
+    GetVTKOutput();
+  };
+  typedef SharedPtr<TProfileMergeFilter> PProfileMergeFilter;
+
+
   //---------------------------------------------------------------
   struct TGaussImpl: virtual TGauss
   {
@@ -499,7 +562,11 @@ namespace VISU
 
   struct TValForTimeImpl: virtual TValForTime
   {
+    PProfileMergeFilter myProfileMergeFilter;
     TGeom2Value myGeom2Value;
+    vtkIdType myNbGauss;
+   
+    TValForTimeImpl();
 
     const TMeshValue& 
     GetMeshValue(vtkIdType theGeom) const;
@@ -507,8 +574,6 @@ namespace VISU
     TMeshValue& 
     GetMeshValue(vtkIdType theGeom);
 
-    vtkIdType myNbGauss;
-
     virtual
     int
     GetNbGauss(vtkIdType theGeom) const;
index 166cbbeee81495d46d9c16fa62141fd5595bef6f..716b52adae73b1b229caf61c8b373efa87d8fc9c 100644 (file)
@@ -1952,15 +1952,14 @@ VISU_MedConvertor
                       VISU::PMEDField theField, 
                       VISU::PMEDValForTime theValForTime)
 {
-  PProfileImpl aProfile = theValForTime->myProfile;
-  TSource& aProfileSource = aProfile->mySource;
+  PProfileMergeFilter aProfileMergeFilter = aValForTime->myProfileMergeFilter;
   return LoadValForTime(theMed,
                        theMesh,
                        theMeshOnEntity,
                        theField,
                        theValForTime,
                        false,
-                       aProfileSource.myIsDone);
+                       aProfileMergeFilter->myIsVTKDone);
 }