| 157 | } |
| 158 | |
| 159 | export function buildReconstruction(options: ReconstructionBuilderOptions = {}): Reconstruction { |
| 160 | const cameras = options.cameras ?? [buildCamera()]; |
| 161 | const images = options.images ?? [buildImage({ cameraId: cameras[0].cameraId })]; |
| 162 | const points3D = options.points3D; |
| 163 | |
| 164 | const imageStats = options.imageStats ?? new Map( |
| 165 | images.map((image) => [ |
| 166 | image.imageId, |
| 167 | buildImageStats({ numPoints3D: countTriangulatedPoints(image.points2D) }), |
| 168 | ]) |
| 169 | ); |
| 170 | |
| 171 | return { |
| 172 | cameras: new Map(cameras.map((camera) => [camera.cameraId, camera])), |
| 173 | images: new Map(images.map((image) => [image.imageId, image])), |
| 174 | ...(points3D ? { points3D: new Map(points3D.map((point) => [point.point3DId, point])) } : {}), |
| 175 | imageStats, |
| 176 | connectedImagesIndex: options.connectedImagesIndex ?? new Map(), |
| 177 | globalStats: buildGlobalStats(options.globalStats), |
| 178 | imageToPoint3DIds: options.imageToPoint3DIds ?? buildImageToPoint3DIds(images), |
| 179 | ...(options.rigData ? { rigData: options.rigData } : {}), |
| 180 | }; |
| 181 | } |
| 182 | |
| 183 | export function buildLoadedFiles(options: LoadedFilesBuilderOptions = {}): LoadedFiles { |
| 184 | return { |