default:
aDataSetAttributes = theSource->GetCellData();
}
- int aNumberOfComponents=theField->myNbComp;
+
+ int aNbComp = theField->myNbComp;
vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(aNumberOfComponents) {
+ switch(aNbComp) {
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("VISU_FIELD");
- aDataSetAttributes->AddArray(aFArr);
- aFArr->Delete();
- //
+
+ vtkFloatArray *aDataArray = vtkFloatArray::New();
+ aDataArray->SetNumberOfComponents(aNbComp);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ aDataSetAttributes->AddArray(aDataArray);
+ aDataArray->SetName("VISU_FIELD");
+
TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
TGeom2Value::const_iterator anIter = aGeom2Value.begin();
- int aTupleIdx = 0, aTupleId = 0;
- vector<float>aVal(aNumberOfComponents);
- //
- for(; anIter != aGeom2Value.end(); anIter++){
+ TVector<float> aDataValues(aNbComp);
+ for(int aTupleId = 0; 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;
INITMSG(MYDEBUG,
"- aGeom = "<<aGeom<<
"; aNbElem = "<<aNbElem<<
- "; aNbComp = "<<aNumberOfComponents<<
+ "; aNbComp = "<<aNbComp<<
"; aNbGauss = "<<aNbGauss<<
endl);
- //
- //int aNbDim=(aNumberOfComponents==1)? 1 : 3;
- int aNbComp2=aNumberOfComponents;
- if (aNumberOfComponents==2 || aNumberOfComponents==4) {
+
+ int aNbComp2 = aNbComp;
+ if(aNbComp == 2 || aNbComp == 4)
aNbComp2 = 2;
- }
- else if (aNumberOfComponents>4){
+ else if(aNbComp > 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];
- }
- aVal[iC]/=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];
+
+ for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = 0.0;
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
}
- aVal[iC]/=aNbGauss;
+ aDataValues[iComp] /= aNbGauss;
}
- aFArr->SetTuple(aTupleIdx++, &aVal[0]);
+ aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
+ aDataArray->SetTuple(aTupleId,&aDataValues[0]);
}
}
+ aFloatArray->Delete();
+ aDataArray->Delete();
}
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++, aTupleId++){
const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp2; iComp++){
- aValue[iComp] += aValueSlice[iComp];
- }
for(int iComp = 0; iComp < aNbComp; iComp++){
aDataValues[iComp] = aValueSlice[iComp];
}
- aFloatArray->SetTuple(aTupleId,aValue);
+ aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
aDataArray->SetTuple(aTupleId,&aDataValues[0]);
}
}