From: YOANN AUDOUIN Date: Mon, 15 Mar 2021 09:21:25 +0000 (+0100) Subject: [EDF 23070] SerafinReader: Correction for vector identification X-Git-Tag: V9_7_0rc2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc38707ce57519ad5f5ff841b98fab538fccc4c3;p=tools%2Fparavisaddons_common.git [EDF 23070] SerafinReader: Correction for vector identification Adding new exception to not vectorise. Also add option to deactivate vectorisation in plugin properties. --- diff --git a/src/SerafinReader/geo_TW.slf b/src/SerafinReader/geo_TW.slf deleted file mode 100644 index 058d01f..0000000 Binary files a/src/SerafinReader/geo_TW.slf and /dev/null differ 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)