| 160 | } |
| 161 | |
| 162 | Expected<std::array<SimpleVolumeMinMax, 3>> meshToDirectionVolume( const MeshToDirectionVolumeParams& params ) |
| 163 | { |
| 164 | MR_TIMER; |
| 165 | VolumeIndexer indexer( params.vol.dimensions ); |
| 166 | std::vector<MeshProjectionResult> projs; |
| 167 | |
| 168 | auto getPoint = [&indexer, ¶ms] ( VoxelId i ) |
| 169 | { |
| 170 | const auto c = Vector3f( indexer.toPos( i ) ) + Vector3f::diagonal( 0.5f ); |
| 171 | return params.vol.origin + mult( params.vol.voxelSize, c ); |
| 172 | }; |
| 173 | |
| 174 | { |
| 175 | std::vector<Vector3f> points( indexer.size() ); |
| 176 | for ( auto i = VoxelId( size_t( 0 ) ); i < indexer.size(); ++i ) |
| 177 | { |
| 178 | points[i] = getPoint( i ); |
| 179 | } |
| 180 | params.projector->findProjections( projs, points ); |
| 181 | } |
| 182 | |
| 183 | std::array<SimpleVolumeMinMax, 3> res; |
| 184 | for ( auto& v : res ) |
| 185 | { |
| 186 | v.voxelSize = params.vol.voxelSize; |
| 187 | v.dims = params.vol.dimensions; |
| 188 | v.data.resize( indexer.size() ); |
| 189 | } |
| 190 | |
| 191 | for ( auto i = VoxelId( size_t( 0 ) ); i < indexer.size(); ++i ) |
| 192 | { |
| 193 | const auto d = ( getPoint( i ) - projs[i].proj.point ).normalized(); |
| 194 | res[0].data[i] = d.x; |
| 195 | res[1].data[i] = d.y; |
| 196 | res[2].data[i] = d.z; |
| 197 | } |
| 198 | |
| 199 | for ( auto& v : res ) |
| 200 | { |
| 201 | std::tie( v.min, v.max ) = parallelMinMax( v.data ); |
| 202 | } |
| 203 | |
| 204 | return res; |
| 205 | } |
| 206 | |
| 207 | |
| 208 | } //namespace MR |
no test coverage detected