10 #ifndef vtk_m_worklet_SplitSharpEdges_h
11 #define vtk_m_worklet_SplitSharpEdges_h
36 template <
typename Po
intFromCellSetType>
39 const PointFromCellSetType& pFromCellSet,
43 typename PointFromCellSetType::CellShapeTag cellShape = pFromCellSet.GetCellShape(cellIndexG);
44 typename PointFromCellSetType::IndicesType cellConnections = pFromCellSet.GetIndices(cellIndexG);
53 if (edgeIndex >= numEdges)
60 numPointsInCell, 0, edgeIndex, cellShape, localEdgeIndices[0]));
62 numPointsInCell, 1, edgeIndex, cellShape, localEdgeIndices[1]));
63 vtkm::Id2 canonicalEdgeId(cellConnections[localEdgeIndices[0]],
64 cellConnections[localEdgeIndices[1]]);
65 if (canonicalEdgeId[0] == pointIndex || canonicalEdgeId[1] == pointIndex)
67 if ((edge0G[0] == -1) && (edge0G[1] == -1))
69 edge0G = canonicalEdgeId;
73 edge1G = canonicalEdgeId;
84 template <
typename Po
intFromCellSetType,
typename Inc
identCellVecType>
86 const PointFromCellSetType& pFromCellSet,
87 const IncidentCellVecType& incidentCells,
88 const vtkm::Id currentCellLocalIndex)
90 int neighboringCellIndex = -1;
92 size_t neighboringCellsCount = 0;
93 for (
vtkm::IdComponent incidentCellIndex = 0; incidentCellIndex < numberOfIncidentCells;
96 if (currentCellLocalIndex == incidentCellIndex)
100 vtkm::Id cellIndexG = incidentCells[incidentCellIndex];
101 typename PointFromCellSetType::CellShapeTag cellShape = pFromCellSet.GetCellShape(cellIndexG);
102 typename PointFromCellSetType::IndicesType cellConnections =
103 pFromCellSet.GetIndices(cellIndexG);
106 vtkm::exec::CellEdgeNumberOfEdges(numPointsInCell, cellShape, numEdges);
112 if (edgeIndex >= numEdges)
117 vtkm::exec::CellEdgeLocalIndex(numPointsInCell, 0, edgeIndex, cellShape, localEdgeIndices[0]);
118 vtkm::exec::CellEdgeLocalIndex(numPointsInCell, 1, edgeIndex, cellShape, localEdgeIndices[1]);
119 vtkm::Id2 canonicalEdgeId(cellConnections[localEdgeIndices[0]],
120 cellConnections[localEdgeIndices[1]]);
121 if ((canonicalEdgeId[0] == eOI[0] && canonicalEdgeId[1] == eOI[1]) ||
122 (canonicalEdgeId[0] == eOI[1] && canonicalEdgeId[1] == eOI[0]))
124 neighboringCellIndex = incidentCellIndex;
125 neighboringCellsCount++;
130 return neighboringCellIndex;
134 template <
typename Inc
identCellVecType,
typename Po
intFromCellSetType,
typename FaceNormalVecType>
136 const IncidentCellVecType& incidentCells,
138 const PointFromCellSetType& pFromCellSet,
139 const FaceNormalVecType& faceNormals,
140 vtkm::Id visitedCellsRegionIndex[64],
143 const vtkm::IdComponent numberOfIncidentCells = incidentCells.GetNumberOfComponents();
145 if (numberOfIncidentCells <= 1)
155 for (
vtkm::IdComponent incidentCellIndex = 0; incidentCellIndex < numberOfIncidentCells;
158 vtkm::Id cellIndexG = incidentCells[incidentCellIndex];
160 if (!visitedCells.
test(incidentCellIndex))
163 visitedCells.
set(incidentCellIndex);
164 visitedCellsRegionIndex[incidentCellIndex] = regionIndex;
167 vtkm::Id2 edge0G(-1, -1), edge1G(-1, -1);
168 internal::FindRelatedEdges(pointIndex, cellIndexG, pFromCellSet, edge0G, edge1G);
170 for (
size_t i = 0; i < 2; i++)
172 vtkm::Id2 currentEdgeG = i == 0 ? edge0G : edge1G;
174 while (currentTestingCellIndex >= 0)
177 int neighboringCellIndexQuery = internal::FindNeighborCellInLocalIndex(
178 currentEdgeG, pFromCellSet, incidentCells, currentTestingCellIndex);
181 if (neighboringCellIndexQuery != -1 && !visitedCells.
test(neighboringCellIndexQuery))
186 auto thisNormal = faceNormals[currentTestingCellIndex];
188 auto neighborNormal = faceNormals[neighborCellIndex];
190 if (vtkm::dot(thisNormal, neighborNormal) > cosFeatureAngle)
192 visitedCells.
set(neighborCellIndex);
195 visitedCellsRegionIndex[neighborCellIndex] = regionIndex;
198 currentTestingCellIndex = neighborCellIndex;
199 vtkm::Id2 neighborCellEdge0G(-1, -1), neighborCellEdge1G(-1, -1);
200 internal::FindRelatedEdges(pointIndex,
201 incidentCells[currentTestingCellIndex],
206 if ((currentEdgeG == neighborCellEdge0G) ||
207 currentEdgeG ==
vtkm::Id2(neighborCellEdge0G[1], neighborCellEdge0G[0]))
209 currentEdgeG = neighborCellEdge1G;
213 currentEdgeG = neighborCellEdge0G;
218 currentTestingCellIndex = -1;
223 currentTestingCellIndex =
258 WholeCellSetIn<Cell, Point>,
270 template <
typename IncidentCellVecType,
271 typename PointFromCellSetType,
272 typename FaceNormalVecType>
275 const PointFromCellSetType& pFromCellSet,
276 const FaceNormalVecType& faceNormals,
281 vtkm::Id visitedCellsRegionIndex[64] = { 0 };
282 const bool foundConnections = internal::FindConnectedCellOwnerships(this->
CosFeatureAngle,
287 visitedCellsRegionIndex,
289 if (!foundConnections)
297 vtkm::Id numberOfCellsNeedUpdate = 0;
301 if (visitedCellsRegionIndex[i] > 0)
303 numberOfCellsNeedUpdate++;
306 newPointNum = regionIndex - 1;
307 cellNum = numberOfCellsNeedUpdate;
326 WholeCellSetIn<Cell, Point>,
330 WholeArrayOut cellTopologyUpdateTuples);
335 _4 newPointStartingIndex,
336 _5 pointCellsStartingIndex,
337 _6 cellTopologyUpdateTuples);
340 template <
typename IncidentCellVecType,
341 typename PointFromCellSetType,
342 typename FaceNormalVecType,
343 typename CellTopologyUpdateTuples>
346 const PointFromCellSetType& pFromCellSet,
347 const FaceNormalVecType& faceNormals,
348 const vtkm::Id& newPointStartingIndex,
349 const vtkm::Id& pointCellsStartingIndex,
350 CellTopologyUpdateTuples& cellTopologyUpdateTuples)
const
353 vtkm::Id visitedCellsRegionIndex[64] = { 0 };
354 const bool foundConnections = internal::FindConnectedCellOwnerships(this->
CosFeatureAngle,
359 visitedCellsRegionIndex,
361 if (foundConnections)
365 vtkm::Id cellTopologyUpdateTuplesIndex = pointCellsStartingIndex;
369 if (visitedCellsRegionIndex[i])
376 cellTopologyUpdateTuples.Set(cellTopologyUpdateTuplesIndex, tuple);
377 cellTopologyUpdateTuplesIndex++;
388 template <
typename CellSetType,
389 typename FaceNormalsType,
390 typename CoordsComType,
391 typename CoordsInStorageType,
392 typename CoordsOutStorageType,
393 typename NewCellSetType>
395 const CellSetType& oldCellset,
397 const FaceNormalsType& faceNormals,
400 NewCellSetType& newCellset)
405 featureAngle /
static_cast<vtkm::FloatDefault>(180.0) * vtkm::Pi<vtkm::FloatDefault>();
410 invoke(classifyPoint, oldCellset, oldCellset, faceNormals, newPointNums, cellNeedUpdateNums);
430 oldCoords.GetNumberOfValues(),
431 this->NewPointsIdArray,
436 newCoords.Allocate(oldCoords.GetNumberOfValues() + totalNewPointsNum);
439 if (totalNewPointsNum > 0)
442 vtkm::Id newCoordsIndex = oldCoords.GetNumberOfValues();
443 auto oldCoordsPortal = oldCoords.ReadPortal();
444 auto newCoordsPortal = newCoords.WritePortal();
445 auto newPointNumsPortal = newPointNums.
WritePortal();
446 for (
vtkm::Id i = 0; i < oldCoords.GetNumberOfValues(); i++)
448 for (
vtkm::Id j = 0; j < newPointNumsPortal.Get(i); j++)
450 newPointsIdArrayPortal.Set(newCoordsIndex, i);
451 newCoordsPortal.Set(newCoordsIndex++, oldCoordsPortal.Get(i));
458 cellTopologyUpdateTuples.
Allocate(cellsNeedUpdateNum);
466 invoke(splitSharpEdge,
470 newpointStartingIndexs,
471 pointCellsStartingIndexs,
472 cellTopologyUpdateTuples);
473 auto ctutPortal = cellTopologyUpdateTuples.
ReadPortal();
483 auto connectivityArrayHandleP = connectivityArrayHandle.WritePortal();
484 auto offsetArrayHandle =
486 auto offsetArrayHandleP = offsetArrayHandle.WritePortal();
489 vtkm::Id cellId(ctutPortal.Get(i)[0]), oldPointId(ctutPortal.Get(i)[1]),
490 newPointId(ctutPortal.Get(i)[2]);
491 vtkm::Id bound = (cellId + 1 == offsetArrayHandle.GetNumberOfValues())
492 ? connectivityArrayHandle.GetNumberOfValues()
493 : offsetArrayHandleP.Get(cellId + 1);
495 for (
vtkm::Id j = offsetArrayHandleP.Get(cellId); j < bound; j++, k++)
497 if (connectivityArrayHandleP.Get(j) == oldPointId)
499 connectivityArrayHandleP.Set(j, newPointId);
513 #endif // vtk_m_worklet_SplitSharpEdges_h