Replies: 2 comments 6 replies
-
|
Hello! To use negative weights or offset you need to enable it using: params.dist.bidirectionalMode = false;but unfortunately it seems that there are some bugs if weights are actually negative (we will fix them soon). This mode still works if all weights are non-negative, so you can try code like this: {
// Create some mesh
auto mesh = MR::makeTorus();
// Create VertScalars obj with weights for every vertex
auto vertSize = mesh.topology.vertSize();
MR::VertScalars scalars( vertSize );
MR::ParallelFor( scalars, [&] ( MR::VertId v )
{
scalars[v] = mesh.points[v].x / 5.0f; // Individual extra offset sizes for points
} );
auto params = MR::WeightedShell::ParametersMetric();
// Algorithm is voxel based, voxel size affects performance and form of result mesh
params.voxelSize = MR::suggestVoxelSize( mesh, 1000 );
// common basic offset applied for all point
// Vertex-specific weighted offsets applied after the basic one
auto minmax = std::minmax_element( MR::begin( scalars ), MR::end( scalars ) );
auto minW = *minmax.first;
params.offset = 0.2f + minW; // compensate offset by adding minimum weight to it
params.dist.maxWeight = *minmax.second - minW; // should always have maximum between weights provided
MR::ParallelFor( scalars, [&] ( MR::VertId v )
{
scalars[v] -= minW; // compensate weights to be >= 0
} );
params.dist.bidirectionalMode = false;
auto res = MR::WeightedShell::meshShell( mesh, scalars, params );
if ( !res.has_value() )
{
std::cerr << res.error();
return 1;
}
auto saveRes = MR::MeshSave::toAnySupportedFormat( *res, "offset_weighted_nobidir.stl" );
if ( !saveRes.has_value() )
{
std::cerr << saveRes.error();
return 1;
}
return 0;
}Please note that here we normalize weights to be positive and shift offset to compensate it, so result should be the same. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Thanks for reporting this. We are working on a fix in the branch: #5506 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Uh oh!
There was an error while loading. Please reload this page.
-
Thank you so much for your help:

The example [Mesh Weighted Offset] provided by the management uses the
meshShellmethod to offset mesh points. The code is as follows:However, meshShell can only set positive weight values. I changed
scalars[v] = std::fabs(mesh.points[v].x / 5.0f)toscalars[v] = mesh.points[v].x / 5.0f, hoping to achieve a positive weight causing the mesh points to move outwards and a negative weight causing the mesh to shrink inwards. However, I found that after setting it to negative, the areas that should have shrunk became damaged. Is there any way I can achieve this functionality?Thank you very much for your help.
Beta Was this translation helpful? Give feedback.
All reactions