| 293 | } |
| 294 | |
| 295 | void Reconstruction::Load(const DatabaseCache& database_cache) { |
| 296 | // Add cameras. |
| 297 | cameras_.reserve(database_cache.NumCameras()); |
| 298 | for (const auto& [camera_id, camera] : database_cache.Cameras()) { |
| 299 | if (ExistsCamera(camera_id)) { |
| 300 | struct Camera& existing_camera = Camera(camera_id); |
| 301 | THROW_CHECK_EQ(existing_camera.model_id, camera.model_id); |
| 302 | THROW_CHECK_EQ(existing_camera.width, camera.width); |
| 303 | THROW_CHECK_EQ(existing_camera.height, camera.height); |
| 304 | } else { |
| 305 | AddCamera(camera); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | // Add rigs. |
| 310 | rigs_.reserve(database_cache.NumRigs()); |
| 311 | for (const auto& [rig_id, rig] : database_cache.Rigs()) { |
| 312 | if (ExistsRig(rig_id)) { |
| 313 | class Rig& existing_rig = Rig(rig_id); |
| 314 | THROW_CHECK(existing_rig.RefSensorId() == rig.RefSensorId()); |
| 315 | THROW_CHECK(existing_rig.SensorIds() == rig.SensorIds()); |
| 316 | } else { |
| 317 | AddRig(rig); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // Add frames. |
| 322 | frames_.reserve(database_cache.NumFrames()); |
| 323 | for (const auto& [frame_id, frame] : database_cache.Frames()) { |
| 324 | if (ExistsFrame(frame_id)) { |
| 325 | class Frame& existing_frame = Frame(frame_id); |
| 326 | THROW_CHECK(existing_frame.RigId() == frame.RigId()); |
| 327 | THROW_CHECK(existing_frame.DataIds() == frame.DataIds()); |
| 328 | } else { |
| 329 | AddFrame(frame); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | // Add images. |
| 334 | images_.reserve(database_cache.NumImages()); |
| 335 | |
| 336 | for (const auto& [image_id, image] : database_cache.Images()) { |
| 337 | if (ExistsImage(image_id)) { |
| 338 | class Image& existing_image = Image(image_id); |
| 339 | THROW_CHECK_EQ(existing_image.Name(), image.Name()); |
| 340 | if (existing_image.NumPoints2D() == 0) { |
| 341 | existing_image.SetPoints2D(image.Points2D()); |
| 342 | } else { |
| 343 | THROW_CHECK_EQ(image.NumPoints2D(), existing_image.NumPoints2D()); |
| 344 | } |
| 345 | } else { |
| 346 | AddImage(image); |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | void Reconstruction::TearDown() { |
| 352 | // Remove all non-registered frames/images. |
nothing calls this directly
no test coverage detected