diff --git a/Filters/General/vtkAxisAlignedReflectionFilter.h b/Filters/General/vtkAxisAlignedReflectionFilter.h index abb79a3835d1af7ebf42751dae4050d9d9105d99..c5d7f8f70f47bc565f6fc3ce3ec9e99867fa3b54 100644 --- a/Filters/General/vtkAxisAlignedReflectionFilter.h +++ b/Filters/General/vtkAxisAlignedReflectionFilter.h @@ -135,14 +135,16 @@ protected: int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; int FillInputPortInformation(int port, vtkInformation* info) override; -private: - vtkAxisAlignedReflectionFilter(const vtkAxisAlignedReflectionFilter&) = delete; - void operator=(const vtkAxisAlignedReflectionFilter&) = delete; - /** * Compute the bounds of the input data object. + * It has to be virtual protected because in a distributed context, + * the bounds will need to be computed differently. */ - void ComputeBounds(vtkDataObject* input, double bounds[6]); + virtual void ComputeBounds(vtkDataObject* input, double bounds[6]); + +private: + vtkAxisAlignedReflectionFilter(const vtkAxisAlignedReflectionFilter&) = delete; + void operator=(const vtkAxisAlignedReflectionFilter&) = delete; /** * Find all the reflectable arrays in the input, then reflect them to the output diff --git a/Filters/Parallel/CMakeLists.txt b/Filters/Parallel/CMakeLists.txt index 5fb83c8bd6e5287f6d5eea7a0a64110e4c987101..0eddb9357d2dd8472c8ee9404f25fd4768c74f72 100644 --- a/Filters/Parallel/CMakeLists.txt +++ b/Filters/Parallel/CMakeLists.txt @@ -3,6 +3,7 @@ set(classes vtkAggregateDataSetFilter vtkAlignImageDataSetFilter vtkAngularPeriodicFilter + vtkPAxisAlignedReflectionFilter vtkCleanArrays vtkCollectGraph vtkCollectPolyData diff --git a/Filters/Parallel/vtkPAxisAlignedReflectionFilter.cxx b/Filters/Parallel/vtkPAxisAlignedReflectionFilter.cxx new file mode 100644 index 0000000000000000000000000000000000000000..2e21d1ce015aa5040103def9b2ab4b8336c4c89b --- /dev/null +++ b/Filters/Parallel/vtkPAxisAlignedReflectionFilter.cxx @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen +// SPDX-License-Identifier: BSD-3-Clause +#include "vtkPAxisAlignedReflectionFilter.h" + +#include "vtkBoundingBox.h" +#include "vtkMultiProcessController.h" +#include "vtkObjectFactory.h" + +VTK_ABI_NAMESPACE_BEGIN +vtkStandardNewMacro(vtkPAxisAlignedReflectionFilter); +vtkCxxSetObjectMacro(vtkPAxisAlignedReflectionFilter, Controller, vtkMultiProcessController); +//------------------------------------------------------------------------------ +vtkPAxisAlignedReflectionFilter::vtkPAxisAlignedReflectionFilter() +{ + this->SetController(vtkMultiProcessController::GetGlobalController()); +} + +//------------------------------------------------------------------------------ +vtkPAxisAlignedReflectionFilter::~vtkPAxisAlignedReflectionFilter() +{ + this->SetController(nullptr); +} + +//------------------------------------------------------------------------------ +void vtkPAxisAlignedReflectionFilter::ComputeBounds(vtkDataObject* input, double bounds[6]) +{ + vtkBoundingBox bbox; + this->Superclass::ComputeBounds(input, bounds); + bbox.SetBounds(bounds); + + if (this->Controller) + { + this->Controller->GetCommunicator()->ComputeGlobalBounds( + this->Controller->GetLocalProcessId(), this->Controller->GetNumberOfProcesses(), &bbox); + bbox.GetBounds(bounds); + } +} + +//------------------------------------------------------------------------------ +void vtkPAxisAlignedReflectionFilter::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os, indent); + os << indent << "Controller: " << this->Controller << endl; +} +VTK_ABI_NAMESPACE_END diff --git a/Filters/Parallel/vtkPAxisAlignedReflectionFilter.h b/Filters/Parallel/vtkPAxisAlignedReflectionFilter.h new file mode 100644 index 0000000000000000000000000000000000000000..0962fcd6137abf2ac93c5701a8ea28ecdfd7d6eb --- /dev/null +++ b/Filters/Parallel/vtkPAxisAlignedReflectionFilter.h @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen +// SPDX-License-Identifier: BSD-3-Clause +/** + * @class vtkPAxisAlignedReflectionFilter + * @brief distributed version of vtkAxisAlignedReflectionFilter + * + * vtkPAxisAlignedReflectionFilter is a distributed version of vtkAxisAlignedReflectionFilter which + * takes into consideration the full dataset bounds for performing the reflection. + */ + +#ifndef vtkPAxisAlignedReflectionFilter_h +#define vtkPAxisAlignedReflectionFilter_h + +#include "vtkAxisAlignedReflectionFilter.h" +#include "vtkFiltersParallelModule.h" // For export macro + +VTK_ABI_NAMESPACE_BEGIN +class vtkMultiProcessController; + +class VTKFILTERSPARALLEL_EXPORT vtkPAxisAlignedReflectionFilter + : public vtkAxisAlignedReflectionFilter +{ +public: + static vtkPAxisAlignedReflectionFilter* New(); + vtkTypeMacro(vtkPAxisAlignedReflectionFilter, vtkAxisAlignedReflectionFilter); + void PrintSelf(ostream& os, vtkIndent indent) override; + + ///@{ + /** + * Get/Set the parallel controller. + */ + void SetController(vtkMultiProcessController*); + vtkGetObjectMacro(Controller, vtkMultiProcessController); + ///@} + +protected: + vtkPAxisAlignedReflectionFilter(); + ~vtkPAxisAlignedReflectionFilter() override; + + /** + * Compute the bounds of the input data object. + */ + void ComputeBounds(vtkDataObject* input, double bounds[6]) override; + +private: + vtkPAxisAlignedReflectionFilter(const vtkPAxisAlignedReflectionFilter&) = delete; + void operator=(const vtkPAxisAlignedReflectionFilter&) = delete; + + vtkMultiProcessController* Controller = nullptr; +}; + +VTK_ABI_NAMESPACE_END +#endif