Skip to main content
3 of 7
added 111 characters in body
Aminos
  • 103
  • 4

Split a string of line segments into several other line segments

I have written a code to extend "n" points, constituting "n-1" lines ,to constitute more lines so you can map "m" data to "m" lines with m > n-1.

This is the function I wrote : https://github.com/embeddedmz/split_a_string_of_2d_line_segments/blob/ef73e6c0b7b0c5b48aa091ffd75ae5d3b3ba4f67/mainwindow.cpp#L137 It fails to add all the points with some data sets like the one I made for the demo (a C++/Qt program) I am forced to use the last point of the points to extend as the last point in the output list. It was really hard to write, I did it in 2019 with the VTK framework (coloring lines on a map background with data, there was not enough GeoJSON points) and I want to improve the code.

Has anyone ever coded something like this ?

Update: when I change the greater or equal sign of line to 223 to a great sign, I can reach the last point.

In my french blog (you can translate it), I briefly describe what the algorithm is supposed to do: https://mmzoughi.wordpress.com/2022/08/22/decouper-une-chaine-de-segments-de-ligne-en-plusieurs-autres-segments-de-ligne/

enter image description here

Aminos
  • 103
  • 4