I have a group of ci::Rectf’s that i would like to combine into a Shape2d if they are touching.(or Path2D, but i think a Path2D cannot be drawSolid/filled in ). I would also like to check if a ci::Rectf is not touching any other ci::Recf and give it its own shape.
Can Cinder already do this automatically?
My first solution would be iterative, brute force and O(n2). Improvements/critique welcome!
1 - pick the first rect from array of rects.
2 - call it Rect1
3 - remove Rect1 from the array of rects
4 - convert into a Shape
5 - call it Shape1
6 - loop through the array of rects
7 - test if Shape1 is touching each rect
8 - If touching a rect, say Rect2
9 - combine Shape1 and Rect2
10 - remove Rect2 from array of rects
11 - when finished loop store Shape1 in an array
12 - repeat steps 1 - 11 until array of rects empty