VTK  9.7.1
vtkExtractSelection.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
35 #ifndef vtkExtractSelection_h
36 #define vtkExtractSelection_h
37 
38 #include "vtkDataObjectAlgorithm.h"
39 #include "vtkFiltersExtractionModule.h" // For export macro
40 
41 #include "vtkSelectionNode.h" // for vtkSelectionNode::SelectionContent
42 #include "vtkSmartPointer.h" // for smart pointer
43 
44 VTK_ABI_NAMESPACE_BEGIN
46 class vtkSignedCharArray;
47 class vtkSelection;
48 class vtkSelectionNode;
49 class vtkSelector;
51 class vtkTable;
52 
53 class VTKFILTERSEXTRACTION_EXPORT vtkExtractSelection : public vtkDataObjectAlgorithm
54 {
55 public:
56  static vtkExtractSelection* New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
65  {
66  this->SetInputConnection(1, algOutput);
67  }
68 
70 
75  vtkSetMacro(PreserveTopology, bool);
76  vtkGetMacro(PreserveTopology, bool);
77  vtkBooleanMacro(PreserveTopology, bool);
79 
81 
87  vtkGetMacro(HyperTreeGridToUnstructuredGrid, bool);
88  vtkSetMacro(HyperTreeGridToUnstructuredGrid, bool);
89  vtkBooleanMacro(HyperTreeGridToUnstructuredGrid, bool);
91 
92 protected:
94  ~vtkExtractSelection() override;
95 
99  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
100  vtkInformationVector* outputVector) override;
101  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
102  vtkInformationVector* outputVector) override;
106  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
107  vtkInformationVector* outputVector) override;
108 
109  // Gets the attribute association of the selection. Currently we support ROW, POINT, and CELL.
110  // If the selection types are mismatched the boolean parameter will be set to false, otherwise
111  // it will be true after the function returns.
112  vtkDataObject::AttributeTypes GetAttributeTypeOfSelection(vtkSelection* sel, bool& sane);
113 
118  virtual vtkSmartPointer<vtkSelector> NewSelectionOperator(
120 
121  enum class EvaluationResult
122  {
123  INVALID,
124  NONE,
125  MIXED,
126  ALL
127  };
132  EvaluationResult EvaluateSelection(vtkDataObject* dataObject,
133  vtkDataObject::AttributeTypes association, vtkSelection* selection,
134  std::map<std::string, vtkSmartPointer<vtkSelector>>& selectors);
135 
144  vtkSmartPointer<vtkUnsignedCharArray> EvaluateColorArrayInSelection(
145  vtkDataObject* dataObject, vtkDataObject::AttributeTypes association, vtkSelection* selection);
146 
150  void AddColorArrayOnObject(vtkDataObject* dataObject, vtkUnsignedCharArray* colorArray);
151 
159  vtkSmartPointer<vtkDataObject> ExtractElements(vtkDataObject* inputBlock,
160  vtkDataObject::AttributeTypes elementType, EvaluationResult evaluationResult,
161  vtkDataObject* outputBlock);
162 
163  int FillInputPortInformation(int port, vtkInformation* info) override;
164 
169  void ExtractSelectedCells(vtkDataSet* input, vtkUnstructuredGrid* output,
170  vtkSignedCharArray* cellInside, bool extractAll);
176  void ExtractSelectedPoints(vtkDataSet* input, vtkUnstructuredGrid* output,
177  vtkSignedCharArray* pointInside, bool extractAll);
182  void ExtractSelectedRows(
183  vtkTable* input, vtkTable* output, vtkSignedCharArray* rowsInside, bool extractAll);
184 
185  bool PreserveTopology = false;
186 
187 private:
188  vtkExtractSelection(const vtkExtractSelection&) = delete;
189  void operator=(const vtkExtractSelection&) = delete;
190 
192  bool HyperTreeGridToUnstructuredGrid = false;
193 };
194 
195 VTK_ABI_NAMESPACE_END
196 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
a node in a vtkSelection the defines the selection criteria.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
data object that represents a "selection" in VTK.
Definition: vtkSelection.h:49
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
void SetSelectionConnection(vtkAlgorithmOutput *algOutput)
Convenience method to specify the selection connection (2nd input port)
Proxy object to connect input/output ports.
SelectionContent
Indicate the means by which data is selected.
a simple class to control print indentation
Definition: vtkIndent.h:28
dataset represents arbitrary combinations of all possible cell types
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input)
Set the connection for the given input port index.
dynamic, self-adjusting array of signed char
dynamic, self-adjusting array of unsigned char
extract a subset from a vtkDataSet.
Superclass for algorithms that produce only data object as output.
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Store zero or more vtkInformation instances.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
general representation of visualization data
Definition: vtkDataObject.h:55
AttributeTypes
Possible attribute types.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.