1 #include <vtkSliderRepresentation2D.h>     2 #include <vtkProperty2D.h>     3 #include <vtkAlgorithmOutput.h>     4 #include <vtkTextProperty.h>     5 #include <vtkRectilinearGrid.h>     6 #include <vtkGeometryFilter.h>     7 #include <vtkRectilinearGridGeometryFilter.h>     8 #include <vtkUnstructuredGrid.h>     9 #include <vtkUnstructuredGridGeometryFilter.h>    11 #include <vtkCutter.h>    12 #include <vtkImplicitBoolean.h>    13 #include <vtkOutlineFilter.h>    14 #include <vtkCubeAxesActor2D.h>    15 #include <vtkAppendPolyData.h>    16 #include <vtkAssignAttribute.h>    17 #include <vtkCamera.h>    18 #include <vtkTextActor.h>    19 #include <vtkCornerAnnotation.h>    20 #include <vtkCoordinate.h>    21 #include <vtkExtractEdges.h>    22 #include <vtkTransformPolyDataFilter.h>    23 #include <vtkTransformFilter.h>    39     cutgeometry=vtkSmartPointer<vtkExtractGeometry>::New();
    46                                   vtkSmartPointer<vtkPlane> planeXYZ )
    50       double trans_origin[3];
    51       planeXYZ->GetOrigin(trans_origin);
    52       double planepos=trans_origin[idim];
    54       planepos+=(0.01+1.0e-8)*((
double)dx)*delta;
    55       planepos=std::min(planepos,trans_bounds[2*idim+1]+1.0e-10*delta);
    56       planepos=std::max(planepos,trans_bounds[2*idim+0]-1.0e-10*delta);
    57       trans_origin[idim]=planepos;
    58       planeXYZ->SetOrigin(trans_origin);
    79     double trans_origin[3];
    80     planeXYZ->GetOrigin(trans_origin);
    82     RTMessage(
"plane_" + plane+
"=" + std::to_string(planepos));
    87     const std::string plane,
    89     const std::string key,  
    91     vtkSmartPointer<vtkPlane> planeXYZ)
    94     if (!edit && key==plane)
   105     if (edit&& key==
"Escape")
   131         int vis=
axes->GetVisibility();
   133         axes->SetVisibility(vis);
   144         int vis=
splot->GetVisibility();
   146         splot->SetVisibility(vis);
   162         cbar->SetVisibility(vis);
   174         bcbar->SetVisibility(vis);
   181       &&(key==
"x"|| key==
"y"|| key==
"z")
   200   template <
class DATA, 
class FILTER>
   205       auto cr=vtkDoubleArray::SafeDownCast(DATA::SafeDownCast(
data_producer->GetOutputDataObject(0))->GetCellData()->GetAbstractArray(
"cellregions"));
   207       auto scalar = vtkSmartPointer<vtkAssignAttribute>::New();
   210         scalar->Assign(
"cellregions",vtkDataSetAttributes::SCALARS,vtkAssignAttribute::CELL_DATA);
   214       auto geometry=vtkSmartPointer<FILTER>::New();
   216         geometry->SetInputConnection(scalar->GetOutputPort());
   218         geometry->SetInputConnection(
data_producer->GetOutputPort());
   222       auto transgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
   223       transgeometry->SetInputConnection(geometry->GetOutputPort());
   226       auto  cells = vtkSmartPointer<vtkPolyDataMapper>::New();
   227       cells->SetInputConnection(transgeometry->GetOutputPort());
   231         cells->UseLookupTableScalarRangeOn();
   235         cells->ScalarVisibilityOff();
   237 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   238       cells->ImmediateModeRenderingOn();
   240       cellplot = vtkSmartPointer<vtkActor>::New();
   243         cellplot->GetProperty()->SetColor(0.9,0.9,0.9);
   265         auto  celledges = vtkSmartPointer<vtkPolyDataMapper>::New();
   266         celledges->SetInputConnection(transgeometry->GetOutputPort());
   267         celledges->ScalarVisibilityOff();
   268 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   269         celledges->ImmediateModeRenderingOn();
   271         auto celledgeplot = vtkSmartPointer<vtkActor>::New();
   272         celledgeplot->SetMapper(celledges);
   273         celledgeplot->GetProperty()->SetColor(0,0,0);
   274         celledgeplot->GetProperty()->SetRepresentationToWireframe();
   278       if (cr && 
state.show_grid_colorbar)
   281         cbar->SetTitle(
"C    ");
   282         cbar->SetLabelFormat(
" %-2.0f     ");
   285         cbar->SetNumberOfLabels((
int)(range[1]-range[0]+1));
   295       auto bcr=vtkDoubleArray::SafeDownCast(boundary_data->GetCellData()->GetAbstractArray(
"boundarycellregions"));
   298         auto bscalar = vtkSmartPointer<vtkAssignAttribute>::New();
   299         bscalar->Assign(
"boundarycellregions",vtkDataSetAttributes::SCALARS,vtkAssignAttribute::CELL_DATA);
   302         auto bgeometry=vtkSmartPointer<FILTER>::New();
   303         bgeometry->SetInputConnection(bscalar->GetOutputPort());
   305         auto transbgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
   306         transbgeometry->SetInputConnection(bgeometry->GetOutputPort());
   309         auto  bcells = vtkSmartPointer<vtkPolyDataMapper>::New();
   310         bcells->SetInputConnection(transbgeometry->GetOutputPort());
   312         bcells->UseLookupTableScalarRangeOn();
   314         bcells->ScalarVisibilityOn();
   315 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   316         bcells->ImmediateModeRenderingOn();
   318         bcellplot = vtkSmartPointer<vtkActor>::New();
   320         bcellplot->GetProperty()->SetLineWidth(5);
   323         if( 
state.show_grid_colorbar)
   326           bcbar->SetTitle(
"B    ");
   327           bcbar->SetLabelFormat(
" %-2.0f     ");
   330           bcbar->SetNumberOfLabels((
int)(brange[1]-brange[0]+1));
   341   template <
class DATA,
class FILTER>
   347       auto cr=vtkDoubleArray::SafeDownCast(DATA::SafeDownCast(
data_producer->GetOutputDataObject(0))->GetCellData()->GetAbstractArray(
"cellregions"));
   349       auto scalar = vtkSmartPointer<vtkAssignAttribute>::New();
   352         scalar->Assign(
"cellregions",vtkDataSetAttributes::SCALARS,vtkAssignAttribute::CELL_DATA);
   356         cell_lut->SetTableRange(range[0],range[1]);
   365       auto transgeometry=vtkSmartPointer<vtkTransformFilter>::New();
   370         transgeometry->SetInputConnection(scalar->GetOutputPort());
   372         transgeometry->SetInputConnection(
data_producer->GetOutputPort());
   377       cutgeometry->SetInputConnection(transgeometry->GetOutputPort());
   379       auto cutpolydata=vtkSmartPointer<vtkGeometryFilter>::New();
   380       cutpolydata->SetInputConnection(
cutgeometry->GetOutputPort());
   382       auto  cells = vtkSmartPointer<vtkPolyDataMapper>::New();
   383       cells->SetInputConnection(cutpolydata->GetOutputPort());
   387         cells->UseLookupTableScalarRangeOn();
   391         cells->ScalarVisibilityOff();
   392 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   393       cells->ImmediateModeRenderingOn();
   395       cellplot = vtkSmartPointer<vtkActor>::New();
   398         cellplot->GetProperty()->SetColor(0.9,0.9,0.9);
   414       auto  celledges = vtkSmartPointer<vtkPolyDataMapper>::New();
   415       celledges->SetInputConnection(cutpolydata->GetOutputPort());
   416       celledges->ScalarVisibilityOff();
   417 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   418       celledges->ImmediateModeRenderingOn();
   420       auto celledgeplot = vtkSmartPointer<vtkActor>::New();
   421       celledgeplot->SetMapper(celledges);
   422       celledgeplot->GetProperty()->SetColor(0,0,0);
   423       celledgeplot->GetProperty()->SetRepresentationToWireframe();
   430         cbar->SetLabelFormat(
" %-2.0f     ");
   431         cbar->SetNumberOfLabels((
int)(range[1]-range[0]+1));
   432         cbar->SetTitle(
"c    ");
   441       auto bcr=vtkDoubleArray::SafeDownCast(boundary_data->GetCellData()->GetAbstractArray(
"boundarycellregions"));
   445         auto bscalar = vtkSmartPointer<vtkAssignAttribute>::New();
   446         bscalar->Assign(
"boundarycellregions",vtkDataSetAttributes::SCALARS,vtkAssignAttribute::CELL_DATA);
   447         bscalar->SetInputDataObject(boundary_data);
   448         bcr->GetRange(brange);
   450         bface_lut->SetTableRange(brange[0],brange[1]);
   452         auto bgeometry=vtkSmartPointer<FILTER>::New();
   453         bgeometry->SetInputConnection(bscalar->GetOutputPort());
   455         auto transbgeometry=vtkSmartPointer<vtkTransformPolyDataFilter>::New();
   456         transbgeometry->SetInputConnection(bgeometry->GetOutputPort());
   460         bcutgeometry->SetInputConnection(transbgeometry->GetOutputPort());
   462         auto bcutpolydata=vtkSmartPointer<vtkGeometryFilter>::New();
   463         bcutpolydata->SetInputConnection(
bcutgeometry->GetOutputPort());
   467         auto  bcells = vtkSmartPointer<vtkPolyDataMapper>::New();
   468         bcells->SetInputConnection(bcutpolydata->GetOutputPort());
   470         bcells->UseLookupTableScalarRangeOn();
   472         bcells->ScalarVisibilityOn();
   473 #ifdef VTK_HAS_MAPPER_IMMEDIATE_RENDERING_ON   474         bcells->ImmediateModeRenderingOn();
   476         bcellplot = vtkSmartPointer<vtkActor>::New();
   481         auto bedges= vtkSmartPointer<vtkExtractEdges>::New();
   482         bedges->SetInputConnection(
bcutgeometry->GetOutputPort());
   483         auto  bemapper = vtkSmartPointer<vtkPolyDataMapper>::New();
   484         bemapper->SetInputConnection(bedges->GetOutputPort());
   485         bemapper->ScalarVisibilityOff();
   486         bedgeplot = vtkSmartPointer<vtkActor>::New();
   487         bedgeplot->GetProperty()->SetColor(0,0,0);
   493         bcbar->SetTitle(
"b    ");
   494         bcbar->SetLabelFormat(
" %-2.0f     ");
   495         bcbar->SetNumberOfLabels((
int)(brange[1]-brange[0]+1));
   508       if (
state.spacedim==2)
   509         this->RTBuildVTKPipeline2D<vtkUnstructuredGrid,vtkGeometryFilter>();
   511         this->RTBuildVTKPipeline3D<vtkUnstructuredGrid,vtkGeometryFilter>(); 
   516       if (
state.spacedim==2)
   517         this->RTBuildVTKPipeline2D<vtkRectilinearGrid,vtkRectilinearGridGeometryFilter>();
   519         this->RTBuildVTKPipeline3D<vtkRectilinearGrid,vtkRectilinearGridGeometryFilter>();
 
void RTBuildVTKPipeline2D()
2D Filter 
 
vtkSmartPointer< vtkActor > bcellplot
 
int RTProcessPlaneKey(const std::string plane, int idim, const std::string key, bool &edit, vtkSmartPointer< vtkPlane > planeXYZ)
 
void RTShowPlanePos(vtkSmartPointer< vtkPlane > planeXYZ, const std::string plane, int idim)
 
vtkSmartPointer< vtkExtractGeometry > cutgeometry
 
vtkSmartPointer< vtkActor > bedgeplot
 
vtkSmartPointer< vtkActor > cellplot
 
vtkSmartPointer< vtkActor > edgeplot
 
void RTProcessKey(const std::string key) override final
Process keyboard and mouse move events. 
 
vtkSmartPointer< vtkExtractGeometry > bcutgeometry
 
void RTBuildVTKPipeline3D()
3D Filter 
 
int RTProcessPlaneMove(const std::string plane, int idim, int dx, int dy, bool &edit, vtkSmartPointer< vtkPlane > planeXYZ)
 
vtkSmartPointer< vtkScalarBarActor > BuildColorBar(vtkSmartPointer< vtkPolyDataMapper > mapper, int irank=0)
 
void RTProcessMove(int dx, int dy) override final
 
void RTBuildVTKPipeline() override final
Generic access to filter.