From: apo Date: Thu, 1 May 2008 06:18:00 +0000 (+0000) Subject: Example of cutting ELNO data X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9363db07ef9ccd0ec5ffbf5c26261902b9b4c9bc;p=modules%2Fvisu.git Example of cutting ELNO data --- diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index d660d7b4..752c4ab6 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -48,6 +48,13 @@ #include "VISU_ElnoGeometryFilter.hxx" #include "VISU_OpenGLElnoMapper.hxx" +#include +#include + +#include +#include + + // VTK includes #include #include @@ -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);