From: pkv Date: Wed, 21 Sep 2005 12:59:55 +0000 (+0000) Subject: Treatment of attributes with no limited number of components X-Git-Tag: BR-D5-38-2003_D2005-12-10~170 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9a95b1d210cfe0ace4a69d5559579475f3b302dd;p=modules%2Fvisu.git Treatment of attributes with no limited number of components --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index b960be24..4ffd602e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -1061,9 +1061,9 @@ namespace 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); @@ -1072,74 +1072,72 @@ namespace 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; + vectoraVal(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 = "<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; + vectoraVal(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 = "<GetNumberOfComponents(); + vectorv(aNumberOfComponents); + // vtkFloatArray *newScalars = vtkFloatArray::New(); ostringstream aName; - aName<GetName(); aName<<", "; aName<GetName(); aName<<", "; aName<SetName(aName.str().c_str()); newScalars->SetNumberOfComponents(1); newScalars->SetNumberOfTuples(theNbComp); + // for (int ptId = 0; ptId < theNbComp; ptId++) { - float v[3], s; - inVectors->GetTuple(ptId,v); - if ( theScalarMode < 1 || theScalarMode > 3) + 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 + } + else { s = v[theScalarMode - 1]; + } newScalars->SetTuple1(ptId, s); } theOutputData->SetScalars(newScalars); - //theOutputData->SetActiveScalars(newScalars->GetName()); newScalars->Delete(); } - void VISU_Extractor::Execute(){ vtkDataSet *input = this->GetInput(), *output = this->GetOutput(); output->CopyStructure(input);