| 127 | } |
| 128 | |
| 129 | Expected<void> FastWindingNumber::calcSelfIntersections( FaceBitSet& res, float beta, const ProgressCallback& cb ) |
| 130 | { |
| 131 | MR_TIMER; |
| 132 | return prepareData_( subprogress( cb, 0.0, 0.5f ) ).and_then( [&]() -> Expected<void> |
| 133 | { |
| 134 | const auto totalSize = mesh_.topology.faceSize(); |
| 135 | const auto bufferSize = maxBufferSize( getCudaSafeMemoryLimit(), totalSize, sizeof( float ) ); |
| 136 | |
| 137 | DynamicArrayF cudaResult; |
| 138 | CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.resize( bufferSize ) ); |
| 139 | if ( !reportProgress( cb, 0.6f ) ) |
| 140 | return unexpectedOperationCanceled(); |
| 141 | |
| 142 | std::vector<float> wns; |
| 143 | wns.resize( totalSize ); |
| 144 | |
| 145 | const auto cb1 = subprogress( cb, 0.60f, 0.90f ); |
| 146 | const auto iterCount = chunkCount( totalSize, bufferSize ); |
| 147 | size_t iterIndex = 0; |
| 148 | |
| 149 | for ( const auto [offset, size] : splitByChunks( totalSize, bufferSize ) ) |
| 150 | { |
| 151 | const auto cb2 = subprogress( cb1, iterIndex++, iterCount ); |
| 152 | |
| 153 | fastWindingNumberFromMesh( data_->toData(), cudaResult.data(), beta, size, offset ); |
| 154 | CUDA_LOGE_RETURN_UNEXPECTED( cudaGetLastError() ); |
| 155 | if ( !reportProgress( cb2, 0.33f ) ) |
| 156 | return unexpectedOperationCanceled(); |
| 157 | |
| 158 | CUDA_LOGE_RETURN_UNEXPECTED( cudaResult.copyTo( wns.data() + offset, size ) ); |
| 159 | if ( !reportProgress( cb2, 1.00f ) ) |
| 160 | return unexpectedOperationCanceled(); |
| 161 | } |
| 162 | |
| 163 | res.resize( totalSize ); |
| 164 | if ( !BitSetParallelForAll( res, [&] (FaceId f) |
| 165 | { |
| 166 | if ( wns[f] < 0 || wns[f] > 1 ) |
| 167 | res.set( f ); |
| 168 | }, subprogress( cb, 0.9f, 1.0f ) ) ) |
| 169 | return unexpectedOperationCanceled(); |
| 170 | |
| 171 | return {}; |
| 172 | } ); |
| 173 | } |
| 174 | |
| 175 | Expected<void> FastWindingNumber::calcFromGrid( std::vector<float>& res, const Vector3i& dims, const AffineXf3f& gridToMeshXf, float beta, const ProgressCallback& cb ) |
| 176 | { |
nothing calls this directly
no test coverage detected