mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'fix-degenerates' into release-2.1
6e674ddea Fix degenerate polygon removal Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3126
This commit is contained in:
commit
1be389b123
9
docs/changelog/fix-degenerates.md
Normal file
9
docs/changelog/fix-degenerates.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Fix degenerate cell removal
|
||||
|
||||
There was a bug in `CleanGrid` when removing degenerate polygons where it
|
||||
would not detect if the first and last point were the same. This has been
|
||||
fixed.
|
||||
|
||||
There was also an error with function overloading that was causing 0D and
|
||||
3D cells to enter the wrong computation for degenerate cells. This has also
|
||||
been fixed.
|
@ -140,7 +140,7 @@ void TestPointMerging()
|
||||
<< std::endl;
|
||||
cleanGrid.SetRemoveDegenerateCells(true);
|
||||
vtkm::cont::DataSet noDegenerateCells = cleanGrid.Execute(inData);
|
||||
constexpr vtkm::Id numNonDegenerateCells = 33;
|
||||
constexpr vtkm::Id numNonDegenerateCells = 18;
|
||||
VTKM_TEST_ASSERT(noDegenerateCells.GetNumberOfCells() == numNonDegenerateCells);
|
||||
VTKM_TEST_ASSERT(noDegenerateCells.GetCellSet().GetNumberOfPoints() == farFastMergeNumPoints);
|
||||
VTKM_TEST_ASSERT(noDegenerateCells.GetNumberOfPoints() == farFastMergeNumPoints);
|
||||
|
@ -44,18 +44,20 @@ struct RemoveDegenerateCells
|
||||
{
|
||||
const vtkm::IdComponent numPoints = pointIds.GetNumberOfComponents();
|
||||
vtkm::IdComponent numUnduplicatedPoints = 0;
|
||||
for (vtkm::IdComponent localPointId = 0; localPointId < numPoints; ++localPointId)
|
||||
// Skip first point if it is the same as the last.
|
||||
for (vtkm::IdComponent localPointId = ((pointIds[0] != pointIds[numPoints - 1]) ? 0 : 1);
|
||||
localPointId < numPoints;
|
||||
++localPointId)
|
||||
{
|
||||
++numUnduplicatedPoints;
|
||||
if (numUnduplicatedPoints >= dimensionality + 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
while (((localPointId < numPoints - 1) &&
|
||||
(pointIds[localPointId] == pointIds[localPointId + 1])) ||
|
||||
((localPointId == numPoints - 1) && (pointIds[localPointId] == pointIds[0])))
|
||||
// Skip over any repeated points. Assume any repeated points are adjacent.
|
||||
while ((localPointId < numPoints - 1) &&
|
||||
(pointIds[localPointId] == pointIds[localPointId + 1]))
|
||||
{
|
||||
// Skip over any repeated points. Assume any repeated points are adjacent.
|
||||
++localPointId;
|
||||
}
|
||||
}
|
||||
@ -65,7 +67,7 @@ struct RemoveDegenerateCells
|
||||
template <typename CellShapeTag, typename PointVecType>
|
||||
VTKM_EXEC bool CheckForDimensionality(vtkm::CellTopologicalDimensionsTag<0>,
|
||||
CellShapeTag,
|
||||
PointVecType&&)
|
||||
PointVecType&&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -73,9 +75,10 @@ struct RemoveDegenerateCells
|
||||
template <typename CellShapeTag, typename PointVecType>
|
||||
VTKM_EXEC bool CheckForDimensionality(vtkm::CellTopologicalDimensionsTag<3>,
|
||||
CellShapeTag shape,
|
||||
PointVecType&& pointIds)
|
||||
PointVecType&& pointIds) const
|
||||
{
|
||||
const vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, *this);
|
||||
vtkm::IdComponent numFaces;
|
||||
vtkm::exec::CellFaceNumberOfFaces(shape, numFaces);
|
||||
vtkm::Id numValidFaces = 0;
|
||||
for (vtkm::IdComponent faceId = 0; faceId < numFaces; ++faceId)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user