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

Function TEST

source/MRTest/MRMarchingCubesTests.cpp:9–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7{
8
9TEST( MRMesh, MarchingCubes )
10{
11 SimpleVolume fltVol
12 {
13 .dims = { 10, 10, 10 },
14 .voxelSize = { 1, 1, 1 }
15 };
16 fltVol.data.reserve( 1000 );
17 for ( int z = 0; z < 10; ++z )
18 {
19 for ( int y = 0; y < 10; ++y )
20 {
21 for ( int x = 0; x < 10; ++x )
22 {
23 fltVol.data.push_back( Vector3f( x - 4.5f, y - 4.5f, z - 4.5f ).lengthSq() < sqr( 4 ) );
24 }
25 }
26 }
27
28 MarchingCubesParams vparams;
29 vparams.iso = 0.5f;
30 vparams.cb = [](float) { return true; };
31 auto maybeMeshA = marchingCubes( fltVol, vparams );
32 EXPECT_TRUE( maybeMeshA.has_value() );
33 EXPECT_TRUE( maybeMeshA->topology.numValidFaces() > 0 );
34
35 SimpleBinaryVolume binVol
36 {
37 .data = VoxelBitSet{ fltVol.data.size() },
38 .dims = fltVol.dims,
39 .voxelSize = fltVol.voxelSize
40 };
41 BitSetParallelForAll( binVol.data, [&]( VoxelId v )
42 {
43 if ( fltVol.data[v] > 0.5f )
44 binVol.data.set( v );
45 } );
46 auto maybeMeshB = marchingCubes( binVol, vparams );
47 EXPECT_TRUE( maybeMeshB.has_value() );
48 EXPECT_TRUE( maybeMeshB->topology.numValidFaces() > 0 );
49 EXPECT_EQ( *maybeMeshA, *maybeMeshB );
50}
51
52} //namespace MR

Callers

nothing calls this directly

Calls 9

marchingCubesFunction · 0.85
BitSetParallelForAllFunction · 0.85
push_backMethod · 0.80
numValidFacesMethod · 0.80
sqrFunction · 0.50
reserveMethod · 0.45
lengthSqMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected