/usr/share/vtk/AMR/Cxx/HierarchicalBoxPipeline.cxx is in vtk-examples 5.8.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /*=========================================================================
Program: Visualization Toolkit
Module: HierarchicalBoxPipeline.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This example demonstrates how hierarchical box (uniform rectilinear)
// AMR datasets can be processed using the new vtkHierarchicalBoxDataSet class.
//
// The command line arguments are:
// -I => run in interactive mode; unless this is used, the program will
// not allow interaction and exit
// -D <path> => path to the data; the data should be in <path>/Data/
#include "vtkCamera.h"
#include "vtkCellDataToPointData.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkContourFilter.h"
#include "vtkDebugLeaks.h"
#include "vtkExtractLevel.h"
#include "vtkHierarchicalDataSetGeometryFilter.h"
#include "vtkOutlineCornerFilter.h"
#include "vtkHierarchicalPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShrinkPolyData.h"
#include "vtkTestUtilities.h"
#include "vtkXMLHierarchicalBoxDataReader.h"
int main(int argc, char* argv[])
{
// Standard rendering classes
vtkRenderer *ren = vtkRenderer::New();
vtkCamera* cam = ren->GetActiveCamera();
cam->SetPosition(-5.1828, 5.89733, 8.97969);
cam->SetFocalPoint(14.6491, -2.08677, -8.92362);
cam->SetViewUp(0.210794, 0.95813, -0.193784);
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
char* cfname =
vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/chombo3d/chombo3d.vtm");
vtkXMLHierarchicalBoxDataReader* reader =
vtkXMLHierarchicalBoxDataReader::New();
reader->SetFileName(cfname);
delete[] cfname;
// geometry filter
vtkHierarchicalDataSetGeometryFilter* geom =
vtkHierarchicalDataSetGeometryFilter::New();
geom->SetInputConnection(0, reader->GetOutputPort(0));
vtkShrinkPolyData* shrink = vtkShrinkPolyData::New();
shrink->SetShrinkFactor(0.5);
shrink->SetInputConnection(0, geom->GetOutputPort(0));
// Rendering objects
vtkHierarchicalPolyDataMapper* shMapper = vtkHierarchicalPolyDataMapper::New();
shMapper->SetInputConnection(0, shrink->GetOutputPort(0));
vtkActor* shActor = vtkActor::New();
shActor->SetMapper(shMapper);
shActor->GetProperty()->SetColor(0, 0, 1);
ren->AddActor(shActor);
// corner outline
vtkOutlineCornerFilter* ocf = vtkOutlineCornerFilter::New();
vtkCompositeDataPipeline* pipeline = vtkCompositeDataPipeline::New();
ocf->SetExecutive(pipeline);
pipeline->Delete();
ocf->SetInputConnection(0, reader->GetOutputPort(0));
// Rendering objects
// This one is actually just a vtkPolyData so it doesn't need a hierarchical
// mapper, but we use this one to test hierarchical mapper with polydata input
vtkHierarchicalPolyDataMapper* ocMapper = vtkHierarchicalPolyDataMapper::New();
ocMapper->SetInputConnection(0, ocf->GetOutputPort(0));
vtkActor* ocActor = vtkActor::New();
ocActor->SetMapper(ocMapper);
ocActor->GetProperty()->SetColor(1, 0, 0);
ren->AddActor(ocActor);
// cell 2 point and contour
vtkExtractLevel* el = vtkExtractLevel::New();
el->SetInputConnection(0, reader->GetOutputPort(0));
el->AddLevel(2);
vtkCellDataToPointData* c2p = vtkCellDataToPointData::New();
pipeline = vtkCompositeDataPipeline::New();
c2p->SetExecutive(pipeline);
pipeline->Delete();
c2p->SetInputConnection(0, el->GetOutputPort(0));
vtkContourFilter* contour = vtkContourFilter::New();
pipeline = vtkCompositeDataPipeline::New();
contour->SetExecutive(pipeline);
pipeline->Delete();
contour->SetInputConnection(0, c2p->GetOutputPort(0));
contour->SetValue(0, -0.013);
contour->SetInputArrayToProcess(
0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"phi");
// Rendering objects
vtkHierarchicalPolyDataMapper* contMapper =
vtkHierarchicalPolyDataMapper::New();
contMapper->SetInputConnection(0, contour->GetOutputPort(0));
vtkActor* contActor = vtkActor::New();
contActor->SetMapper(contMapper);
contActor->GetProperty()->SetColor(1, 0, 0);
ren->AddActor(contActor);
ren->SetBackground(1,1,1);
renWin->SetSize(300,300);
ren->ResetCamera();
iren->Start();
ocf->Delete();
ocMapper->Delete();
ocActor->Delete();
c2p->Delete();
contour->Delete();
contMapper->Delete();
contActor->Delete();
el->Delete();
geom->Delete();
shMapper->Delete();
shActor->Delete();
ren->Delete();
renWin->Delete();
iren->Delete();
reader->Delete();
shrink->Delete();
return 0;
}
|