From: Yoann Audouin Date: Fri, 9 Jul 2021 07:32:57 +0000 (+0200) Subject: [SerafinReader] Correcting issue with time X-Git-Tag: V9_8_0a1~1^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5b57ed784c215aed2a03797b8d5fd08a9a82e1a9;p=tools%2Fparavisaddons_common.git [SerafinReader] Correcting issue with time --- diff --git a/src/SerafinReader/Test/result.slf b/src/SerafinReader/Test/result.slf new file mode 100644 index 0000000..8cdc452 Binary files /dev/null and b/src/SerafinReader/Test/result.slf differ diff --git a/src/SerafinReader/Test/test_SerafinReader.py b/src/SerafinReader/Test/test_SerafinReader.py index a557ff4..ed0c02a 100644 --- a/src/SerafinReader/Test/test_SerafinReader.py +++ b/src/SerafinReader/Test/test_SerafinReader.py @@ -37,3 +37,15 @@ assert(np.all(data <= 1e-8)) reader = SerafinReader(FileName='geo_3d_dp.slf') reader.UpdatePipeline() reader_ds = servermanager.Fetch(reader) + +# Reading file with time steps (10) +reader = SerafinReader(FileName='result.slf') +reader.UpdatePipeline() +reader_ds = servermanager.Fetch(reader) + +# Using animationScene to get tim information +anim = GetAnimationScene() +tk = anim.TimeKeeper +times = tk.TimestepValues +ref_times = [i*1.0 for i in range(10)] +assert(times == ref_times) diff --git a/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h b/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h index 4ad19d5..1bedf18 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h +++ b/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h @@ -149,7 +149,7 @@ typedef struct int64_t ConnectivityPosition ; // La position dans le fichier de la table de connectivité int64_t XPosition; // La position dans le fichier de la table des valeurs de X int64_t YPosition; // La position dans le fichier de la table des valeurs de Y - int64_t DataPosision; // La position dans le fichier des blocs de données + int64_t DataPosition; // La position dans le fichier des blocs de données int NumberOfDate ; // Information sur le temps étudié @@ -246,8 +246,12 @@ public: // Associe la date de début de simulation void GetDate(SerafinDate* date) { - date->day = this->metadata->Date[2]; date->month = this->metadata->Date[1]; date->year = this->metadata->Date[0]; - date->hour = this->metadata->Date[3]; date->min = this->metadata->Date[4]; date->sec = this->metadata->Date[5]; + date->day = this->metadata->Date[2]; + date->month = this->metadata->Date[1]; + date->year = this->metadata->Date[0]; + date->hour = this->metadata->Date[3]; + date->min = this->metadata->Date[4]; + date->sec = this->metadata->Date[5]; }; // Simplifie la lecture des informations de discrétisation @@ -262,9 +266,11 @@ public: double GetTime(int timeid) { double value = 0; - FileStream->seekg( this->index->DataPosision + this->index->DataBlocSize * timeid , std::ios_base::beg ) ; + FileStream->seekg( this->index->DataPosition + this->index->DataBlocSize * timeid , + std::ios_base::beg ) ; skipReadingHeader(FileStream); (*this.*readFloatArray)(&(value), 1); + return value; }; @@ -406,7 +412,7 @@ protected: int64_t GoToData(const int time) { if (time >= GetTotalTime()) return 0 ; - FileStream->seekg( this->index->DataPosision + this->index->DataBlocSize * time + this->index->TimeSize, std::ios_base::beg ) ; + FileStream->seekg( this->index->DataPosition + this->index->DataBlocSize * time + this->index->TimeSize, std::ios_base::beg ) ; return FileStream->tellg(); }; diff --git a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx index 299ab92..d5b2ce9 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx +++ b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx @@ -346,7 +346,7 @@ void stdSerafinReader::createIndex () - 2*index->FieldSize - (this->index->IntSize*ndp*nelem+2*this->index->TagSize); // Index to data - this->index->DataPosision = (this->index->FileSize) - (this->index->DataSize); + this->index->DataPosition = (this->index->FileSize) - (this->index->DataSize); // Index of Y coordinates this->index->YPosition = this->index->XPosition + this->index->FieldSize; @@ -357,7 +357,6 @@ void stdSerafinReader::createIndex () this->index->NumberOfDate = (this->index->DataSize)/(this->index->DataBlocSize); - //vtkDebugMacro(<< "Number of Date: " << this->index->NumberOfDate << endl); }; @@ -491,14 +490,13 @@ int vtkSerafinReader::RequestInformation(vtkInformation *vtkNotUsed(request), int i=0; double* TimeValues = new double[totime]; - for (i=0; iReader->GetTime(i) ;} - - outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), &TimeValues[0], totime); + for (i=0; iReader->GetTime(i) ; } + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), &TimeValues[0], totime); double timeRange[2]; timeRange[0] = TimeValues[0]; timeRange[1] = TimeValues[totime-1]; - outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); + outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), &timeRange[0], 2); }; } diff --git a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h index 9f650ee..676ea7d 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h +++ b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h @@ -83,6 +83,11 @@ public: vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); + // Mandatory for time manipulation + vtkSetMacro(TimeStep, int); + vtkGetMacro(TimeStep, int); + int GetNumberOfTimeSteps() {this->Reader->GetTotalTime();}; + vtkSetMacro(BuildVectors, int); vtkGetMacro(BuildVectors, int); diff --git a/src/SerafinReader/plugin/sources.xml b/src/SerafinReader/plugin/sources.xml index e0825c7..2d56bd4 100644 --- a/src/SerafinReader/plugin/sources.xml +++ b/src/SerafinReader/plugin/sources.xml @@ -20,6 +20,16 @@ + + + + + Available timestep values. + + +