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:283
ErrorCode
Definition: ErrorCode.h:19
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
VTKM_EXEC VecFromPortalPermute< IndexVecType, PortalType > make_VecFromPortalPermute(const IndexVecType *index, const PortalType &portal)
Definition: VecFromPortalPermute.h:166
VTKM_EXEC vtkm::ErrorCode FindCell(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:163
CellStructureType CellSet
Definition: exec/CellLocatorTwoLevel.h:298
VTKM_EXEC vtkm::ErrorCode FindCellImpl(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Definition: exec/CellLocatorTwoLevel.h:245
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
ReadPortal< DimVec3 > LeafDimensions
Definition: exec/CellLocatorTwoLevel.h:291
ReadPortal< vtkm::Id > CellStartIndex
Definition: exec/CellLocatorTwoLevel.h:294
VTKM_EXEC vtkm::ErrorCode PointInLeaf(const FloatVec3 &point, const vtkm::Id &leafIdx, vtkm::Id &cellId, FloatVec3 ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:219
int16_t Int16
Definition: Types.h:158
vtkm::Id CellId
Definition: exec/CellLocatorTwoLevel.h:158
vtkm::Id LeafIdx
Definition: exec/CellLocatorTwoLevel.h:159
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
static VTKM_EXEC vtkm::ErrorCode PointInsideCell(FloatVec3 point, CellShapeTag cellShape, CoordsType cellPoints, FloatVec3 ¶metricCoordinates, bool &inside)
Definition: exec/CellLocatorTwoLevel.h:108
typename vtkm::cont::ArrayHandle< T >::ReadPortalType ReadPortal
Definition: exec/CellLocatorTwoLevel.h:99
Definition: CoordinateSystem.h:25
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
#define VTKM_CONT
Definition: ExportMacros.h:57
ReadPortal< vtkm::Id > CellCount
Definition: exec/CellLocatorTwoLevel.h:295
vtkm::Vec< vtkm::FloatDefault, 3 > Vec3f
Vec3f corresponds to a 3-dimensional vector of floating point values.
Definition: Types.h:1014
Definition: DeviceAdapterTag.h:52
VTKM_EXEC vtkm::ErrorCode FindCell(const FloatVec3 &point, vtkm::Id &cellId, FloatVec3 ¶metric, LastCell &lastCell) const
Definition: exec/CellLocatorTwoLevel.h:170
#define VTKM_RETURN_ON_ERROR(call)
Definition: ErrorCode.h:111
typename VecType::ComponentType ComponentType
Type of the components in the vector.
Definition: VecTraits.h:73
VTKM_CONT 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
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:92
ReadPortal< vtkm::Id > CellIds
Definition: exec/CellLocatorTwoLevel.h:296
VTKM_EXEC vtkm::ErrorCode PointInCell(const vtkm::Vec3f &point, const vtkm::Id &cid, vtkm::Vec3f ¶metric) const
Definition: exec/CellLocatorTwoLevel.h:200
Definition: exec/CellLocatorTwoLevel.h:156
static vtkm::IdComponent GetNumberOfComponents(const VecType &vec)
Number of components in the given vector.