static void buildSnapIndex( QgsFeatureIterator &fi, QgsSpatialIndex &index, QVector<AnchorPoint> &pnts, QgsFeedback *feedback, int &count, int totalCount ) { QgsFeature f; int pntId = 0; while ( fi.nextFeature( f ) ) { if ( feedback->isCanceled() ) break; QgsGeometry g = f.geometry(); for ( auto it = g.vertices_begin(); it != g.vertices_end(); ++it ) { QgsPoint pt = *it; QgsRectangle rect( pt.x(), pt.y(), pt.x(), pt.y() ); QList<QgsFeatureId> ids = index.intersects( rect ); if ( ids.isEmpty() ) { // add to tree and to structure index.insertFeature( pntId, pt.boundingBox() ); AnchorPoint xp; xp.x = pt.x(); xp.y = pt.y(); xp.anchor = -1; pnts.append( xp ); pntId++; } } ++count; feedback->setProgress( 100. * count / totalCount ); } }