Skip to content

Commit

Permalink
FastWindingNumber::calcFromGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedr committed Jan 2, 2025
1 parent 5abbba7 commit c4b6dcc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions source/MRCuda/MRCudaFastWindingNumber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ Expected<void> FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float
} );
}

Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb )
Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& 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 )
Expand All @@ -145,19 +145,19 @@ Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& 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(
int3{ dims.x, dims.y, dims.z },
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 {};
Expand Down
2 changes: 1 addition & 1 deletion source/MRCuda/MRCudaFastWindingNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MRCUDA_CLASS FastWindingNumber : public IFastWindingNumber
// see methods' descriptions in IFastWindingNumber
MRCUDA_API Expected<void> calcFromVector( std::vector<float>& res, const std::vector<Vector3f>& points, float beta, FaceId skipFace, const ProgressCallback& cb ) override;
MRCUDA_API Expected<void> calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb ) override;
MRCUDA_API Expected<void> calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) override;
MRCUDA_API Expected<void> calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) override;
MRCUDA_API Expected<void> calcFromGridWithDistances( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, const DistanceToMeshOptions& options, const ProgressCallback& cb ) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion source/MRMesh/MRFastWindingNumber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Expected<void> FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float
return {};
}

Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb )
Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb )
{
MR_TIMER

Expand Down
4 changes: 2 additions & 2 deletions source/MRMesh/MRFastWindingNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class IFastWindingNumber
/// <param name="dims">dimensions of the grid</param>
/// <param name="gridToMeshXf">transform from integer grid locations to voxel's centers in mesh reference frame</param>
/// <param name="beta">determines the precision of the approximation: the more the better, recommended value 2 or more</param>
virtual Expected<void> calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb = {} ) = 0;
virtual Expected<void> calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb = {} ) = 0;

/// <summary>
/// calculates distances with the sign obtained from generalized winding number in each point from a three-dimensional grid;
Expand All @@ -61,7 +61,7 @@ class MRMESH_CLASS FastWindingNumber : public IFastWindingNumber
// see methods' descriptions in IFastWindingNumber
MRMESH_API Expected<void> calcFromVector( std::vector<float>& res, const std::vector<Vector3f>& points, float beta, FaceId skipFace, const ProgressCallback& cb ) override;
MRMESH_API Expected<void> calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb ) override;
MRMESH_API Expected<void> calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, ProgressCallback cb ) override;
MRMESH_API Expected<void> calcFromGrid( std::vector<float>& 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<void> calcFromGridWithDistances( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, const DistanceToMeshOptions& options, const ProgressCallback& cb ) override;

Expand Down

0 comments on commit c4b6dcc

Please sign in to comment.