| 7 | #include <iostream> |
| 8 | |
| 9 | int 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 | } |
nothing calls this directly
no test coverage detected