Go to the documentation of this file.
29 #ifndef viskores_m_worklet_TriangleWinding_h
30 #define viskores_m_worklet_TriangleWinding_h
75 template <
typename NormalCompType,
typename CellPo
intsType,
typename CoordsPortal>
77 CellPointsType& cellPoints,
78 const CoordsPortal& coords)
const
81 if (cellPoints.GetNumberOfComponents() != 3)
88 const NormalType p0 = coords.Get(cellPoints[0]);
89 const NormalType p1 = coords.Get(cellPoints[1]);
90 const NormalType p2 = coords.Get(cellPoints[2]);
91 const NormalType v01 = p1 - p0;
92 const NormalType v02 = p2 - p0;
94 if (viskores::Dot(cellNormal, triangleNormal) < 0)
98 cellPoints[1] = cellPoints[2];
110 template <
typename CellShapeTag>
116 cellSizeOut = cellSizeIn;
117 cellShapeOut = cellShapeIn.Id;
129 template <
typename InputIds,
typename Coords,
typename Normal,
typename OutputIds>
131 const Coords& coords,
133 OutputIds& outputIds)
const
135 VISKORES_ASSERT(inputIds.GetNumberOfComponents() == outputIds.GetNumberOfComponents());
138 if (inputIds.GetNumberOfComponents() != 3)
145 outputIds[i] = inputIds[i];
150 const Normal p0 = coords.Get(inputIds[0]);
151 const Normal p1 = coords.Get(inputIds[1]);
152 const Normal p2 = coords.Get(inputIds[2]);
153 const Normal v01 = p1 - p0;
154 const Normal v02 = p2 - p0;
156 if (viskores::Dot(normal, triangleNormal) < 0)
158 outputIds[0] = inputIds[0];
159 outputIds[1] = inputIds[2];
160 outputIds[2] = inputIds[1];
164 outputIds[0] = inputIds[0];
165 outputIds[1] = inputIds[1];
166 outputIds[2] = inputIds[2];
176 template <
typename CellSetType,
typename CoordsType,
typename CellNormalsType>
178 const CoordsType& coords,
179 const CellNormalsType& cellNormals,
182 const auto numCells = cellSet.GetNumberOfCells();
185 this->Result = cellSet;
196 invoker(worklet, cellSet, cellShapes, numIndices);
208 auto rangeSizes = rangeHandleSizes.ReadPortal().Get(0);
209 auto rangeShapes = rangeHandleShapes.ReadPortal().Get(0);
211 const bool sameSize = viskores::Abs(rangeSizes.Max - rangeSizes.Min) < 0.5;
212 const bool sameShape = viskores::Abs(rangeShapes.Max - rangeShapes.Min) < 0.5;
214 if (sameSize && sameShape)
231 viskores::cont::make_ArrayHandleCounting<viskores::Id>(0, cellSize, numCells);
235 invoker(worklet, cellSet, coords, cellNormals, connGroupVec);
238 outCells.
Fill(cellSet.GetNumberOfPoints(), cellShape, cellSize, conn);
239 this->Result = outCells;
255 invoker(worklet, cellSet, coords, cellNormals, connGroupVec);
258 outCells.
Fill(cellSet.GetNumberOfPoints(), cellShapes, conn, offsets);
259 this->Result = outCells;
264 template <
typename S,
typename C,
typename O,
typename CoordsType,
typename CellNormalsType>
266 const CoordsType& coords,
267 const CellNormalsType& cellNormals,
275 this->Result = cellSet;
290 WindToCellNormals dispatcher;
291 dispatcher.Invoke(cellNormals, cells, coords);
298 this->Result = newCells;
302 template <
typename C,
typename CoordsType,
typename CellNormalsType>
304 const CoordsType& coords,
305 const CellNormalsType& cellNormals,
310 const auto numCells = cellSet.GetNumberOfCells();
313 this->Result = cellSet;
328 WindToCellNormals dispatcher;
329 dispatcher.Invoke(cellNormals, cells, coords);
332 newCells.
Fill(cellSet.GetNumberOfPoints(),
334 cellSet.GetNumberOfPointsInCell(0),
337 this->Result = newCells;
341 template <
typename CellSetType,
typename CoordsType,
typename CellNormalsType>
343 const CoordsType& coords,
344 const CellNormalsType& cellNormals)
357 #endif // viskores_m_worklet_TriangleWinding_h
void(FieldIn cellNormals, FieldInOut cellPoints, WholeArrayIn coords) ControlSignature
Definition: TriangleWinding.h:72
A control signature tag for input fields on the cells of the topology.
Definition: WorkletMapTopology.h:299
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:32
void CastAndCall(const DynamicObject &dynamicObject, Functor &&f, Args &&... args)
A Generic interface to CastAndCall.
Definition: CastAndCall.h:55
A control signature tag for input connectivity.
Definition: WorkletMapTopology.h:289
void operator()(const viskores::Vec< NormalCompType, 3 > &cellNormal, CellPointsType &cellPoints, const CoordsPortal &coords) const
Definition: TriangleWinding.h:76
viskores::UInt8 GetCellShape(viskores::Id) const override
Definition: CellSetSingleType.h:241
A control signature tag for input fields.
Definition: WorkletMapField.h:68
An execution signature tag to get the shape of the visited cell.
Definition: WorkletMapTopology.h:406
void(CellSetIn cells, FieldOutCell shapes, FieldOutCell sizes) ControlSignature
Definition: TriangleWinding.h:107
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:265
An execution signature tag to get the number of incident points.
Definition: WorkletMapTopology.h:416
const ConnectivityChooser< VisitTopology, IncidentTopology >::OffsetsArrayType & GetOffsetsArray(VisitTopology, IncidentTopology) const
Returns the viskores::cont::ArrayHandle containing the offsets into theconnectivity information.
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
An execution signature tag to get the indices of the incident points.
Definition: WorkletMapTopology.h:426
viskores::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const viskores::Vec< T, 3 > &x, const viskores::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:188
static viskores::cont::UnknownCellSet Run(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals)
Definition: TriangleWinding.h:342
const ConnectivityChooser< VisitTopology, IncidentTopology >::ConnectivityArrayType & GetConnectivityArray(VisitTopology, IncidentTopology) const
Returns the viskores::cont::ArrayHandle containing the connectivity information.
void operator()(const viskores::cont::CellSetExplicit< S, C, O > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:265
Definition: TriangleWinding.h:70
static bool Copy(viskores::cont::DeviceAdapterId devId, const viskores::cont::ArrayHandle< T, CIn > &input, viskores::cont::ArrayHandle< U, COut > &output)
Definition: Algorithm.h:422
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:600
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:107
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
Dispatcher for worklets that inherit from WorkletMapField.
Definition: DispatcherMapField.h:33
Definition: TriangleWinding.h:105
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
Defines an irregular collection of cells.
Definition: CastAndCall.h:44
void operator()(const viskores::cont::CellSetSingleType< C > &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals, int)
Definition: TriangleWinding.h:303
void(PointIndices, _2, _3, _4) ExecutionSignature
Definition: TriangleWinding.h:127
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
void(CellShape, PointCount, _2, _3) ExecutionSignature
Definition: TriangleWinding.h:108
void(CellSetIn cellsIn, WholeArrayIn coords, FieldInCell cellNormals, FieldOutCell cellsOut) ControlSignature
Definition: TriangleWinding.h:126
Definition: Normalize.h:30
void Fill(viskores::Id numPoints, const viskores::cont::ArrayHandle< viskores::UInt8, ShapesStorageTag > &cellTypes, const viskores::cont::ArrayHandle< viskores::Id, ConnectivityStorageTag > &connectivity, const viskores::cont::ArrayHandle< viskores::Id, OffsetsStorageTag > &offsets)
Set all the cells of the mesh.
viskores::Id GetNumberOfCells() const override
void operator()(const CellSetType &cellSet, const CoordsType &coords, const CellNormalsType &cellNormals,...)
Definition: TriangleWinding.h:177
void ConvertNumComponentsToOffsets(const viskores::cont::UnknownArrayHandle &numComponentsArray, viskores::cont::ArrayHandle< viskores::Id > &offsetsArray, viskores::Id &componentsArraySize, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
ConvertNumComponentsToOffsets takes an array of Vec sizes (i.e.
Definition: TriangleWinding.h:171
void operator()(const CellShapeTag cellShapeIn, const viskores::IdComponent cellSizeIn, viskores::UInt8 &cellShapeOut, viskores::IdComponent &cellSizeOut) const
Definition: TriangleWinding.h:111
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
void ReleaseResourcesExecution() const
Releases any resources being used in the execution environment (that are not being shared by the cont...
Definition: ArrayHandle.h:593
viskores::Id GetNumberOfPoints() const override
A CellSet of an unknown type.
Definition: UnknownCellSet.h:56
void operator()(const InputIds &inputIds, const Coords &coords, const Normal &normal, OutputIds &outputIds) const
Definition: TriangleWinding.h:130
A control signature tag for output fields.
Definition: WorkletMapTopology.h:334
const ConnectivityChooser< VisitTopology, IncidentTopology >::ShapesArrayType & GetShapesArray(VisitTopology, IncidentTopology) const
Returns the viskores::cont::ArrayHandle holding the shape information.
void Fill(viskores::Id numPoints, viskores::UInt8 shapeId, viskores::IdComponent numberOfPointsPerCell, const viskores::cont::ArrayHandle< viskores::Id, ConnectivityStorageTag > &connectivity)
Set all the cells of the mesh.
Definition: CellSetSingleType.h:211
viskores::cont::ArrayHandleGroupVecVariable< ComponentsArrayHandleType, OffsetsArrayHandleType > make_ArrayHandleGroupVecVariable(const ComponentsArrayHandleType &componentsArray, const OffsetsArrayHandleType &offsetsArray)
make_ArrayHandleGroupVecVariable is convenience function to generate an ArrayHandleGroupVecVariable.
Definition: ArrayHandleGroupVecVariable.h:332
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:42
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:49
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:47
viskores::cont::UnknownCellSet Result
Definition: TriangleWinding.h:173
void(_1 cellNormal, _2 cellPoints, _3 coords) ExecutionSignature
Definition: TriangleWinding.h:73
viskores::cont::ArrayHandle< viskores::Range > ArrayRangeCompute(const viskores::cont::UnknownArrayHandle &array, bool computeFiniteRange=false, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
Compute the range of the data in an array handle.
A short fixed-length array.
Definition: Types.h:365
Definition: TriangleWinding.h:121
#define VISKORES_EXEC
Definition: ExportMacros.h:59
This worklet ensures that triangle windings are consistent with provided cell normals.
Definition: TriangleWinding.h:66