Go to the documentation of this file.
20 #ifndef vtkm_m_worklet_OrientPointAndCellNormals_h
21 #define vtkm_m_worklet_OrientPointAndCellNormals_h
61 return vtkm::Dot(v1, v2) >= 0;
91 void(_1 coord, _2 pointNormal, _3 ranges, _4 activePoints, _5 visitedPoints);
93 template <
typename CoordT,
typename NormalT,
typename RangePortal>
96 const RangePortal& ranges,
98 bool& isVisited)
const
102 const auto& range = ranges.Get(dim);
103 const auto val =
static_cast<decltype(range.Min)
>(point[dim]);
104 if (val <= range.Min)
107 ref[dim] =
static_cast<NormalT
>(-1);
108 Align(pointNormal, ref);
113 else if (val >= range.Max)
116 ref[dim] =
static_cast<NormalT
>(1);
117 Align(pointNormal, ref);
135 BitFieldInOut activeCells,
136 BitFieldInOut visitedCells,
142 template <
typename CellList,
typename ActiveCellsBitPortal,
typename VisitedCellsBitPortal>
144 ActiveCellsBitPortal& activeCells,
145 VisitedCellsBitPortal& visitedCells)
const
151 if (!visitedCells.OrBitAtomic(cellId,
true))
153 activeCells.SetBitAtomic(cellId,
true);
167 WholeArrayIn pointNormals,
168 WholeArrayInOut cellNormals,
169 BitFieldIn visitedPoints);
178 template <
typename PointList,
179 typename PointNormalsPortal,
180 typename CellNormalsPortal,
181 typename VisitedPointsBitPortal>
184 const PointNormalsPortal& pointNormals,
185 CellNormalsPortal& cellNormals,
186 const VisitedPointsBitPortal& visitedPoints)
const
193 const vtkm::Id pointId = pointIds[p];
194 if (visitedPoints.GetBit(pointId))
205 const auto refNormal = pointNormals.Get(refPointId);
206 auto normal = cellNormals.Get(cellId);
207 if (
Align(normal, refNormal))
209 cellNormals.Set(cellId, normal);
220 BitFieldInOut activePoints,
221 BitFieldInOut visitedPoints,
227 template <
typename Po
intList,
typename ActivePo
intsBitPortal,
typename VisitedPo
intsBitPortal>
229 ActivePointsBitPortal& activePoints,
230 VisitedPointsBitPortal& visitedPoints)
const
235 const vtkm::Id pointId = pointIds[p];
236 if (!visitedPoints.OrBitAtomic(pointId,
true))
238 activePoints.SetBitAtomic(pointId,
true);
252 WholeArrayInOut pointNormals,
253 WholeArrayIn cellNormals,
254 BitFieldIn visitedCells);
263 template <
typename CellList,
264 typename CellNormalsPortal,
265 typename PointNormalsPortal,
266 typename VisitedCellsBitPortal>
269 PointNormalsPortal& pointNormals,
270 const CellNormalsPortal& cellNormals,
271 const VisitedCellsBitPortal& visitedCells)
const
279 if (visitedCells.GetBit(cellId))
290 const auto refNormal = cellNormals.Get(refCellId);
291 auto normal = pointNormals.Get(pointId);
292 if (
Align(normal, refNormal))
294 pointNormals.Set(pointId, normal);
299 template <
typename CellSetType,
300 typename CoordsCompType,
301 typename CoordsStorageType,
302 typename PointNormalCompType,
303 typename PointNormalStorageType,
304 typename CellNormalCompType,
305 typename CellNormalStorageType>
307 const CellSetType& cells,
321 const vtkm::Id numCells = cells.GetNumberOfCells();
324 "OrientPointAndCellNormals worklet (%lld points, %lld cells)",
325 static_cast<vtkm::Int64
>(coords.GetNumberOfValues()),
326 static_cast<vtkm::Int64
>(numCells));
352 MarkSourcePoints dispatcher;
353 dispatcher.Invoke(coords, pointNormals, ranges, activePoints, visitedPoints);
356 for (
size_t iter = 1;; ++iter)
363 "MarkActiveCells from " << numActive <<
" active points.");
365 dispatcher.Invoke(cells, activeCellBits, visitedCellBits, activePoints);
370 if (numActiveCells == 0)
373 "Iteration " << iter <<
": Traversal complete; no more cells");
378 "Iteration " << iter <<
": Processing " << numActiveCells <<
" cell normals.");
383 dispatcher.Invoke(cells, pointNormals, cellNormals, visitedPointBits);
391 "MarkActivePoints from " << numActive <<
" active cells.");
393 dispatcher.Invoke(cells, activePointBits, visitedPointBits, activeCells);
399 if (numActivePoints == 0)
402 "Iteration " << iter <<
": Traversal complete; no more points");
407 "Iteration " << iter <<
": Processing " << numActivePoints <<
" point normals.");
412 dispatcher.Invoke(cells, pointNormals, cellNormals, visitedCellBits);
421 #endif // vtkm_m_worklet_OrientPointAndCellNormals_h
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
Manages an array-worth of data.
Definition: ArrayHandle.h:283
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
static VTKM_CONT vtkm::Id BitFieldToUnorderedSet(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::BitField &bits, vtkm::cont::ArrayHandle< Id, IndicesStorage > &indices)
Definition: Algorithm.h:389
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
A control signature tag for output fields.
Definition: WorkletMapField.h:60
Orients normals to point outside of the dataset.
Definition: OrientPointAndCellNormals.h:53
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_EXEC void operator()(const PointList &pointIds, const vtkm::Id cellId, const PointNormalsPortal &pointNormals, CellNormalsPortal &cellNormals, const VisitedPointsBitPortal &visitedPoints) const
Definition: OrientPointAndCellNormals.h:182
Definition: OrientPointAndCellNormals.h:248
_4(PointIndices pointIds, _2 activePoint, _3 visitedPoint) ExecutionSignature
Definition: OrientPointAndCellNormals.h:223
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
static VTKM_EXEC bool Align(vtkm::Vec< T, 3 > &normal, const vtkm::Vec< T, 3 > &ref)
Definition: OrientPointAndCellNormals.h:67
Definition: OrientPointAndCellNormals.h:82
static VTKM_EXEC bool SameDirection(const vtkm::Vec< T, 3 > &v1, const vtkm::Vec< T, 3 > &v2)
Definition: OrientPointAndCellNormals.h:59
Definition: OrientPointAndCellNormals.h:131
_4(CellIndices cellIds, _2 activeCells, _3 visitedCells) ExecutionSignature
Definition: OrientPointAndCellNormals.h:138
void(CellIndices cellIds, InputIndex pointId, _2 pointNormals, _3 cellNormals, _4 visitedCells) ExecutionSignature
Definition: OrientPointAndCellNormals.h:259
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
Base class for worklets that map from Cells to Points.
Definition: WorkletMapTopology.h:274
void(CellSetIn cells, WholeArrayInOut pointNormals, WholeArrayIn cellNormals, BitFieldIn visitedCells) ControlSignature
Definition: OrientPointAndCellNormals.h:254
Definition: OrientPointAndCellNormals.h:163
void(_1 coord, _2 pointNormal, _3 ranges, _4 activePoints, _5 visitedPoints) ExecutionSignature
Definition: OrientPointAndCellNormals.h:91
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
A control signature tag for input fields.
Definition: WorkletMapField.h:49
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
Definition: OrientPointAndCellNormals.h:216
void(FieldIn coords, FieldInOut pointNormals, WholeArrayIn ranges, FieldOut activePoints, FieldOut visitedPoints) ControlSignature
Definition: OrientPointAndCellNormals.h:89
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:71
VTKM_CONT vtkm::cont::ArrayHandleBitField make_ArrayHandleBitField(const vtkm::cont::BitField &bitField)
Definition: ArrayHandleBitField.h:196
VTKM_CONT void AllocateAndFill(vtkm::Id numberOfBits, ValueType value, vtkm::cont::Token &token) const
Allocate the requested number of bits and fill with the requested bit or word.
Definition: BitField.h:575
VTKM_EXEC void operator()(const vtkm::Vec< CoordT, 3 > &point, vtkm::Vec< NormalT, 3 > &pointNormal, const RangePortal &ranges, bool &isActive, bool &isVisited) const
Definition: OrientPointAndCellNormals.h:94
IncidentElementIndices CellIndices
Definition: WorkletMapTopology.h:288
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:261
static constexpr vtkm::Id INVALID_ID
Definition: OrientPointAndCellNormals.h:55
A short fixed-length array.
Definition: Types.h:767
VTKM_EXEC bool operator()(const PointList &pointIds, ActivePointsBitPortal &activePoints, VisitedPointsBitPortal &visitedPoints) const
Definition: OrientPointAndCellNormals.h:228
VTKM_EXEC bool operator()(const CellList &cellIds, ActiveCellsBitPortal &activeCells, VisitedCellsBitPortal &visitedCells) const
Definition: OrientPointAndCellNormals.h:143
Definition: BitField.h:497
void(CellSetIn cells, WholeArrayIn pointNormals, WholeArrayInOut cellNormals, BitFieldIn visitedPoints) ControlSignature
Definition: OrientPointAndCellNormals.h:169
void(CellSetIn cell, BitFieldInOut activeCells, BitFieldInOut visitedCells, FieldInOutPoint activePoints) ControlSignature
Definition: OrientPointAndCellNormals.h:137
Mask using a given array of indices to include in the output.
Definition: MaskIndices.h:30
void(CellSetIn cell, BitFieldInOut activePoints, BitFieldInOut visitedPoints, FieldInOutCell activeCells) ControlSignature
Definition: OrientPointAndCellNormals.h:222
VTKM_CONT_EXPORT vtkm::cont::ArrayHandle< vtkm::Range > ArrayRangeCompute(const vtkm::cont::UnknownArrayHandle &array, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
Compute the range of the data in an array handle.
FieldInOut FieldInOutPoint
Definition: WorkletMapTopology.h:284
VTKM_EXEC void operator()(const CellList &cellIds, const vtkm::Id pointId, PointNormalsPortal &pointNormals, const CellNormalsPortal &cellNormals, const VisitedCellsBitPortal &visitedCells) const
Definition: OrientPointAndCellNormals.h:267
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
void(PointIndices pointIds, InputIndex cellId, _2 pointNormals, _3 cellNormals, _4 visitedPoints) ExecutionSignature
Definition: OrientPointAndCellNormals.h:174
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
static VTKM_CONT void Run(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< PointNormalCompType, 3 >, PointNormalStorageType > &pointNormals, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientPointAndCellNormals.h:306
FieldInOut FieldInOutCell
Definition: WorkletMapTopology.h:265