Skip to content

[WireRestShape] Fix initTopology accumulation for N≥3 sections#226

Closed
lkarstensen wants to merge 2 commits intosofa-framework:masterfrom
lkarstensen:fix/issue-225-wire-rest-shape-init-topology
Closed

[WireRestShape] Fix initTopology accumulation for N≥3 sections#226
lkarstensen wants to merge 2 commits intosofa-framework:masterfrom
lkarstensen:fix/issue-225-wire-rest-shape-init-topology

Conversation

@lkarstensen
Copy link
Copy Markdown

Fixes #225.

Note: This PR is stacked on #224. The diff currently includes the RodStraightSection fix; once #224 merges this PR will reduce to a single commit.

Problem

WireRestShape::initTopology uses two accumulator variables to track the running point-coordinate offset and edge index offset across sections. Both were updated via assignment instead of accumulation:

prev_length = length;        // reset to local section length — should accumulate
prev_edges = nbrVisuEdges;   // reset to local edge count — should accumulate

For N≤2 sections the assignment and accumulation forms produce the same value after the first iteration, so those wires are unaffected. For N≥3 sections, section 2 onward receives corrupted point coordinates (overlapping prior sections) and wrong edge indices, producing a degenerate EdgeSetTopologyContainer.

Fix

prev_length += length;
prev_edges += nbrVisuEdges;

Zero behavioural change for N≤2 wires.

Testing

Manually verified: 3-section wire fails on master, initialises correctly with this patch applied (on top of #224).

Lennart Karstensen added 2 commits April 29, 2026 16:34
…ons (sofa-framework#223)

x_used is the global curvilinear abscissa; adding x_start again placed
the rest node at 2*x_start + local_offset instead of x_used. For wires
with two or more RodStraightSections this produced enormous elastic
restoring forces at every timestep, causing simulation explosion.

Fix: use x_used directly, consistent with RodSpireSection and RodMeshSection.
…logy

Fixes sofa-framework#225. Both accumulators were reset via assignment instead of
accumulation, corrupting point coordinates and edge indices for any
wire with three or more sections.
@lkarstensen
Copy link
Copy Markdown
Author

Withdrawing — fix for #225 does not produce the expected improvement. Further investigation needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WireRestShape::initTopology corrupts topology for N≥3 sections

1 participant