Go to the documentation of this file.
10 #ifndef vtkm_exec_celllocatorrectilineargrid_h
11 #define vtkm_exec_celllocatorrectilineargrid_h
49 template <vtkm::IdComponent dimensions>
56 : PlaneSize(planeSize)
58 , PointDimensions(ToId3(cellSet.GetPointDimensions()))
59 , Dimensions(dimensions)
63 this->AxisPortals[0] = coordsExecPortal.GetFirstPortal();
64 this->MinPoint[0] = coordsContPortal.GetFirstPortal().Get(0);
65 this->MaxPoint[0] = coordsContPortal.GetFirstPortal().Get(this->PointDimensions[0] - 1);
67 this->AxisPortals[1] = coordsExecPortal.GetSecondPortal();
68 this->MinPoint[1] = coordsContPortal.GetSecondPortal().Get(0);
69 this->MaxPoint[1] = coordsContPortal.GetSecondPortal().Get(this->PointDimensions[1] - 1);
72 this->AxisPortals[2] = coordsExecPortal.GetThirdPortal();
73 this->MinPoint[2] = coordsContPortal.GetThirdPortal().Get(0);
74 this->MaxPoint[2] = coordsContPortal.GetThirdPortal().Get(this->PointDimensions[2] - 1);
82 if (point[0] < this->MinPoint[0] || point[0] > this->MaxPoint[0])
84 if (point[1] < this->MinPoint[1] || point[1] > this->MaxPoint[1])
86 if (this->Dimensions == 3)
88 if (point[2] < this->MinPoint[2] || point[2] > this->MaxPoint[2])
100 return this->FindCell(point, cellId, parametric);
108 if (!this->IsInside(point))
116 for (
vtkm::Int32 dim = 0; dim < this->Dimensions; ++dim)
123 if (point[dim] == MaxPoint[dim])
125 logicalCell[dim] = this->PointDimensions[dim] - 2;
131 vtkm::Id maxIndex = this->PointDimensions[dim] - 1;
134 minVal = this->AxisPortals[dim].Get(minIndex);
135 maxVal = this->AxisPortals[dim].Get(maxIndex);
136 while (maxIndex > minIndex + 1)
138 vtkm::Id midIndex = (minIndex + maxIndex) / 2;
140 if (point[dim] <= midVal)
151 logicalCell[dim] = minIndex;
152 parametric[dim] = (point[dim] - minVal) / (maxVal - minVal);
155 cellId = logicalCell[2] * this->PlaneSize + logicalCell[1] * this->RowSize + logicalCell[0];
173 #endif //vtkm_exec_celllocatorrectilineargrid_h
ErrorCode
Definition: ErrorCode.h:19
VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f ¶metric, LastCell &vtkmNotUsed(lastCell)) const
Definition: exec/CellLocatorRectilinearGrid.h:95
typename AxisHandle::ReadPortalType AxisPortalType
Definition: exec/CellLocatorRectilinearGrid.h:37
static VTKM_CONT vtkm::Id3 ToId3(vtkm::Id2 &&src)
Definition: exec/CellLocatorRectilinearGrid.h:41
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_CONT 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:50
static VTKM_CONT vtkm::Id3 && ToId3(vtkm::Id3 &&src)
Definition: exec/CellLocatorRectilinearGrid.h:40
VTKM_CONT 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:574
VTKM_EXEC vtkm::ErrorCode FindCell(const vtkm::Vec3f &point, vtkm::Id &cellId, vtkm::Vec3f ¶metric) const
Definition: exec/CellLocatorRectilinearGrid.h:104
Definition: CastAndCall.h:32
ArrayHandleCartesianProduct is a specialization of ArrayHandle.
Definition: ArrayHandleCartesianProduct.h:326
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::Id Dimensions
Definition: exec/CellLocatorRectilinearGrid.h:168
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Id3 PointDimensions
Definition: exec/CellLocatorRectilinearGrid.h:165
#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:1003
Definition: DeviceAdapterTag.h:52
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::Vec3f MaxPoint
Definition: exec/CellLocatorRectilinearGrid.h:167
vtkm::Vec3f MinPoint
Definition: exec/CellLocatorRectilinearGrid.h:166
VTKM_CONT ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:414
int32_t Int32
Definition: Types.h:160
Definition: exec/CellLocatorRectilinearGrid.h:31
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
typename RectilinearType::ReadPortalType RectilinearPortalType
Definition: exec/CellLocatorRectilinearGrid.h:38
static VTKM_CONT vtkm::Id3 ToId3(vtkm::Id &&src)
Definition: exec/CellLocatorRectilinearGrid.h:42
vtkm::Id PlaneSize
Definition: exec/CellLocatorRectilinearGrid.h:161
VTKM_EXEC bool IsInside(const vtkm::Vec3f &point) const
Definition: exec/CellLocatorRectilinearGrid.h:79
Definition: exec/CellLocatorRectilinearGrid.h:45
vtkm::Id RowSize
Definition: exec/CellLocatorRectilinearGrid.h:162