// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "vtkDoubleArray.h"
#include "vtkInformation.h"
#include "vtkQuadratureSchemeDefinition.h"
+#include "vtkInformationQuadratureSchemeDefinitionVectorKey.h"
#include "MEDUtilities.hxx"
-#define protected public
#include "vtkFieldData.h"
+#include <sstream>
+
+const char vtkGenerateVectors::VECTOR_SUFFIX[]="_Vector";
+
+std::string vtkGenerateVectors::SuffixFieldName(const std::string& name)
+{
+ std::ostringstream oss; oss << name << VECTOR_SUFFIX;
+ return oss.str();
+}
+
void vtkGenerateVectors::Operate(vtkFieldData *fd)
{
if(!fd)
return ;
const int nbOfArrs(fd->GetNumberOfArrays());
+ std::vector<vtkDoubleArray *> daToAppend;
for(int i=0;i<nbOfArrs;i++)
{
vtkDataArray *arr(fd->GetArray(i));
if(nbOfCompo<=1 || nbOfCompo==3)
continue;
if(nbOfCompo==2)
- fd->SetArray(i,Operate2Compo(arrc));
+ daToAppend.push_back(Operate2Compo(arrc));
else
- fd->SetArray(i,OperateMoreThan3Compo(arrc));
+ daToAppend.push_back(OperateMoreThan3Compo(arrc));
+ }
+ for(std::vector<vtkDoubleArray *>::const_iterator it=daToAppend.begin();it!=daToAppend.end();it++)
+ {
+ vtkDoubleArray *elt(*it);
+ if(!elt)
+ continue;
+ fd->AddArray(elt);
+ elt->Delete();
}
}
pt[3*i+2]=0.;
}
ret->SetNumberOfComponents(3);
- ret->SetName(oldArr->GetName());
+ std::string newName(SuffixFieldName(oldArr->GetName()));
+ ret->SetName(newName.c_str());
ret->SetComponentName(0,oldArr->GetComponentName(0));
ret->SetComponentName(1,oldArr->GetComponentName(1));
ret->SetArray(pt,3*nbOfTuples,0,VTK_DATA_ARRAY_FREE);
pt[3*i+2]=inPt[nbOfCompo*i+2];
}
ret->SetNumberOfComponents(3);
- ret->SetName(oldArr->GetName());
+ std::string newName(SuffixFieldName(oldArr->GetName()));
+ ret->SetName(newName.c_str());
ret->SetComponentName(0,oldArr->GetComponentName(0));
ret->SetComponentName(1,oldArr->GetComponentName(1));
ret->SetComponentName(2,oldArr->GetComponentName(2));
}
if(oldArr->GetInformation()->Get(MEDUtilities::ELGA()))
arr->GetInformation()->Set(MEDUtilities::ELGA(),1);
+ vtkInformationQuadratureSchemeDefinitionVectorKey *key(vtkQuadratureSchemeDefinition::DICTIONARY());
+ if(key->Has(oldArr->GetInformation()))
+ {
+ int dictSize(key->Size(oldArr->GetInformation()));
+ vtkQuadratureSchemeDefinition **dict = new vtkQuadratureSchemeDefinition *[dictSize];
+ key->GetRange(oldArr->GetInformation(),dict,0,0,dictSize);
+ key->SetRange(arr->GetInformation(),dict,0,0,dictSize);
+ delete [] dict;
+ }
if(oldArr->GetInformation()->Get(MEDUtilities::ELNO()))
arr->GetInformation()->Set(MEDUtilities::ELNO(),1);
}