VTK  9.7.20261114
vtkResolveHangingNodes.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
115
116#ifndef vtkResolveHangingNodes_h
117#define vtkResolveHangingNodes_h
118
119#include "vtkBoundingBox.h" // For BoundaryBins
121#include "vtkFiltersCoreModule.h" // For export macro
122#include "vtkSmartPointer.h" // For vtkSmartPointer
123#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
124
125#include <bitset> // For BoundaryBins
126#include <map> // For MergeReceivedPoints
127#include <string> // For OriginalCellIdsName
128#include <type_traits> // For BoundaryBins
129#include <vector> // For std::vector
130
131VTK_ABI_NAMESPACE_BEGIN
132class vtkDataSet;
134class vtkPointSet;
135class vtkPolyData;
136
138{
139public:
142 void PrintSelf(ostream& os, vtkIndent indent) override;
143
145
149 vtkSetClampMacro(Tolerance, double, 0.0, 0.1);
150 vtkGetMacro(Tolerance, double);
152
158 vtkGetMacro(NumberOfLevels, int);
159
161
166 vtkSetMacro(Decompose, bool);
167 vtkGetMacro(Decompose, bool);
168 vtkBooleanMacro(Decompose, bool);
170
172
177 vtkSetMacro(ComputeInverseMeasure, bool);
178 vtkGetMacro(ComputeInverseMeasure, bool);
179 vtkBooleanMacro(ComputeInverseMeasure, bool);
181
183
188 vtkSetMacro(PassThroughCellIds, bool);
189 vtkGetMacro(PassThroughCellIds, bool);
190 vtkBooleanMacro(PassThroughCellIds, bool);
192
194
200
201protected:
203 ~vtkResolveHangingNodes() override = default;
204
206 vtkInformationVector* outputVector) override;
207 int FillInputPortInformation(int port, vtkInformation* info) override;
209 vtkInformationVector* outputVector) override;
210
216 virtual bool UseRemotePoints() { return false; }
217
225 virtual void GetGlobalMeasureRange(double vtkNotUsed(range)[2], int& vtkNotUsed(dimension)) {}
226
247 virtual std::vector<vtkSmartPointer<vtkPolyData>> GetRemotePoints(
248 const std::vector<vtkPolyData*>& boundaries, const std::vector<int>& partitionedDataSetIds);
249
261 virtual void GetCentroidGlobalIdsOffset(vtkIdType& vtkNotUsed(maxGlobalId),
262 vtkIdType numberOfCentroidPoints, vtkIdType& offset, vtkIdType& totalNumberOfCentroidPoints)
263 {
264 offset = 0;
265 totalNumberOfCentroidPoints = numberOfCentroidPoints;
266 }
267
268#ifndef __VTK_WRAP__
275 static vtkBoundingBox GetBoundaryBounds(vtkPolyData* boundary, double tolerance);
276
285 struct VTKFILTERSCORE_EXPORT BoundaryBins
286 {
287 // Target number of bins (see vtkBoundingBox::ComputeDivisions).
288 static constexpr vtkIdType TargetNumberOfBins = 32 * 32 * 32;
289
290 // Bounds of the bins, which may be larger than the bounds the bins were initialized with along
291 // an axis where they are flat (see vtkBoundingBox::ComputeDivisions).
293 int Divisions[3] = { 1, 1, 1 };
294 // One bit per bin, by bin index. ComputeDivisions never makes more bins than the target.
295 using OccupiedBitset = std::bitset<TargetNumberOfBins>;
296 // diy sends it as raw bytes.
297 static_assert(
298 std::is_trivially_copyable_v<OccupiedBitset>, "the bitset must be trivially copyable");
300
301 // Set the bounds and the divisions, with bins as close to cubes as possible, all unoccupied.
302 // The result only depends on `bounds`, so a neighbor initialized with the same bounds has the
303 // same bins, and only the occupied bits need to be exchanged.
304 void Initialize(const vtkBoundingBox& bounds);
305
307
308 // The bin indices ijk of the point `x`, clamped to the bins.
309 void GetBinIndices(const double* x, int ijk[3]) const;
310
311 vtkIdType GetBinIndex(const int ijk[3]) const;
312
314
315 vtkIdType GetBinIndex(const double* x) const;
316
317 bool IsBinOccupied(vtkIdType binId) const;
318
319 // Whether `x` is within the bounds, in an occupied bin.
320 bool IsInOccupiedBin(const double* x) const;
321 };
322
330 static void BinBoundaryElements(BoundaryBins& bins, vtkPolyData* boundary, double tolerance);
331
338 vtkPolyData* source, const BoundaryBins& bins);
339#endif
340
350 const std::map<int, vtkSmartPointer<vtkPolyData>>& received, vtkPolyData* reference) const;
351
352 double Tolerance = 1e-6;
354 bool Decompose = true;
356 bool PassThroughCellIds = false;
357 std::string OriginalCellIdsName = "vtkOriginalResolvedCellIds";
358
359private:
361 void operator=(const vtkResolveHangingNodes&) = delete;
362
370 int CheckAndResolvePartitions(std::vector<vtkSmartPointer<vtkDataSet>> inputs,
371 std::vector<vtkSmartPointer<vtkPointSet>> outputs,
372 const std::vector<int>& partitionedDataSetIds);
373
383 template <int Dim>
384 int ResolvePartitions(const std::vector<vtkSmartPointer<vtkDataSet>>& inputs,
385 const std::vector<vtkSmartPointer<vtkPointSet>>& outputs,
386 const std::vector<int>& partitionedDataSetIds);
387
393 int ResolvePartitionedDataSet(vtkPartitionedDataSet* inputPDS, vtkPartitionedDataSet* outputPDS);
394
395 // The largest point global id that the new global ids of the center points follow: the largest
396 // one of the whole input, then of the center points numbered so far, so that the
397 // vtkPartitionedDataSet of a collection, resolved one after the other, get unique global ids.
398 vtkIdType MaxPointGlobalId = -1;
399};
400
401VTK_ABI_NAMESPACE_END
402#endif
Fast, simple class for representing and operating on 3D bounds.
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
composite dataset to encapsulates a dataset consisting of partitions.
concrete class for storing a set of points
Definition vtkPointSet.h:98
concrete dataset represents vertices, lines, polygons, and triangle strips
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkSmartPointer< vtkPolyData > ExtractPointsInBins(vtkPolyData *source, const BoundaryBins &bins)
Helper for the exchange of points between partitions: the points of the boundary source of a partitio...
static vtkResolveHangingNodes * New()
static void BinBoundaryElements(BoundaryBins &bins, vtkPolyData *boundary, double tolerance)
Helper for the exchange of points between partitions: bin the boundary elements of boundary (its cell...
vtkSetStdStringFromCharMacro(OriginalCellIdsName)
The name of the cell array of PassThroughCellIds.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
virtual void GetCentroidGlobalIdsOffset(vtkIdType &maxGlobalId, vtkIdType numberOfCentroidPoints, vtkIdType &offset, vtkIdType &totalNumberOfCentroidPoints)
Called with the largest point global id of the local partitions, -1 without point global ids,...
virtual std::vector< vtkSmartPointer< vtkPolyData > > GetRemotePoints(const std::vector< vtkPolyData * > &boundaries, const std::vector< int > &partitionedDataSetIds)
Called with the true boundary of every local partition: the edges (2D) or faces (3D) without neighbor...
vtkSmartPointer< vtkPolyData > MergeReceivedPoints(const std::map< int, vtkSmartPointer< vtkPolyData > > &received, vtkPolyData *reference) const
Helper for GetRemotePoints(): merge the points received from other partitions, by partition id,...
vtkGetCharFromStdStringMacro(OriginalCellIdsName)
The name of the cell array of PassThroughCellIds.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkResolveHangingNodes()=default
virtual void GetGlobalMeasureRange(double range[2], int &dimension)
Called with the range (min, max) of the measures of the candidate cells of the local partitions,...
static vtkBoundingBox GetBoundaryBounds(vtkPolyData *boundary, double tolerance)
Helper for the exchange of points between partitions: the bounds of the true boundary boundary of a p...
virtual bool UseRemotePoints()
Whether the points of the partitions of other processes are needed to resolve the boundary of the loc...
~vtkResolveHangingNodes() override=default
Hold a reference to a vtkObjectBase instance.
Helper for the exchange of points between partitions: the bins of the boundary of a partition,...
void Initialize(const vtkBoundingBox &bounds)
vtkIdType GetBinIndex(const double *x) const
std::bitset< TargetNumberOfBins > OccupiedBitset
bool IsInOccupiedBin(const double *x) const
vtkIdType GetBinIndex(const int ijk[3]) const
void SetBinOccupied(vtkIdType binId)
bool IsBinOccupied(vtkIdType binId) const
static constexpr vtkIdType TargetNumberOfBins
void GetBinIndices(const double *x, int ijk[3]) const
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
int vtkIdType
Definition vtkType.h:366
#define VTK_MARSHALAUTO