From 9294e0dc0a012c38dbdf262c9a999700aed025f7 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 23 Sep 2005 14:14:59 +0000 Subject: [PATCH] To fix a regression --- src/CONVERTOR/VISU_Convertor_impl.cxx | 80 ++++++++++++--------------- src/PIPELINE/VISU_Extractor.cxx | 68 ++++++++++++----------- 2 files changed, 70 insertions(+), 78 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 4ffd602e..b64cd6d2 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -1079,7 +1079,7 @@ namespace vtkFloatArray *aFArr=vtkFloatArray::New(); aFArr->SetNumberOfComponents(aNumberOfComponents); aFArr->SetNumberOfTuples(aNbTuples); - aFArr->SetName("FIELD"); + aFArr->SetName("VISU_FIELD"); aDataSetAttributes->AddArray(aFArr); aFArr->Delete(); // @@ -1303,9 +1303,9 @@ namespace 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); @@ -1314,26 +1314,23 @@ namespace 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(); + vtkFloatArray *aDataArray = vtkFloatArray::New(); + aDataArray->SetNumberOfComponents(aNbComp); + aDataArray->SetNumberOfTuples(aNbTuples); + aDataSetAttributes->AddArray(aDataArray); + aDataArray->SetName("VISU_FIELD"); // - TGeom2Value& aGeom2Value = theValForTime->myGeom2Value; + const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value; PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh; const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); - int aTupleIdx = 0, aTupleId = 0; - vectoraVal(aNumberOfComponents); + TVector aDataValues(aNbComp); // - for(; anIter != aGeom2GaussSubMesh.end(); anIter++){ + for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){ vtkIdType aGeom = anIter->first; PGaussSubMeshImpl aGaussSubMesh = anIter->second; if(!aGaussSubMesh->myIsDone) @@ -1345,55 +1342,46 @@ namespace "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 aNbElem = aMeshValue.myNbElem; if(aNbGauss < 1) continue; INITMSG(MYDEBUG,"- aGeom = "<GetNumberOfComponents(); - vectorv(aNumberOfComponents); - // - vtkFloatArray *newScalars = vtkFloatArray::New(); - ostringstream aName; - aName<GetName(); aName<<", "; aName<SetName(aName.str().c_str()); - newScalars->SetNumberOfComponents(1); - newScalars->SetNumberOfTuples(theNbComp); - // - for (int ptId = 0; ptId < theNbComp; ptId++) { - float s; - aFArr->GetTuple (ptId, &v[0]); - if (!theScalarMode) { - //if ( theScalarMode < 1 || theScalarMode > 3) { - s = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); - } - else { - s = v[theScalarMode - 1]; + vtkDataArray* aVectors = theInputData->GetVectors(); + vtkDataArray* aFieldArray = theInputData->GetArray("VISU_FIELD"); + if(vtkDataArray* aDataArray = aVectors){ + if(vtkFloatArray *aFloatArray = dynamic_cast(aDataArray)){ + int aNbComp = aFloatArray->GetNumberOfComponents(); + std::vector anArray(aNbComp); + // + vtkFloatArray *aScalars = vtkFloatArray::New(); + aScalars->SetNumberOfTuples(theNbElems); + aScalars->SetNumberOfComponents(1); + // + if(!theScalarMode){ + for(int anId = 0; anId < theNbElems; anId++){ + aFloatArray->GetTuple(anId,&anArray[0]); + float aVector[3] = {anArray[0], anArray[1], anArray[2]}; + float aScalar = sqrt(aVector[0]*aVector[0] + aVector[1]*aVector[1] + aVector[2]*aVector[2]); + aScalars->SetTuple1(anId,aScalar); + } + }else{ + for(int anId = 0; anId < theNbElems; anId++){ + aFloatArray->GetTuple(anId,&anArray[0]); + aScalars->SetTuple1(anId,anArray[theScalarMode - 1]); + } + } + theOutputData->SetScalars(aScalars); + aScalars->Delete(); } - newScalars->SetTuple1(ptId, s); } - theOutputData->SetScalars(newScalars); - newScalars->Delete(); } void VISU_Extractor::Execute(){ @@ -95,19 +99,19 @@ void VISU_Extractor::Execute(){ output->GetCellData()->CopyAllOff(); if(input->GetPointData()->GetNumberOfArrays()){ output->GetPointData()->CopyVectorsOn(); - int nbComp = input->GetNumberOfPoints(); + int aNbElems = input->GetNumberOfPoints(); vtkPointData *inData = input->GetPointData(), *outData = output->GetPointData(); if(inData->GetAttribute(vtkDataSetAttributes::VECTORS)) - execute(nbComp,myScalarMode,inData,outData); + execute(aNbElems,myScalarMode,inData,outData); else output->GetPointData()->CopyScalarsOn(); outData->PassData(inData); }else{ output->GetCellData()->CopyVectorsOn(); - int nbComp = input->GetNumberOfCells(); + int aNbElems = input->GetNumberOfCells(); vtkCellData *inData = input->GetCellData(), *outData = output->GetCellData(); if(inData->GetAttribute(vtkDataSetAttributes::VECTORS)) - execute(nbComp,myScalarMode,inData,outData); + execute(aNbElems,myScalarMode,inData,outData); else output->GetCellData()->CopyScalarsOn(); outData->PassData(inData); -- 2.39.2