Go to the documentation of this file.
10 #ifndef vtk_m_worklet_tube_h
11 #define vtk_m_worklet_tube_h
46 WholeArrayIn pointCoords,
47 FieldOut nonIncidentPtsPerPolyline,
48 FieldOut ptsPerPolyline,
50 FieldOut numTubeConnIds,
56 _3 nonIncidentPtsPerPolyline,
63 template <
typename CellShapeTag,
typename Po
intIndexType,
typename InPo
intsType>
66 const PointIndexType& ptIndices,
67 const InPointsType& inPts,
79 for (
int i = 1; i < numPoints; ++i)
84 numNonCoincidentPoints++;
92 ptsPerPolyline = numPoints;
93 nonIncidentPtsPerPolyline = numNonCoincidentPoints;
94 ptsPerTube = this->
NumSides * numNonCoincidentPoints;
109 nonIncidentPtsPerPolyline = 0;
134 WholeArrayIn pointCoords,
136 WholeArrayOut newNormals);
151 template <
typename InPo
intsType,
typename Po
intIndexType>
153 const PointIndexType& ptIndices,
157 auto ps = inPts.Get(ptIndices[start]);
159 while (end < numPoints)
161 auto pe = inPts.Get(ptIndices[end]);
170 template <
typename CellShapeTag,
171 typename PointIndexType,
172 typename InPointsType,
173 typename OutNormalType>
176 const PointIndexType& ptIndices,
177 const InPointsType& inPts,
179 OutNormalType& outNormals)
const
191 if (sNextId != numPoints)
193 p0 = inPts.Get(ptIndices[sNextId]);
194 p1 = inPts.Get(ptIndices[sNextId + 1]);
199 for (
vtkm::Id i = 0; i < numPoints; i++)
200 outNormals.Set(polylineOffset + i, this->DefaultNorm);
205 while (++sNextId < numPoints)
208 if (sNextId != numPoints)
210 p0 = inPts.Get(ptIndices[sNextId]);
211 p1 = inPts.Get(ptIndices[sNextId + 1]);
229 if (sNextId >= numPoints)
234 normal[(j + 2) % 3] = 0;
235 normal[(j + 1) % 3] = 1;
236 normal[j] = -sPrev[(j + 1) % 3] / sPrev[j];
243 while (++sNextId < numPoints)
246 if (sNextId == numPoints)
249 p0 = inPts.Get(ptIndices[sNextId]);
250 p1 = inPts.Get(ptIndices[sNextId + 1]);
269 if ((vtkm::Dot(normal, c) * vtkm::Dot(w, c)) < 0)
272 for (
vtkm::Id i = lastNormalId; i < sNextId; i++)
273 outNormals.Set(polylineOffset + i, normal);
274 lastNormalId = sNextId;
276 normal = (f1 * q) + (f2 * w);
279 for (
vtkm::Id i = lastNormalId; i < numPoints; i++)
280 outNormals.Set(polylineOffset + i, normal);
302 WholeArrayIn pointCoords,
303 WholeArrayIn normals,
307 WholeArrayOut newPointCoords,
308 WholeArrayOut outPointSrcIdx);
314 _4 numNonCoincidentPts,
327 template <
typename CellShapeTag,
328 typename PointIndexType,
329 typename InPointsType,
330 typename InNormalsType,
331 typename OutPointsType,
332 typename OutPointSrcIdxType>
335 const PointIndexType& ptIndices,
336 const InPointsType& inPts,
337 const InNormalsType& inNormals,
338 const vtkm::Id& numNonCoincidentPts,
341 OutPointsType& outPts,
342 OutPointSrcIdxType& outPointSrcIdx)
const
361 outPts.Set(outIdx, p);
362 outPointSrcIdx.Set(outIdx, pIdx);
367 while (j < numPoints)
375 else if (jNext == numPoints)
385 pNextIdx = ptIndices[jNext];
386 pNext = inPts.Get(pNextIdx);
393 auto s = (sPrev + sNext) / 2.;
401 this->
RaiseError(
"Bad normal in Tube worklet.");
415 normal = w * cosValue + nP * sinValue;
416 auto newPt = p + this->
Radius * normal;
417 outPts.Set(outIdx, newPt);
418 outPointSrcIdx.Set(outIdx, pIdx);
428 outPts.Set(outIdx, p);
429 outPointSrcIdx.Set(outIdx, pIdx);
435 template <
typename Po
intIndexType,
typename InPo
intsType>
437 const InPointsType& inPts,
446 pNextIdx = ptIndices[i];
479 WholeArrayOut outConnectivity,
480 WholeArrayOut outCellSrcIdx);
490 template <
typename CellShapeTag,
typename OutConnType,
typename OutCellSrcIdxType>
496 OutConnType& outConn,
497 OutCellSrcIdxType& outCellSrcIdx)
const
504 vtkm::Id tubePtOffset = (this->
Capping ? tubePointOffset + 1 : tubePointOffset);
510 outConn.Set(outIdx + 0, tubePtOffset + i * this->NumSides + j);
511 outConn.Set(outIdx + 1, tubePtOffset + i * this->NumSides + (j + 1) % this->
NumSides);
512 outConn.Set(outIdx + 2,
513 tubePtOffset + (i + 1) * this->NumSides + (j + 1) % this->NumSides);
514 outCellSrcIdx.Set(outIdx / 3, inCellIndex);
518 outConn.Set(outIdx + 0, tubePtOffset + i * this->NumSides + j);
519 outConn.Set(outIdx + 1,
520 tubePtOffset + (i + 1) * this->NumSides + (j + 1) % this->NumSides);
521 outConn.Set(outIdx + 2, tubePtOffset + (i + 1) * this->NumSides + j);
522 outCellSrcIdx.Set(outIdx / 3, inCellIndex);
530 vtkm::Id startCenterPt = 0 + tubePointOffset;
533 outConn.Set(outIdx + 0, startCenterPt);
534 outConn.Set(outIdx + 1, startCenterPt + 1 + j);
535 outConn.Set(outIdx + 2, startCenterPt + 1 + ((j + 1) % this->
NumSides));
536 outCellSrcIdx.Set(outIdx / 3, inCellIndex);
541 vtkm::Id endCenterPt = (tubePointOffset + 1) + (numPoints * this->NumSides);
546 outConn.Set(outIdx + 0, endCenterPt);
547 outConn.Set(outIdx + 1, endOffsetPt + j);
548 outConn.Set(outIdx + 2, endOffsetPt + ((j + 1) % this->
NumSides));
549 outCellSrcIdx.Set(outIdx / 3, inCellIndex);
572 template <
typename SourceArrayType,
typename T>
574 const SourceArrayType& sourceArray,
577 output = sourceArray.Get(sourceIdx);
604 template <
typename Storage>
623 countInvoker.Invoke(cellset,
625 nonIncidentPtsPerPolyline,
632 if (totalPolylinePts == 0)
637 vtkm::Id totalTubeCells = totalTubeConnIds / 3;
640 tubePointOffsets, tubeConnOffsets;
643 vtkm::cont::make_ArrayHandleCast<vtkm::Id>(nonIncidentPtsPerPolyline),
644 nonIncidentPolylinePtOffset);
650 normals.Allocate(totalPolylinePts);
653 genNormalsDisp.Invoke(cellset, coords, polylinePtOffset, normals);
661 genPtsDisp.Invoke(cellset,
664 nonIncidentPtsPerPolyline,
672 newConnectivity.
Allocate(totalTubeConnIds);
676 genCellsDisp.Invoke(cellset,
677 nonIncidentPtsPerPolyline,
704 #endif // vtk_m_worklet_tube_h
bool Capping
Definition: worklet/Tube.h:458
VTKM_EXEC_CONT vtkm::Float32 Sqrt(vtkm::Float32 x)
Compute the square root of x.
Definition: Math.h:958
vtkm::cont::ArrayHandle< vtkm::Id > GetOutputPointSourceIndex() const
Definition: worklet/Tube.h:689
VTKM_CONT GeneratePoints(const bool &capping, const vtkm::Id &n, const vtkm::FloatDefault &r)
Definition: worklet/Tube.h:293
vtkm::Id NumSides
Definition: worklet/Tube.h:696
void(CellShape shapeType, PointCount numPoints, PointIndices ptIndices, _2 inPts, _3 polylineOffset, _4 outNormals) ExecutionSignature
Definition: worklet/Tube.h:142
#define VTKM_EXEC
Definition: ExportMacros.h:51
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_EXEC_CONT vtkm::Float32 Cos(vtkm::Float32 x)
Compute the cosine of x.
Definition: Math.h:269
VTKM_CONT bool CanConvert() const
Returns true if this cell set can be retrieved as the given type.
Definition: UnknownCellSet.h:161
vtkm::Id NumSides
Definition: worklet/Tube.h:117
void(CellShape shapeType, PointCount numPoints, PointIndices ptIndices, _2 inPts, _3 inNormals, _4 numNonCoincidentPts, _5 tubePointOffsets, _6 polylineOffset, _7 outPts, _8 outPointSrcIdx) ExecutionSignature
Definition: worklet/Tube.h:318
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
A control signature tag for output fields.
Definition: WorkletMapField.h:60
Definition: worklet/Tube.h:30
IncidentElementCount PointCount
Definition: WorkletMapTopology.h:267
VTKM_EXEC_CONT void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:168
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
_1 InputDomain
Definition: worklet/Tube.h:567
Definition: worklet/Tube.h:289
void(CellShape shapeType, InputIndex inCellIndex, _2 ptsPerPolyline, _3 tubePointOffset, _4 tubeConnOffsets, _5 outConn, _6 outCellSrcIdx) ExecutionSignature
Definition: worklet/Tube.h:487
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
void(CellSetIn cellset, WholeArrayIn pointCoords, FieldOut nonIncidentPtsPerPolyline, FieldOut ptsPerPolyline, FieldOut ptsPerTube, FieldOut numTubeConnIds, FieldOut validCell) ControlSignature
Definition: worklet/Tube.h:51
Definition: CastAndCall.h:34
Definition: worklet/Tube.h:465
VTKM_CONT void SetNumberOfSides(vtkm::Id n)
Definition: worklet/Tube.h:600
A CellSet of an unknown type.
Definition: UnknownCellSet.h:48
IncidentElementIndices PointIndices
Definition: WorkletMapTopology.h:269
VTKM_CONT MapField()
Definition: worklet/Tube.h:570
VTKM_EXEC_CONT vtkm::Float32 Sin(vtkm::Float32 x)
Compute the sine of x.
Definition: Math.h:210
void(CellSetIn cellset, WholeArrayIn pointCoords, WholeArrayIn normals, FieldInCell numNonCoincidentPts, FieldInCell tubePointOffsets, FieldInCell polylineOffset, WholeArrayOut newPointCoords, WholeArrayOut outPointSrcIdx) ControlSignature
Definition: worklet/Tube.h:308
_1 InputDomain
Definition: worklet/Tube.h:143
_1 InputDomain
Definition: worklet/Tube.h:488
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
VTKM_CONT void SetCapping(bool v)
Definition: worklet/Tube.h:598
Definition: worklet/Tube.h:122
VTKM_EXEC_CONT T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:157
void(CellSetIn cellset, WholeArrayIn pointCoords, FieldInCell polylineOffset, WholeArrayOut newNormals) ControlSignature
Definition: worklet/Tube.h:136
VTKM_EXEC void operator()(const CellShapeTag &shapeType, const vtkm::IdComponent &numPoints, const PointIndexType &ptIndices, const InPointsType &inPts, const vtkm::Id &polylineOffset, OutNormalType &outNormals) const
Definition: worklet/Tube.h:174
VTKM_EXEC vtkm::IdComponent FindNextNonCoincidentPointIndex(const PointIndexType &ptIndices, const InPointsType &inPts, vtkm::IdComponent start, vtkm::IdComponent numPoints) const
Definition: worklet/Tube.h:436
VTKM_CONT void Run(const vtkm::cont::ArrayHandle< vtkm::Vec3f, Storage > &coords, const vtkm::cont::UnknownCellSet &cellset, vtkm::cont::ArrayHandle< vtkm::Vec3f > &newPoints, vtkm::cont::CellSetSingleType<> &newCells)
Definition: worklet/Tube.h:605
A scatter that maps input to some numbers of output.
Definition: ScatterCounting.h:44
static VTKM_CONT ScatterType MakeScatter(const vtkm::cont::ArrayHandle< vtkm::Id > &validCell)
Definition: worklet/Tube.h:146
VTKM_CONT Tube()
Definition: worklet/Tube.h:582
vtkm::FloatDefault Radius
Definition: worklet/Tube.h:697
vtkm::worklet::ScatterCounting ScatterType
Definition: worklet/Tube.h:320
VTKM_EXEC void operator()(const CellShapeTag &shapeType, vtkm::Id inCellIndex, const vtkm::IdComponent &numPoints, const vtkm::Id &tubePointOffset, const vtkm::Id &tubeConnOffset, OutConnType &outConn, OutCellSrcIdxType &outCellSrcIdx) const
Definition: worklet/Tube.h:491
@ CELL_SHAPE_POLY_LINE
Definition: CellShape.h:40
Dispatcher for worklets that inherit from WorkletMapTopology.
Definition: DispatcherMapTopology.h:31
A control signature tag for input fields.
Definition: WorkletMapField.h:49
static VTKM_CONT T ScanExclusive(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, vtkm::cont::ArrayHandle< T, COut > &output)
Definition: Algorithm.h:816
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
Base class for worklets that map from Points to Cells.
Definition: WorkletMapTopology.h:255
VTKM_CONT CountSegments(const bool &capping, const vtkm::Id &n)
Definition: worklet/Tube.h:38
VTKM_CONT void SetRadius(vtkm::FloatDefault r)
Definition: worklet/Tube.h:602
vtkm::Vec3f DefaultNorm
Definition: worklet/Tube.h:285
#define VTKM_CONT
Definition: ExportMacros.h:57
bool Capping
Definition: worklet/Tube.h:695
bool Capping
Definition: worklet/Tube.h:557
vtkm::Id NumSides
Definition: worklet/Tube.h:459
@ CELL_SHAPE_TRIANGLE
Definition: CellShape.h:41
_1 InputDomain
Definition: worklet/Tube.h:61
Definition: worklet/Tube.h:562
static constexpr vtkm::FloatDefault vecMagnitudeEps
Definition: worklet/Tube.h:124
void(_1 sourceIdx, _2 sourceArray, _3 output) ExecutionSignature
Definition: worklet/Tube.h:566
vtkm::FloatDefault Theta
Definition: worklet/Tube.h:461
VTKM_EXEC void operator()(const vtkm::Id &sourceIdx, const SourceArrayType &sourceArray, T &output) const
Definition: worklet/Tube.h:573
static VTKM_CONT ScatterType MakeScatter(const vtkm::cont::ArrayHandle< vtkm::Id > &validCell)
Definition: worklet/Tube.h:322
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::Id NumVertsPerCell
Definition: worklet/Tube.h:118
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
_1 InputDomain
Definition: worklet/Tube.h:319
static VTKM_CONT U Reduce(vtkm::cont::DeviceAdapterId devId, const vtkm::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:656
void(CellShape shapeType, PointCount numPoints, PointIndices ptIndices, _2 inPts, _3 nonIncidentPtsPerPolyline, _4 ptsPerPolyline, _5 ptsPerTube, _6 numTubeConnIds, _7 validCell) ExecutionSignature
Definition: worklet/Tube.h:60
Definition: CastAndCall.h:36
float Float32
Definition: Types.h:154
VTKM_EXEC void operator()(const CellShapeTag &shapeType, const vtkm::IdComponent &numPoints, const PointIndexType &ptIndices, const InPointsType &inPts, vtkm::IdComponent &nonIncidentPtsPerPolyline, vtkm::Id &ptsPerPolyline, vtkm::Id &ptsPerTube, vtkm::Id &numTubeConnIds, vtkm::Id &validCell) const
Definition: worklet/Tube.h:64
Definition: worklet/Tube.h:34
vtkm::FloatDefault Radius
Definition: worklet/Tube.h:460
vtkm::Id NumSides
Definition: worklet/Tube.h:558
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::worklet::ScatterCounting ScatterType
Definition: worklet/Tube.h:144
void(FieldIn sourceIdx, WholeArrayIn sourceArray, FieldOut output) ControlSignature
Definition: worklet/Tube.h:565
VTKM_CONT GenerateNormals()
Definition: worklet/Tube.h:128
VTKM_EXEC vtkm::IdComponent FindValidSegment(const InPointsType &inPts, const PointIndexType &ptIndices, const vtkm::IdComponent &numPoints, vtkm::IdComponent start) const
Definition: worklet/Tube.h:152
vtkm::cont::ArrayHandle< vtkm::Id > OutputPointSourceIndex
Definition: worklet/Tube.h:699
VTKM_CONT GenerateCells(const bool &capping, const vtkm::Id &n)
Definition: worklet/Tube.h:469
VTKM_CONT Tube(const bool &capping, const vtkm::Id &n, const vtkm::FloatDefault &r)
Definition: worklet/Tube.h:590
FieldInVisit FieldInCell
Definition: WorkletMapTopology.h:261
VTKM_EXEC void operator()(const CellShapeTag &shapeType, const vtkm::IdComponent &numPoints, const PointIndexType &ptIndices, const InPointsType &inPts, const InNormalsType &inNormals, const vtkm::Id &numNonCoincidentPts, const vtkm::Id &tubePointOffsets, const vtkm::Id &polylineOffset, OutPointsType &outPts, OutPointSrcIdxType &outPointSrcIdx) const
Definition: worklet/Tube.h:333
VTKM_EXEC void RaiseError(const char *message) const
Definition: FunctorBase.h:40
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
bool Capping
Definition: worklet/Tube.h:116
void(CellSetIn cellset, FieldInCell ptsPerPolyline, FieldInCell tubePointOffsets, FieldInCell tubeConnOffsets, WholeArrayOut outConnectivity, WholeArrayOut outCellSrcIdx) ControlSignature
Definition: worklet/Tube.h:480
vtkm::cont::ArrayHandle< vtkm::Id > OutputCellSourceIndex
Definition: worklet/Tube.h:698
vtkm::cont::ArrayHandle< vtkm::Id > GetOutputCellSourceIndex() const
Definition: worklet/Tube.h:685