/** +++++++++++++++++ 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();
// Identify variable vector
//vtkDebugMacro( << "Computing Var Infor" << endl);
- this->ComputeVarInfo();
+ this->ComputeVarInfo(BuildVectors);
};
/* ******************* Destructeur ***************** */
//{
// // 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;
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){
};
}
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;
/* 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();
delete this->Internal;
}
-void vtkSerafinReader::SetTimeUnit(int value)
-{
- cerr << "TimeUnit " << value << endl;
-}
int vtkSerafinReader::RequestInformation(vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
return 0;
}
- this->Reader = new stdSerafinReader( FileStream);
+ this->Reader = new stdSerafinReader( FileStream, this->BuildVectors);
{//Gestion du temps
const int totime = this->Reader->GetTotalTime();
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);
this->Reader->GetVarValues(time, i, 0, data->GetPointer (0), size);
}
- {//Stockage des donnees
- };
output->GetPointData()->AddArray(data);
data->Delete();
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:
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 **/
</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>