From: apo Date: Thu, 29 Sep 2005 15:34:48 +0000 (+0000) Subject: To fix a regression with wrong cashing of timestamp's data X-Git-Tag: BR-D5-38-2003_D2005-12-10~107 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e60de598fb2da36213ba29cf9eaa5989404c4f8c;p=modules%2Fvisu.git To fix a regression with wrong cashing of timestamp's data --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 8ea39fb0..30f24fed 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -26,6 +26,7 @@ #include "VISU_Convertor_impl.hxx" #include "VISU_ConvertorUtils.hxx" +#include "VTKViewer_AppendFilter.h" #include #include @@ -40,14 +41,13 @@ #include #include -#include +#include #include #include #include #include -#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() = "<GetPointData()->GetActualMemorySize()*1000)< TVTKSource; + typedef vtkSmartPointer TVTKSource; typedef vtkSmartPointer TVTKPoints; + typedef vtkSmartPointer TVTKMergeFilter; + typedef vtkSmartPointer 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 TCoordArray; typedef TSlice 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 TPointsDim; TPointsDim myPointsDim; TVectorID myVectorID; @@ -253,6 +279,43 @@ namespace VISU typedef SharedPtr 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 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; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 166cbbee..716b52ad 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -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); }