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

Function main

examples/cpp-examples/MeshOffsetWeighted.dox.cpp:9–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <iostream>
8
9int main()
10{
11 // Create some mesh
12 auto mesh = MR::makeTorus();
13
14 // Create VertScalars obj with weights for every vertex
15 auto vertSize = mesh.topology.vertSize();
16 MR::VertScalars scalars( vertSize );
17 MR::ParallelFor( scalars, [&] ( MR::VertId v )
18 {
19 scalars[v] = std::abs( mesh.points[v].x / 5.0f ); // Individual extra offset sizes for points
20 } );
21
22 auto params = MR::WeightedShell::ParametersMetric();
23 // Algorithm is voxel based, voxel size affects performance and form of result mesh
24 params.voxelSize = MR::suggestVoxelSize( mesh, 1000 );
25 // common basic offset applied for all point
26 // Vertex-specific weighted offsets applied after the basic one
27 params.offset = 0.2f;
28 params.dist.maxWeight = *std::max_element( begin( scalars ), end( scalars ) ); // should always have maximum between weights provided
29
30 auto res = MR::WeightedShell::meshShell( mesh, scalars, params );
31 if ( !res.has_value() )
32 {
33 std::cerr << res.error();
34 return 1;
35 }
36
37 auto saveRes = MR::MeshSave::toAnySupportedFormat( *res, "offset_weighted.ctm" );
38 if ( !saveRes.has_value() )
39 {
40 std::cerr << saveRes.error();
41 return 1;
42 }
43 return 0;
44}

Callers

nothing calls this directly

Calls 11

makeTorusFunction · 0.85
ParallelForFunction · 0.85
absFunction · 0.85
ParametersMetricClass · 0.85
suggestVoxelSizeFunction · 0.85
meshShellFunction · 0.85
errorMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
toAnySupportedFormatFunction · 0.50
vertSizeMethod · 0.45

Tested by

no test coverage detected