53 #ifndef vtk_m_worklet_contourtree_augmented_process_contourtree_inc_set_triangle_superarc_id_h
54 #define vtk_m_worklet_contourtree_augmented_process_contourtree_inc_set_triangle_superarc_id_h
63 namespace contourtree_augmented
65 namespace process_contourtree_inc
79 WholeArrayIn endpoints,
80 WholeArrayIn dataField,
81 WholeArrayIn isovalue,
82 WholeArrayIn sortOrder,
83 WholeArrayIn sortIndices,
84 WholeArrayIn contourTreeSuperparents,
85 WholeArrayIn contourTreeWhenTransferred,
86 WholeArrayIn contourTreeHyperparents,
87 WholeArrayIn contourTreeHyperarcs,
88 WholeArrayIn contourTreeHypernodes,
89 WholeArrayIn contourTreeSupernodes,
90 WholeArrayIn meshExtremaPeaks,
91 WholeArrayIn meshExtremaPits,
92 WholeArrayOut superarcIds
96 ExecutionSignature(
InputIndex, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14);
110 template <
typename EndpointsArrayPortalType,
111 typename InFieldArrayPortalType,
112 typename InArrayPortalType,
113 typename OutArrayPortalType>
115 const EndpointsArrayPortalType& endpointsPortal,
116 const InFieldArrayPortalType& fieldPortal,
117 const InFieldArrayPortalType& isovaluePortal,
118 const InArrayPortalType& sortOrder,
119 const InArrayPortalType& sortIndices,
120 const InArrayPortalType& contourTreeSuperparentsPortal,
121 const InArrayPortalType& contourTreeWhenTransferredPortal,
122 const InArrayPortalType& contourTreeHyperparentsPortal,
123 const InArrayPortalType& contourTreeHyperarcsPortal,
124 const InArrayPortalType& contourTreeHypernodesPortal,
125 const InArrayPortalType& contourTreeSupernodesPortal,
126 const InArrayPortalType& meshExtremaPeaksPortal,
127 const InArrayPortalType& meshExtremaPitsPortal,
128 const OutArrayPortalType& superarcIdsPortal)
const
132 using namespace vtkm;
136 Float32 isovalue = isovaluePortal.Get(node);
141 vtkm::Id edgeEndpointA = sortIndices.Get(endpointsPortal.Get(node)[0]);
142 vtkm::Id edgeEndpointB = sortIndices.Get(endpointsPortal.Get(node)[1]);
146 if (edgeEndpointA < edgeEndpointB)
149 edgeEndpointA = edgeEndpointB;
150 edgeEndpointB = temp;
154 vtkm::Id top = meshExtremaPeaksPortal.Get(edgeEndpointA);
155 vtkm::Id bottom = meshExtremaPitsPortal.Get(edgeEndpointB);
162 vtkm::Id topWhen = contourTreeWhenTransferredPortal.Get(topSuperparent);
163 vtkm::Id bottomWhen = contourTreeWhenTransferredPortal.Get(bottomSuperparent);
166 vtkm::Id topHyperparent = contourTreeHyperparentsPortal.Get(topSuperparent);
167 vtkm::Id bottomHyperparent = contourTreeHyperparentsPortal.Get(bottomSuperparent);
184 topSuperparent = contourTreeHyperarcsPortal.Get(
MaskedIndex(topHyperparent));
185 top = contourTreeSupernodesPortal.Get(
MaskedIndex(topSuperparent));
187 topWhen = contourTreeWhenTransferredPortal.Get(
MaskedIndex(topSuperparent));
193 if (fieldPortal.Get(sortOrder.Get(
MaskedIndex(top))) < isovalue)
195 hyperparent = topHyperparent;
200 topHyperparent = contourTreeHyperparentsPortal.Get(
MaskedIndex(topSuperparent));
206 bottomSuperparent = contourTreeHyperarcsPortal.Get(
MaskedIndex(bottomHyperparent));
207 bottom = contourTreeSupernodesPortal.Get(
MaskedIndex(bottomSuperparent));
208 bottomWhen = contourTreeWhenTransferredPortal.Get(
MaskedIndex(bottomSuperparent));
213 if (fieldPortal.Get(sortOrder.Get(
MaskedIndex(bottom))) > isovalue)
215 hyperparent = bottomHyperparent;
220 bottomHyperparent = contourTreeHyperparentsPortal.Get(
MaskedIndex(bottomSuperparent));
227 hyperparent = bottomHyperparent;
232 if (
IsAscending(contourTreeHyperarcsPortal.Get(hyperparent)))
236 vtkm::Id lowSupernode = contourTreeHypernodesPortal.Get(hyperparent);
243 highSupernode = contourTreeHypernodesPortal.Get(
MaskedIndex(hyperparent) + 1) - 1;
249 if (fieldPortal.Get(sortOrder.Get(
255 superarcIdsPortal.Set(node, highSupernode);
260 while (highSupernode - lowSupernode > 1)
263 vtkm::Id midSupernode = (lowSupernode + highSupernode) / 2;
268 if (fieldPortal.Get(sortOrder.Get((contourTreeSupernodesPortal.Get((midSupernode))))) >
270 highSupernode = midSupernode;
273 lowSupernode = midSupernode;
281 superarcIdsPortal.Set(node, lowSupernode);
287 vtkm::Id highSupernode = contourTreeHypernodesPortal.Get(hyperparent);
297 lowSupernode = contourTreeHypernodesPortal.Get(
MaskedIndex(hyperparent) + 1) - 1;
304 if (fieldPortal.Get(sortOrder.Get(
310 superarcIdsPortal.Set(node, lowSupernode);
315 while (lowSupernode - highSupernode > 1)
318 vtkm::Id midSupernode = (highSupernode + lowSupernode) / 2;
324 contourTreeSupernodesPortal.Get(
MaskedIndex(midSupernode))))) > isovalue)
325 highSupernode = midSupernode;
328 lowSupernode = midSupernode;
335 superarcIdsPortal.Set(node, highSupernode);