Go to the documentation of this file.
10 #ifndef vtkm_exec_celllocatorrectilineargrid_h
11 #define vtkm_exec_celllocatorrectilineargrid_h
60 template <vtkm::IdComponent dimensions>
67 : PlaneSize(planeSize)
69 , PointDimensions(ToId3(cellSet.GetPointDimensions()))
70 , Dimensions(dimensions)
74 this->AxisPortals[0] = coordsExecPortal.GetFirstPortal();
75 this->MinPoint[0] = coordsContPortal.GetFirstPortal().Get(0);
76 this->MaxPoint[0] = coordsContPortal.GetFirstPortal().Get(this->PointDimensions[0] - 1);
78 this->AxisPortals[1] = coordsExecPortal.GetSecondPortal();
79 this->MinPoint[1] = coordsContPortal.GetSecondPortal().Get(0);
80 this->MaxPoint[1] = coordsContPortal.GetSecondPortal().Get(this->PointDimensions[1] - 1);
83 this->AxisPortals[2] = coordsExecPortal.GetThirdPortal();
84 this->MinPoint[2] = coordsContPortal.GetThirdPortal().Get(0);
85 this->MaxPoint[2] = coordsContPortal.GetThirdPortal().Get(this->PointDimensions[2] - 1);
93 if (point[0] < this->MinPoint[0] || point[0] > this->MaxPoint[0])
95 if (point[1] < this->MinPoint[1] || point[1] > this->MaxPoint[1])
97 if (this->Dimensions == 3)
99 if (point[2] < this->MinPoint[2] || point[2] > this->MaxPoint[2])
111 return this->FindCell(point, cellId, parametric);
119 if (!this->IsInside(point))
127 for (
vtkm::Int32 dim = 0; dim < this->Dimensions; ++dim)
134 if (point[dim] == MaxPoint[dim])
136 logicalCell[dim] = this->PointDimensions[dim] - 2;
142 vtkm::Id maxIndex = this->PointDimensions[dim] - 1;
145 minVal = this->AxisPortals[dim].Get(minIndex);
146 maxVal = this->AxisPortals[dim].Get(maxIndex);
147 while (maxIndex > minIndex + 1)
149 vtkm::Id midIndex = (minIndex + maxIndex) / 2;
151 if (point[dim] <= midVal)
162 logicalCell[dim] = minIndex;
163 parametric[dim] = (point[dim] - minVal) / (maxVal - minVal);
166 cellId = logicalCell[2] * this->PlaneSize + logicalCell[1] * this->RowSize + logicalCell[0];
184 #endif //vtkm_exec_celllocatorrectilineargrid_h
Manages an array-worth of data.
Definition: ArrayHandle.h:300
ErrorCode
Identifies whether an operation was successful or what type of error it had.
Definition: ErrorCode.h:28
typename AxisHandle::ReadPortalType AxisPortalType
Definition: exec/CellLocatorRectilinearGrid.h:46
static vtkm::Id3 && ToId3(vtkm::Id3 &&src)
Definition: exec/CellLocatorRectilinearGrid.h:50
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
Defines a 1-, 2-, or 3-dimensional structured grid of points.
Definition: CastAndCall.h:32
@ Success
A successful operation.
ArrayHandleCartesianProduct is a specialization of ArrayHandle.
Definition: ArrayHandleCartesianProduct.h:334
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:312
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
CellLocatorRectilinearGrid(const vtkm::Id planeSize, const vtkm::Id rowSize, const vtkm::cont::CellSetStructured< dimensions > &cellSet, const RectilinearType &coords, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: exec/CellLocatorRectilinearGrid.h:61
static vtkm::Id3 ToId3(vtkm::Id2 &&src)
Definition: exec/CellLocatorRectilinearGrid.h:51
vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f ¶metric, LastCell &) const
Locate the cell containing the provided point.
Definition: exec/CellLocatorRectilinearGrid.h:106
bool IsInside(const vtkm::Vec3f &point) const
Definition: exec/CellLocatorRectilinearGrid.h:90
vtkm::Id Dimensions
Definition: exec/CellLocatorRectilinearGrid.h:179
typename Superclass::ReadPortalType ReadPortalType
Definition: ArrayHandleCartesianProduct.h:351
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id3 PointDimensions
Definition: exec/CellLocatorRectilinearGrid.h:176
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
vtkm::Vec< vtkm::Id, 3 > Id3
Id3 corresponds to a 3-dimensional index for 3d arrays.
Definition: Types.h:1044
@ CellNotFound
A cell matching some given criteria could not be found.
static vtkm::Id3 ToId3(vtkm::Id &&src)
Definition: exec/CellLocatorRectilinearGrid.h:52
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f ¶metric) const
Locate the cell containing the provided point.
Definition: exec/CellLocatorRectilinearGrid.h:115
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:236
vtkm::Vec3f MaxPoint
Definition: exec/CellLocatorRectilinearGrid.h:178
vtkm::Vec3f MinPoint
Definition: exec/CellLocatorRectilinearGrid.h:177
int32_t Int32
Base type to use for 32-bit signed integer numbers.
Definition: Types.h:181
ReadPortalType PrepareForInput(vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token) const
Prepares this array to be used as an input to an operation in the execution environment.
Definition: ArrayHandle.h:599
Structure for locating cells.
Definition: exec/CellLocatorRectilinearGrid.h:40
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
typename RectilinearType::ReadPortalType RectilinearPortalType
Definition: exec/CellLocatorRectilinearGrid.h:47
vtkm::Id PlaneSize
Definition: exec/CellLocatorRectilinearGrid.h:172
Structure capturing the location of a cell in the search structure.
Definition: exec/CellLocatorRectilinearGrid.h:56
vtkm::Id RowSize
Definition: exec/CellLocatorRectilinearGrid.h:173