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
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkIntegrateAttributes
* @brief Integrates lines, surfaces and volume.
*
* Integrates all point and cell data attributes while computing
* length, area or volume. Works for 1D, 2D or 3D. Only one dimensionality
* at a time. For volume, this filter ignores all but 3D cells. It
* will not compute the volume contained in a closed surface.
* The output of this filter is a single point and vertex. The attributes
* for this point and cell will contain the integration results
* for the corresponding input attributes.
*/
#ifndef vtkIntegrateAttributes_h
#define vtkIntegrateAttributes_h
#include "vtkFiltersParallelModule.h" // For export macro
#include "vtkSmartPointer.h" // For holding strategy
#include "vtkUnstructuredGridAlgorithm.h"
VTK_ABI_NAMESPACE_BEGIN
class vtkDataSet;
class vtkDataSetAttributes;
class vtkIdList;
class vtkInformation;
class vtkInformationVector;
class vtkIntegrateAttributesFieldList;
class vtkIntegrationStrategy;
class vtkMultiProcessController;
class VTKFILTERSPARALLEL_EXPORT vtkIntegrateAttributes : public vtkUnstructuredGridAlgorithm
{
public:
static vtkIntegrateAttributes* New();
vtkTypeMacro(vtkIntegrateAttributes, vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
///@{
/**
* Get/Set the parallel controller to use. By default, set to.
* `vtkMultiProcessController::GlobalController`.
*/
void SetController(vtkMultiProcessController* controller);
vtkGetObjectMacro(Controller, vtkMultiProcessController);
///@}
///@{
/**
* Get/Set the integration strategy.
*/
void SetIntegrationStrategy(vtkIntegrationStrategy* strategy);
vtkIntegrationStrategy* GetIntegrationStrategy();
///@}
///@{
/**
* If set to true then the filter will divide all output cell data arrays (the integrated values)
* by the computed volume/area of the dataset. Defaults to false.
*/
vtkSetMacro(DivideAllCellDataByVolume, bool);
vtkGetMacro(DivideAllCellDataByVolume, bool);
///@}
protected:
vtkIntegrateAttributes();
~vtkIntegrateAttributes() override;
vtkMultiProcessController* Controller;
int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
// Create a default executive.
vtkExecutive* CreateDefaultExecutive() override;
int FillInputPortInformation(int, vtkInformation*) override;
static int CompareIntegrationDimension(vtkDataSet* output, int dim, double& totalSum,
double totalSumCenter[3], int& integrationDimension);
static void ZeroAttributes(vtkDataSetAttributes* outda);
bool DivideAllCellDataByVolume;
static void IntegrateSatelliteData(vtkDataSetAttributes* inda, vtkDataSetAttributes* outda);
int PieceNodeMinToNode0(vtkUnstructuredGrid* data, double& totalSum, double totalSumCenter[3],
int& integrationDimension);
void SendPiece(vtkUnstructuredGrid* src, double totalSum, const double totalSumCenter[3],
int integrationDimension);
void ReceivePiece(vtkUnstructuredGrid* mergeTo, int fromId, double& totalSum,
double totalSumCenter[3], int& integrationDimension);
// This function assumes the data is in the format of the output of this filter with one
// point/cell having the value computed as its only tuple. It divides each value by sum,
// skipping the last data array if requested (so the volume doesn't get divided by itself
// and set to 1).
static void DivideDataArraysByConstant(
vtkDataSetAttributes* data, bool skipLastArray, double sum);
private:
vtkIntegrateAttributes(const vtkIntegrateAttributes&) = delete;
void operator=(const vtkIntegrateAttributes&) = delete;
vtkSmartPointer<vtkIntegrationStrategy> IntegrationStrategy;
class vtkIntegrateAttributesFunctor;
static void AllocateAttributes(
vtkIntegrateAttributesFieldList& fieldList, vtkDataSetAttributes* outda);
static void InitializeAttributes(vtkDataSetAttributes* outda);
void ExecuteBlock(vtkDataSet* input, vtkUnstructuredGrid* output, int fieldset_index,
vtkIntegrateAttributesFieldList& pdList, vtkIntegrateAttributesFieldList& cdList,
double& totalSum, double totalSumCenter[3], int integrationDimension);
public:
enum CommunicationIds
{
IntegrateAttrInfo = 2000,
IntegrateAttrData
};
};
VTK_ABI_NAMESPACE_END
#endif
|