10 #ifndef vtkm_m_worklet_Clip_h 
   11 #define vtkm_m_worklet_Clip_h 
   37 #if defined(THRUST_MAJOR_VERSION) && THRUST_MAJOR_VERSION == 1 && THRUST_MINOR_VERSION == 8 && \ 
   38   THRUST_SUBMINOR_VERSION < 3 
   42 VTKM_THIRDPARTY_PRE_INCLUDE
 
   43 #include <thrust/detail/type_traits.h> 
   44 VTKM_THIRDPARTY_POST_INCLUDE
 
   45 #define THRUST_SCAN_WORKAROUND 
  110 template <
typename T>
 
  113   return static_cast<T
>(scale * 
static_cast<vtkm::Float64>(val));
 
  116 template <
typename T, vtkm::IdComponent NumComponents>
 
  123 template <
typename Device>
 
  124 class ExecutionConnectivityExplicit
 
  133   ExecutionConnectivityExplicit() = 
default;
 
  142     : Shapes(shapes.PrepareForOutput(stats.NumberOfCells, Device(), token))
 
  143     , NumberOfIndices(numberOfIndices.PrepareForOutput(stats.NumberOfCells, Device(), token))
 
  144     , Connectivity(connectivity.PrepareForOutput(stats.NumberOfIndices, Device(), token))
 
  145     , Offsets(offsets.PrepareForOutput(stats.NumberOfCells, Device(), token))
 
  150   void SetCellShape(
vtkm::Id cellIndex, 
vtkm::UInt8 shape) { this->Shapes.Set(cellIndex, shape); }
 
  155     this->NumberOfIndices.Set(cellIndex, numIndices);
 
  161     this->Offsets.Set(cellIndex, indexOffset);
 
  167     this->Connectivity.Set(connectivityIndex, pointIndex);
 
  172   IdComponentPortal NumberOfIndices;
 
  173   IdPortal Connectivity;
 
  181   ConnectivityExplicit() = 
default;
 
  188                        const ClipStats& stats)
 
  190     , NumberOfIndices(numberOfIndices)
 
  191     , Connectivity(connectivity)
 
  197   template <
typename Device>
 
  198   VTKM_CONT ExecutionConnectivityExplicit<Device> PrepareForExecution(
 
  202     ExecutionConnectivityExplicit<Device> execConnectivity(
 
  203       this->Shapes, this->NumberOfIndices, this->Connectivity, this->Offsets, this->Stats, token);
 
  204     return execConnectivity;
 
  243     template <
typename CellShapeTag, 
typename ScalarFieldVec, 
typename DeviceAdapter>
 
  246                               const ScalarFieldVec& scalars,
 
  247                               const internal::ClipTables::DevicePortal<DeviceAdapter>& clippingData,
 
  266       vtkm::Id index = clippingData.GetCaseIndex(shape.Id, caseId);
 
  267       clipDataIndex = index;
 
  268       vtkm::Id numberOfCells = clippingData.ValueAt(index++);
 
  272         vtkm::Id cellShape = clippingData.ValueAt(index++);
 
  273         vtkm::Id numberOfIndices = clippingData.ValueAt(index++);
 
  284             vtkm::Id element = clippingData.ValueAt(index);
 
  296             vtkm::Id element = clippingData.ValueAt(index);
 
  301             else if (element < 100)
 
  328                                   ExecObject clipTables,
 
  329                                   ExecObject connectivityObject,
 
  330                                   WholeArrayOut edgePointReverseConnectivity,
 
  331                                   WholeArrayOut edgePointInterpolation,
 
  332                                   WholeArrayOut inCellReverseConnectivity,
 
  333                                   WholeArrayOut inCellEdgeReverseConnectivity,
 
  334                                   WholeArrayOut inCellEdgeInterpolation,
 
  335                                   WholeArrayOut inCellInterpolationKeys,
 
  336                                   WholeArrayOut inCellInterpolationInfo,
 
  337                                   WholeArrayOut cellMapOutputToInput);
 
  356     template <
typename CellShapeTag,
 
  357               typename PointVecType,
 
  358               typename ScalarVecType,
 
  359               typename ConnectivityObject,
 
  361               typename EdgeInterpolationPortalType,
 
  362               typename DeviceAdapter>
 
  365                               const PointVecType& points,
 
  366                               const ScalarVecType& scalars,
 
  369                               const internal::ClipTables::DevicePortal<DeviceAdapter>& clippingData,
 
  370                               ConnectivityObject& connectivityObject,
 
  372                               EdgeInterpolationPortalType& edgePointInterpolation,
 
  375                               EdgeInterpolationPortalType& inCellEdgeInterpolation,
 
  395       vtkm::Id numberOfCells = clippingData.ValueAt(clipIndex++);
 
  396       for (
vtkm::Id cell = 0; cell < numberOfCells; ++cell)
 
  398         vtkm::UInt8 cellShape = clippingData.ValueAt(clipIndex++);
 
  414                point++, inCellInterpPointIndex++, clipIndex++)
 
  418             inCellInterpolationKeys.Set(inCellInterpPointIndex, workIndex);
 
  421               inCellInterpolationInfo.Set(inCellInterpPointIndex, points[entry - 100]);
 
  435                 this->
swap(edge[0], edge[1]);
 
  438                 static_cast<vtkm::Float64>(scalars[edge[1]] - scalars[edge[0]]);
 
  440               inCellEdgeReverseConnectivity.Set(inCellEdgeInterpIndex, inCellInterpPointIndex);
 
  441               inCellEdgeInterpolation.Set(inCellEdgeInterpIndex, ei);
 
  442               inCellEdgeInterpIndex++;
 
  460           connectivityObject.SetCellShape(cellIndex, cellShape);
 
  461           connectivityObject.SetNumberOfIndices(cellIndex, numberOfPoints);
 
  462           connectivityObject.SetIndexOffset(cellIndex, connectivityIndex);
 
  470               inCellReverseConnectivity.Set(inCellIndex++, connectivityIndex);
 
  471               connectivityObject.SetConnectivity(connectivityIndex, inCellPoints);
 
  474             else if (entry >= 100) 
 
  476               connectivityObject.SetConnectivity(connectivityIndex++, points[entry - 100]);
 
  490                 this->
swap(edge[0], edge[1]);
 
  493                 static_cast<vtkm::Float64>(scalars[edge[1]] - scalars[edge[0]]);
 
  496               edgePointReverseConnectivity.Set(edgeIndex, connectivityIndex++);
 
  497               edgePointInterpolation.Set(edgeIndex, ei);
 
  501           cellMapOutputToInput.Set(cellIndex, workIndex);
 
  507     template <
typename T>
 
  529                                   FieldIn destinationIndices,
 
  530                                   WholeArrayOut destinationData);
 
  536     template <
typename ConnectivityDataType>
 
  539                               ConnectivityDataType& destinationData)
 const 
  541       destinationData.Set(destinationIndex, (sourceValue + 
EdgePointOffset));
 
  563     template <
typename ConnectivityDataType>
 
  565                               ConnectivityDataType& destinationData)
 const 
  567       auto sourceValue = destinationData.Get(destinationIndex);
 
  586   template <
typename CellSetType, 
typename ScalarsArrayHandle>
 
  588                                     const ScalarsArrayHandle& scalars,
 
  599     statsDispatcher.Invoke(cellSet, scalars, this->
ClipTablesInstance, clipStats, clipTableIndices);
 
  611     internal::ConnectivityExplicit connectivityObject(
 
  612       shapes, numberOfIndices, connectivity, offsets, total);
 
  634     cellSetDispatcher.Invoke(cellSet,
 
  640                              edgePointReverseConnectivity,
 
  642                              cellPointReverseConnectivity,
 
  643                              cellPointEdgeReverseConnectivity,
 
  644                              cellPointEdgeInterpolation,
 
  660                                        edgeInterpolationIndexToUnique,
 
  665                                        cellPointEdgeInterpolation,
 
  666                                        cellInterpolationIndexToUnique,
 
  677       scatterEdgePointConnectivity);
 
  678     scatterEdgeDispatcher.Invoke(
 
  679       edgeInterpolationIndexToUnique, edgePointReverseConnectivity, connectivity);
 
  680     scatterEdgeDispatcher.Invoke(cellInterpolationIndexToUnique,
 
  681                                  cellPointEdgeReverseConnectivity,
 
  686       scatterInCellPointConnectivity);
 
  687     scatterInCellDispatcher.Invoke(cellPointReverseConnectivity, connectivity);
 
  690     vtkm::Id numberOfPoints = scalars.GetNumberOfValues() +
 
  695     output.
Fill(numberOfPoints, shapes, connectivity, offsets);
 
  699   template <
typename CellSetType, 
typename ImplicitFunction>
 
  705                              const CellSetType& cellSet,
 
  706                              const ImplicitFunction& 
function,
 
  719     template <
typename ArrayHandleType>
 
  726         clipScalars(handle, this->
Function);
 
  741   template <
typename CellSetType, 
typename ImplicitFunction>
 
  743                                     const ImplicitFunction& clipFunction,
 
  751       this, cellSet, clipFunction, offset, invert, &output);
 
  757   template <
typename CellSetType, 
typename ImplicitFunction>
 
  759                                     const ImplicitFunction& clipFunction,
 
  763     return this->
Run(cellSet, clipFunction, 0.0, coords, invert);
 
  766   template <
typename ArrayHandleType>
 
  778                      ArrayHandleType* output)
 
  800       template <
typename EdgeInterp, 
typename OutputFieldPortal>
 
  802                                 OutputFieldPortal& field,
 
  805         using T = 
typename OutputFieldPortal::ValueType;
 
  806         T v1 = field.Get(ei.Vertex1);
 
  807         T v2 = field.Get(ei.Vertex2);
 
  809                   static_cast<T
>(internal::Scale(T(v1 - v2), ei.Weight) + v1));
 
  823       template <
typename MappedValueVecType, 
typename MappedValueType>
 
  827         MappedValueType sum = toReduce[0];
 
  830           MappedValueType value = toReduce[i];
 
  832           sum = 
static_cast<MappedValueType
>(sum + value);
 
  834         centroid = internal::Scale(sum, 1. / 
static_cast<vtkm::Float64>(numValues));
 
  838     template <
typename Storage>
 
  847       ArrayHandleType result;
 
  848       result.Allocate(numberOfOriginalValues + numberOfEdgePoints + numberOfInCellPoints);
 
  865         inCellInterpolationDispatcher;
 
  866       inCellInterpolationDispatcher.Invoke(interpolationKeys, toReduceValues, reducedValues);
 
  867       vtkm::Id inCellPointsOffset = numberOfOriginalValues + numberOfEdgePoints;
 
  869         reducedValues, 0, reducedValues.
GetNumberOfValues(), result, inCellPointsOffset);
 
  882   template <
typename ValueType, 
typename StorageType>
 
  919 #if defined(THRUST_SCAN_WORKAROUND) 
  927 struct is_integral<
vtkm::worklet::ClipStats> : 
public true_type
 
  934 #endif // vtkm_m_worklet_Clip_h