VTK  9.7.1
vtkGenerateStatistics.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright 2025 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
52 #ifndef vtkGenerateStatistics_h
53 #define vtkGenerateStatistics_h
54 
55 #include "vtkFiltersParallelStatisticsModule.h" //needed for exports
57 
58 #include <memory>
59 #include <unordered_map>
60 #include <vector>
61 
62 VTK_ABI_NAMESPACE_BEGIN
63 
65 class vtkDataObjectToTable;
66 class vtkFieldData;
68 class vtkUniformGridAMR;
70 class vtkCellGrid;
71 class vtkDataSet;
72 class vtkGraph;
73 class vtkTable;
76 class vtkStatisticsAccumulator;
80 
81 class VTKFILTERSPARALLELSTATISTICS_EXPORT vtkGenerateStatistics
83 {
84 public:
85  static vtkGenerateStatistics* New();
87  void PrintSelf(ostream& os, vtkIndent indent) override;
88 
90 
96  vtkGetMacro(AttributeMode, int);
97  vtkSetMacro(AttributeMode, int);
99 
103  int GetNumberOfAttributeArrays();
104 
108  const char* GetAttributeArrayName(int nn);
109 
113  int GetAttributeArrayStatus(const char* arrName);
114 
116 
119  void EnableAttributeArray(const char* arrName);
120  void ClearAttributeArrays();
122 
124 
140  vtkSetClampMacro(TrainingFraction, double, 0.0, 1.0);
141  vtkGetMacro(TrainingFraction, double);
143 
145 
148  virtual void SetController(vtkMultiProcessController*);
149  vtkGetObjectMacro(Controller, vtkMultiProcessController);
151 
153 
156  virtual void SetStatisticsAlgorithm(vtkStatisticsAlgorithm*);
157  vtkGetObjectMacro(StatisticsAlgorithm, vtkStatisticsAlgorithm);
159 
167  vtkSetMacro(WeightByCellMeasure, vtkTypeBool);
168  vtkGetMacro(WeightByCellMeasure, vtkTypeBool);
169  vtkBooleanMacro(WeightByCellMeasure, vtkTypeBool);
171 
175  vtkSetMacro(SingleModel, vtkTypeBool);
176  vtkGetMacro(SingleModel, vtkTypeBool);
177  vtkBooleanMacro(SingleModel, vtkTypeBool);
179 
180 protected:
182  ~vtkGenerateStatistics() override;
183 
184  int FillInputPortInformation(int port, vtkInformation* info) override;
185  // int FillOutputPortInformation(int port, vtkInformation* info) override;
186 
187  int RequestData(
188  vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
189 
198  void TranslateRequests(vtkDataObject* data);
199 
205  int RequestLocalDataDispatch(
206  vtkDataObject* dataObject, vtkPartitionedDataSetCollection* modelTree);
207 
213  int RequestDataNonComposite(vtkDataObject* dataObject, vtkStatisticalModel* model);
214 
216  int RequestDataAMR(vtkUniformGridAMR* amr, vtkPartitionedDataSetCollection* modelTree);
218  int RequestDataPDC(
221  int RequestDataPD(vtkPartitionedDataSet* pd, vtkStatisticalModel* model);
223  int RequestDataCellGrid(vtkCellGrid* cellGrid, vtkStatisticalModel* model);
226  int RequestDataPlain(vtkDataObject* dataObject, vtkStatisticalModel* model);
227 
236  void PrepareAlgorithmRequests(const std::vector<vtkSmartPointer<vtkAbstractArray>>& columns);
237 
247  virtual vtkIdType GetNumberOfObservationsForTraining(vtkIdType N);
248 
254  void ShallowCopy(vtkDataObject* out, vtkDataObject* in);
255 
262  void GenerateSubset(std::unordered_map<vtkIdType, vtkIdType>& subset, vtkIdType numberOfTuples,
263  double trainingFraction, vtkUnsignedCharArray* ghostMarks, unsigned char ghostMask);
264 
265  using PointsOfCellsWeightMap =
266  std::unordered_map<vtkIdType, std::unordered_map<vtkIdType, double>>;
272  void ComputeCellToPointWeights(PointsOfCellsWeightMap& cellToPointsToWeights, vtkDataSet* dataSet,
273  const std::unordered_map<vtkIdType, vtkIdType>& subset);
274 
280  void ComputeEdgeToVertexWeights(
281  std::unordered_map<vtkIdType, std::unordered_map<vtkIdType, double>>& edgesToVertsToWeights,
282  vtkGraph* graph, const std::unordered_map<vtkIdType, vtkIdType>& subset);
283 
288  const std::unordered_map<vtkIdType, vtkIdType>& subset);
289 
294  vtkDataSet* data, const std::unordered_map<vtkIdType, vtkIdType>& subset,
295  const PointsOfCellsWeightMap& cellsToPointsToWeights);
296 
298  vtkGraph* data, const std::unordered_map<vtkIdType, vtkIdType>& subset,
299  const std::unordered_map<vtkIdType, std::unordered_map<vtkIdType, double>>&
300  edgesToVertsToWeights);
301 
303  vtkDataObject* data, const std::unordered_map<vtkIdType, vtkIdType>& subset,
304  vtkIdType numberOfSamples);
305 
311  int MergeRemoteModels(vtkPartitionedDataSetCollection* modelTree);
312 
318  int MergeModelTrees(
320 
322  int ComputeDerivedData(vtkPartitionedDataSetCollection* modelTree);
323 
328  std::unique_ptr<vtkStatisticsAlgorithmPrivate> P;
331 
332 private:
333  // This class is internal so it can access protected data.
334  class StatisticsAccumulator;
335 
337  void operator=(const vtkGenerateStatistics&) = delete;
338 };
339 
340 VTK_ABI_NAMESPACE_END
341 
342 #endif // vtkGenerateStatistics_h
composite dataset to encapsulates a dataset consisting of partitions.
Statistical modeling of non-tabular data adapted from VTK geometric datasets.
std::unique_ptr< vtkStatisticsAlgorithmPrivate > P
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a base class for statistical modeling of other data
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Methods for subclasses to override to handle different pipeline requests.
int vtkIdType
Definition: vtkType.h:363
std::unordered_map< vtkIdType, std::unordered_map< vtkIdType, double >> PointsOfCellsWeightMap
int vtkTypeBool
Definition: vtkABI.h:64
Base class for graph data types.
Definition: vtkGraph.h:282
Base class for statistics algorithms.
vtkMultiProcessController * Controller
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
abstract superclass for composite (multi-block or AMR) datasets
vtkStatisticsAlgorithm * StatisticsAlgorithm
a simple class to control print indentation
Definition: vtkIndent.h:28
boost::graph_traits< vtkGraph * >::vertex_descriptor target(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Key for integer values in vtkInformation.
Superclass for algorithms that produce vtkPartitionedDataSetCollectionAlgorithm.
dynamic, self-adjusting array of unsigned char
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:59
Store zero or more vtkInformation instances.
static vtkAlgorithm * New()
general representation of visualization data
Definition: vtkDataObject.h:55
Legacy, empty shell inheriting vtkAMRDataObject.
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51
Composite dataset that groups datasets as a collection.
Multiprocessing communication superclass.