Go to the documentation of this file.
11 #ifndef vtk_m_worklet_contour_MarchingCells_h
12 #define vtk_m_worklet_contour_MarchingCells_h
42 namespace marching_cells
83 ExecObject classifyTable);
87 template <
typename CellShapeType,
88 typename IsoValuesType,
90 typename ClassifyTableType>
92 const IsoValuesType& isovalues,
93 const FieldInType& fieldIn,
95 const ClassifyTableType& classifyTable)
const
99 vtkm::IdComponent numVerticesPerCell = classifyTable.GetNumVerticesPerCell(shape.Id);
101 for (
vtkm::Id i = 0; i < numIsoValues; ++i)
106 caseNumber |= (fieldIn[j] > isovalues.Get(i)) << j;
109 sum += classifyTable.GetNumTriangles(shape.Id, caseNumber);
125 template <
typename FieldType>
127 template <
typename FieldType>
142 ,
InterpIdPortal(interpIds.PrepareForOutput(3 * size, device, token))
192 template <
typename T>
198 template <
typename ArrayHandleType>
205 WholeArrayIn isoValues,
208 ExecObject classifyTable,
209 ExecObject triTable);
215 template <
typename CellShape,
216 typename IsoValuesType,
217 typename FieldInType,
218 typename ClassifyTableType,
219 typename TriTableType,
220 typename IndicesVecType>
222 const IsoValuesType& isovalues,
223 const FieldInType& fieldIn,
225 const ClassifyTableType& classifyTable,
226 const TriTableType& triTable,
230 const IndicesVecType& indices)
const
232 const vtkm::Id outputPointId = 3 * outputCellId;
238 vtkm::IdComponent numVerticesPerCell = classifyTable.GetNumVerticesPerCell(shape.Id);
240 for (i = 0; i < numIsoValues; ++i)
242 const FieldType ivalue = isovalues.Get(i);
249 caseNumber |= (fieldIn[j] > ivalue) << j;
252 sum += classifyTable.GetNumTriangles(shape.Id, caseNumber);
253 if (sum > visitIndex)
259 visitIndex = sum - visitIndex - 1;
264 auto edgeVertices = triTable.GetEdgeVertices(shape.Id, caseNumber, visitIndex, triVertex);
265 const FieldType fieldValue0 = fieldIn[edgeVertices.first];
266 const FieldType fieldValue1 = fieldIn[edgeVertices.second];
275 outputPointId + triVertex,
276 vtkm::Id2(indices[edgeVertices.first], indices[edgeVertices.second]));
290 template <
typename T>
296 template <
typename T,
typename U>
302 template <
typename T,
typename U>
306 U&& t =
static_cast<U
>(a);
322 template <
typename T,
323 typename ValuesInType,
324 typename Values2InType,
325 typename ValuesOutType,
326 typename Values2OutType>
328 const ValuesInType& values1,
329 const Values2InType& values2,
330 ValuesOutType& valueOut1,
331 Values2OutType& valueOut2)
const
333 valueOut1 = values1[0];
334 valueOut2 = values2[0];
348 template <
typename T>
356 template <
typename KeyType,
typename KeyStorage>
373 weights = writeWeights;
374 cellids = writeCells;
387 template <vtkm::IdComponent Comp>
401 WholeCellSetIn<Cell, Point>,
402 WholeArrayIn pointCoordinates,
403 WholeArrayIn inputField,
417 template <
typename FromIndexType,
418 typename CellSetInType,
419 typename WholeCoordinatesIn,
420 typename WholeFieldIn,
423 const FromIndexType& cellIds,
425 const CellSetInType& geometry,
426 const WholeCoordinatesIn& pointCoordinates,
427 const WholeFieldIn& inputField,
428 NormalType& normal)
const
431 gradient(numCells, cellIds, pointId, geometry, pointCoordinates, inputField, normal);
434 template <
typename FromIndexType,
435 typename WholeCoordinatesIn,
436 typename WholeFieldIn,
442 const WholeCoordinatesIn& pointCoordinates,
443 const WholeFieldIn& inputField,
444 NormalType& normal)
const
456 gradient(boundary, points, field, normal);
468 WholeCellSetIn<Cell, Point>,
469 WholeArrayIn pointCoordinates,
470 WholeArrayIn inputField,
471 WholeArrayIn weights,
486 template <
typename FromIndexType,
487 typename CellSetInType,
488 typename WholeCoordinatesIn,
489 typename WholeFieldIn,
490 typename WholeWeightsIn,
493 const FromIndexType& cellIds,
495 const CellSetInType& geometry,
496 const WholeCoordinatesIn& pointCoordinates,
497 const WholeFieldIn& inputField,
499 const WholeWeightsIn& weights,
500 NormalType& normal)
const
504 gradient(numCells, cellIds, pointId, geometry, pointCoordinates, inputField, grad1);
506 NormalType grad0 = normal;
507 auto weight = weights.Get(edgeId);
511 template <
typename FromIndexType,
512 typename WholeCoordinatesIn,
513 typename WholeFieldIn,
514 typename WholeWeightsIn,
520 const WholeCoordinatesIn& pointCoordinates,
521 const WholeFieldIn& inputField,
523 const WholeWeightsIn& weights,
524 NormalType& normal)
const
537 gradient(boundary, points, field, grad1);
539 NormalType grad0 = normal;
540 auto weight = weights.Get(edgeId);
545 normal = normal * vtkm::RSqrt(mag2);
553 template <
typename CoordinateSystem,
554 typename NormalCType,
555 typename InputFieldType,
556 typename InputStorageType,
562 const CellSet cellset,
594 template <
typename CellSetType,
595 typename CoordinateSystem,
597 typename StorageTagField,
598 typename StorageTagVertices,
599 typename StorageTagNormals,
600 typename CoordinateType,
603 const CellSetType& cells,
604 const CoordinateSystem& coordinateSystem,
605 const std::vector<ValueType>& isovalues,
630 invoker(classifyCell, isoValuesHandle, inputField, cells, numOutputTrisPerCell, classTable);
640 sharedState.
CellIdMap = scatter.GetOutputToInputMap();
646 originalCellIdsForPoints,
672 if (isovalues.size() == 1)
678 originalCellIdsForPoints,
688 originalCellIdsForPoints,
702 invoker(MapPointField{},
716 genNorms(coordinateSystem,
731 #endif // vtk_m_worklet_contour_MarchingCells_h
VTKM_CONT void ArrayCopyDevice(const vtkm::cont::ArrayHandle< InValueType, InStorage > &source, vtkm::cont::ArrayHandle< OutValueType, OutStorage > &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopyDevice.h:75
void(_1, _2, _3, _4, _5) ExecutionSignature
Definition: MarchingCells.h:319
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
VTKM_CONT vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:217
Definition: MarchingCells.h:393
Manages an array-worth of data.
Definition: ArrayHandle.h:283
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
_1 InputDomain
Definition: MarchingCells.h:320
vtkm::cont::ArrayHandle< vtkm::Float32, S > make_ScalarField(const vtkm::cont::ArrayHandle< vtkm::Float32, S > &ah)
Definition: MarchingCells.h:47
void ControlSignature(CellSetIn, WholeCellSetIn< Cell, Point >, WholeArrayIn pointCoordinates, WholeArrayIn inputField, WholeArrayIn weights, FieldInOutPoint normals)
Definition: MarchingCells.h:467
Definition: MarchingCells.h:388
Definition: MarchingCellTables.h:539
Definition: FieldPropagation.h:25
VTKM_EXEC_CONT bool operator()(const T &a, const T &b) const
Definition: MarchingCells.h:291
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
A control signature tag for output fields.
Definition: WorkletMapField.h:60
void operator()(const CoordinateSystem &coordinates, const vtkm::cont::Invoker &invoker, vtkm::cont::ArrayHandle< vtkm::Vec< NormalCType, 3 >> &normals, const vtkm::cont::ArrayHandle< InputFieldType, InputStorageType > &field, const CellSet cellset, const vtkm::cont::ArrayHandle< vtkm::Id2 > &edges, const vtkm::cont::ArrayHandle< vtkm::FloatDefault > &weights) const
Definition: MarchingCells.h:558
vtkm::cont::ArrayHandle< vtkm::FloatDefault > InterpolationWeights
Definition: CommonState.h:33
VTKM_EXEC vtkm::Id operator()(const vtkm::Id2 &edge) const
Definition: MarchingCells.h:390
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_EXEC_CONT bool operator()(const vtkm::internal::ArrayPortalValueReference< T > &a, const U &b) const
Definition: MarchingCells.h:303
A control signature tag for input values.
Definition: WorkletReduceByKey.h:70
const VTKM_EXEC vtkm::exec::BoundaryState & GetBoundaryState() const
Definition: ThreadIndicesNeighborhood.h:87
VTKM_EXEC void operator()(const vtkm::IdComponent &numCells, const FromIndexType &cellIds, vtkm::Id pointId, const CellSetInType &geometry, const WholeCoordinatesIn &pointCoordinates, const WholeFieldIn &inputField, vtkm::Id edgeId, const WholeWeightsIn &weights, NormalType &normal) const
Definition: MarchingCells.h:492
_1 InputDomain
Definition: MarchingCells.h:408
VTKM_EXEC void operator()(const vtkm::IdComponent &numCells, const FromIndexType &cellIds, vtkm::Id pointId, const CellSetInType &geometry, const WholeCoordinatesIn &pointCoordinates, const WholeFieldIn &inputField, NormalType &normal) const
Definition: MarchingCells.h:422
void(CellCount, CellIndices, InputIndex, _2, _3, _4, _5) ExecutionSignature
Definition: MarchingCells.h:406
static VTKM_CONT void LowerBounds(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, const vtkm::cont::ArrayHandle< T, CVal > &values, vtkm::cont::ArrayHandle< vtkm::Id, COut > &output)
Definition: Algorithm.h:604
bool GenerateNormals
Definition: CommonState.h:32
void ControlSignature(CellSetIn cellset, WholeArrayIn isoValues, FieldInPoint fieldIn, ExecObject metaData, ExecObject classifyTable, ExecObject triTable)
Definition: MarchingCells.h:204
Definition: CastAndCall.h:34
Definition: MarchingCells.h:460
A control signature tag for reduced output values.
Definition: WorkletReduceByKey.h:150
VTKM_EXEC void operator()(const vtkm::Pair< T, vtkm::Id2 > &input, vtkm::Id2 &output) const
Definition: MarchingCells.h:349
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
typename StorageType::ReadPortalType ReadPortalType
Definition: ArrayHandle.h:294
Container for thread information in a WorkletPointNeighborhood.
Definition: ThreadIndicesPointNeighborhood.h:24
_1 InputDomain
Definition: MarchingCells.h:343
VTKM_EXEC void operator()(const CellShape shape, const IsoValuesType &isovalues, const FieldInType &fieldIn, const EdgeWeightGenerateMetaData::ExecObject &metaData, const ClassifyTableType &classifyTable, const TriTableType &triTable, vtkm::Id inputCellId, vtkm::Id outputCellId, vtkm::IdComponent visitIndex, const IndicesVecType &indices) const
Definition: MarchingCells.h:221
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
Compute the weights for each edge that is used to generate a point in the resulting iso-surface.
Definition: MarchingCells.h:193
VTKM_EXEC_CONT T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:157
Definition: MarchingCells.h:312
A token to hold the scope of an ArrayHandle or other object.
Definition: Token.h:35
bool MergeDuplicatePoints
Definition: CommonState.h:31
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:44
Definition: PointGradient.h:29
IncidentElementCount CellCount
Definition: WorkletMapTopology.h:286
Base class for worklets that map from Cells to Points.
Definition: WorkletMapTopology.h:274
VTKM_CONT vtkm::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:474
A control signature tag for input fields.
Definition: WorkletMapField.h:49
Definition: WorkletReduceByKey.h:42
Definition: CommonState.h:24
VTKM_CONT vtkm::cont::ArrayHandleZip< FirstHandleType, SecondHandleType > make_ArrayHandleZip(const FirstHandleType &first, const SecondHandleType &second)
A convenience function for creating an ArrayHandleZip.
Definition: ArrayHandleZip.h:288
Definition: MarchingCellTables.h:477
Allows launching any worklet without a dispatcher.
Definition: Invoker.h:41
FirstType first
The pair's first object.
Definition: Pair.h:50
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
static VTKM_CONT ScatterType MakeScatter(const vtkm::cont::ArrayHandle< vtkm::Id2 > &edges)
Definition: MarchingCells.h:481
_1 InputDomain
Definition: MarchingCells.h:477
VTKM_EXEC void operator()(const T &, const ValuesInType &values1, const Values2InType &values2, ValuesOutType &valueOut1, Values2OutType &valueOut2) const
Definition: MarchingCells.h:327
Definition: MarchingCells.h:339
void(_1, _2) ExecutionSignature
Definition: MarchingCells.h:342
FieldInIncident FieldInPoint
Definition: WorkletMapTopology.h:259
#define VTKM_CONT
Definition: ExportMacros.h:57
A control signature tag for input keys.
Definition: WorkletReduceByKey.h:56
typename StorageType::WritePortalType WritePortalType
Definition: ArrayHandle.h:295
VTKM_EXEC void operator()(CellShapeType shape, const IsoValuesType &isovalues, const FieldInType &fieldIn, vtkm::IdComponent &numTriangles, const ClassifyTableType &classifyTable) const
Definition: MarchingCells.h:91
void(CellShape, _1, _2, _4, _5) ExecutionSignature
Definition: MarchingCells.h:84
A scatter that maps input to output based on a permutation array.
Definition: ScatterPermutation.h:32
VTKM_CONT KeyArrayHandleType GetUniqueKeys() const
Definition: Keys.h:175
uint8_t UInt8
Definition: Types.h:157
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
@ CELL_SHAPE_TRIANGLE
Definition: CellShape.h:41
VTKM_EXEC_CONT ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:32
static VTKM_CONT ScatterType MakeScatter(const ArrayHandleType &numOutputTrisPerCell)
Definition: MarchingCells.h:199
IncidentElementIndices CellIndices
Definition: WorkletMapTopology.h:288
Definition: ConnectivityStructured.h:24
Base ExecutionObjectBase for execution objects to inherit from so that you can use an arbitrary objec...
Definition: ExecutionObjectBase.h:31
Definition: DeviceAdapterTag.h:52
Definition: MarchingCells.h:76
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::cont::CellSetSingleType execute(const CellSetType &cells, const CoordinateSystem &coordinateSystem, const std::vector< ValueType > &isovalues, const vtkm::cont::ArrayHandle< ValueType, StorageTagField > &inputField, vtkm::cont::ArrayHandle< vtkm::Vec< CoordinateType, 3 >, StorageTagVertices > &vertices, vtkm::cont::ArrayHandle< vtkm::Vec< NormalType, 3 >, StorageTagNormals > &normals, vtkm::worklet::contour::CommonState &sharedState)
Definition: MarchingCells.h:602
vtkm::cont::ArrayHandle< vtkm::Id > CellIdMap
Definition: CommonState.h:35
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:141
FieldOut FieldOutPoint
Definition: WorkletMapTopology.h:282
Manage keys for a WorkletReduceByKey.
Definition: Keys.h:131
void(WholeArrayIn isoValues, FieldInPoint fieldIn, CellSetIn cellSet, FieldOutCell outNumTriangles, ExecObject classifyTable) ControlSignature
Definition: MarchingCells.h:83
typename VecType::ComponentType ComponentType
Type of the components in the vector.
Definition: VecTraits.h:73
Definition: MarchingCells.h:551
void(CellCount, CellIndices, InputIndex, _2, _3, _4, WorkIndex, _5, _6) ExecutionSignature
Definition: MarchingCells.h:475
void(CellShape, _2, _3, _4, _5, _6, InputIndex, WorkIndex, VisitIndex, PointIndices) ExecutionSignature
Definition: MarchingCells.h:211
void(FieldIn, FieldOut) ControlSignature
Definition: MarchingCells.h:341
_3 InputDomain
Definition: MarchingCells.h:85
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
The ExecutionSignature tag to use to get the visit index.
Definition: VisitIndex.h:43
vtkm::worklet::ScatterCounting ScatterType
Definition: MarchingCells.h:196
vtkm::cont::ArrayHandle< vtkm::Id2 > InterpolationEdgeIds
Definition: CommonState.h:34
FieldInOut FieldInOutPoint
Definition: WorkletMapTopology.h:284
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
VTKM_CONT void ReleaseResources() const
Releases all resources in both the control and execution environments.
Definition: ArrayHandle.h:559
void MergeDuplicates(const vtkm::cont::Invoker &invoker, const vtkm::cont::ArrayHandle< KeyType, KeyStorage > &original_keys, vtkm::cont::ArrayHandle< vtkm::FloatDefault > &weights, vtkm::cont::ArrayHandle< vtkm::Id2 > &edgeIds, vtkm::cont::ArrayHandle< vtkm::Id > &cellids, vtkm::cont::ArrayHandle< vtkm::Id > &connectivity)
Definition: MarchingCells.h:357
void(KeysIn keys, ValuesIn valuesIn1, ValuesIn valuesIn2, ReducedValuesOut valueOut1, ReducedValuesOut valueOut2) ControlSignature
Definition: MarchingCells.h:318
VTKM_EXEC_CONT bool operator()(const vtkm::Pair< T, U > &a, const vtkm::Pair< T, U > &b) const
Definition: MarchingCells.h:297
VTKM_EXEC void operator()(const vtkm::IdComponent &vtkmNotUsed(numCells), const FromIndexType &vtkmNotUsed(cellIds), vtkm::Id pointId, vtkm::exec::ConnectivityStructured< Cell, Point, 3 > &geometry, const WholeCoordinatesIn &pointCoordinates, const WholeFieldIn &inputField, vtkm::Id edgeId, const WholeWeightsIn &weights, NormalType &normal) const
Definition: MarchingCells.h:516
void(CellSetIn, WholeCellSetIn< Cell, Point >, WholeArrayIn pointCoordinates, WholeArrayIn inputField, FieldOutPoint normals) ControlSignature
Definition: MarchingCells.h:404
SecondType second
The pair's second object.
Definition: Pair.h:55
Retrieves field values from a neighborhood.
Definition: FieldNeighborhood.h:36
_1 InputDomain
Definition: MarchingCells.h:213
VTKM_EXEC void operator()(const vtkm::IdComponent &vtkmNotUsed(numCells), const FromIndexType &vtkmNotUsed(cellIds), vtkm::Id pointId, vtkm::exec::ConnectivityStructured< Cell, Point, 3 > &geometry, const WholeCoordinatesIn &pointCoordinates, const WholeFieldIn &inputField, NormalType &normal) const
Definition: MarchingCells.h:438
static VTKM_CONT ScatterType MakeScatter(const vtkm::cont::ArrayHandle< vtkm::Id2 > &edges)
Definition: MarchingCells.h:412
Definition: StructuredPointGradient.h:25
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
FieldOut FieldOutCell
Definition: WorkletMapTopology.h:263
Definition: MarchingCells.h:288
The ExecutionSignature tag to use to get the work index.
Definition: WorkIndex.h:39
vtkm::worklet::ScatterPermutation< typename PointIdsArray::StorageTag > ScatterType
Definition: MarchingCells.h:409
VTKM_CONT detail::MakeArrayHandleCastImpl< T, typename ArrayType::ValueType, ArrayType >::ReturnType make_ArrayHandleCast(const ArrayType &array, const T &=T())
make_ArrayHandleCast is convenience function to generate an ArrayHandleCast.
Definition: ArrayHandleCast.h:255
VTKM_EXEC void operator()(const vtkm::Id2 &input, vtkm::Id2 &output) const
Definition: MarchingCells.h:346
vtkm::worklet::ScatterPermutation< typename PointIdsArray::StorageTag > ScatterType
Definition: MarchingCells.h:478