Wrong non-manifolds (vtkFeatureEdges)
I found a bug with non-manifold edges in vtkFeatureEdges. The filter marks an edge, that is not non-manifold.
Here are the steps to reproduce:
#!/usr/bin/env python
# *-* coding: UTF-8 *-*
from vtkmodules.vtkFiltersCore import vtkFeatureEdges
from vtkmodules.vtkIOLegacy import vtkPolyDataReader
from vtkmodules.vtkCommonCore import vtkIdList
from collections import defaultdict
reader = vtkPolyDataReader()
reader.SetFileName('c1.vtk')
reader.Update()
pd = reader.GetOutput()
features = vtkFeatureEdges()
features.BoundaryEdgesOff()
features.FeatureEdgesOff()
features.ManifoldEdgesOff()
features.NonManifoldEdgesOn()
features.SetInputConnection(reader.GetOutputPort())
features.Update()
lines = features.GetOutput()
if lines.GetNumberOfCells() > 0:
pd.BuildLinks()
itr = lines.GetLines().NewIterator()
while not itr.IsDoneWithTraversal():
line = itr.GetCurrentCell()
a = lines.GetPoint(line.GetId(0))
b = lines.GetPoint(line.GetId(1))
a2 = pd.FindPoint(a)
b2 = pd.FindPoint(b)
a3 = vtkIdList()
b3 = vtkIdList()
pd.GetPointCells(a2, a3)
pd.GetPointCells(b2, b3)
neigs = defaultdict(list)
for i in range(a3.GetNumberOfIds()):
neigs[a3.GetId(i)].append(a2)
for i in range(b3.GetNumberOfIds()):
neigs[b3.GetId(i)].append(b2)
for p, ids in neigs.items():
if len(ids) > 1:
print(p, ids)
pts = vtkIdList()
pd.GetCellPoints(p, pts)
try:
f, s = ids
ids_ = [ pts.GetId(i) for i in range(pts.GetNumberOfIds()) ]
print(ids_)
index1 = ids_.index(f)
index2 = ids_.index(s)
neighbored = ids_[0 if index1 == pts.GetNumberOfIds()-1 else index1+1] == s or \
ids_[0 if index2 == pts.GetNumberOfIds()-1 else index2+1] == f
print(index1, index2, neighbored)
except ValueError as e:
print(e)
itr.GoToNextCell()
The output is:
18666 [9648, 9647]
[9643, 9649, 9648, 9647, 9646, 9645, 9642]
2 3 True
18667 [9648, 9647]
[9648, 9650, 9651, 9652, 9653, 9647]
0 5 True
18682 [9648, 9647]
[9583, 9582, 9647, 9653, 9652, 9651, 9650, 9648, 9604]
7 2 False
The last output shows that the points inside the cell are not neighbored. Therefore, the edge is manifold.