File: vtkExtractBlock.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (118 lines) | stat: -rw-r--r-- 3,835 bytes parent folder | download | duplicates (5)
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
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class vtkExtractBlock
 * @brief extracts blocks from a vtkDataObjectTree subclass.
 *
 * vtkExtractBlock is a filter that extracts blocks from a vtkDataObjectTree
 * subclass such as vtkPartitionedDataSet, vtkPartitionedDataSetCollection, etc.
 * using their composite-ids (also called flat-index).
 *
 * The composite-id can be obtained by performing a pre-order traversal of the
 * tree (including empty nodes). For example, consider a tree with nodes named
 * `A(B (D, E), C(F, G))`.  Pre-order traversal yields: `A, B, D, E, C, F, G`;
 * hence, composite-id of `A` is `0`, while index of `C` is `4`.
 *
 * `0` identifies the root-node. Thus, choosing `0` will result in the entire
 * input dataset being passed to the output.
 *
 * @sa vtkGroupDataSetsFilter vtkMergeBlocks
 */

#ifndef vtkExtractBlock_h
#define vtkExtractBlock_h

#include "vtkFiltersExtractionModule.h" // For export macro
#include "vtkPassInputTypeAlgorithm.h"

VTK_ABI_NAMESPACE_BEGIN
class vtkDataObjectTreeIterator;
class vtkPartitionedDataSet;
class vtkMultiBlockDataSet;
class vtkDataObjectTree;

class VTKFILTERSEXTRACTION_EXPORT vtkExtractBlock : public vtkPassInputTypeAlgorithm
{
  class vtkSet;

public:
  ///@{
  /**
   * Standard methods for instantiation, type information, and printing.
   */
  static vtkExtractBlock* New();
  vtkTypeMacro(vtkExtractBlock, vtkPassInputTypeAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;
  ///@{

  ///@{
  /**
   * Select the block indices to extract.  Each node in the multi-block tree
   * is identified by an \c index. The index can be obtained by performing a
   * preorder traversal of the tree (including empty nodes). eg. A(B (D, E),
   * C(F, G)).  Inorder traversal yields: A, B, D, E, C, F, G Index of A is
   * 0, while index of C is 4. (Note: specifying node 0 means the input is
   * copied to the output.)
   */
  void AddIndex(unsigned int index);
  void RemoveIndex(unsigned int index);
  void RemoveAllIndices();
  ///@}

  ///@{
  /**
   * When set, the output multiblock dataset will be pruned to remove empty
   * nodes. On by default.
   *
   * This has no effect for vtkPartitionedDataSetCollection.
   */
  vtkSetMacro(PruneOutput, vtkTypeBool);
  vtkGetMacro(PruneOutput, vtkTypeBool);
  vtkBooleanMacro(PruneOutput, vtkTypeBool);
  ///@}

  ///@{
  /**
   * This is used only when PruneOutput is ON. By default, when pruning the
   * output i.e. remove empty blocks, if node has only 1 non-null child block,
   * then that node is removed. To preserve these parent nodes, set this flag to
   * true. Off by default.
   *
   * This has no effect for vtkPartitionedDataSetCollection.
   */
  vtkSetMacro(MaintainStructure, vtkTypeBool);
  vtkGetMacro(MaintainStructure, vtkTypeBool);
  vtkBooleanMacro(MaintainStructure, vtkTypeBool);
  ///@}

protected:
  vtkExtractBlock();
  ~vtkExtractBlock() override;

  /**
   * Internal key, used to avoid pruning of a branch.
   */
  static vtkInformationIntegerKey* DONT_PRUNE();

  /// Implementation of the algorithm.
  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
  int FillInputPortInformation(int port, vtkInformation* info) override;

  /// Extract subtree
  void CopySubTree(vtkDataObjectTreeIterator* loc, vtkDataObjectTree* output,
    vtkDataObjectTree* input, vtkSet& activeIndices);
  bool Prune(vtkMultiBlockDataSet* mblock);
  bool Prune(vtkPartitionedDataSet* mpiece);
  bool Prune(vtkDataObject* branch);

  vtkTypeBool PruneOutput;
  vtkTypeBool MaintainStructure;

private:
  vtkExtractBlock(const vtkExtractBlock&) = delete;
  void operator=(const vtkExtractBlock&) = delete;
  vtkSet* Indices;
};

VTK_ABI_NAMESPACE_END
#endif