| 114 | } |
| 115 | |
| 116 | Expected<void> ComputeToolDistance::computeToolDistance( std::vector<float>& output, const Vector3i& dims, float voxelSize, |
| 117 | const Vector3f& origin, float padding ) const |
| 118 | { |
| 119 | MR_TIMER; |
| 120 | |
| 121 | CUDA_LOGE_RETURN_UNEXPECTED( cudaSetDevice( 0 ) ); |
| 122 | |
| 123 | VolumeIndexer indexer( { dims.x, dims.y, dims.z }, voxelSize, { origin.x, origin.y, origin.z } ); |
| 124 | |
| 125 | if ( impl_->toolSpec ) |
| 126 | { |
| 127 | std::visit( overloaded { [&] ( auto&& tool ) |
| 128 | { |
| 129 | computeToolDistanceKernel( |
| 130 | impl_->output.data(), output.size(), |
| 131 | indexer, |
| 132 | impl_->toolpath, |
| 133 | tool, |
| 134 | padding |
| 135 | ); |
| 136 | } }, *impl_->toolSpec ); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | const auto toolRadius = impl_->toolBox.max.x + padding; |
| 141 | const auto toolMinHeight = impl_->toolBox.min.y - padding; |
| 142 | const auto toolMaxHeight = impl_->toolBox.max.y + padding; |
| 143 | |
| 144 | computeToolDistanceKernel( |
| 145 | impl_->output.data(), output.size(), |
| 146 | indexer, |
| 147 | impl_->toolpath, |
| 148 | impl_->toolProfile, |
| 149 | toolRadius, toolMinHeight, toolMaxHeight, |
| 150 | padding |
| 151 | ); |
| 152 | } |
| 153 | CUDA_LOGE_RETURN_UNEXPECTED( cudaDeviceSynchronize() ); |
| 154 | CUDA_LOGE_RETURN_UNEXPECTED( cudaGetLastError() ); |
| 155 | |
| 156 | CUDA_LOGE_RETURN_UNEXPECTED( impl_->output.copyTo( output.data(), output.size() ) ); |
| 157 | |
| 158 | return {}; |
| 159 | } |
| 160 | |
| 161 | } // namespace MR::Cuda |
| 162 |
no test coverage detected