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

Function readByBlocks

source/MRMesh/MRProgressReadWrite.cpp:35–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35bool readByBlocks( std::istream& in, char* data, size_t dataSize, ProgressCallback callback /*= {}*/, size_t blockSize /*= ( size_t( 1 ) << 16 )*/ )
36{
37 if ( !dataSize )
38 return true;
39
40 if ( !callback )
41 {
42 in.read( data, dataSize );
43 return true;
44 }
45
46 int blockIndex = 0;
47 for ( size_t max = dataSize / blockSize; blockIndex < max; ++blockIndex )
48 {
49 in.read( data + blockIndex * blockSize, blockSize );
50 if ( !callback( float( blockIndex * blockSize ) / dataSize ) )
51 return false;
52 }
53 const size_t remnant = dataSize - blockIndex * blockSize;
54 if ( remnant )
55 in.read( data + blockIndex * blockSize, remnant );
56 if ( !callback( float( blockIndex * blockSize + remnant ) / dataSize ) )
57 return false;
58
59 return true;
60}
61
62}

Callers 6

fromMrmeshFunction · 0.85
readMethod · 0.85
fromMrLinesFunction · 0.85
fromRawFunction · 0.85
fromMrDistanceMapFunction · 0.85
fromCtmFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected