Volume reorientation

Reorient Volume rotates the study grid about the volume centre so axial slices follow the occlusal plane and the midline is vertical. It is a display and review convenience on a derived grid; it changes no source voxel and establishes no measurement accuracy. The app remains not validated for diagnostic use.

Before reorientation, the current study grid is the acquisition grid. After Apply, every workspace uses the resampled derived grid, including Endo segmentation, editing and canal points. Show Original disables an enhancement preview and shows the unenhanced current-grid image; it does not reverse reorientation or recover an acquired slice. Reset to Source rereads the original files and restores the acquisition grid, subject to the confirmation and work-replacement rules below.

Design

Lifecycle

Apply runs through ViewerModel.openStudy with an acquisition loader and a transform that finishes before install. The StudyWorkBarrier drains, heavy work is cancelled, and caches and textures are released. Grid bounds and live mobile-memory preflight run before I/O and again before resampling. A failed acquisition read, rejected grid, failed transform or cancellation keeps the previous voxel storage and its anchored work, including saved views, report notes, imported implant bodies and Undo history. Cancellation and request ownership are checked again before publication, so a superseded worker cannot replace a newer study. No separate saved-state checkpoint is needed.

Only a completed replacement calls install and removes work anchored to the old grid. Display settings and the window (window, inversion, brightness, gamma, slabs, projections, surface style and detail, volume preset and opacity, crosshairs, canals, an operator-set bone threshold, enhancement options and the workspace) are carried over; slice indices and viewports start centred on the new grid. Successful Apply and Reset remain unsaved changes.

Apply shows a confirmation naming what the new grid removes: measurements, canal traces, arches, dental segmentation with its edits and reviews, Endo work and the implant plan. Cancel changes nothing. Reset to Source reads the acquisition again through the same path, without applying the folder's saved state.

Save State

StudySaveState.reorientation stores the angles and the resampling rule as an optional field; states without it decode as before. The state's geometry and sourceDigest describe the grid the state was saved on. On restore, after the acquisition decodes, the stored reorientation is read first (StudySaveState.reorientation(in:)), the grid is rebuilt (memory check included), the reoriented volume is installed and only then are the fingerprint and geometry compared and the rest restored against that grid. If the state does not match, the acquisition is shown with default views and the usual "saved state not applied" message. Review files (.cbctreview) record the angles too. Open State or Review… follows the same rule for a document chosen elsewhere (restoreDifferentImportRegionIfNeeded(rebuildReorientation:), as recovery copies use): when its import region or angles differ from the open grid, the grid is rebuilt from the source and the whole document validated against it before anything live changes; a failure leaves the current session unchanged.

Suggestion

Services/VolumeReorientationSuggestion.swift fits the occlusal plane as the least-squares plane through the occlusal contacts: in every grid column that holds teeth of both jaws, the midpoint between the lowest upper-tooth voxel and the highest lower-tooth voxel (columns with a gap over 15 mm are skipped; at least 40 are needed). The midline follows the long axis of all teeth voxels projected onto that plane, which estimates the arch chord without depending on the distal-most teeth. The fitted frame is converted to pitch, roll and yaw relative to the acquisition. It is a starting point the operator reviews and edits, not an anatomical landmark analysis.

Limits