From 9f5922064743632c38e3eafe3256d32b8ba3e57c Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 22 May 2008 15:43:38 +0000 Subject: [PATCH] Fix for Bug NPAL19763 - EDF 714 VISU : Can't read a med file --- src/CONVERTOR/VISU_AppendFilter.cxx | 6 +++--- src/CONVERTOR/VISU_AppendFilterUtilities.cxx | 20 ++++++++++++++++-- src/CONVERTOR/VISU_MeshValue.cxx | 20 ++++++++++++------ src/PIPELINE/VISU_ColoredPL.cxx | 2 +- src/PIPELINE/VISU_Extractor.cxx | 22 ++++++++++---------- 5 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/CONVERTOR/VISU_AppendFilter.cxx b/src/CONVERTOR/VISU_AppendFilter.cxx index 604e38c1..c605d563 100644 --- a/src/CONVERTOR/VISU_AppendFilter.cxx +++ b/src/CONVERTOR/VISU_AppendFilter.cxx @@ -56,14 +56,14 @@ VISU_AppendFilter vtkInformationVector *theOutputVector) { bool anIsExecuted = false; - if(GetNumberOfInputConnections(0) > 1 || IsMergingInputs() || IsMappingInputs()) + if( IsMergingInputs() || IsMappingInputs() ) anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector, - this->GetNumberOfInputConnections(0), + GetNumberOfInputConnections( 0 ), theOutputVector, GetSharedPointSet(), IsMergingInputs(), IsMappingInputs()); - if(!anIsExecuted) + if( !anIsExecuted ) anIsExecuted = Superclass::RequestData(theRequest, theInputVector, theOutputVector); diff --git a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx index 3294684d..8d46b280 100644 --- a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx @@ -191,14 +191,30 @@ namespace bool theIsMergingInputs, bool theIsMappingInputs) { - if(theSharedPointSet){ + if ( theNumberOfInputConnections == 1 ) { + // get the input and ouptut + vtkDataSet *anInput = VISU::GetInput( theInputVector, 0 ); + vtkDataSet* anOutput = VISU::GetOutput( theOutputVector ); + + // This has to be here because it initialized all field datas. + anOutput->CopyStructure( anInput ); + + // Pass all. (data object's field data is passed by the + // superclass after this method) + anOutput->GetPointData()->PassData( anInput->GetPointData() ); + anOutput->GetCellData()->PassData( anInput->GetCellData() ); + + return 1; + } + + if ( theSharedPointSet ) { vtkPoints* aPoints = theSharedPointSet->GetPoints(); if(aPoints->GetNumberOfPoints() < 1) return true; TDataSet* anOutput = TDataSet::SafeDownCast(VISU::GetOutput(theOutputVector)); vtkIdType anNbInputs = theNumberOfInputConnections; - if(theIsMergingInputs){ + if ( theIsMergingInputs ) { TCellIdMerger aFunctor(anNbInputs); ForEachInput(theInputVector, anNbInputs, aFunctor); diff --git a/src/CONVERTOR/VISU_MeshValue.cxx b/src/CONVERTOR/VISU_MeshValue.cxx index 51b4a72d..b4b265ed 100644 --- a/src/CONVERTOR/VISU_MeshValue.cxx +++ b/src/CONVERTOR/VISU_MeshValue.cxx @@ -280,7 +280,7 @@ namespace VISU std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime); vtkDataSetAttributes* aDataSetAttributes; - switch(theEntity){ + switch ( theEntity ) { case VISU::NODE_ENTITY : aDataSetAttributes = theSource->GetPointData(); break; @@ -291,10 +291,18 @@ namespace VISU typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; TVTKDataArray *aSelectedDataArray = TVTKDataArray::New(); vtkIdType aNbComp = theField->myNbComp; - aSelectedDataArray->SetNumberOfComponents( 3 ); + + switch ( aNbComp ) { + case 1: + aSelectedDataArray->SetNumberOfComponents( 1 ); + aDataSetAttributes->SetScalars( aSelectedDataArray ); + break; + default: + aSelectedDataArray->SetNumberOfComponents( 3 ); + aDataSetAttributes->SetVectors( aSelectedDataArray ); + } aSelectedDataArray->SetNumberOfTuples( aNbTuples ); aSelectedDataArray->SetName( aFieldName.c_str() ); - aDataSetAttributes->SetVectors( aSelectedDataArray ); TVTKDataArray *aFullDataArray = TVTKDataArray::New(); aFullDataArray->SetNumberOfComponents( aNbComp ); @@ -325,9 +333,9 @@ namespace VISU true); INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); + aSelectedDataArray->SetVoidArray( aMeshValue->GetPointer(), + aMeshValue->size(), + true ); INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<SetLookupTable(GetMapperTable()); GetMapper()->InterpolateScalarsBeforeMappingOn(); - GetMapper()->SetUseLookupTableScalarRange(true); + GetMapper()->SetUseLookupTableScalarRange( true ); GetMapper()->SetColorModeToMapScalars(); GetMapper()->ScalarVisibilityOn(); } diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index e44145e3..eb078e3a 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -168,27 +168,27 @@ VISU_Extractor vtkInformationVector **theInputVector, vtkInformationVector *theOutputVector) { - vtkDataSet *anInput = VISU::GetInput(theInputVector, 0); - vtkDataSet *anOutput = VISU::GetOutput(theOutputVector); + vtkDataSet *anInput = VISU::GetInput( theInputVector, 0 ); + vtkDataSet *anOutput = VISU::GetOutput( theOutputVector ); - anOutput->CopyStructure(anInput); + anOutput->CopyStructure( anInput ); vtkPointData *anInputPointData = anInput->GetPointData(); vtkPointData *anOutputPointData = anOutput->GetPointData(); - anOutputPointData->PassData(anInputPointData); - if(VISU::IsDataOnPoints(anInput)){ + anOutputPointData->PassData( anInputPointData ); + if ( VISU::IsDataOnPoints( anInput ) ) { int aNbElems = anInput->GetNumberOfPoints(); - if(anInputPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbElems, myScalarMode, anInputPointData, anOutputPointData); + if ( anInputPointData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) + ExecuteScalars( aNbElems, myScalarMode, anInputPointData, anOutputPointData ); } vtkCellData *anInputCellData = anInput->GetCellData(); vtkCellData *anOutputCellData = anOutput->GetCellData(); - anOutputCellData->PassData(anInputCellData); - if(VISU::IsDataOnCells(anInput)){ + anOutputCellData->PassData( anInputCellData ); + if ( VISU::IsDataOnCells( anInput ) ) { int aNbElems = anInput->GetNumberOfCells(); - if(anInputCellData->GetAttribute(vtkDataSetAttributes::VECTORS)) - ExecuteScalars(aNbElems, myScalarMode, anInputCellData, anOutputCellData); + if ( anInputCellData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) + ExecuteScalars( aNbElems, myScalarMode, anInputCellData, anOutputCellData ); } return 1; -- 2.39.2