Go to the documentation of this file.
10 #ifndef vtk_m_worklet_ExtractStructured_h
11 #define vtk_m_worklet_ExtractStructured_h
36 namespace extractstructured
41 class SubArrayPermutePoints
44 SubArrayPermutePoints() =
default;
55 , IncludeBoundary(includeBoundary)
62 return (this->IncludeBoundary && (idx == this->MaxIdx)) ? (this->Last)
63 : (this->First + (idx * this->Stride));
75 using ControlSignature = void(FieldIn, FieldOut, WholeArrayIn);
77 explicit ExtractCopy(
const vtkm::Id3& dim)
79 , XYDim(dim[0] * dim[1])
85 return index[0] + index[1] * this->XDim + index[2] * this->XYDim;
88 template <
typename ScalarType,
typename WholeFieldIn>
91 const WholeFieldIn& inputField)
const
93 output = inputField.Get(this->ToFlat(index));
112 ArrayHandleCartesianProduct<AxisIndexArrayPoints, AxisIndexArrayPoints, AxisIndexArrayPoints>;
116 ArrayHandleCartesianProduct<AxisIndexArrayCells, AxisIndexArrayCells, AxisIndexArrayCells>;
122 bool includeBoundary)
124 auto fnctr = extractstructured::internal::SubArrayPermutePoints(
125 count, first, last, stride, includeBoundary);
149 for (
int i = 0; i < 3 && (forcedDimensionality == 0); ++i)
151 if (inputPointDims[i] > 1)
153 dimensions[dimensionality] = inputPointDims[i];
154 offset[dimensionality] = inputOffsets[i];
159 switch (dimensionality)
191 bool includeBoundary,
208 bool includeBoundary,
225 bool includeBoundary,
230 return this->
Compute(3, pdims, offsets, voi, sampleRate, includeBoundary, includeOffset);
238 bool includeBoundary,
249 if (sampleRate[0] < 1 || sampleRate[1] < 1 || sampleRate[2] < 1)
256 offset_vec = offsets;
257 for (
int i = 0; i < dimensionality; ++i)
259 if (dimensionality > i)
261 if (offset_vec[i] >= voi[i].Min)
263 globalOffset[i] = offset_vec[i];
264 this->
VOI[i].Min = offset_vec[i];
265 if (globalOffset[i] + ptdim[i] < voi[i].Max)
269 this->
VOI[i].Max = globalOffset[i] + ptdim[i];
275 tmpDims[i] = voi[i].Max - globalOffset[i];
278 else if (offset_vec[i] < voi[i].Min)
280 if (offset_vec[i] + ptdim[i] < voi[i].Min)
291 globalOffset[i] = voi[i].Min;
292 this->
VOI[i].Min = voi[i].Min;
293 if (globalOffset[i] + ptdim[i] < voi[i].Max)
295 this->
VOI[i].Max = globalOffset[i] + ptdim[i];
299 tmpDims[i] = voi[i].Max - globalOffset[i];
325 for (
int i = 0; i < dimensionality; ++i)
328 ((includeBoundary && ((voiDims[i] - 1) % this->
SampleRate[i])) ? 1 : 0);
350 this->SampleRate[0]),
353 this->SampleRate[1]),
356 this->SampleRate[2]));
370 bool includeBoundary,
389 template <
typename CellSetType>
405 template <
typename CellSetList>
409 bool includeBoundary,
413 CallRun cr(
this, voi, sampleRate, includeBoundary, includeOffset, output);
430 using CoordType = CoordsArray::ValueType;
431 using ValueType = CoordType::ComponentType;
434 CoordType inOrigin = portal.GetOrigin();
435 CoordType inSpacing = portal.GetSpacing();
437 CoordType outOrigin =
439 inOrigin[1] +
static_cast<ValueType
>(this->VOI.Y.Min) * inSpacing[1],
440 inOrigin[2] +
static_cast<ValueType
>(this->VOI.Z.Min) * inSpacing[2]);
441 CoordType outSpacing = inSpacing *
static_cast<CoordType
>(this->
SampleRate);
457 vtkm::cont::ArrayHandle<vtkm::FloatDefault> arrays[3] = { coords.
GetFirstArray(),
463 for (
int i = 0; i < 3; ++i)
465 if (arrays[i].GetNumberOfValues() == 1)
483 template <
typename T,
typename Storage>
487 using namespace extractstructured::internal;
498 template <
typename T,
typename Storage>
502 using namespace extractstructured::internal;
507 ExtractCopy worklet(inputCellDimensions);
509 invoke(worklet, this->
ValidCells, result, field);
528 #endif // vtk_m_worklet_ExtractStructured_h
VTKM_CONT void ArrayCopyDevice(const vtkm::cont::ArrayHandle< InValueType, InStorage > &source, vtkm::cont::ArrayHandle< OutValueType, OutStorage > &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopyDevice.h:75
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
vtkm::RangeId X
Definition: RangeId3.h:29
#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
VTKM_CONT ThirdHandleType GetThirdArray() const
Definition: ArrayHandleCartesianProduct.h:372
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
vtkm::RangeId Y
Definition: RangeId3.h:30
VTKM_CONT vtkm::cont::ArrayHandleCounting< CountingValueType > make_ArrayHandleCounting(CountingValueType start, CountingValueType step, vtkm::Id length)
A convenience function for creating an ArrayHandleCounting.
Definition: ArrayHandleCounting.h:151
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
Definition: CastAndCall.h:32
A CellSet of an uncertain type.
Definition: UncertainCellSet.h:38
VTKM_CONT vtkm::cont::ArrayHandleImplicit< FunctorType > make_ArrayHandleImplicit(FunctorType functor, vtkm::Id length)
make_ArrayHandleImplicit is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleImplicit.h:198
vtkm::Id Max
Definition: RangeId.h:31
VTKM_CONT T ArrayGetValue(vtkm::Id id, const vtkm::cont::ArrayHandle< T, S > &data)
Obtain a small set of values from an ArrayHandle with minimal device transfers.
Definition: ArrayGetValues.h:264
This class is thrown when VTK-m encounters data of a type that is incompatible with the current opera...
Definition: ErrorBadType.h:25
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::RangeId Z
Definition: RangeId3.h:31
vtkm::Id Min
Definition: RangeId.h:30
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
VTKM_CONT SecondHandleType GetSecondArray() const
Definition: ArrayHandleCartesianProduct.h:368
VTKM_CONT WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:435
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_EXEC_CONT bool IsNonEmpty() const
Determine if the range is non-empty.
Definition: RangeId3.h:77
vtkm::Vec< vtkm::Id, 3 > Id3
Id3 corresponds to a 3-dimensional index for 3d arrays.
Definition: Types.h:1003
VTKM_CONT FirstHandleType GetFirstArray() const
Definition: ArrayHandleCartesianProduct.h:364
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
SchedulingRangeType GetPointDimensions() const
Definition: CellSetStructured.h:64
void SetPointDimensions(SchedulingRangeType dimensions)
Definition: CellSetStructured.h:49
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
VTKM_CONT ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:414
Represent 3D integer range.
Definition: RangeId3.h:27
void SetGlobalPointIndexStart(SchedulingRangeType start)
Definition: CellSetStructured.h:59
SchedulingRangeType GetGlobalPointIndexStart() const
Definition: CellSetStructured.h:78
VTKM_CONT vtkm::cont::ArrayHandleCartesianProduct< FirstHandleType, SecondHandleType, ThirdHandleType > make_ArrayHandleCartesianProduct(const FirstHandleType &first, const SecondHandleType &second, const ThirdHandleType &third)
A convenience function for creating an ArrayHandleCartesianProduct.
Definition: ArrayHandleCartesianProduct.h:384
An ArrayHandle that computes values on the fly.
Definition: ArrayHandleImplicit.h:174
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
VTKM_EXEC_CONT vtkm::Id3 Dimensions() const
Definition: RangeId3.h:101