Salome HOME
[EDF 23070] SerafinReader: Correction for vector identification
authorYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Mon, 15 Mar 2021 09:21:25 +0000 (10:21 +0100)
committerYOANN AUDOUIN <B61570@dsp0919998.atlas.edf.fr>
Mon, 15 Mar 2021 09:42:54 +0000 (10:42 +0100)
Adding new exception to not vectorise.
Also add option to deactivate vectorisation in plugin properties.

src/SerafinReader/geo_TW.slf [deleted file]
src/SerafinReader/plugin/SerafinReaderModule/stdSerafinReader.h
src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.cxx
src/SerafinReader/plugin/SerafinReaderModule/vtkSerafinReader.h
src/SerafinReader/plugin/sources.xml

diff --git a/src/SerafinReader/geo_TW.slf b/src/SerafinReader/geo_TW.slf
deleted file mode 100644 (file)
index 058d01f..0000000
Binary files a/src/SerafinReader/geo_TW.slf and /dev/null differ
index e068209a8411f4f327159451055776c216525b8e..4ad19d5aab15f2029485d935b75787e4a37f1956 100644 (file)
@@ -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
index 8a086ac50ebbe76adc4958589559d7f3b10ef871..299ab922d1b5ea63ff15303d764f22fd470ab785 100644 (file)
@@ -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<string> 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<string> vec0 {" U ", " X ", "QX ", "U0 "};
     list<string> vec1 {" V ", " Y ", "QY ", "V0 "};
     list<string> vec2 {" W ", " Z ", "QZ ", "W0 "};
     list<list<string>> 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();
index d4f96167a71565a6547c23b9c2a977c46e4dae47..9f650ee284865f6e58155a1dfa5dea639ffe84f0 100644 (file)
@@ -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 **/
 
index 32f6b493cc8e9e3b54a11460a7feaafa48ab80a6..e0825c72fef4582fa13b528043fc6d7c3e5ecae4 100644 (file)
         </Documentation>
       </StringVectorProperty>
 
-      <DoubleVectorProperty name="TimestepValues"
-                            repeatable="1"
-                            information_only="1">
-        <TimeStepsInformationHelper/>
-      </DoubleVectorProperty>
-
-      <DoubleVectorProperty name="TimeRange"
-                            information_only="1">
-        <TimeRangeInformationHelper/>
-      </DoubleVectorProperty>
-
-      <IntVectorProperty name="Time Units"
-                         command="SetTimeUnit"
+      <IntVectorProperty name="BuildVectors"
+                         command="SetBuildVectors"
                          number_of_elements="1"
                          default_values="1">
-        <EnumerationDomain name="enum">
-          <Entry value="1" text="Seconds"/>
-          <Entry value="2" text="Hours"/>
-          <Entry value="3" text="Days"/>
-          <Entry value="4" text="Years"/>
-        </EnumerationDomain>
+        <BooleanDomain name="bool"/>
         <Documentation>
-          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)
         </Documentation>
       </IntVectorProperty>