Go to the documentation of this file.
21 #ifndef vtkm_m_worklet_TriangleWinding_h
22 #define vtkm_m_worklet_TriangleWinding_h
67 template <
typename NormalCompType,
typename CellPo
intsType,
typename CoordsPortal>
69 CellPointsType& cellPoints,
70 const CoordsPortal& coords)
const
73 if (cellPoints.GetNumberOfComponents() != 3)
80 const NormalType p0 = coords.Get(cellPoints[0]);
81 const NormalType p1 = coords.Get(cellPoints[1]);
82 const NormalType p2 = coords.Get(cellPoints[2]);
83 const NormalType v01 = p1 - p0;
84 const NormalType v02 = p2 - p0;
85 const NormalType triangleNormal =
vtkm::Cross(v01, v02);
86 if (vtkm::Dot(cellNormal, triangleNormal) < 0)
90 cellPoints[1] = cellPoints[2];
102 template <
typename CellShapeTag>
108 cellSizeOut = cellSizeIn;
109 cellShapeOut = cellShapeIn.Id;
121 template <
typename InputIds,
typename Coords,
typename Normal,
typename OutputIds>
123 const Coords& coords,
125 OutputIds& outputIds)
const
127 VTKM_ASSERT(inputIds.GetNumberOfComponents() == outputIds.GetNumberOfComponents());
130 if (inputIds.GetNumberOfComponents() != 3)
137 outputIds[i] = inputIds[i];
142 const Normal p0 = coords.Get(inputIds[0]);
143 const Normal p1 = coords.Get(inputIds[1]);
144 const Normal p2 = coords.Get(inputIds[2]);
145 const Normal v01 = p1 - p0;
146 const Normal v02 = p2 - p0;
148 if (vtkm::Dot(normal, triangleNormal) < 0)
150 outputIds[0] = inputIds[0];
151 outputIds[1] = inputIds[2];
152 outputIds[2] = inputIds[1];
156 outputIds[0] = inputIds[0];
157 outputIds[1] = inputIds[1];
158 outputIds[2] = inputIds[2];
168 template <
typename CellSetType,
typename CoordsType,
typename CellNormalsType>
170 const CoordsType& coords,
171 const CellNormalsType& cellNormals,
174 const auto numCells = cellSet.GetNumberOfCells();
177 this->Result = cellSet;
188 invoker(worklet, cellSet, cellShapes, numIndices);
200 auto rangeSizes = rangeHandleSizes.ReadPortal().Get(0);
201 auto rangeShapes = rangeHandleShapes.ReadPortal().Get(0);
203 const bool sameSize = vtkm::Abs(rangeSizes.Max - rangeSizes.Min) < 0.5;
204 const bool sameShape = vtkm::Abs(rangeShapes.Max - rangeShapes.Min) < 0.5;
206 if (sameSize && sameShape)
209 cellShape =
static_cast<vtkm::UInt8>(rangeShapes.Min + 0.5);
222 auto offsets = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, cellSize, numCells);
226 invoker(worklet, cellSet, coords, cellNormals, connGroupVec);
229 outCells.
Fill(cellSet.GetNumberOfPoints(), cellShape, cellSize, conn);
230 this->Result = outCells;
246 invoker(worklet, cellSet, coords, cellNormals, connGroupVec);
249 outCells.
Fill(cellSet.GetNumberOfPoints(), cellShapes, conn, offsets);
250 this->Result = outCells;
255 template <
typename S,
typename C,
typename O,
typename CoordsType,
typename CellNormalsType>
257 const CoordsType& coords,
258 const CellNormalsType& cellNormals,
266 this->Result = cellSet;
277 const auto& offsets =
281 WindToCellNormals dispatcher;
282 dispatcher.Invoke(cellNormals, cells, coords);
289 this->Result = newCells;
293 template <
typename C,
typename CoordsType,
typename CellNormalsType>
295 const CoordsType& coords,
296 const CellNormalsType& cellNormals,
301 const auto numCells = cellSet.GetNumberOfCells();
304 this->Result = cellSet;
315 const auto& offsets =
319 WindToCellNormals dispatcher;
320 dispatcher.Invoke(cellNormals, cells, coords);
323 newCells.
Fill(cellSet.GetNumberOfPoints(),
325 cellSet.GetNumberOfPointsInCell(0),
328 this->Result = newCells;
332 template <
typename CellSetType,
typename CoordsType,
typename CellNormalsType>
334 const CoordsType& coords,
335 const CellNormalsType& cellNormals)
348 #endif // vtkm_m_worklet_TriangleWinding_h
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
void(CellSetIn cellsIn, WholeArrayIn coords, FieldInCell cellNormals, FieldOutCell cellsOut) ControlSignature
Definition: TriangleWinding.h:118
void(CellSetIn cells, FieldOutCell shapes, FieldOutCell sizes) ControlSignature
Definition: TriangleWinding.h:99
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_CONT void operator()(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals,...)
Definition: TriangleWinding.h:169
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
VTKM_CONT void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:465
static VTKM_CONT vtkm::cont::UnknownCellSet Run(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals)
Definition: TriangleWinding.h:333
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
Definition: CastAndCall.h:34
VTKM_CONT void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:552
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
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:47
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
VTKM_DEPRECATED_SUPPRESS_BEGIN VTKM_CONT vtkm::UInt8 GetCellShape(vtkm::Id vtkmNotUsed(cellIndex)) const override
Definition: CellSetSingleType.h:215
Definition: TriangleWinding.h:62
Definition: TriangleWinding.h:97
const VTKM_CONT ConnectivityChooser< VisitTopology, IncidentTopology >::OffsetsArrayType & GetOffsetsArray(VisitTopology, IncidentTopology) const
VTKM_EXEC void operator()(const InputIds &inputIds, const Coords &coords, const Normal &normal, OutputIds &outputIds) const
Definition: TriangleWinding.h:122
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
VTKM_CONT void operator()(const vtkm::cont::CellSetExplicit< S, C, O > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:256
Definition: Normalize.h:22
A control signature tag for input fields.
Definition: WorkletMapField.h:49
void(CellShape, PointCount, _2, _3) ExecutionSignature
Definition: TriangleWinding.h:100
VTKM_EXEC_CONT vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const vtkm::Vec< T, 3 > &x, const vtkm::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:177
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
void(_1 cellNormal, _2 cellPoints, _3 coords) ExecutionSignature
Definition: TriangleWinding.h:65
VTKM_CONT vtkm::cont::ArrayHandleGroupVecVariable< ComponentsArrayHandleType, OffsetsArrayHandleType > make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType &componentsArray, const OffsetsArrayHandleType &offsetsArray)
make_ArrayHandleGroupVecVariable is convenience function to generate an ArrayHandleGroupVecVariable.
Definition: ArrayHandleGroupVecVariable.h:308
VTKM_EXEC void operator()(const vtkm::Vec< NormalCompType, 3 > &cellNormal, CellPointsType &cellPoints, const CoordsPortal &coords) const
Definition: TriangleWinding.h:68
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:71
VTKM_CONT void Fill(vtkm::Id numPoints, const vtkm::cont::ArrayHandle< vtkm::UInt8, ShapesStorageTag > &cellTypes, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity, const vtkm::cont::ArrayHandle< vtkm::Id, OffsetsStorageTag > &offsets)
Second method to add cells – all at once.
uint8_t UInt8
Definition: Types.h:157
vtkm::cont::UnknownCellSet Result
Definition: TriangleWinding.h:165
VTKM_CONT void operator()(const vtkm::cont::CellSetSingleType< C > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:294
Definition: TriangleWinding.h:163
VTKM_CONT vtkm::Id GetNumberOfPoints() const override
A short fixed-length array.
Definition: Types.h:767
VTKM_CONT_EXPORT void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
void(FieldIn cellNormals, FieldInOut cellPoints, WholeArrayIn coords) ControlSignature
Definition: TriangleWinding.h:64
Definition: TriangleWinding.h:113
const VTKM_CONT ConnectivityChooser< VisitTopology, IncidentTopology >::ShapesArrayType & GetShapesArray(VisitTopology, IncidentTopology) const
void(PointIndices, _2, _3, _4) ExecutionSignature
Definition: TriangleWinding.h:119
Definition: CastAndCall.h:36
VTKM_EXEC void operator()(const CellShapeTag cellShapeIn, const vtkm::IdComponent cellSizeIn, vtkm::UInt8 &cellShapeOut, vtkm::IdComponent &cellSizeOut) const
Definition: TriangleWinding.h:103
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
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_CONT void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Definition: CellSetSingleType.h:186
VTKM_CONT vtkm::Id GetNumberOfCells() const override
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
const VTKM_CONT ConnectivityChooser< VisitTopology, IncidentTopology >::ConnectivityArrayType & GetConnectivityArray(VisitTopology, IncidentTopology) const
This worklet ensures that triangle windings are consistent with provided cell normals.
Definition: TriangleWinding.h:58
FieldInVisit FieldInCell
Definition: WorkletMapTopology.h:261
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263