GetCellEdgeNeighbors gives all 0s

Hello,I have a cude ,and want to get the neighbors of each cell iterating edge like this:

GetCellEdgeNeighbors( cellId , edgeStart , edgeEnd , xxx)

In expectation,each edge should have one neighbor,but all got 0,and if set cellId to -1,I got one neighbor for each edge, runnable code like this:

#include <iostream>
#include <string>
#include <vector>
#include <vtkOBJReader.h>

struct Edge {
		long long from;
		long long to;
};

//if face is [0 1 2 3],it's edges will be {[0,1],[1,2],[2,3],[3,0]}
//caution last point will connect back to first point as last edge
std::vector<Edge> faceToEdges(std::vector<long long> face) {
	std::vector<Edge> edges;

	int size = face.size();
	for (int i = 1; i <= size; i++) {
		if (i == size) { //link last point to first point
			edges.emplace_back(Edge { face.at(i - 1), face.at(0) });
		} else { //link previous point to current point
			edges.emplace_back(Edge { face.at(i - 1), face.at(i) });
		}
	}

	return edges;
}

//extract point(indexes) of each cell,then push these cells into a vector,similar to EBO
std::vector<std::vector<long long>> faceTable(vtkPolyData *pd) {
	std::vector<std::vector<long long>> cs;

	vtkCellArray *polys = pd->GetPolys();

	vtkIdType npts;
	const vtkIdType *indx;

	for (polys->InitTraversal(); polys->GetNextCell(npts, indx);) {
		std::vector<long long> cell;
		for (int i = 0; i < npts; i++) {
			cell.emplace_back(indx[i]);
		}
		cs.emplace_back(cell);
	}

	return cs;
}

int main(int, char*[]) {

	auto fileName =  "/home/alex/workspace/Geometry-Python/files/Cube-With-Reversed-Normal.obj";
//	auto fileName = "/path/to/cube.obj";

	vtkNew<vtkOBJReader> reader;
	reader->SetFileName(fileName);
	reader->Update();
	auto pd = reader->GetOutput();

	std::cout << "Point number: " << pd->GetNumberOfPoints() << std::endl<< std::endl;

	pd->BuildLinks();

	auto cells = faceTable(pd);

	for (long long i = 0; i < cells.size(); i++) {
		auto edges = faceToEdges(cells.at(i));
		for (auto &edge : edges) {
			vtkNew<vtkIdList> neighbors;
			pd->GetCellEdgeNeighbors(i, edge.from, edge.to, neighbors);
			std::cout << "Cell " << i << " Edge " << edge.from << "-" << edge.to << " neighbors: " << neighbors->GetNumberOfIds() << std::endl;
		}
	}

	return 1;
}

And the output like this:

Point number: 24

Cell 0 Edge 0-1 neighbors: 0
Cell 0 Edge 1-2 neighbors: 0
Cell 0 Edge 2-3 neighbors: 0
Cell 0 Edge 3-0 neighbors: 0
Cell 1 Edge 4-5 neighbors: 0
Cell 1 Edge 5-6 neighbors: 0
....

As you can,all 0s, the questions are:

1,Why does “cellId= -1” give wanted result,but all real cellId gives 0?

2,Each cude has 8 points,why does “pd->GetNumberOfPoints()” give 24?

My suspicion is that you have coincident points, so that the cells are not topologically joined. Use something like vtkCleanPolyData or vtkStaticCleanPolyData to merge the coincident points.

You are right,thanks!!