From 6bdf8628f07a66b15c3a6d81a2d8c12c2d487ef2 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 21 Apr 2021 20:16:46 +0200 Subject: [PATCH] #3457 box PolyDataToActor with color table map --- packages/vtk/src/bbvtkPolyDataToActor.cxx | 75 ++++++++++++++++++++++- packages/vtk/src/bbvtkPolyDataToActor.h | 12 +++- packages/vtk/src/bbvtkSurfaceTexture.cxx | 2 +- 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/packages/vtk/src/bbvtkPolyDataToActor.cxx b/packages/vtk/src/bbvtkPolyDataToActor.cxx index b76c114..50df079 100644 --- a/packages/vtk/src/bbvtkPolyDataToActor.cxx +++ b/packages/vtk/src/bbvtkPolyDataToActor.cxx @@ -44,6 +44,7 @@ #include "vtkProperty.h" #include "vtkLinearTransform.h" #include "vtkCleanPolyData.h" +#include "vtkFieldData.h" #include "bbvtkPolyDataToActor.h" #include "bbvtkPackage.h" @@ -73,6 +74,9 @@ namespace bbvtk bbSetInputScalarVisibility(false); polydatamapper = NULL; vtkactor = NULL; + + bbSetInputScalarVisibilityOn_LookupTable(NULL); + bbSetInputScalarVisibilityOn_NameColorArray(""); } @@ -104,6 +108,51 @@ namespace bbvtk } + + +/* + +----------------------------------------------- + +https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ScalarBarActor +https://vtk.org/Wiki/VTK/Examples/Cxx/VisualizationAlgorithms/TubesFromSplines +https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ElevationBandsWithGlyphs + +vtkSmartPointer scalars = vtkSmartPointer::New(); + scalars set value .... +poly->GetPointData()->SetScalars(scalars); or poly->GetPointData()->SetActiveScalars(""); + +vtkSmartPointer hueLut = vtkSmartPoint | ^~ +er::New(); + hueLut Build .... + + mapper->SetInputData(poly); + mapper->ScalarVisibilityOn(); + mapper->SetScalarModeToUsePointData(); Point of Cell ... + + default: mapper->SetColorModeToDirectScalars() Busca scalars 3 componentes [R,G,B] float 0..1 or integer 0..255 + else: + mapper->SetColorModeToMapScalars() El vector scalar solo tiene un componente + mapper->SetLookupTable( hueLut ); + + To change Array + mapper->SelectColorArray(""); + + mapper->SetUseLookupTableScalarRange( true/false ) true:Para compartir lookuptable con otros mappers + si false then + mapper->SetScalarRange( min, max); Range especifico este mapper + mapper->SetScalarRange( tubePolyData->GetScalarRange() ); + +------------------------------------------ + + mapper->ScalarVisibilityOff(); -> SetScalarModeToDefault() + Utiliza el color del actor + +---------------------------------------- + +*/ + + //--------------------------------------------------------------------- void PolyDataToActor::DoProcess() @@ -170,7 +219,31 @@ printf("EED WARNNING! PolyDataToActor::DoProcess which is the default values o if (bbGetInputScalarVisibility()==true ) { - polydatamapper->ScalarVisibilityOn(); + polydatamapper->ScalarVisibilityOn(); + if (bbGetInputScalarVisibilityOn_LookupTable()!=NULL) + { +// polydatamapper->SetScalarModeToDefault(); +// polydatamapper->SetScalarModeToUseCellData(); +// polydatamapper->SetScalarModeToUseCellFieldData(); +// polydatamapper->SetScalarModeToUseFieldData(); // 1/2 hausdorff->SetTargetDistanceMethodToPointToCell(); +// polydatamapper->SetScalarModeToUsePointData(); // * + polydatamapper->SetScalarModeToUsePointFieldData(); + + polydatamapper->SetColorModeToMapScalars(); + + polydatamapper->SetLookupTable( bbGetInputScalarVisibilityOn_LookupTable() ); + if (bbGetInputScalarVisibilityOn_NameColorArray()!="") + { + polydatamapper->SelectColorArray( bbGetInputScalarVisibilityOn_NameColorArray().c_str() ); +// bbGetInputIn()->PrintSelf(std::cout, vtkIndent(2)); + } + + if (bbGetInputScalarVisibilityOn_ScalarRange().size()==2) + { + polydatamapper->SetScalarRange( bbGetInputScalarVisibilityOn_ScalarRange()[0] , bbGetInputScalarVisibilityOn_ScalarRange()[1] ); + } + + } // if ScalarVisibilityOn_LookupTable } else { polydatamapper->ScalarVisibilityOff(); } // ScalarVisibility diff --git a/packages/vtk/src/bbvtkPolyDataToActor.h b/packages/vtk/src/bbvtkPolyDataToActor.h index 9dd2790..583f0f7 100644 --- a/packages/vtk/src/bbvtkPolyDataToActor.h +++ b/packages/vtk/src/bbvtkPolyDataToActor.h @@ -61,6 +61,7 @@ #include "vtkPolyDataMapper.h" #include "vtkProp3D.h" #include "vtkActor.h" +#include "vtkScalarsToColors.h" #include #include "bbtkAtomicBlackBox.h" @@ -88,6 +89,10 @@ namespace bbvtk BBTK_DECLARE_INPUT(Representation, int); BBTK_DECLARE_INPUT(LineWidth, double); BBTK_DECLARE_INPUT(ScalarVisibility, bool); + BBTK_DECLARE_INPUT(ScalarVisibilityOn_LookupTable, vtkScalarsToColors*); + BBTK_DECLARE_INPUT(ScalarVisibilityOn_NameColorArray, std::string); + BBTK_DECLARE_INPUT(ScalarVisibilityOn_ScalarRange, std::vector); + BBTK_DECLARE_OUTPUT(Out,vtkProp3D *); BBTK_PROCESS(DoProcess); @@ -111,7 +116,12 @@ namespace bbvtk BBTK_INPUT(PolyDataToActor,Transform,"Linear Transform (4x4 homogeneous)",vtkLinearTransform*,""); BBTK_INPUT(PolyDataToActor,Representation,"0 points,1 wireframe, 2(default) surface",int,""); BBTK_INPUT(PolyDataToActor,LineWidth,"Width of the wireframe (1 default)",double,""); - BBTK_INPUT(PolyDataToActor,ScalarVisibility,"Scalar Visibility (false default)",bool,""); + BBTK_INPUT(PolyDataToActor,ScalarVisibility,"(false default) a) ScalarVisibility:false use color actor. b) ScalarVisibility:true use PolyData->SetScalars [3-components-RGB] (float 0..1 or int 0..255). c) ScalarVisibility:true and SetLookupTable use PolyData->SetScalars [1-component] d) ScalarVisibility:true and SetLookupTable SelectColorArray() use PolyData->SetScalars( scalar() ). e) For c/d SetScalarRange just for the mapper. d) [-1,-1] take PolyData->GetScalarRange()",bool,""); + + BBTK_INPUT(PolyDataToActor,ScalarVisibilityOn_LookupTable,"LookupTable (need ScalarVisibility true)",vtkScalarsToColors*,""); + BBTK_INPUT(PolyDataToActor,ScalarVisibilityOn_NameColorArray,"Name of the array in PolyData (need ScalarVisibility true)",std::string,""); + BBTK_INPUT(PolyDataToActor,ScalarVisibilityOn_ScalarRange,"[min,max] Make ScalarRange independent from LookupTable (need ScalarVisibility true)", std::vector ,""); + BBTK_OUTPUT(PolyDataToActor,Out,"Extracted iso-surface",vtkProp3D *,""); BBTK_END_DESCRIBE_BLACK_BOX(PolyDataToActor); diff --git a/packages/vtk/src/bbvtkSurfaceTexture.cxx b/packages/vtk/src/bbvtkSurfaceTexture.cxx index 0fe8f31..1e002aa 100644 --- a/packages/vtk/src/bbvtkSurfaceTexture.cxx +++ b/packages/vtk/src/bbvtkSurfaceTexture.cxx @@ -55,7 +55,7 @@ void SurfaceTexture::Process() // Generate the colors for each point based on the color map colors = vtkUnsignedCharArray::New(); colors->SetNumberOfComponents(3); - colors->SetName("Colors"); +// colors->SetName("ColorsEED"); // Create the color map if (bbGetInputColorType()==1) { -- 2.47.1