13 #ifndef vtk_m_worklet_contour_flyingedges_pass4y_h
14 #define vtk_m_worklet_contour_flyingedges_pass4y_h
27 namespace flying_edges
58 WholeArrayIn cell_tri_count,
59 WholeArrayIn edgeData,
61 WholeArrayOut connectivity,
62 WholeArrayOut edgeIds,
63 WholeArrayOut weights,
64 WholeArrayOut inputCellIds);
66 void(
ThreadIndices, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11,
WorkIndex);
69 typename FieldInPointId3,
70 typename FieldInPointId,
71 typename WholeTriField,
72 typename WholeEdgeField,
73 typename WholeDataField,
74 typename WholeConnField,
75 typename WholeEdgeIdField,
76 typename WholeWeightField,
77 typename WholeCellIdField>
79 const FieldInPointId3& axis_sums,
80 const FieldInPointId& axis_mins,
81 const FieldInPointId& axis_maxs,
82 const WholeTriField& cellTriCount,
83 const WholeEdgeField& edges,
84 const WholeDataField& field,
85 const WholeConnField& conn,
86 const WholeEdgeIdField& interpolatedEdgeIds,
87 const WholeWeightField& weights,
88 const WholeCellIdField& inputCellIds,
95 vtkm::Id cell_tri_offset = cellTriCount.Get(oidx);
96 vtkm::Id next_tri_offset = cellTriCount.Get(oidx + 1);
97 if (cell_tri_offset == next_tri_offset)
104 AxisToSum{}, this->
PointDims, threadIndices, axis_sums, axis_mins, axis_maxs, edges);
114 auto edgeCase =
getEdgeCase(edges, state.startPos, (state.axis_inc * state.left));
116 for (
vtkm::Id i = state.left; i < state.right; ++i)
118 edgeCase =
getEdgeCase(edges, state.startPos, (state.axis_inc * i));
124 state.cellId, edgeCase, numTris, edgeIds, cell_tri_offset, conn, inputCellIds);
131 this->
Generate(state.boundaryStatus,
137 (state.axis_inc * i),
143 state.increment(AxisToSum{}, pdims);
148 template <
typename WholeDataField,
typename WholeIEdgeField,
typename WholeWeightField>
150 const WholeDataField& field,
151 const WholeIEdgeField& interpolatedEdgeIds,
152 const WholeWeightField& weights,
163 auto s0 = field.Get(pos[0]);
168 auto writeIndex = edgeIds[0];
169 pos[1] = startPos[0] + offset + incs[AxisToSum::xindex];
170 auto s1 = field.Get(pos[1]);
171 T t =
static_cast<T
>((this->IsoValue - s0) / (s1 - s0));
173 interpolatedEdgeIds.Set(writeIndex, pos);
178 auto writeIndex = edgeIds[4];
179 pos[1] = startPos[1] + offset;
180 auto s1 = field.Get(pos[1]);
181 T t =
static_cast<T
>((this->IsoValue - s0) / (s1 - s0));
183 interpolatedEdgeIds.Set(writeIndex, pos);
188 auto writeIndex = edgeIds[8];
189 pos[1] = startPos[2] + offset;
190 auto s1 = field.Get(pos[1]);
191 T t =
static_cast<T
>((this->IsoValue - s0) / (s1 - s0));
193 interpolatedEdgeIds.Set(writeIndex, pos);
210 this->
InterpolateEdge(pos[0], incs, 5, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
211 this->
InterpolateEdge(pos[0], incs, 9, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
214 this->
InterpolateEdge(pos[0], incs, 11, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
218 this->
InterpolateEdge(pos[0], incs, 7, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
223 this->
InterpolateEdge(pos[0], incs, 1, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
224 this->
InterpolateEdge(pos[0], incs, 10, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
227 this->
InterpolateEdge(pos[0], incs, 3, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
232 this->
InterpolateEdge(pos[0], incs, 2, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
233 this->
InterpolateEdge(pos[0], incs, 6, edgeUses, edgeIds, field, interpolatedEdgeIds, weights);
240 template <
typename WholeField,
typename WholeIEdgeField,
typename WholeWeightField>
246 const WholeField& field,
247 const WholeIEdgeField& interpolatedEdgeIds,
248 const WholeWeightField& weights)
const
253 if (!edgeUses[edgeNum])
257 const vtkm::Id writeIndex = edgeIds[edgeNum];
265 vtkm::Id2 iEdge(currentIdx + vtkm::Dot(offsets1, incs), currentIdx + vtkm::Dot(offsets2, incs));
267 interpolatedEdgeIds.Set(writeIndex, iEdge);
269 auto s0 = field.Get(iEdge[0]);
270 auto s1 = field.Get(iEdge[1]);
271 T t =
static_cast<T
>((this->IsoValue - s0) / (s1 - s0));
276 template <
typename T>
288 bool generateNormals)
292 if (!generateNormals)
294 this->NormalWriteOffset = -1;
299 FieldIn interpWeight,
302 WholeArrayOut normals);
305 template <
typename PT,
typename WholeInputField,
typename WholeNormalField>
309 const WholeInputField& field,
310 WholeNormalField& normals,
314 vtkm::Vec3f point1 = this->Coordinates.Get(interpEdgeIds[0]);
315 vtkm::Vec3f point2 = this->Coordinates.Get(interpEdgeIds[1]);
316 outPoint =
vtkm::Lerp(point1, point2, weight);
320 if (this->NormalWriteOffset >= 0)
323 const vtkm::Id3& dims = this->Coordinates.GetDimensions();
324 vtkm::Id3 ijk{ interpEdgeIds[0] % dims[0],
325 (interpEdgeIds[0] / dims[0]) % dims[1],
326 interpEdgeIds[0] / (dims[0] * dims[1]) };
331 coord_neighborhood(this->Coordinates, boundary);
337 gradient(boundary, coord_neighborhood, field_neighborhood, g0);
341 (interpEdgeIds[1] / dims[0]) % dims[1],
342 interpEdgeIds[1] / (dims[0] * dims[1]) };
343 gradient(boundary, coord_neighborhood, field_neighborhood, g1);
349 n = n * vtkm::RSqrt(mag2);
351 normals.Set(this->NormalWriteOffset + oidx, n);