Go to the documentation of this file.
10 #ifndef vtk_m_worklet_PointMerge_h
11 #define vtk_m_worklet_PointMerge_h
48 #ifdef VTKM_USE_64BIT_IDS
74 if (boundLengths[dimIndex] > vtkm::Epsilon64())
77 if (minBinWidth < (2 * delta))
82 binWidths[dimIndex] = 2.0 * delta;
88 binWidths[dimIndex] = minBinWidth;
94 binWidths[dimIndex] = 1.0;
104 :
Offset(bounds.
X.Min, bounds.Y.Min, bounds.Z.Min)
121 if (directions[dimIndex])
123 shiftedLocator.
Offset[dimIndex] -= (0.5 * binWidths[dimIndex]);
126 return shiftedLocator;
129 template <
typename T>
151 ExecObject binLocator,
155 template <
typename T>
179 ValuesInOut pointIndices,
180 ValuesInOut pointCoordinates,
181 ExecObject binLocator,
185 template <
typename IndexVecInType,
typename CoordinateVecInType,
typename IndexVecOutType>
187 CoordinateVecInType& pointCoordinates,
189 IndexVecOutType& neighborIndices)
const
198 using CoordType =
typename CoordinateVecInType::ComponentType;
201 VTKM_ASSERT(numPoints == pointCoordinates.GetNumberOfComponents());
202 VTKM_ASSERT(numPoints == neighborIndices.GetNumberOfComponents());
207 neighborIndices[i] = i;
214 CoordType p0 = pointCoordinates[i];
220 if (neighborIndices[i] == neighborIndices[j])
225 CoordType p1 = pointCoordinates[j];
233 if ((bin0 == bin1) &&
238 if (neighborIndices[j] == j)
241 neighborIndices[j] = neighborIndices[i];
249 if (neighborIndices[i] < neighborIndices[j])
251 neighborhoodToGrow = neighborIndices[i];
252 neighborhoodToAbsorb = neighborIndices[j];
256 neighborhoodToGrow = neighborIndices[j];
257 neighborhoodToAbsorb = neighborIndices[i];
263 if (neighborIndices[k] == neighborhoodToAbsorb)
265 neighborIndices[k] = neighborhoodToGrow;
281 if (i == neighborhood)
284 CoordType centroid = pointCoordinates[i];
288 if (neighborhood == neighborIndices[j])
290 centroid = centroid + pointCoordinates[j];
294 centroid = centroid / numInGroup;
297 vtkm::Id groupIndex = pointIndices[i];
298 pointCoordinates[i] = centroid;
301 if (neighborhood == neighborIndices[j])
303 pointCoordinates[j] = centroid;
304 pointIndices[j] = groupIndex;
317 template <
typename MapPortalType>
323 outputIndices[i] = newIndex;
329 template <
typename T>
349 FindNeighbors(fastCheck, delta), keys, indexNeighborMap, points, binLocator, neighborIndices);
353 template <
typename T>
368 this->
RunOneIteration(delta, fastCheck, binLocator, points, indexNeighborMap);
419 uniquePointCoordinates);
420 points = uniquePointCoordinates;
423 template <
typename TL,
typename SL>
434 Run(delta, fastCheck, bounds, concretePoints);
437 points = concretePoints;
449 Run(delta, fastCheck, bounds, concretePoints);
452 points = concretePoints;
455 template <
typename ShapeStorage,
typename ConnectivityStorage,
typename OffsetsStorage>
468 template <
typename T,
typename S>
474 self.MapPointField(inArray, outArray);
480 template <
typename InArrayHandle,
typename OutArrayHandle>
486 template <
typename T,
typename S>
496 template <
typename TL,
typename SL>
514 #endif //vtk_m_worklet_PointMerge_h
VTKM_CONT BinLocator ShiftBins(const vtkm::Bounds &bounds, vtkm::Float64 delta, const vtkm::Vec< bool, 3 > &directions)
Definition: PointMerge.h:113
Manages an array-worth of data.
Definition: ArrayHandle.h:283
VTKM_EXEC_CONT vtkm::HashType Hash(const InVecType &inVec)
Returns a 32-bit hash on a group of integer-type values.
Definition: Hash.h:106
Definition: PointMerge.h:148
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
VTKM_EXEC void operator()(IndexVecInType &pointIndices, CoordinateVecInType &pointCoordinates, const BinLocator &binLocator, IndexVecOutType &neighborIndices) const
Definition: PointMerge.h:186
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
static VTKM_CONT void RunOneIteration(vtkm::Float64 delta, bool fastCheck, const BinLocator &binLocator, vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 >> &points, const vtkm::cont::ArrayHandle< vtkm::Id > &indexNeighborMap)
Definition: PointMerge.h:330
A control signature tag for output fields.
Definition: WorkletMapField.h:60
static constexpr vtkm::Id MaxBinsPerDimension
Definition: PointMerge.h:56
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_CONT vtkm::cont::CellSetExplicit< ShapeStorage, VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG, OffsetsStorage > MapCellSet(const vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &inCellSet) const
Map cell indices.
Definition: RemoveUnusedPoints.h:128
Definition: PointMerge.h:165
VTKM_CONT void ArrayCopyShallowIfPossible(const vtkm::cont::UnknownArrayHandle source, vtkm::cont::ArrayHandle< T, S > &destination)
Copies from an unknown to a known array type.
Definition: ArrayCopy.h:182
vtkm::Vec3f_64 Offset
Definition: PointMerge.h:45
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
VTKM_EXEC_CONT vtkm::Id3 FindBin(const vtkm::Vec< T, 3 > &worldCoords) const
Definition: PointMerge.h:130
A control signature tag for output values.
Definition: WorkletReduceByKey.h:102
void(_1, _2, _3) ExecutionSignature
Definition: PointMerge.h:153
Definition: PointMerge.h:43
VTKM_CONT vtkm::cont::UncertainArrayHandle< TL, SL > MapPointField(const vtkm::cont::UncertainArrayHandle< TL, SL > &inArray) const
Definition: PointMerge.h:497
void(FieldIn pointCoordinates, ExecObject binLocator, FieldOut hashesOut) ControlSignature
Definition: PointMerge.h:152
VTKM_EXEC void operator()(const vtkm::Vec< T, 3 > &coordiantes, const BinLocator binLocator, vtkm::HashType &hashOut) const
Definition: PointMerge.h:156
static VTKM_CONT void Run(const vtkm::worklet::internal::KeysBase &keys, const InArrayType &inValues, const OutArrayType &outAverages)
Compute average values based on a set of Keys.
Definition: AverageByKey.h:63
bool FastCheck
Definition: PointMerge.h:168
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
vtkm::UInt32 HashType
Definition: Hash.h:20
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
VTKM_CONT void MapPointField(const InArrayHandle &inArray, OutArrayHandle &outArray) const
Definition: PointMerge.h:481
Base ExecutionAndControlObjectBase class.
Definition: ExecutionAndControlObjectBase.h:28
VTKM_EXEC_CONT vtkm::Float32 Floor(vtkm::Float32 x)
Round x to the largest integer value not greater than x.
Definition: Math.h:2204
Definition: PointMerge.h:466
VTKM_EXEC_CONT vtkm::Float64 Length() const
Returns the length of the range.
Definition: Range.h:87
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::Vec< vtkm::Float64, 3 > Vec3f_64
Vec3f_64 corresponds to a 3-dimensional vector of 64-bit floating point values.
Definition: Types.h:1026
VTKM_CONT FindNeighbors(bool fastCheck=true, vtkm::Float64 delta=vtkm::Epsilon64())
Definition: PointMerge.h:172
#define X
Definition: ClipTables.h:2430
VTKM_CONT void Run(vtkm::Float64 delta, bool fastCheck, const vtkm::Bounds &bounds, vtkm::cont::UnknownArrayHandle &points)
Definition: PointMerge.h:440
A control signature tag for input fields.
Definition: WorkletMapField.h:49
Definition: WorkletReduceByKey.h:42
vtkm::Float64 DeltaSquared
Definition: PointMerge.h:167
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
vtkm::worklet::Keys< vtkm::Id > MergeKeys
Definition: PointMerge.h:508
vtkm::Range Z
Definition: Bounds.h:33
VTKM_CONT vtkm::cont::CellSetExplicit< ShapeStorage, VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG, OffsetsStorage > MapCellSet(const vtkm::cont::CellSetExplicit< ShapeStorage, ConnectivityStorage, OffsetsStorage > &inCellSet) const
Definition: PointMerge.h:458
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input keys.
Definition: WorkletReduceByKey.h:56
BinLocator PrepareForControl() const
Definition: PointMerge.h:144
VTKM_CONT KeyArrayHandleType GetUniqueKeys() const
Definition: Keys.h:175
Represent an axis-aligned 3D bounds in space.
Definition: Bounds.h:29
constexpr VTKM_EXEC_CONT vtkm::Vec< T, vtkm::IdComponent(sizeof...(Ts)+1)> make_Vec(T value0, Ts &&... args)
Initializes and returns a Vec containing all the arguments.
Definition: Types.h:1212
VTKM_CONT BinLocator()
Definition: PointMerge.h:60
vtkm::Vec< vtkm::Id, 3 > Id3
Id3 corresponds to a 3-dimensional index for 3d arrays.
Definition: Types.h:1003
VTKM_CONT vtkm::cont::ArrayHandle< T > MapPointField(const vtkm::cont::ArrayHandle< T, S > &inArray) const
Definition: PointMerge.h:487
static constexpr vtkm::IdComponent BitsPerDimension
Definition: PointMerge.h:54
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle< T, S > &inArray, vtkm::cont::UnknownArrayHandle &outHolder, const PointMerge &self) const
Definition: PointMerge.h:469
VTKM_CONT vtkm::cont::ArrayHandlePermutation< IndexArrayHandleType, ValueArrayHandleType > make_ArrayHandlePermutation(IndexArrayHandleType indexArray, ValueArrayHandleType valueArray)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandlePermutation.h:279
Definition: DeviceAdapterTag.h:52
An ArrayHandle of an uncertain value type and storage.
Definition: UncertainArrayHandle.h:39
Definition: CastAndCall.h:36
Manage keys for a WorkletReduceByKey.
Definition: Keys.h:131
Definition: PointMerge.h:39
double Float64
Definition: Types.h:155
vtkm::Range X
Definition: Bounds.h:31
vtkm::Range Y
Definition: Bounds.h:32
static VTKM_CONT vtkm::Vec3f_64 ComputeBinWidths(const vtkm::Bounds &bounds, vtkm::Float64 delta)
Definition: PointMerge.h:67
vtkm::worklet::Keys< vtkm::Id > GetMergeKeys() const
Definition: PointMerge.h:505
VTKM_CONT void Run(vtkm::Float64 delta, bool fastCheck, const vtkm::Bounds &bounds, vtkm::cont::ArrayHandle< vtkm::Vec< T, 3 >> &points)
Definition: PointMerge.h:354
BinLocator PrepareForExecution(vtkm::cont::DeviceAdapterId, vtkm::cont::Token &) const
Definition: PointMerge.h:139
void(_2, _3, _4, _5) ExecutionSignature
Definition: PointMerge.h:183
VTKM_CONT void Run(vtkm::Float64 delta, bool fastCheck, const vtkm::Bounds &bounds, vtkm::cont::UncertainArrayHandle< TL, SL > &points)
Definition: PointMerge.h:424
vtkm::cont::ArrayHandle< vtkm::Id > PointInputToOutputMap
Definition: PointMerge.h:509
vtkm::Vec3f_64 Scale
Definition: PointMerge.h:46
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
VTKM_CONT BinLocator(const vtkm::Bounds &bounds, vtkm::Float64 delta=0.0)
Definition: PointMerge.h:103
void(KeysIn keys, ValuesInOut pointIndices, ValuesInOut pointCoordinates, ExecObject binLocator, ValuesOut neighborIndices) ControlSignature
Definition: PointMerge.h:182