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 operator()(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals,...)
Definition: TriangleWinding.h:169
An execution signature tag to get the shape of the visited cell.
Definition: WorkletMapTopology.h:396
void(CellSetIn cellsIn, WholeArrayIn coords, FieldInCell cellNormals, FieldOutCell cellsOut) ControlSignature
Definition: TriangleWinding.h:118
const ConnectivityChooser< VisitTopology, IncidentTopology >::OffsetsArrayType & GetOffsetsArray(VisitTopology, IncidentTopology) const
Returns the vtkm::cont::ArrayHandle containing the offsets into theconnectivity information.
void(CellSetIn cells, FieldOutCell shapes, FieldOutCell sizes) ControlSignature
Definition: TriangleWinding.h:99
void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Set all the cells of the mesh.
Definition: CellSetSingleType.h:200
#define VTKM_EXEC
Definition: ExportMacros.h:51
void operator()(const CellShapeTag cellShapeIn, const vtkm::IdComponent cellSizeIn, vtkm::UInt8 &cellShapeOut, vtkm::IdComponent &cellSizeOut) const
Definition: TriangleWinding.h:103
Groups connected points that have the same field value.
Definition: Atomic.h:19
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:577
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:34
const ConnectivityChooser< VisitTopology, IncidentTopology >::ConnectivityArrayType & GetConnectivityArray(VisitTopology, IncidentTopology) const
Returns the vtkm::cont::ArrayHandle containing the connectivity information.
vtkm::Id GetNumberOfPoints() const override
A control signature tag for input connectivity.
Definition: WorkletMapTopology.h:280
vtkm::UInt8 GetCellShape(vtkm::Id) const override
Definition: CellSetSingleType.h:229
static vtkm::cont::UnknownCellSet Run(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals)
Definition: TriangleWinding.h:333
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
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)
Set all the cells of the mesh.
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:180
A control signature tag for input fields on the cells of the topology.
Definition: WorkletMapTopology.h:290
Definition: TriangleWinding.h:62
void ConvertNumComponentsToOffsets(const vtkm::cont::UnknownArrayHandle &numComponentsArray, vtkm::cont::ArrayHandle< vtkm::Id > &offsetsArray, vtkm::Id &componentsArraySize, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
Definition: TriangleWinding.h:97
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:25
vtkm::Id GetNumberOfCells() const override
Definition: Normalize.h:22
A control signature tag for input fields.
Definition: WorkletMapField.h:60
void(CellShape, PointCount, _2, _3) ExecutionSignature
Definition: TriangleWinding.h:100
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:256
void(_1 cellNormal, _2 cellPoints, _3 coords) ExecutionSignature
Definition: TriangleWinding.h:65
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:99
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:584
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
A control signature tag for output fields.
Definition: WorkletMapTopology.h:324
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
static bool Copy(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:411
vtkm::cont::UnknownCellSet Result
Definition: TriangleWinding.h:165
Definition: TriangleWinding.h:163
A short fixed-length array.
Definition: Types.h:357
void operator()(const InputIds &inputIds, const Coords &coords, const Normal &normal, OutputIds &outputIds) const
Definition: TriangleWinding.h:122
void(FieldIn cellNormals, FieldInOut cellPoints, WholeArrayIn coords) ControlSignature
Definition: TriangleWinding.h:64
Definition: TriangleWinding.h:113
void operator()(const vtkm::cont::CellSetExplicit< S, C, O > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:256
void operator()(const vtkm::cont::CellSetSingleType< C > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:294
void(PointIndices, _2, _3, _4) ExecutionSignature
Definition: TriangleWinding.h:119
void operator()(const vtkm::Vec< NormalCompType, 3 > &cellNormal, CellPointsType &cellPoints, const CoordsPortal &coords) const
Definition: TriangleWinding.h:68
Defines an irregular collection of cells.
Definition: CastAndCall.h:36
vtkm::cont::ArrayHandle< vtkm::Range > ArrayRangeCompute(const vtkm::cont::UnknownArrayHandle &array, bool computeFiniteRange=false, vtkm::cont::DeviceAdapterId device=vtkm::cont::DeviceAdapterTagAny{})
Compute the range of the data in an array handle.
An execution signature tag to get the number of incident points.
Definition: WorkletMapTopology.h:406
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:490
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
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:323
This worklet ensures that triangle windings are consistent with provided cell normals.
Definition: TriangleWinding.h:58
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:39
const ConnectivityChooser< VisitTopology, IncidentTopology >::ShapesArrayType & GetShapesArray(VisitTopology, IncidentTopology) const
Returns the vtkm::cont::ArrayHandle holding the shape information.
An execution signature tag to get the indices of the incident points.
Definition: WorkletMapTopology.h:416