Go to the documentation of this file.
20 #ifndef vtkm_m_worklet_OrientCellNormals_h
21 #define vtkm_m_worklet_OrientCellNormals_h
61 return vtkm::Dot(v1, v2) >= 0;
87 template <
typename CoordT,
typename RangePortal>
90 bool isActive =
false;
93 const auto& range = ranges.Get(dim);
94 const auto val =
static_cast<decltype(range.Min)
>(point[dim]);
95 if (val <= range.Min || val >= range.Max)
114 WholeArrayInOut cellNormals,
116 BitFieldInOut activeCells,
117 BitFieldInOut visitedCells,
131 template <
typename CellList,
133 typename RangePortal,
134 typename CellNormalPortal,
135 typename ActiveCellsBitPortal,
136 typename VisitedCellsBitPortal>
139 const RangePortal& ranges,
140 CellNormalPortal& cellNormals,
141 ActiveCellsBitPortal& activeCells,
142 VisitedCellsBitPortal& visitedCells,
144 bool& pointIsVisited)
const
146 using NormalType =
typename CellNormalPortal::ValueType;
148 "Cell Normals expected to have 3 components.");
149 using NormalCompType =
typename NormalType::ComponentType;
152 const NormalType refNormal = [&]() -> NormalType {
153 NormalType normal{ NormalCompType{ 0 } };
154 NormalCompType numNormals{ 0 };
157 const auto range = ranges.Get(dim);
158 const auto val =
static_cast<decltype(range.Min)
>(coord[dim]);
159 if (val <= range.Min)
161 NormalType compNormal{ NormalCompType{ 0 } };
162 compNormal[dim] = NormalCompType{ -1 };
163 normal += compNormal;
166 else if (val >= range.Max)
168 NormalType compNormal{ NormalCompType{ 0 } };
169 compNormal[dim] = NormalCompType{ 1 };
170 normal += compNormal;
175 VTKM_ASSERT(
"Source point is not on a boundary?" && numNormals > 0.5);
176 return normal / numNormals;
186 if (!visitedCells.OrBitAtomic(cellId,
true))
188 activeCells.SetBitAtomic(cellId,
true);
190 NormalType cellNormal = cellNormals.Get(cellId);
191 if (
Align(cellNormal, refNormal))
193 cellNormals.Set(cellId, cellNormal);
199 pointIsActive =
false;
200 pointIsVisited =
true;
210 BitFieldInOut activePoints,
211 BitFieldInOut visitedPoints,
217 template <
typename Po
intList,
typename ActivePo
intsBitPortal,
typename VisitedPo
intsBitPortal>
219 ActivePointsBitPortal& activePoints,
220 VisitedPointsBitPortal& visitedPoints)
const
225 const vtkm::Id pointId = pointIds[p];
226 if (!visitedPoints.OrBitAtomic(pointId,
true))
228 activePoints.SetBitAtomic(pointId,
true);
244 WholeArrayOut refCells,
245 BitFieldInOut activeCells,
246 BitFieldIn visitedCells,
255 template <
typename CellList,
256 typename RefCellPortal,
257 typename ActiveCellBitPortal,
258 typename VisitedCellBitPortal>
260 RefCellPortal& refCells,
261 ActiveCellBitPortal& activeCells,
262 const VisitedCellBitPortal& visitedCells)
const
271 if (visitedCells.GetBit(cellId))
283 if (!visitedCells.GetBit(cellId))
285 if (!activeCells.OrBitAtomic(cellId,
true))
287 refCells.Set(cellId, refCellId);
303 WholeArrayInOut cellNormals,
309 template <
typename CellNormalsPortal>
312 CellNormalsPortal& cellNormals)
const
314 const auto refNormal = cellNormals.Get(refCellId);
315 auto normal = cellNormals.Get(cellId);
316 if (
Align(normal, refNormal))
318 cellNormals.Set(cellId, normal);
326 template <
typename CellSetType,
327 typename CoordsCompType,
328 typename CoordsStorageType,
329 typename CellNormalCompType,
330 typename CellNormalStorageType>
332 const CellSetType& cells,
339 const vtkm::Id numCells = cells.GetNumberOfCells();
342 "OrientCellNormals worklet (%lld points, %lld cells)",
343 static_cast<vtkm::Int64
>(numPoints),
344 static_cast<vtkm::Int64
>(numCells));
370 vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(
INVALID_ID, numCells), refCells);
385 "ProcessSourceCells from " << numActive <<
" source points.");
398 for (
size_t iter = 1;; ++iter)
405 "MarkActivePoints from " << numActive <<
" active cells.");
419 "MarkActiveCells from " << numActive <<
" active points.");
431 if (numActiveCells == 0)
438 "Iteration " << iter <<
": Processing " << numActiveCells <<
" normals.");
455 #endif // vtkm_m_worklet_OrientCellNormals_h
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
Manages an array-worth of data.
Definition: ArrayHandle.h:283
VTKM_EXEC bool operator()(const vtkm::Id cellId, const vtkm::Id refCellId, CellNormalsPortal &cellNormals) const
Definition: OrientCellNormals.h:310
VTKM_EXEC bool operator()(const PointList &pointIds, ActivePointsBitPortal &activePoints, VisitedPointsBitPortal &visitedPoints) const
Definition: OrientCellNormals.h:218
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
static VTKM_CONT void Run(const CellSetType &cells, const vtkm::cont::ArrayHandle< vtkm::Vec< CoordsCompType, 3 >, CoordsStorageType > &coords, vtkm::cont::ArrayHandle< vtkm::Vec< CellNormalCompType, 3 >, CellNormalStorageType > &cellNormals)
Definition: OrientCellNormals.h:331
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
Definition: OrientCellNormals.h:240
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
_5(CellIndices cellIds, _2 refCells, _3 activeCells, _4 visitedCells) ExecutionSignature
Definition: OrientCellNormals.h:251
Definition: OrientCellNormals.h:108
void(FieldIn coords, WholeArrayIn ranges, FieldOut activePoints) ControlSignature
Definition: OrientCellNormals.h:84
Orients normals to point outside of the dataset.
Definition: OrientCellNormals.h:53
static VTKM_EXEC bool Align(vtkm::Vec< T, 3 > &normal, const vtkm::Vec< T, 3 > &ref)
Definition: OrientCellNormals.h:67
VTKM_EXEC bool operator()(const CellList &cellIds, RefCellPortal &refCells, ActiveCellBitPortal &activeCells, const VisitedCellBitPortal &visitedCells) const
Definition: OrientCellNormals.h:259
void(CellIndices cellIds, _2 coords, _3 ranges, _4 cellNormals, _5 activeCells, _6 visitedCells, _7 activePoints, _8 visitedPoints) ExecutionSignature
Definition: OrientCellNormals.h:127
static VTKM_CONT bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:410
Definition: OrientCellNormals.h:206
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
void(CellSetIn cell, BitFieldInOut activePoints, BitFieldInOut visitedPoints, FieldInOutCell activeCells) ControlSignature
Definition: OrientCellNormals.h:212
Definition: OrientCellNormals.h:81
_3(InputIndex cellId, _1 refCellId, _2 cellNormals) ExecutionSignature
Definition: OrientCellNormals.h:305
Base class for worklets that map from Cells to Points.
Definition: WorkletMapTopology.h:274
A control signature tag for input fields.
Definition: WorkletMapField.h:49
_3(_1 coord, _2 ranges) ExecutionSignature
Definition: OrientCellNormals.h:85
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
#define VTKM_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:18
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
VTKM_EXEC bool operator()(const vtkm::Vec< CoordT, 3 > &point, const RangePortal &ranges) const
Definition: OrientCellNormals.h:88
static constexpr vtkm::Id INVALID_ID
Definition: OrientCellNormals.h:55
#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
void(FieldIn refCells, WholeArrayInOut cellNormals, FieldInOut visitedCells) ControlSignature
Definition: OrientCellNormals.h:304
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
FieldInVisit FieldInPoint
Definition: WorkletMapTopology.h:280
A short fixed-length array.
Definition: Types.h:767
_4(PointIndices pointIds, _2 activePoints, _3 visitedPoints) ExecutionSignature
Definition: OrientCellNormals.h:213
Definition: BitField.h:497
void(CellSetIn cells, FieldInPoint coords, WholeArrayIn ranges, WholeArrayInOut cellNormals, BitFieldInOut activeCells, BitFieldInOut visitedCells, FieldInOutPoint activePoints, FieldInOutPoint visitedPoints) ControlSignature
Definition: OrientCellNormals.h:119
Mask using a given array of indices to include in the output.
Definition: MaskIndices.h:30
The VecTraits class gives several static members that define how to use a given type as a vector.
Definition: VecTraits.h:66
static VTKM_EXEC bool SameDirection(const vtkm::Vec< T, 3 > &v1, const vtkm::Vec< T, 3 > &v2)
Definition: OrientCellNormals.h:59
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.
VTKM_EXEC void operator()(const CellList &cellIds, const vtkm::Vec< CoordComp, 3 > &coord, const RangePortal &ranges, CellNormalPortal &cellNormals, ActiveCellsBitPortal &activeCells, VisitedCellsBitPortal &visitedCells, bool &pointIsActive, bool &pointIsVisited) const
Definition: OrientCellNormals.h:137
FieldInOut FieldInOutPoint
Definition: WorkletMapTopology.h:284
Definition: OrientCellNormals.h:299
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
void(CellSetIn cells, WholeArrayOut refCells, BitFieldInOut activeCells, BitFieldIn visitedCells, FieldInOutPoint activePoints) ControlSignature
Definition: OrientCellNormals.h:247
FieldInOut FieldInOutCell
Definition: WorkletMapTopology.h:265