RoomPlan: How to track rooms across a CapturedStructure.init(from:) call?

I'd like to be able to associate some data with each CapturedRoom scan and maintain those associations when CapturedRooms are combined in a CapturedStructure.

For example, in the delegate method captureView(didPresent:error:), I'd like to associate external data with the CapturedRoom. That's easy enough to do with a Swift dictionary, using the CapturedRoom's identifier as the key to the associated data.

However, when I assemble a list of CapturedRooms into a CapturedStructure using StructureBuilder.init(from:), the rooms in the output CapturedStructure have different identifiers so their associations to the external data are lost.

Is there any way to track or identify CapturedRoom objects that are input into a StructureBuilder to the rooms in the CapturedStructure output? I looked for something like a "userdata" property on a CapturedRoom that might be preserved, but couldn't find one. And since the room identifiers change when they are built into a CapturedStructure, I don't see an obvious way to do this.

Did you find a work around for this? I have noticed that when converting the room's to JSON, the room identifier is omitted in most cases, which doesn't help!!

I tried using a UUID in the name of the various JSON files, but once the array goes into the StructureBuilder, like you said, the room's no longer match. It's very frustrating!

I've looked into this a little more and I've noticed that window, door and floor identifiers seem to stay the same across the structure builder, so it might be possible to identify a room using a floor identifier?

I need to explore this more.

@tomasmcguinness I've noticed that the floor identifiers from input CapturedRoom(s) do not stay the same in the merged CapturedStructure. However, other identifiers such as walls, windows, doors, openings, and objects do stay the same. So it should be possible to devise an algorithm which keys off of those items to track external data associations across the CapturedRooms->CapturedStructure merge.

I suppose the reason why room and floor IDs don't remain the same is that there's a chance that multiple CapturedRooms may be merged into a single room in the resulting CapturedStucture. This means there isn't necessarily a 1:1 mapping of CapturedRooms to rooms in the output CapturedStructure. This adds a little twist to the data tracking algorithm.

RoomPlan: How to track rooms across a CapturedStructure.init(from:) call?
 
 
Q