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

Function countVoxelsWithValuePred

source/MRVoxels/MRFloatGrid.cpp:161–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161size_t countVoxelsWithValuePred( const FloatGrid& grid, const std::function<bool( float )>& pred )
162{
163 MR_TIMER;
164 if ( !pred || !grid )
165 {
166 assert( false );
167 return 0;
168 }
169 tbb::enumerable_thread_specific<size_t> tls( 0 );
170 openvdb::tools::foreach( grid->cbeginValueAll(), [&] ( const openvdb::FloatGrid::ValueAllCIter& it )
171 {
172 if ( !pred( it.getValue() ) )
173 return;
174 auto& local = tls.local();
175 local += it.getBoundingBox().volume();
176 } );
177 size_t res = 0;
178 for ( const auto& t : tls )
179 res += t;
180 return res;
181}
182
183size_t countVoxelsWithValueLess( const FloatGrid& grid, float value )
184{

Callers 2

countVoxelsWithValueLessFunction · 0.85

Calls 3

getValueMethod · 0.45
volumeMethod · 0.45
getBoundingBoxMethod · 0.45

Tested by

no test coverage detected