Go to the documentation of this file.
18 #ifndef viskores_exec_CellLocatorTwoLevel_h
19 #define viskores_exec_CellLocatorTwoLevel_h
37 namespace cl_uniform_bins
50 DimensionType Padding;
63 return idx[0] + (dim[0] * (idx[1] + (dim[1] * idx[2])));
72 l1Grid.Origin + (
static_cast<FloatVec3
>(idx) * l1Grid.BinSize),
73 l1Grid.BinSize /
static_cast<FloatVec3
>(dim) };
76 template <
typename Po
intsVecType>
77 VISKORES_EXEC inline Bounds ComputeCellBounds(
const PointsVecType& points)
82 CoordsType minp = points[0], maxp = points[0];
85 minp = viskores::Min(minp, points[i]);
86 maxp = viskores::Max(maxp, points[i]);
89 return { FloatVec3(minp), FloatVec3(maxp) };
111 template <
typename CellStructureType>
118 template <
typename T>
122 typename viskores::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType;
127 template <
typename CellShapeTag,
typename CoordsType>
129 CellShapeTag cellShape,
130 CoordsType cellPoints,
134 auto bounds = viskores::internal::cl_uniform_bins::ComputeCellBounds(cellPoints);
135 if (point[0] >= bounds.Min[0] && point[0] <= bounds.Max[0] && point[1] >= bounds.Min[1] &&
136 point[1] <= bounds.Max[1] && point[2] >= bounds.Min[2] && point[2] <= bounds.Max[2])
139 cellPoints, point, cellShape, parametricCoordinates));
140 inside = viskores::exec::CellInside(parametricCoordinates, cellShape);
151 template <
typename CellSetType>
158 const CellSetType& cellSet,
162 : TopLevel(topLevelGrid)
163 , LeafDimensions(leafDimensions.PrepareForInput(device, token))
164 , LeafStartIndex(leafStartIndex.PrepareForInput(device, token))
165 , CellStartIndex(cellStartIndex.PrepareForInput(device, token))
166 , CellCount(cellCount.PrepareForInput(device, token))
167 , CellIds(cellIds.PrepareForInput(device, token))
168 , CellSet(cellSet.PrepareForInput(device,
172 , Coords(coords.GetDataAsMultiplexer().PrepareForInput(device, token))
190 return this->FindCellImpl(point, cellId, parametric, lastCell);
202 if ((lastCell.
CellId >= 0) && (lastCell.
CellId < this->CellSet.GetNumberOfElements()) &&
211 if ((lastCell.
LeafIdx >= 0) && (lastCell.
LeafIdx < this->CellCount.GetNumberOfValues()) &&
220 return this->FindCellImpl(point, cellId, parametric, lastCell);
229 auto indices = this->CellSet.GetIndices(cid);
233 auto status = PointInsideCell(point, this->CellSet.GetCellShape(cid), pts, pc, inside);
250 viskores::Id end = start + this->CellCount.Get(leafIdx);
275 using namespace viskores::internal::cl_uniform_bins;
281 DimVec3 binId3 =
static_cast<DimVec3>((point - this->TopLevel.Origin) / this->TopLevel.BinSize);
282 if (binId3[0] >= 0 && binId3[0] < this->TopLevel.Dimensions[0] && binId3[1] >= 0 &&
283 binId3[1] < this->TopLevel.Dimensions[1] && binId3[2] >= 0 &&
284 binId3[2] < this->TopLevel.Dimensions[2])
286 viskores::Id binId = ComputeFlatIndex(binId3, this->TopLevel.Dimensions);
288 auto ldim = this->LeafDimensions.Get(binId);
289 if (!ldim[0] || !ldim[1] || !ldim[2])
294 auto leafGrid = ComputeLeafGrid(binId3, ldim, this->TopLevel);
296 DimVec3 leafId3 =
static_cast<DimVec3>((point - leafGrid.Origin) / leafGrid.BinSize);
298 leafId3 = viskores::Max(
DimVec3(0), viskores::Min(ldim -
DimVec3(1), leafId3));
300 viskores::Id leafStart = this->LeafStartIndex.Get(binId);
301 viskores::Id leafIdx = leafStart + ComputeFlatIndex(leafId3, leafGrid.Dimensions);
314 viskores::internal::cl_uniform_bins::Grid
TopLevel;
329 #endif //viskores_exec_CellLocatorTwoLevel_h
CoordsPortalType Coords
Definition: exec/CellLocatorTwoLevel.h:324
CellStructureType CellSet
Definition: exec/CellLocatorTwoLevel.h:323
typename viskores::cont::ArrayHandle< T >::ReadPortalType ReadPortal
Definition: exec/CellLocatorTwoLevel.h:119
ReadPortal< viskores::Id > LeafStartIndex
Definition: exec/CellLocatorTwoLevel.h:317
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:32
viskores::ErrorCode PointInCell(const viskores::Vec3f &point, const viskores::Id &cid, viskores::Vec3f ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:225
Structure for locating cells.
Definition: exec/CellLocatorTwoLevel.h:112
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:181
static viskores::ErrorCode PointInsideCell(FloatVec3 point, CellShapeTag cellShape, CoordsType cellPoints, FloatVec3 ¶metricCoordinates, bool &inside)
Definition: exec/CellLocatorTwoLevel.h:128
ReadPortal< viskores::Id > CellStartIndex
Definition: exec/CellLocatorTwoLevel.h:319
ErrorCode
Identifies whether an operation was successful or what type of error it had.
Definition: ErrorCode.h:36
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::Id LeafIdx
Definition: exec/CellLocatorTwoLevel.h:180
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:38
viskores::ErrorCode FindCellImpl(const FloatVec3 &point, viskores::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Definition: exec/CellLocatorTwoLevel.h:270
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:325
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
ReadPortal< viskores::Id > CellCount
Definition: exec/CellLocatorTwoLevel.h:320
Structure capturing the location of a cell in the search structure.
Definition: exec/CellLocatorTwoLevel.h:177
viskores::ErrorCode FindCell(const FloatVec3 &point, viskores::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Locate the cell containing the provided point.
Definition: exec/CellLocatorTwoLevel.h:195
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
#define VISKORES_RETURN_ON_ERROR(call)
Definition: ErrorCode.h:210
VecFromPortalPermute< IndexVecType, PortalType > make_VecFromPortalPermute(const IndexVecType *index, const PortalType &portal)
Definition: VecFromPortalPermute.h:181
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::ErrorCode FindCell(const FloatVec3 &point, viskores::Id &cellId, FloatVec3 ¶metric) const
Locate the cell containing the provided point.
Definition: exec/CellLocatorTwoLevel.h:185
#define VISKORES_CONT
Definition: ExportMacros.h:65
static constexpr viskores::IdComponent GetNumberOfComponents(const T &)
Returns the number of components in the given vector.
Definition: VecTraits.h:102
Groups connected points that have the same field value.
Definition: Atomic.h:27
CellLocatorTwoLevel(const viskores::internal::cl_uniform_bins::Grid &topLevelGrid, const viskores::cont::ArrayHandle< DimVec3 > &leafDimensions, const viskores::cont::ArrayHandle< viskores::Id > &leafStartIndex, const viskores::cont::ArrayHandle< viskores::Id > &cellStartIndex, const viskores::cont::ArrayHandle< viskores::Id > &cellCount, const viskores::cont::ArrayHandle< viskores::Id > &cellIds, const CellSetType &cellSet, const viskores::cont::CoordinateSystem &coords, viskores::cont::DeviceAdapterId device, viskores::cont::Token &token)
Definition: exec/CellLocatorTwoLevel.h:152
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
@ CellNotFound
A cell matching some given criteria could not be found.
typename viskores::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType CoordsPortalType
Definition: exec/CellLocatorTwoLevel.h:122
@ Success
A successful operation.
viskores::internal::cl_uniform_bins::Grid TopLevel
Definition: exec/CellLocatorTwoLevel.h:314
T ComponentType
Type of the components in the vector.
Definition: VecTraits.h:79
ReadPortal< DimVec3 > LeafDimensions
Definition: exec/CellLocatorTwoLevel.h:316
ReadPortal< viskores::Id > CellIds
Definition: exec/CellLocatorTwoLevel.h:321
viskores::Id CellId
Definition: exec/CellLocatorTwoLevel.h:179
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:43
#define VISKORES_EXEC
Definition: ExportMacros.h:59
viskores::ErrorCode PointInLeaf(const FloatVec3 &point, const viskores::Id &leafIdx, viskores::Id &cellId, FloatVec3 ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:244
viskores::Vec< viskores::FloatDefault, 3 > Vec3f
Vec3f corresponds to a 3-dimensional vector of floating point values.
Definition: Types.h:1064