diff --git a/source/MRCuda/MRCudaFastWindingNumber.cpp b/source/MRCuda/MRCudaFastWindingNumber.cpp index e86359f05c01..b968913ca957 100644 --- a/source/MRCuda/MRCudaFastWindingNumber.cpp +++ b/source/MRCuda/MRCudaFastWindingNumber.cpp @@ -124,10 +124,10 @@ Expected FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float } ); } -Expected FastWindingNumber::calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) +Expected FastWindingNumber::calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) { MR_TIMER - if ( auto maybe = prepareData_( {} ) ) + if ( auto maybe = prepareData_( subprogress( cb, 0.0, 0.5f ) ) ) return unexpected( std::move( maybe.error() ) ); const auto getCudaMatrix = [] ( const AffineXf3f& xf ) @@ -145,7 +145,7 @@ Expected FastWindingNumber::calcFromGrid( std::vector& res, const V const size_t size = size_t( dims.x ) * dims.y * dims.z; DynamicArrayF cudaResult; CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.resize( size ) ); - if ( !reportProgress( cb, 0.0f ) ) + if ( !reportProgress( cb, 0.6f ) ) return unexpectedOperationCanceled(); fastWindingNumberFromGrid( @@ -153,11 +153,11 @@ Expected FastWindingNumber::calcFromGrid( std::vector& res, const V cudaGridToMeshXf, data_->dipoles.data(), data_->cudaNodes.data(), data_->cudaMeshPoints.data(), data_->cudaFaces.data(), cudaResult.data(), beta ); - CUDA_LOGE_RETURN_UNEXPECTED( cudaGetLastError() ); + if ( !reportProgress( cb, 0.7f ) ) + return unexpectedOperationCanceled(); CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.toVector( res ) ); - if ( !reportProgress( cb, 1.0f ) ) return unexpectedOperationCanceled(); return {}; diff --git a/source/MRCuda/MRCudaFastWindingNumber.h b/source/MRCuda/MRCudaFastWindingNumber.h index 0545aae5e3ea..79f8c2821a25 100644 --- a/source/MRCuda/MRCudaFastWindingNumber.h +++ b/source/MRCuda/MRCudaFastWindingNumber.h @@ -26,7 +26,7 @@ class MRCUDA_CLASS FastWindingNumber : public IFastWindingNumber // see methods' descriptions in IFastWindingNumber MRCUDA_API Expected calcFromVector( std::vector& res, const std::vector& points, float beta, FaceId skipFace, const ProgressCallback& cb ) override; MRCUDA_API Expected calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb ) override; - MRCUDA_API Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) override; + MRCUDA_API Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) override; MRCUDA_API Expected calcFromGridWithDistances( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, const DistanceToMeshOptions& options, const ProgressCallback& cb ) override; private: diff --git a/source/MRMesh/MRFastWindingNumber.cpp b/source/MRMesh/MRFastWindingNumber.cpp index c710b2ceeddc..802bbdeffe04 100644 --- a/source/MRMesh/MRFastWindingNumber.cpp +++ b/source/MRMesh/MRFastWindingNumber.cpp @@ -51,7 +51,7 @@ Expected FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float return {}; } -Expected FastWindingNumber::calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) +Expected FastWindingNumber::calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) { MR_TIMER diff --git a/source/MRMesh/MRFastWindingNumber.h b/source/MRMesh/MRFastWindingNumber.h index 097dc2b8e395..d675d3eeb54e 100644 --- a/source/MRMesh/MRFastWindingNumber.h +++ b/source/MRMesh/MRFastWindingNumber.h @@ -36,7 +36,7 @@ class IFastWindingNumber /// dimensions of the grid /// transform from integer grid locations to voxel's centers in mesh reference frame /// determines the precision of the approximation: the more the better, recommended value 2 or more - virtual Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb = {} ) = 0; + virtual Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb = {} ) = 0; /// /// calculates distances with the sign obtained from generalized winding number in each point from a three-dimensional grid; @@ -61,7 +61,7 @@ class MRMESH_CLASS FastWindingNumber : public IFastWindingNumber // see methods' descriptions in IFastWindingNumber MRMESH_API Expected calcFromVector( std::vector& res, const std::vector& points, float beta, FaceId skipFace, const ProgressCallback& cb ) override; MRMESH_API Expected calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb ) override; - MRMESH_API Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) override; + MRMESH_API Expected calcFromGrid( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) override; MRMESH_API float calcWithDistances( const Vector3f& p, const DistanceToMeshOptions& options ); MRMESH_API Expected calcFromGridWithDistances( std::vector& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, const DistanceToMeshOptions& options, const ProgressCallback& cb ) override;