Go to the documentation of this file.
10 #ifndef vtk_m_exec_CellLocatorTwoLevel_h
11 #define vtk_m_exec_CellLocatorTwoLevel_h
29 namespace cl_uniform_bins
42 DimensionType Padding;
55 return idx[0] + (dim[0] * (idx[1] + (dim[1] * idx[2])));
58 VTKM_EXEC inline Grid ComputeLeafGrid(
const DimVec3& idx,
const DimVec3& dim,
const Grid& l1Grid)
62 l1Grid.Origin + (
static_cast<FloatVec3
>(idx) * l1Grid.BinSize),
63 l1Grid.BinSize /
static_cast<FloatVec3
>(dim) };
66 template <
typename Po
intsVecType>
67 VTKM_EXEC inline Bounds ComputeCellBounds(
const PointsVecType& points)
72 CoordsType minp = points[0], maxp = points[0];
75 minp = vtkm::Min(minp, points[i]);
76 maxp = vtkm::Max(maxp, points[i]);
79 return { FloatVec3(minp), FloatVec3(maxp) };
91 template <
typename CellStructureType>
102 typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType;
107 template <
typename CellShapeTag,
typename CoordsType>
109 CellShapeTag cellShape,
110 CoordsType cellPoints,
114 auto bounds = vtkm::internal::cl_uniform_bins::ComputeCellBounds(cellPoints);
115 if (point[0] >= bounds.Min[0] && point[0] <= bounds.Max[0] && point[1] >= bounds.Min[1] &&
116 point[1] <= bounds.Max[1] && point[2] >= bounds.Min[2] && point[2] <= bounds.Max[2])
119 cellPoints, point, cellShape, parametricCoordinates));
120 inside = vtkm::exec::CellInside(parametricCoordinates, cellShape);
131 template <
typename CellSetType>
138 const CellSetType& cellSet,
142 : TopLevel(topLevelGrid)
143 , LeafDimensions(leafDimensions.PrepareForInput(device, token))
144 , LeafStartIndex(leafStartIndex.PrepareForInput(device, token))
145 , CellStartIndex(cellStartIndex.PrepareForInput(device, token))
146 , CellCount(cellCount.PrepareForInput(device, token))
147 , CellIds(cellIds.PrepareForInput(device, token))
148 , CellSet(cellSet.PrepareForInput(device,
152 , Coords(coords.GetDataAsMultiplexer().PrepareForInput(device, token))
166 return this->FindCellImpl(point, cellId, parametric, lastCell);
177 if ((lastCell.
CellId >= 0) && (lastCell.
CellId < this->CellSet.GetNumberOfElements()) &&
186 if ((lastCell.
LeafIdx >= 0) && (lastCell.
LeafIdx < this->CellCount.GetNumberOfValues()) &&
195 return this->FindCellImpl(point, cellId, parametric, lastCell);
204 auto indices = this->CellSet.GetIndices(cid);
208 auto status = PointInsideCell(point, this->CellSet.GetCellShape(cid), pts, pc, inside);
224 vtkm::Id start = this->CellStartIndex.Get(leafIdx);
225 vtkm::Id end = start + this->CellCount.Get(leafIdx);
227 for (
vtkm::Id i = start; i < end; ++i)
231 vtkm::Id cid = this->CellIds.Get(i);
250 using namespace vtkm::internal::cl_uniform_bins;
256 DimVec3 binId3 =
static_cast<DimVec3>((point - this->TopLevel.Origin) / this->TopLevel.BinSize);
257 if (binId3[0] >= 0 && binId3[0] < this->TopLevel.Dimensions[0] && binId3[1] >= 0 &&
258 binId3[1] < this->TopLevel.Dimensions[1] && binId3[2] >= 0 &&
259 binId3[2] < this->TopLevel.Dimensions[2])
261 vtkm::Id binId = ComputeFlatIndex(binId3, this->TopLevel.Dimensions);
263 auto ldim = this->LeafDimensions.Get(binId);
264 if (!ldim[0] || !ldim[1] || !ldim[2])
269 auto leafGrid = ComputeLeafGrid(binId3, ldim, this->TopLevel);
271 DimVec3 leafId3 =
static_cast<DimVec3>((point - leafGrid.Origin) / leafGrid.BinSize);
273 leafId3 = vtkm::Max(
DimVec3(0), vtkm::Min(ldim -
DimVec3(1), leafId3));
275 vtkm::Id leafStart = this->LeafStartIndex.Get(binId);
276 vtkm::Id leafIdx = leafStart + ComputeFlatIndex(leafId3, leafGrid.Dimensions);
304 #endif //vtk_m_exec_CellLocatorTwoLevel_h
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
Definition: exec/CellLocatorTwoLevel.h:92
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
CoordsPortalType Coords
Definition: exec/CellLocatorTwoLevel.h:299
typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType CoordsPortalType
Definition: exec/CellLocatorTwoLevel.h:102
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
CellStructureType CellSet
Definition: exec/CellLocatorTwoLevel.h:298
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
CellLocatorTwoLevel(const vtkm::internal::cl_uniform_bins::Grid &topLevelGrid, const vtkm::cont::ArrayHandle< DimVec3 > &leafDimensions, const vtkm::cont::ArrayHandle< vtkm::Id > &leafStartIndex, const vtkm::cont::ArrayHandle< vtkm::Id > &cellStartIndex, const vtkm::cont::ArrayHandle< vtkm::Id > &cellCount, const vtkm::cont::ArrayHandle< vtkm::Id > &cellIds, const CellSetType &cellSet, const vtkm::cont::CoordinateSystem &coords, vtkm::cont::DeviceAdapterId device, vtkm::cont::Token &token)
Definition: exec/CellLocatorTwoLevel.h:132
ReadPortal< DimVec3 > LeafDimensions
Definition: exec/CellLocatorTwoLevel.h:291
ReadPortal< vtkm::Id > CellStartIndex
Definition: exec/CellLocatorTwoLevel.h:294
@ Success
A successful operation.
T ComponentType
Type of the components in the vector.
Definition: VecTraits.h:71
int16_t Int16
Base type to use for 16-bit signed integer numbers.
Definition: Types.h:173
vtkm::Id CellId
Definition: exec/CellLocatorTwoLevel.h:158
vtkm::Id LeafIdx
Definition: exec/CellLocatorTwoLevel.h:159
typename StorageType::ReadPortalType ReadPortalType
The type of portal used when accessing data in a read-only mode.
Definition: ArrayHandle.h:312
typename vtkm::cont::ArrayHandle< T >::ReadPortalType ReadPortal
Definition: exec/CellLocatorTwoLevel.h:99
Manages a coordinate system for a DataSet.
Definition: CoordinateSystem.h:30
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
vtkm::ErrorCode FindCell(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:163
static constexpr vtkm::IdComponent GetNumberOfComponents(const T &)
Returns the number of components in the given vector.
Definition: VecTraits.h:94
vtkm::ErrorCode FindCell(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Definition: exec/CellLocatorTwoLevel.h:170
VecFromPortalPermute< IndexVecType, PortalType > make_VecFromPortalPermute(const IndexVecType *index, const PortalType &portal)
Definition: VecFromPortalPermute.h:166
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
ReadPortal< vtkm::Id > CellCount
Definition: exec/CellLocatorTwoLevel.h:295
@ CellNotFound
A cell matching some given criteria could not be found.
vtkm::Vec< vtkm::FloatDefault, 3 > Vec3f
Vec3f corresponds to a 3-dimensional vector of floating point values.
Definition: Types.h:1055
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::ErrorCode PointInCell(const vtkm::Vec3f &point, const vtkm::Id &cid, vtkm::Vec3f ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:200
vtkm::ErrorCode FindCellImpl(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Definition: exec/CellLocatorTwoLevel.h:245
static vtkm::ErrorCode PointInsideCell(FloatVec3 point, CellShapeTag cellShape, CoordsType cellPoints, FloatVec3 ¶metricCoordinates, bool &inside)
Definition: exec/CellLocatorTwoLevel.h:108
vtkm::ErrorCode PointInLeaf(const FloatVec3 &point, const vtkm::Id &leafIdx, vtkm::Id &cellId, FloatVec3 ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:219
#define VTKM_RETURN_ON_ERROR(call)
Definition: ErrorCode.h:202
vtkm::internal::cl_uniform_bins::Grid TopLevel
Definition: exec/CellLocatorTwoLevel.h:289
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
ReadPortal< vtkm::Id > LeafStartIndex
Definition: exec/CellLocatorTwoLevel.h:292
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
ReadPortal< vtkm::Id > CellIds
Definition: exec/CellLocatorTwoLevel.h:296
Definition: exec/CellLocatorTwoLevel.h:156