From cc38707ce57519ad5f5ff841b98fab538fccc4c3 Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Mon, 15 Mar 2021 10:21:25 +0100 Subject: [PATCH] [EDF 23070] SerafinReader: Correction for vector identification Adding new exception to not vectorise. Also add option to deactivate vectorisation in plugin properties. --- src/SerafinReader/geo_TW.slf | Bin 397 -> 0 bytes .../SerafinReaderModule/stdSerafinReader.h | 4 +- .../SerafinReaderModule/vtkSerafinReader.cxx | 52 ++++++++++-------- .../SerafinReaderModule/vtkSerafinReader.h | 9 ++- src/SerafinReader/plugin/sources.xml | 25 ++------- 5 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 src/SerafinReader/geo_TW.slf diff --git a/src/SerafinReader/geo_TW.slf b/src/SerafinReader/geo_TW.slf deleted file mode 100644 index 058d01f8f1bd382c23accaad17c9ef6eb8e4bb52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 397 zcma)!O9}!p5JcM_h$|O!fL^*0yh6_h31lX-h#Hw%wtRY)+n5DOluR9Cl%%y)CW zMHePLYYd}3tkcn)_jVn04pSFzgV+BhxC!=P1t@xLL&W*doyw+=9dH6=5B8_nJ%TOR zfeqj;vrG2O*4eXHI_&e$KIi;%rvX&ymR;s)wme1p41Lbitj?<$Z&7@k_9gNS^TQk9 C&m?XD diff --git a/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h b/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h index e068209..4ad19d5 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h +++ b/src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h @@ -177,7 +177,7 @@ class stdSerafinReader : public FFileReader { public: // Simple constructeur (flux en argument) - stdSerafinReader(ifstream* stream); + stdSerafinReader(ifstream* stream, int BuildVectors); // Destructeur de base ~stdSerafinReader() { @@ -380,7 +380,7 @@ protected: void createIndex (); // Identify vector info for each variable - void ComputeVarInfo (); + void ComputeVarInfo (int BuildVectors); ////// Ensemble de fonction de lecture de la table d'index \\\\\\ // [fixés] Déplace la tête de lecture sur la positon id dans la table des valeurs de X ou Y diff --git a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx index 8a086ac..299ab92 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx +++ b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx @@ -209,7 +209,7 @@ FFileReader :: ~FFileReader() /** +++++++++++++++++ Définition des méthodes de la classe stdSerafinReader +++++++++++++++++ **/ /* ******************* Constructeur ***************** */ -stdSerafinReader :: stdSerafinReader(ifstream* stream) : FFileReader(stream) +stdSerafinReader :: stdSerafinReader(ifstream* stream, int BuildVectors) : FFileReader(stream) { // TODO Initialisation des variables this->metadata = new SerafinMetaData(); @@ -225,7 +225,7 @@ stdSerafinReader :: stdSerafinReader(ifstream* stream) : FFileReader(stream) // Identify variable vector //vtkDebugMacro( << "Computing Var Infor" << endl); - this->ComputeVarInfo(); + this->ComputeVarInfo(BuildVectors); }; /* ******************* Destructeur ***************** */ @@ -234,7 +234,7 @@ stdSerafinReader :: stdSerafinReader(ifstream* stream) : FFileReader(stream) //{ // // Ne rien faire pour le moment, provoque une 'legere fuite memoire' maitrisee //}; -void stdSerafinReader::ComputeVarInfo() +void stdSerafinReader::ComputeVarInfo(int BuildVectors) { int pos, ncomp; int found; @@ -245,20 +245,35 @@ void stdSerafinReader::ComputeVarInfo() ncomp = 2; for( int i; i < this->metadata->VarNumber ; i++) { - // must read full buffer as each varaible is a file record + // Only converting to vector if asked for + if(! BuildVectors){ + metadata->nVarList[i].ncomp = 0; + metadata->nVarList[i].icomp = 0; + continue; + } string name(metadata->nVarList[i].name); + + // Exception for which we do not create a vector + list exceptions {"COTE Z", "ELEVATION Z"}; + + found = 0; + for(auto const &excep : exceptions){ + pos = name.find(excep); + if (pos != std::string::npos){ + metadata->nVarList[i].ncomp = 0; + metadata->nVarList[i].icomp = 0; + found = 1; + continue; + } + } + if (found) continue; + + // List of ends of variable that should be converted to vectors list vec0 {" U ", " X ", "QX ", "U0 "}; list vec1 {" V ", " Y ", "QY ", "V0 "}; list vec2 {" W ", " Z ", "QZ ", "W0 "}; list> vec {vec0, vec1, vec2}; - pos = name.find("COTE Z"); - if (pos != std::string::npos){ - metadata->nVarList[i].ncomp = 0; - metadata->nVarList[i].icomp = 0; - continue; - } - found = 0; int k = 0; for(auto const &veci : vec){ @@ -274,10 +289,10 @@ void stdSerafinReader::ComputeVarInfo() }; } k++; - if (found != 0) break; + if (found) break; } // Found a vector go to next variable - if (found != 0) continue; + if (found) continue; // Default values metadata->nVarList[i].ncomp = 0; metadata->nVarList[i].icomp = 0; @@ -288,7 +303,7 @@ void stdSerafinReader::ComputeVarInfo() /* Cette méthode crée un index de taille et de position à partir des informations meta * afin de faciliter la lecture du fichier serafin . */ -void stdSerafinReader :: createIndex () +void stdSerafinReader::createIndex () { int tag = 0 ; int nnodes = GetNumberOfNodes(); @@ -442,10 +457,6 @@ vtkSerafinReader::~vtkSerafinReader() delete this->Internal; } -void vtkSerafinReader::SetTimeUnit(int value) -{ - cerr << "TimeUnit " << value << endl; -} int vtkSerafinReader::RequestInformation(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), @@ -471,7 +482,7 @@ int vtkSerafinReader::RequestInformation(vtkInformation *vtkNotUsed(request), return 0; } - this->Reader = new stdSerafinReader( FileStream); + this->Reader = new stdSerafinReader( FileStream, this->BuildVectors); {//Gestion du temps const int totime = this->Reader->GetTotalTime(); @@ -641,7 +652,6 @@ void vtkSerafinReader::ReadData(vtkUnstructuredGrid *output, int time) std::string name(var->name); name = name.substr(0, name.find_last_not_of(" \n")+1); - // TODO: Creating vector for VELOCITY and stuff if (var->ncomp != 0){ data->SetName(name.c_str()); data->SetNumberOfComponents(3); @@ -656,8 +666,6 @@ void vtkSerafinReader::ReadData(vtkUnstructuredGrid *output, int time) this->Reader->GetVarValues(time, i, 0, data->GetPointer (0), size); } - {//Stockage des donnees - }; output->GetPointData()->AddArray(data); data->Delete(); diff --git a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h index d4f9616..9f650ee 100644 --- a/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h +++ b/src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h @@ -80,13 +80,11 @@ public: vtkTypeMacro(vtkSerafinReader,vtkUnstructuredGridAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); - void SetTimeUnit(int); - vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); - vtkSetMacro(TimeStep, int); - vtkGetMacro(TimeStep, int); + vtkSetMacro(BuildVectors, int); + vtkGetMacro(BuildVectors, int); protected: @@ -108,7 +106,8 @@ protected: char *FileName; // Nom du fichier ouvert par le logiciel Paraview ifstream *FileStream;// Flux de lecture du fichier - int TimeStep; + int TimeStep; // Internal variable to remember actual time step + int BuildVectors; // Defines if variables are to be converter to vectors (when necessary) stdSerafinReader* Reader; /** /!\ Instance de lecture du fichier Serafin **/ diff --git a/src/SerafinReader/plugin/sources.xml b/src/SerafinReader/plugin/sources.xml index 32f6b49..e0825c7 100644 --- a/src/SerafinReader/plugin/sources.xml +++ b/src/SerafinReader/plugin/sources.xml @@ -20,29 +20,14 @@ - - - - - - - - - - - - - - - + - This property indicates which transform mode will be used. + If True tries to compute vectors from varaibles name + (name ending with a space and U/V/W, X/Y/Z, QX/QY/QZ, U0/V0/W0) -- 2.39.2