I used vtkSelectPolyData to find the center area in the circle on the surface of the tooth. But it often failed to give me a satisfying result but showed the error, `Can't follow edge`

. The worse situation is that it crashed when I tried to access the scalar in point data. After reading the source code of vtkSelectPolyData, I realized that the algorithm in `vtkSelectPolyData::RequestData`

can’t found a valid neighbor point for edge point, it stoped working and jump out if the event happened.

The original process looks like these steps.

1, Find the closest point on the input poly data for every point of the circle, then collect the closest point to forms loopIds.

2, Find all mesh edges which are along the loop edge lines. Stop collecting mesh edge points’ ids if the mesh edge is always orthogonal with a loop edge.

3, Mark the points around the mesh edges found in step 2 value -1 and generate a connected circle.

4, Expand the front region (red area).

So I change the logic for step 2, don’t stop collect mesh edge points’ ids, continue to explore the next loop edge point.

```
if ( closest < 0 )
{
Log( IDebug, "numNei: ", numNei, ", id: ", id, ", i: ", i );
m_BrokenPtId = id;
vtkErrorMacro(<<"Can't follow edge");
// triMesh->UnRegister(this);
// this->Mesh->Delete();
// neighbors->Delete();
// edgeIds->Delete();
// loopIds->Delete();
// return 1;
edgeIds->InsertNextId( nextId );
prevId = id;
id = nextId;
inPts->GetPoint( id, x );
}
```

I rewrote the class vtkSelectPolyData to generate a new class CUVtkSelectPolyData and used it in my project. The whole source code can be found in GitHub, vtkSelectExplore .

The new logic need to be tested, maybe it also has defects.