default:
aDataSetAttributes = theSource->GetCellData();
}
-
+ int aNumberOfComponents=theField->myNbComp;
vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField->myNbComp) {
+ switch(aNumberOfComponents) {
case 1:
aFloatArray->SetNumberOfComponents(1);
aDataSetAttributes->SetScalars(aFloatArray);
aFloatArray->SetNumberOfComponents(3);
aDataSetAttributes->SetVectors(aFloatArray);
}
-
+ aFloatArray->Delete();
aFloatArray->SetNumberOfTuples(aNbTuples);
aFloatArray->SetName(aFieldName.c_str());
-
+ //
+ vtkFloatArray *aFArr=vtkFloatArray::New();
+ aFArr->SetNumberOfComponents(aNumberOfComponents);
+ aFArr->SetNumberOfTuples(aNbTuples);
+ aFArr->SetName("FIELD");
+ aDataSetAttributes->AddArray(aFArr);
+ aFArr->Delete();
+ //
TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
TGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
+ int aTupleIdx = 0, aTupleId = 0;
+ vector<float>aVal(aNumberOfComponents);
+ //
+ for(; anIter != aGeom2Value.end(); anIter++){
int aGeom = anIter->first;
const TMeshValue& aMeshValue = anIter->second;
-
+
int aNbElem = aMeshValue.myNbElem;
int aNbGauss = aMeshValue.myNbGauss;
- int aNbComp = aMeshValue.myNbComp;
-
+ //int aNbComp = aMeshValue.myNbComp;
INITMSG(MYDEBUG,
"- aGeom = "<<aGeom<<
"; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNbComp<<
+ "; aNbComp = "<<aNumberOfComponents<<
"; aNbGauss = "<<aNbGauss<<
endl);
-
- int aNbComp2 = aNbComp;
- switch(aNbComp){
- case 1:
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- aValue[iComp] += aValueSlice[iGauss];
- }
- aValue[iComp] /= aNbGauss;
- }
- aFloatArray->SetTuple1(aTupleId++,aValue[0]);
- }
- break;
- case 4:
+ //
+ //int aNbDim=(aNumberOfComponents==1)? 1 : 3;
+ int aNbComp2=aNumberOfComponents;
+ if (aNumberOfComponents==2 || aNumberOfComponents==4) {
aNbComp2 = 2;
- case 2:
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- aValue[iComp] += aValueSlice[iGauss];
- }
- aValue[iComp] /= aNbGauss;
+ }
+ else if (aNumberOfComponents>4){
+ aNbComp2 = 3;
+ }
+ //
+ int iE, iG, iC;
+ for(iE = 0; iE < aNbElem; iE++){
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iE);
+ //aFloatArray
+ for(iC=0; iC<aNumberOfComponents; ++iC){
+ aVal[iC]=0.;
+ }
+ for(iC=0; iC<aNbComp2; iC++){
+ const TCValueSlice& aValueSlice = aValueSliceArr[iC];
+ for(iG=0; iG<aNbGauss; iG++){
+ aVal[iC] += aValueSlice[iG];
}
- aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],0.0);
+ aVal[iC]/=aNbGauss;
}
- break;
- default:
- if(aNbComp > 3)
- aNbComp2 = 3;
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- aValue[iComp] += aValueSlice[iGauss];
- }
- aValue[iComp] /= aNbGauss;
+ aFloatArray->SetTuple(aTupleId++, &aVal[0]);
+ //aFArr
+ for(iC=0; iC<aNumberOfComponents; ++iC){
+ aVal[iC]=0.;
+ }
+ for(iC=0; iC<aNumberOfComponents; iC++) {
+ const TCValueSlice& aValueSlice=aValueSliceArr[iC];
+ for(iG=0; iG<aNbGauss; iG++) {
+ aVal[iC] += aValueSlice[iG];
}
- aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
+ aVal[iC]/=aNbGauss;
}
+ aFArr->SetTuple(aTupleIdx++, &aVal[0]);
}
}
}
int aNbTuples = theSource->GetNumberOfPoints();
std::string aFieldName = GenerateFieldName(theField,theValForTime);
INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh - aNbTuples = "<<aNbTuples<<endl);
-
+ //
vtkDataSetAttributes* aDataSetAttributes;
+ //
switch(theField->myEntity){
case VISU::NODE_ENTITY :
aDataSetAttributes = theSource->GetPointData();
default:
aDataSetAttributes = theSource->GetCellData();
}
-
+ //
+ int aNumberOfComponents=theField->myNbComp;
vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField->myNbComp) {
+ switch(aNumberOfComponents) {
case 1:
aFloatArray->SetNumberOfComponents(1);
aDataSetAttributes->SetScalars(aFloatArray);
aFloatArray->SetNumberOfComponents(3);
aDataSetAttributes->SetVectors(aFloatArray);
}
-
+ aFloatArray->Delete();
aFloatArray->SetNumberOfTuples(aNbTuples);
aFloatArray->SetName(aFieldName.c_str());
-
+ //
+ vtkFloatArray *aFArr=vtkFloatArray::New();
+ aFArr->SetNumberOfComponents(theField->myNbComp);
+ aFArr->SetNumberOfTuples(aNbTuples);
+ aFArr->SetName("FIELD");
+ aDataSetAttributes->AddArray(aFArr);
+ aFArr->Delete();
+ //
TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
- for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ int aTupleIdx = 0, aTupleId = 0;
+ vector<float>aVal(aNumberOfComponents);
+ //
+ for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
vtkIdType aGeom = anIter->first;
PGaussSubMeshImpl aGaussSubMesh = anIter->second;
if(!aGaussSubMesh->myIsDone)
continue;
TGeom2Value::const_iterator anIter2 = aGeom2Value.find(aGeom);
- if(anIter2 == aGeom2Value.end())
- EXCEPTION(runtime_error,"GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
-
+ if(anIter2 == aGeom2Value.end()){
+ EXCEPTION(runtime_error,
+ "GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
+ }
const TMeshValue& aMeshValue = anIter2->second;
int aNbElem = aMeshValue.myNbElem;
int aNbGauss = aMeshValue.myNbGauss;
- int aNbComp = aMeshValue.myNbComp;
+ //int aNbComp = aMeshValue.myNbComp;
if(aNbGauss < 1)
continue;
INITMSG(MYDEBUG,"- aGeom = "<<aGeom<<
"; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNbComp<<
+ "; aNbComp = "<<aNumberOfComponents<<
"; aNbGauss = "<<aNbGauss<<
endl);
-
- int aNbComp2 = aNbComp;
- switch(aNbComp){
- case 1:
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- aValue[iComp] += aValueSlice[iComp];
- }
- aFloatArray->SetTuple1(aTupleId++,aValue[0]);
- }
- }
- break;
- case 4:
+ //
+ int aNbComp2=aNumberOfComponents;
+ if (aNumberOfComponents==2 || aNumberOfComponents==4) {
aNbComp2 = 2;
- case 2:
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- aValue[iComp] += aValueSlice[iComp];
- }
- aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],0.0);
+ }
+ else if (aNumberOfComponents>4){
+ aNbComp2 = 3;
+ }
+ //
+ int iE, iG, iC;
+ for(iE=0; iE<aNbElem; iE++){
+ //aFloatArray
+ for(iC=0; iC<aNumberOfComponents; iC++) {
+ aVal[iC]=0.;
+ }
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iE);
+ for(iG=0; iG<aNbGauss; iG++){
+ const TCValueSlice& aValueSlice=aValueSliceArr[iG];
+ for(iC=0; iC<aNbComp2; iC++) {
+ aVal[iC] += aValueSlice[iC];
}
+ aFloatArray->SetTuple(aTupleId++, &aVal[0]);
}
- break;
- default:
- if(aNbComp > 3)
- aNbComp2 = 3;
- for(int iElem = 0; iElem < aNbElem; iElem++){
- float aValue[] = {0.0, 0.0, 0.0};
- TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- aValue[iComp] += aValueSlice[iComp];
- }
- aFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
+ //aFArr
+ for(iC=0; iC<aNumberOfComponents; iC++) {
+ aVal[iC]=0.;
+ }
+ for(iG=0; iG<aNbGauss; iG++){
+ const TCValueSlice& aValueSlice=aValueSliceArr[iG];
+ for(iC=0; iC<aNumberOfComponents; iC++) {
+ aVal[iC] += aValueSlice[iC];
}
+ aFArr->SetTuple(aTupleIdx++, &aVal[0]);
}
}
- }
+ }// for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+
}