I have 2 lines on a lithographical chart (2 vectors created from coordinates). One line is above another like this: =====. I use WPF to draw these lines dynamically on a canvas based on user selection. Sections between these lines created by 4 points (2 are coordinates between 2 points on the upper line and the other 2 are points on the lower line) are polygons. So, if upper line consists from 10 points (coordinates) and lower line has 10 points (coordinates) we have 5 polygons between them: = = = = =. I need to dynamically outline and paint these polygons based on user selection. For example upper Line_1 points coordinates are: 1,2,3,4,5 (starts with 1) and lower Line_2 points coordinates are: 6,7,8,9,10 (starts with 6). If user wants to see 1st polygon it would be area with coordinates: 1,2,6,7. These points need to go in sequence: 1,2,7,6 to create a proper shape (4 points polygon). If user want to see 1st and 2nd polygons this would be area with coordinates: 1,2,3,8,7,6 (and so on for 3rd, 4th and 5th areas). Areas can only be viewed sequentially started with 1st. In other words user cannot view 1st, 2nd and 4th areas skipping 3rd area. I am struggling to find the best logical solution how to do this.
Let’s say lines coordinates come from 2 arrays: array Line_1 = 1,2,3,4,5 and array Line_2 = 6,7,8,9,10. Then 1st polygon coordinates would be: Line_1, Line_1, Line_2, Line_2. 2nd polygon: Line_1, Line_1, Line_1, Line_2, Line_2, Line_2 etc. I always need to split array Line_1 in the middle, insert two new members from array Line_2 and flip their places: 0, 1, 2, 2, 1, 0. I think to use loops for this.
Can you suggest me a better solution for this task? If not, then can you advise me how to make this more efficient by using loops through 2 arrays? How to split array in the middle, shift its items 2 positions to the right and insert 2 new items? Thank You! :)))