MCPcopy Create free account
hub / github.com/Kitware/VTK / main

Function main

Examples/MultiBlock/Cxx/MultiBlock.cxx:30–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include <sstream>
29
30int main(int argc, char* argv[])
31{
32 vtkCompositeDataPipeline* exec = vtkCompositeDataPipeline::New();
33 vtkAlgorithm::SetDefaultExecutivePrototype(exec);
34 exec->Delete();
35
36 // Standard rendering classes
37 vtkRenderer* ren = vtkRenderer::New();
38 vtkRenderWindow* renWin = vtkRenderWindow::New();
39 renWin->AddRenderer(ren);
40 vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
41 iren->SetRenderWindow(renWin);
42
43 // We will read three files and collect them together in one
44 // multi-block dataset. I broke the combustor dataset into
45 // three pieces and wrote them out separately.
46 int i;
47 vtkXMLStructuredGridReader* reader = vtkXMLStructuredGridReader::New();
48
49 // vtkMultiBlockDataSet represents multi-block datasets. See
50 // the class documentation for more information.
51 vtkMultiBlockDataSet* mb = vtkMultiBlockDataSet::New();
52
53 for (i = 0; i < 3; i++)
54 {
55 // Here we load the three separate files (each containing
56 // a structured grid dataset)
57 std::ostringstream fname;
58 fname << "Data/multicomb_" << i << ".vts" << ends;
59 char* cfname = vtkTestUtilities::ExpandDataFileName(argc, argv, fname.str().c_str());
60 reader->SetFileName(cfname);
61 // We have to update since we are working without a VTK pipeline.
62 // This will read the file and the output of the reader will be
63 // a valid structured grid data.
64 reader->Update();
65 delete[] cfname;
66
67 // We create a copy to avoid adding the same data three
68 // times (the output object of the reader does not change
69 // when the filename changes)
70 vtkStructuredGrid* sg = vtkStructuredGrid::New();
71 sg->ShallowCopy(reader->GetOutput());
72
73 // Add the structured grid to the multi-block dataset
74 mb->SetBlock(i, sg);
75 sg->Delete();
76 }
77 reader->Delete();
78
79 // Multi-block can be processed with regular VTK filters in two ways:
80 // 1. Pass through a multi-block aware consumer. Since a multi-block
81 // aware mapper is not yet available, vtkCompositeDataGeometryFilter
82 // can be used
83 // 2. Assign the composite executive (vtkCompositeDataPipeline) to
84 // all "simple" (that work only on simple, non-composite datasets) filters
85
86 // outline
87 vtkStructuredGridOutlineFilter* of = vtkStructuredGridOutlineFilter::New();

Callers

nothing calls this directly

Calls 15

SetBlockMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
AddRendererMethod · 0.45
SetRenderWindowMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
SetFileNameMethod · 0.45
UpdateMethod · 0.45
ShallowCopyMethod · 0.45
GetOutputMethod · 0.45
SetInputDataMethod · 0.45

Tested by

no test coverage detected