From: apo Date: Fri, 2 May 2008 14:07:14 +0000 (+0000) Subject: To introduce a transparent way for ELNO data processing X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7362827320cbd530125e8914c047f45676a3a335;p=modules%2Fvisu.git To introduce a transparent way for ELNO data processing --- diff --git a/src/CONVERTOR/VISU_MeshValue.cxx b/src/CONVERTOR/VISU_MeshValue.cxx index 84719b36..0ed64565 100644 --- a/src/CONVERTOR/VISU_MeshValue.cxx +++ b/src/CONVERTOR/VISU_MeshValue.cxx @@ -291,17 +291,10 @@ namespace VISU typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; TVTKDataArray *aSelectedDataArray = TVTKDataArray::New(); vtkIdType aNbComp = theField->myNbComp; - 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()); + aSelectedDataArray->SetNumberOfComponents( 3 ); + aSelectedDataArray->SetNumberOfTuples( aNbTuples ); + aSelectedDataArray->SetName( aFieldName.c_str() ); + aDataSetAttributes->SetVectors( aSelectedDataArray ); TVTKDataArray *aFullDataArray = TVTKDataArray::New(); aFullDataArray->SetNumberOfComponents( aNbComp ); diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 8859fc8c..d870f0e1 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -52,6 +52,8 @@ #include "VISU_ElnoAssembleFilter.hxx" #include "VISU_ElnoExtractScalars.hxx" +typedef VISU_ScalarMapPL TPresent; + #include #include @@ -63,7 +65,6 @@ #include #include - // VTK includes #include #include @@ -319,28 +320,35 @@ main(int argc, char** argv) } //VISU_OpenGLElnoMapper* aMapper = VISU_OpenGLElnoMapper::New(); - vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); - aMapper->SetScalarModeToUsePointData(); + //vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + //aMapper->SetScalarModeToUsePointData(); //aMapper->SetInput( aGeometryFilter->GetOutput() ); //aMapper->SetInput( aCutter->GetOutput() ); //aMapper->SetInput( anAssembleFilter->GetOutput() ); - aMapper->SetInput( anElnoWarpVector->GetOutput() ); + //aMapper->SetInput( anElnoWarpVector->GetOutput() ); - VISU_LookupTable* aMapperTable( VISU_LookupTable::New() ); - aMapperTable->SetHueRange( 0.667, 0.0 ); - aMapperTable->SetRange( aScalarRange ); - aMapperTable->Build(); + //VISU_LookupTable* aMapperTable( VISU_LookupTable::New() ); + //aMapperTable->SetHueRange( 0.667, 0.0 ); + //aMapperTable->SetRange( aScalarRange ); + //aMapperTable->Build(); - aMapper->SetLookupTable( aMapperTable ); - aMapper->SetUseLookupTableScalarRange( true ); - aMapper->SetColorModeToMapScalars(); - aMapper->ScalarVisibilityOn(); + //aMapper->SetLookupTable( aPresent->GetBarTable() ); + //aMapper->SetUseLookupTableScalarRange( true ); + //aMapper->SetColorModeToMapScalars(); + //aMapper->ScalarVisibilityOn(); - anActor->SetMapper( aMapper ); + //anActor->SetMapper( aMapper ); + TPresent* aPresent = TPresent::New(); + aPresent->SetUnstructuredGridIDMapper( anUnstructuredGridIDMapper ); + aPresent->Update(); + + anActor->SetMapper( aPresent->GetMapper() ); + vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New(); - aScalarBar->SetLookupTable( aMapperTable ); + //aScalarBar->SetLookupTable( aMapperTable ); + aScalarBar->SetLookupTable( aPresent->GetBarTable() ); vtkPolyData* aPolyData = aGeometryFilter->GetOutput(); vtkCellData* aCellData = aPolyData->GetCellData(); diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx index 313c6d68..7766a56a 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.cxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -28,6 +28,7 @@ #include "VISU_DataSetMapperHolder.hxx" #include "SALOME_ExtractGeometry.h" +#include "VISU_ElnoDisassembleFilter.hxx" #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" @@ -55,10 +56,13 @@ vtkStandardNewMacro(VISU_DataSetMapperHolder); //---------------------------------------------------------------------------- VISU_DataSetMapperHolder ::VISU_DataSetMapperHolder(): - myExtractGeometry(SALOME_ExtractGeometry::New()) + myElnoDisassembleFilter( VISU_ElnoDisassembleFilter::New() ), + myExtractGeometry( SALOME_ExtractGeometry::New() ) { if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<Delete(); + // Clipping functionality myExtractGeometry->Delete(); myExtractGeometry->SetStoreMapping(true); @@ -116,9 +120,10 @@ void VISU_DataSetMapperHolder ::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) { - myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput()); + myElnoDisassembleFilter->SetInput( theIDMapper->GetUnstructuredGridOutput() ); + myExtractGeometry->SetInput( myElnoDisassembleFilter->GetOutput() ); myUnstructuredGridIDMapper = theIDMapper; - SetIDMapper(theIDMapper); + SetIDMapper( theIDMapper ); } diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx index 45fa07fe..87f91682 100644 --- a/src/PIPELINE/VISU_DataSetMapperHolder.hxx +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -32,6 +32,7 @@ class vtkDataSetMapper; class vtkUnstructuredGrid; class SALOME_ExtractGeometry; +class VISU_ElnoDisassembleFilter; //---------------------------------------------------------------------------- @@ -158,8 +159,9 @@ protected: private: //---------------------------------------------------------------------------- VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper; - vtkSmartPointer myDataSetMapper; - vtkSmartPointer myExtractGeometry; //!< Clipping + vtkSmartPointer< VISU_ElnoDisassembleFilter > myElnoDisassembleFilter; //!< Handling ELNO data + vtkSmartPointer< SALOME_ExtractGeometry > myExtractGeometry; //!< Clipping + vtkSmartPointer< vtkDataSetMapper > myDataSetMapper; }; #endif diff --git a/src/PIPELINE/VISU_ElnoAssembleFilter.cxx b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx index 6351d772..70c41ac9 100644 --- a/src/PIPELINE/VISU_ElnoAssembleFilter.cxx +++ b/src/PIPELINE/VISU_ElnoAssembleFilter.cxx @@ -133,6 +133,11 @@ int VISU_ElnoAssembleFilter::RequestData( vtkInformation *vtkNotUsed(request), vtkDataArray *anElnoPointCoords = this->GetInputArrayToProcess( 0, inputVector ); + if ( !anElnoPointCoords ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + vtkPoints *aPoints = anInput->GetPoints(); switch( aPoints->GetDataType() ){ case VTK_DOUBLE: diff --git a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx index 2977a382..d57ac92d 100644 --- a/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx +++ b/src/PIPELINE/VISU_ElnoDisassembleFilter.cxx @@ -221,16 +221,19 @@ namespace vtkPointData *anOutputPointData = theOutput->GetPointData(); anOutputPointData->Allocate( aNbPoints ); + vtkCellData *anInputCellData = theInput->GetCellData(); + vtkDataArray* aVectors = anInputCellData->GetVectors(); + typedef typename VISU::TL::TEnum2VTKArrayType< elno_type >::TResult TElnoDataArray; TElnoDataArray* anElnoPointDataArray = TElnoDataArray::New(); anElnoPointDataArray->SetNumberOfComponents( aGetElnoNodeData.getNbComp() ); anElnoPointDataArray->SetNumberOfTuples( aNbPoints ); - anElnoPointDataArray->SetName( "ELNO_POINT_DATA" ); + anElnoPointDataArray->SetName( "VISU_FIELD" ); TElnoDataArray* anElnoPointVectors = TElnoDataArray::New(); anElnoPointVectors->SetNumberOfComponents( 3 ); anElnoPointVectors->SetNumberOfTuples( aNbPoints ); - anElnoPointVectors->SetName( "ELNO_POINT_VECTORS" ); + anElnoPointVectors->SetName( aVectors->GetName() ); TPointsDataArray* anElnoPointCoords = TPointsDataArray::New(); anElnoPointCoords->SetNumberOfComponents( 3 ); @@ -268,11 +271,15 @@ namespace theInput->GetCellLocationsArray(), aConnectivity ); - vtkCellData *aCellData = theOutput->GetCellData(); - aCellData->PassData( theInput->GetCellData() ); + vtkCellData *anOutputCellData = theOutput->GetCellData(); + anOutputCellData->PassData( anInputCellData ); + + anOutputCellData->RemoveArray( "ELNO_COMPONENT_MAPPER" ); + anOutputCellData->RemoveArray( "ELNO_FIELD" ); + anOutputCellData->RemoveArray( "VISU_FIELD" ); + anOutputCellData->SetVectors( NULL ); - aCellData->RemoveArray( "ELNO_COMPONENT_MAPPER" ); - aCellData->RemoveArray( "ELNO_FIELD" ); + anOutputPointData->PassData( anInputPointData ); anOutputPointData->AddArray( anElnoPointDataArray ); anElnoPointDataArray->Delete(); @@ -338,6 +345,11 @@ int VISU_ElnoDisassembleFilter::RequestData( vtkInformation *vtkNotUsed(request) vtkDataArray *anElnoDataArray = this->GetInputArrayToProcess( 0, inputVector ); vtkDataArray *anElnoDataMapper = this->GetInputArrayToProcess( 1, inputVector ); + if ( !anElnoDataArray ) { + anOutput->ShallowCopy( anInput ); + return 1; + } + vtkPoints *aPoints = anInput->GetPoints(); switch( aPoints->GetDataType() ){ case VTK_DOUBLE: diff --git a/src/PIPELINE/VISU_ElnoExtractScalars.cxx b/src/PIPELINE/VISU_ElnoExtractScalars.cxx index c6178646..574cad53 100644 --- a/src/PIPELINE/VISU_ElnoExtractScalars.cxx +++ b/src/PIPELINE/VISU_ElnoExtractScalars.cxx @@ -42,7 +42,7 @@ VISU_ElnoExtractScalars::VISU_ElnoExtractScalars() 0, // port 0, // connection vtkDataObject::FIELD_ASSOCIATION_POINTS, // field association - "ELNO_POINT_DATA" ); // name + "VISU_FIELD" ); // name myScalarMode = 1; } diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index d7149129..d679ad2e 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -28,6 +28,7 @@ #include "VISU_ScalarMapPL.hxx" #include "VISU_DataSetMapperHolder.hxx" +#include "VISU_ElnoAssembleFilter.hxx" #include "VISU_FieldTransform.hxx" #include "VISU_AppendFilter.hxx" @@ -50,11 +51,14 @@ vtkStandardNewMacro(VISU_ScalarMapPL); VISU_ScalarMapPL ::VISU_ScalarMapPL(): VISU_UnstructuredGridPL(this), + myElnoAssembleFilter( VISU_ElnoAssembleFilter::New() ), myAppendFilter(VISU_AppendFilter::New()), myMergeFilter(VISU_MergeFilter::New()) { SetIsShrinkable(true); + myElnoAssembleFilter->Delete(); + myAppendFilter->SetMergingInputs(true); myAppendFilter->Delete(); @@ -111,8 +115,11 @@ VISU_ScalarMapPL myMergeFilter->AddField("VISU_FIELD", aDataSet); myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + myMergeFilter->AddField("ELNO_POINT_COORDS", aDataSet); + + myElnoAssembleFilter->SetInput( InsertCustomPL() ); - GetDataSetMapper()->SetInput(InsertCustomPL()); + GetDataSetMapper()->SetInput( myElnoAssembleFilter->GetOutput() ); } @@ -122,18 +129,18 @@ VISU_ScalarMapPL ::Update() { Superclass::Update(); - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk"; - // VISU::WriteToFile(GetFieldTransformFilter()->GetUnstructuredGridOutput(), aFileName); - //} - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk"; - // VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName); - //} - //{ - // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk"; - // VISU::WriteToFile(myMergeFilter->GetUnstructuredGridOutput(), aFileName); - //} + { + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk"; + VISU::WriteToFile(GetFieldTransformFilter()->GetUnstructuredGridOutput(), aFileName); + } + { + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk"; + VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName); + } + { + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk"; + VISU::WriteToFile(myMergeFilter->GetUnstructuredGridOutput(), aFileName); + } } diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index dff91d39..5962c4a6 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -34,6 +34,7 @@ #include "VISU_UnstructuredGridPL.hxx" class VISU_DataSetMapperHolder; +class VISU_ElnoAssembleFilter; class VISU_AppendFilter; class VISU_MergeFilter; @@ -115,8 +116,9 @@ private: VISU_ScalarMapPL(const VISU_ScalarMapPL&); // Not implemented. void operator=(const VISU_ScalarMapPL&); // Not implemented. - vtkSmartPointer myAppendFilter; - vtkSmartPointer myMergeFilter; + vtkSmartPointer< VISU_ElnoAssembleFilter > myElnoAssembleFilter; + vtkSmartPointer< VISU_AppendFilter > myAppendFilter; + vtkSmartPointer< VISU_MergeFilter > myMergeFilter; }; #endif