]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Example of cutting ELNO data
authorapo <apo@opencascade.com>
Thu, 1 May 2008 06:18:00 +0000 (06:18 +0000)
committerapo <apo@opencascade.com>
Thu, 1 May 2008 06:18:00 +0000 (06:18 +0000)
src/PIPELINE/VISUPipeLine.cxx

index d660d7b48573b0c27891fef97d410ea5029ef9fb..752c4ab64b91e98d1614637e51b7a7f079e87213 100644 (file)
 #include "VISU_ElnoGeometryFilter.hxx"
 #include "VISU_OpenGLElnoMapper.hxx"
 
+#include <vtkCutter.h>
+#include <vtkPlane.h>
+
+#include <vtkScalarBarActor.h>
+#include <vtkScalarBarWidget.h>
+
+
 // VTK includes
 #include <vtkMaskPoints.h>
 #include <vtkUnstructuredGridReader.h>
@@ -234,21 +241,40 @@ main(int argc, char** argv)
                                                anEntity,
                                                theFieldName,
                                                aTimeStamp);
+
+             vtkUnstructuredGrid* anUnstructuredGrid = anUnstructuredGridIDMapper->GetUnstructuredGridOutput();
+             VISU::WriteToFile( anUnstructuredGrid, "/data/apo/elno_from_id_mapper.vtk" );
              
-             VISU_ElnoWarpVector* anElnoWarpVector = VISU_ElnoWarpVector::New();
-              anElnoWarpVector->SetInput( anUnstructuredGridIDMapper->GetUnstructuredGridOutput() );
+             vtkCutter *aCutter = vtkCutter::New();
+             aCutter->SetInput( anUnstructuredGrid );
+
+             vtkPlane *aPlane = vtkPlane::New();
+             //aPlane->SetOrigin( 100.0, 100.0, 100.0 );
+             //aPlane->SetNormal( 0.0, -1.0, 0.0 );
+             aPlane->SetOrigin( 15.0, 5.0, 5.0 );
+             aPlane->SetNormal( 0.0, 0.0, -1.0 );
+
+             aCutter->SetCutFunction( aPlane );
+             aPlane->Delete();
+             VISU::WriteToFile( aCutter->GetOutput(), "/data/apo/elno_from_cutter.vtk" );
+
+             //VISU_ElnoWarpVector* anElnoWarpVector = VISU_ElnoWarpVector::New();
+              //anElnoWarpVector->SetInput( anUnstructuredGridIDMapper->GetUnstructuredGridOutput() );
 
               VISU_ElnoGeometryFilter *aGeometryFilter = VISU_ElnoGeometryFilter::New();
               aGeometryFilter->SetScalarMode(aComponentNumber);
-              aGeometryFilter->SetInput( anElnoWarpVector->GetOutput() );
+              aGeometryFilter->SetInput( anUnstructuredGrid );
+              //aGeometryFilter->SetInput( anElnoWarpVector->GetOutput() );
+              //aGeometryFilter->SetInput( aCutter->GetOutput() );
+             VISU::WriteToFile( aCutter->GetOutput(), "/data/apo/elno_from_geometry.vtk" );
 
              // To calculate and apply default scale factor
-             {
-               vtkFloatingPointType aScale = VISU_DeformedShapePL::GetScaleFactor( anElnoWarpVector->GetOutput() );
-               vtkFloatingPointType* aRange = aGeometryFilter->GetRange();
-               aScale /= aRange[1];
-               anElnoWarpVector->SetScaleFactor( aScale );
-             }
+             //{
+             //        vtkFloatingPointType aScale = VISU_DeformedShapePL::GetScaleFactor( anElnoWarpVector->GetOutput() );
+             //        vtkFloatingPointType* aRange = aGeometryFilter->GetRange();
+             //        aScale /= aRange[1];
+             //        anElnoWarpVector->SetScaleFactor( aScale );
+             //}
 
               VISU_OpenGLElnoMapper* aMapper = VISU_OpenGLElnoMapper::New();
               aMapper->SetInput( aGeometryFilter->GetOutput() );              
@@ -263,12 +289,20 @@ main(int argc, char** argv)
               aMapper->SetUseLookupTableScalarRange( true );
               aMapper->SetColorModeToMapScalars();
               aMapper->ScalarVisibilityOn();
-              
 
               anActor->SetMapper( aMapper );
 
-              VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
+             vtkPolyData* aPolyData = aGeometryFilter->GetOutput();
+             vtkCellData* aCellData = aPolyData->GetCellData();
+             vtkDataArray* aScalars = aCellData->GetScalars();
+              vtkScalarBarActor* aScalarBar = vtkScalarBarActor::New();
               aScalarBar->SetLookupTable( aMapperTable );
+              aScalarBar->SetTitle( aScalars->GetName() );
+
+             vtkScalarBarWidget* aWidget = vtkScalarBarWidget::New();
+             aWidget->SetScalarBarActor( aScalarBar );
+             aWidget->SetInteractor( anInteractor );
+             aWidget->SetEnabled( true );
 
               aRenderer->AddActor(anActor);
               aRenderer->AddActor2D(aScalarBar);