diff --git a/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp b/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp index e58e7566a79f..5423af94e7a8 100644 --- a/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp +++ b/src/analysis/processing/qgsalgorithmmeshsurfacetopolygon.cpp @@ -128,10 +128,11 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa QgsGeometry lines; QgsMeshFace face; - QMap, int> edges; // edge as key and count of edge occurence as value + QMap, int> edges; // edge as key and count of edge usage as value std::pair edge; - feedback->setProgressText( "Parsing mesh faces to extract edges." ); + if ( feedback ) + feedback->setProgressText( "Parsing mesh faces to extract edges." ); for ( int i = 0; i < mNativeMesh.faceCount(); i++ ) { @@ -172,12 +173,15 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa } } - feedback->setProgress( 100 * i / mNativeMesh.faceCount() ); + if ( feedback ) + feedback->setProgress( 100 * i / mNativeMesh.faceCount() ); } - feedback->setProgress( 0 ); - feedback->setProgressText( "Parsing mesh edges." ); - + if ( feedback ) + { + feedback->setProgress( 0 ); + feedback->setProgressText( "Parsing mesh edges." ); + } std::unique_ptr multiLineString( new QgsMultiLineString() ); int i = 0; @@ -195,15 +199,16 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa std::unique_ptr line( new QgsLineString( mNativeMesh.vertex( it.key().first ), mNativeMesh.vertex( it.key().second ) ) ); multiLineString->addGeometry( line.release() ); } + if ( feedback ) + feedback->setProgress( 100 * i / edges.size() ); - feedback->setProgress( 100 * i / edges.size() ); i++; } - feedback->setProgressText( "Creating final geometry." ); if ( feedback ) { + feedback->setProgressText( "Creating final geometry." ); if ( feedback->isCanceled() ) return QVariantMap(); } @@ -221,6 +226,12 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa { for ( auto pit = multiLinesAbstract->const_parts_begin(); pit != multiLinesAbstract->const_parts_end(); ++pit ) { + if ( feedback ) + { + if ( feedback->isCanceled() ) + return QVariantMap(); + } + std::unique_ptr polygon = std::make_unique(); polygon->setExteriorRing( qgsgeometry_cast< QgsLineString * >( *pit )->clone() ); multiPolygon->addGeometry( polygon.release() ); @@ -260,7 +271,6 @@ QVariantMap QgsMeshSurfaceToPolygonAlgorithm::processAlgorithm( const QVariantMa return QVariantMap(); } - QVariantMap ret; ret[QStringLiteral( "OUTPUT" )] = identifier;