Go to the documentation of this file.
20 #ifndef vtkm_m_worklet_OrientPointNormals_h
21 #define vtkm_m_worklet_OrientPointNormals_h
59 return vtkm::Dot(v1, v2) >= 0;
90 _6(
InputIndex pointId, _1 coord, _2 normal, _3 ranges, _4 activePoints, _5 visitedPoints);
92 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);
113 else if (val >= range.Max)
116 ref[dim] =
static_cast<NormalT
>(1);
138 BitFieldInOut activeCells,
139 BitFieldInOut visitedCells,
146 template <
typename CellListT,
typename ActiveCellsT,
typename VisitedCellsT>
148 ActiveCellsT& activeCells,
149 VisitedCellsT& visitedCells)
const
154 bool checkNotVisited =
false;
155 if (visitedCells.CompareExchangeBitAtomic(cellId, &checkNotVisited,
true))
157 activeCells.SetBitAtomic(cellId,
true);
172 BitFieldInOut activePoints,
173 BitFieldIn visitedPoints,
174 WholeArrayInOut refPoints,
183 template <
typename PointListT,
184 typename ActivePointsT,
185 typename VisitedPointsT,
188 ActivePointsT& activePoints,
189 VisitedPointsT& visitedPoints,
190 RefPointsT& refPoints)
const
198 const bool alreadyVisited = visitedPoints.GetBit(pointId);
215 const bool alreadyVisited = visitedPoints.GetBit(pointId);
218 bool checkNotActive =
false;
219 if (activePoints.CompareExchangeBitAtomic(pointId, &checkNotActive,
true))
221 refPoints.Set(pointId, refPtId);
239 WholeArrayInOut normals,
241 BitFieldInOut visitedPoints);
246 template <
typename NormalsPortal,
typename VisitedPo
intsT>
249 NormalsPortal& normals,
250 VisitedPointsT& visitedPoints)
const
252 visitedPoints.SetBitAtomic(ptId,
true);
254 using Normal =
typename NormalsPortal::ValueType;
255 Normal normal = normals.Get(ptId);
256 const Normal ref = normals.Get(refPtId);
257 if (
Align(normal, ref))
259 normals.Set(ptId, normal);
264 template <
typename CellSetType,
265 typename CoordsCompType,
266 typename CoordsStorageType,
267 typename PointNormalCompType,
268 typename PointNormalStorageType>
270 const CellSetType& cells,
282 const vtkm::Id numCells = cells.GetNumberOfCells();
285 "OrientPointNormals worklet (%lld points, %lld cells)",
286 static_cast<vtkm::Int64
>(coords.GetNumberOfValues()),
287 static_cast<vtkm::Int64
>(numCells));
318 MarkSourcePoints dispatcher;
319 dispatcher.Invoke(coords, pointNormals, ranges, activePoints, visitedPoints, refPoints);
322 for (
size_t iter = 1;; ++iter)
329 "MarkActiveCells from " << numActive <<
" active points.");
331 dispatcher.Invoke(cells, activeCellBits, visitedCellBits, activePoints);
339 "MarkActivePoints from " << numActive <<
" active cells.");
341 dispatcher.Invoke(cells, activePointBits, visitedPointBits, refPoints, activeCells);
347 if (numActivePoints == 0)
354 "Iteration " << iter <<
": Processing " << numActivePoints <<
" normals.");
359 dispatcher.Invoke(refPoints, pointNormals, visitedPointBits);
368 #endif // vtkm_m_worklet_OrientPointNormals_h
void(InputIndex ptId, _1 refPtId, _2 normals, _3 visitedPoints) ExecutionSignature
Definition: OrientPointNormals.h:242
#define VTKM_LOG_SCOPE(level,...)
Definition: Logging.h:265
Manages an array-worth of data.
Definition: ArrayHandle.h:283
void(FieldIn coords, FieldInOut normals, WholeArrayIn ranges, FieldOut activePoints, FieldOut visitedPoints, FieldOut refPoints) ControlSignature
Definition: OrientPointNormals.h:88
#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
_5(PointIndices points, _2 activePoints, _3 visitedPoints, _4 refPoints) ExecutionSignature
Definition: OrientPointNormals.h:179
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
void(CellSetIn cellSet, BitFieldInOut activePoints, BitFieldIn visitedPoints, WholeArrayInOut refPoints, FieldInOutCell activeCells) ControlSignature
Definition: OrientPointNormals.h:175
Definition: OrientPointNormals.h:235
VTKM_EXEC void operator()(const vtkm::Id ptId, const vtkm::Id refPtId, NormalsPortal &normals, VisitedPointsT &visitedPoints) const
Definition: OrientPointNormals.h:247
static VTKM_EXEC bool Align(vtkm::Vec< T, 3 > &normal, const vtkm::Vec< T, 3 > &ref)
Definition: OrientPointNormals.h:65
VTKM_EXEC vtkm::Id operator()(const vtkm::Id pointId, const vtkm::Vec< CoordT, 3 > &point, vtkm::Vec< NormalT, 3 > &normal, const RangePortal &ranges, bool &isActive, bool &isVisited) const
Definition: OrientPointNormals.h:93
Definition: OrientPointNormals.h:133
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
void(CellSetIn cellSet, BitFieldInOut activeCells, BitFieldInOut visitedCells, FieldInOutPoint activePoints) ControlSignature
Definition: OrientPointNormals.h:140
static VTKM_EXEC bool SameDirection(const vtkm::Vec< T, 3 > &v1, const vtkm::Vec< T, 3 > &v2)
Definition: OrientPointNormals.h:57
Orients normals to point outside of the dataset.
Definition: OrientPointNormals.h:51
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
Definition: Normalize.h:22
Definition: OrientPointNormals.h:168
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
A control signature tag for input fields.
Definition: WorkletMapField.h:49
static constexpr vtkm::Id INVALID_ID
Definition: OrientPointNormals.h:53
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
#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_EXEC bool operator()(const CellListT &cells, ActiveCellsT &activeCells, VisitedCellsT &visitedCells) const
Definition: OrientPointNormals.h:147
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
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
A short fixed-length array.
Definition: Types.h:767
Definition: BitField.h:497
void(FieldIn refIds, WholeArrayInOut normals, BitFieldInOut visitedPoints) ControlSignature
Definition: OrientPointNormals.h:241
_6(InputIndex pointId, _1 coord, _2 normal, _3 ranges, _4 activePoints, _5 visitedPoints) ExecutionSignature
Definition: OrientPointNormals.h:90
VTKM_EXEC bool operator()(const PointListT &points, ActivePointsT &activePoints, VisitedPointsT &visitedPoints, RefPointsT &refPoints) const
Definition: OrientPointNormals.h:187
Mask using a given array of indices to include in the output.
Definition: MaskIndices.h:30
Definition: OrientPointNormals.h:80
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.
_4(CellIndices cells, _2 activeCells, _3 visitedCells) ExecutionSignature
Definition: OrientPointNormals.h:141
FieldInOut FieldInOutPoint
Definition: WorkletMapTopology.h:284
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
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)
Definition: OrientPointNormals.h:269
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
FieldInOut FieldInOutCell
Definition: WorkletMapTopology.h:265