]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To introduce a transparent way for ELNO data processing
authorapo <apo@opencascade.com>
Fri, 2 May 2008 14:07:14 +0000 (14:07 +0000)
committerapo <apo@opencascade.com>
Fri, 2 May 2008 14:07:14 +0000 (14:07 +0000)
src/CONVERTOR/VISU_MeshValue.cxx
src/PIPELINE/VISUPipeLine.cxx
src/PIPELINE/VISU_DataSetMapperHolder.cxx
src/PIPELINE/VISU_DataSetMapperHolder.hxx
src/PIPELINE/VISU_ElnoAssembleFilter.cxx
src/PIPELINE/VISU_ElnoDisassembleFilter.cxx
src/PIPELINE/VISU_ElnoExtractScalars.cxx
src/PIPELINE/VISU_ScalarMapPL.cxx
src/PIPELINE/VISU_ScalarMapPL.hxx

index 84719b36ae742973c4594bc3ae0ed83581793fd1..0ed645651a08ab8327f562d2da9675eeb3cdb90d 100644 (file)
@@ -291,17 +291,10 @@ namespace VISU
     typedef typename TL::TEnum2VTKArrayType<EDataType>::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 );
index 8859fc8cf545c6ed84c44afc7521b53d94bf84f1..d870f0e1cfd0d90a08314d38abc8b8e93c831eb6 100644 (file)
@@ -52,6 +52,8 @@
 #include "VISU_ElnoAssembleFilter.hxx"
 #include "VISU_ElnoExtractScalars.hxx"
 
+typedef VISU_ScalarMapPL TPresent;
+
 #include <vtkShrinkFilter.h>
 #include <vtkPointLocator.h>
 
@@ -63,7 +65,6 @@
 #include <vtkScalarBarActor.h>
 #include <vtkScalarBarWidget.h>
 
-
 // VTK includes
 #include <vtkMaskPoints.h>
 #include <vtkUnstructuredGridReader.h>
@@ -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();
index 313c6d683595e6f37b4d510adecc54123e2f4434..7766a56a66bbf81415a01e379a697a86d96b7560 100644 (file)
@@ -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 - "<<this);
 
+  myElnoDisassembleFilter->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 );
 }
 
 
index 45fa07fe6d703347cb8f0a29d564f2ca1bc360a0..87f9168283f34bc6fbea65e342fdf98c95db1def 100644 (file)
@@ -32,6 +32,7 @@
 class vtkDataSetMapper;
 class vtkUnstructuredGrid;
 class SALOME_ExtractGeometry;
+class VISU_ElnoDisassembleFilter;
 
 
 //----------------------------------------------------------------------------
@@ -158,8 +159,9 @@ protected:
 private:
   //----------------------------------------------------------------------------
   VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper;
-  vtkSmartPointer<vtkDataSetMapper> myDataSetMapper;
-  vtkSmartPointer<SALOME_ExtractGeometry> myExtractGeometry; //!< Clipping
+  vtkSmartPointer< VISU_ElnoDisassembleFilter > myElnoDisassembleFilter; //!< Handling ELNO data
+  vtkSmartPointer< SALOME_ExtractGeometry > myExtractGeometry; //!< Clipping
+  vtkSmartPointer< vtkDataSetMapper > myDataSetMapper;
 };
 
 #endif
index 6351d77215defd490f63ee57c40f0912b4d95ed6..70c41ac9a5fdd31715ce83af7d41e446b23b0e96 100644 (file)
@@ -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:
index 2977a38266e1ea25ac18af10f11f6ad52bcd88b4..d57ac92dda8bdadc31ce93b551b5a18bc0570863 100644 (file)
@@ -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:
index c61786464ff37238b2f8725609d746619e4846f7..574cad53c52d514972af9b3dc18a12b1e27a8fd0 100644 (file)
@@ -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;
 }
index d71491290c96e40b2a85e7d08bd72f08f82abe6a..d679ad2eb7f81721e6a24d2a44976ec760012f62 100644 (file)
@@ -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);
+  }
 }
 
 
index dff91d39335b2d410ba6df3f1594a51966ed45eb..5962c4a6799a28a9fa9b4975f8579dff0949c897 100644 (file)
@@ -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<VISU_AppendFilter> myAppendFilter;
-  vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
+  vtkSmartPointer< VISU_ElnoAssembleFilter > myElnoAssembleFilter;
+  vtkSmartPointer< VISU_AppendFilter > myAppendFilter;
+  vtkSmartPointer< VISU_MergeFilter > myMergeFilter;
 };
   
 #endif