MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / meshToDirectionVolume

Function meshToDirectionVolume

source/MRVoxels/MRMeshToDistanceVolume.cpp:162–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162Expected<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, &params] ( 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

Callers 1

convertObjectMethod · 0.85

Calls 9

diagonalFunction · 0.85
getPointFunction · 0.85
parallelMinMaxFunction · 0.85
multFunction · 0.50
toPosMethod · 0.45
sizeMethod · 0.45
findProjectionsMethod · 0.45
resizeMethod · 0.45
normalizedMethod · 0.45

Tested by

no test coverage detected