educelab / volume-cartographer

Volumetric processing toolkit and C++ libraries for the recovery and restoration of damaged cultural materials
GNU General Public License v3.0
63 stars 22 forks source link

(VolPkg) Add support for transform paths #94

Closed csparker247 closed 3 months ago

csparker247 commented 3 months ago

This builds off of the transform functionality added in #67 and #69 to make working with transforms a little more automatic.

First, the single argument VolumePkg::transform(id) and VolumePkg::hasTransform(id) functions now support constructing a composite transform using the -> operator in the id string. The inverse * operator is still fully supported. The following will return a composite transform containing the three identified transforms with inversion already applied to the final transform:

auto tfm = vpkg.transform("20240808111644->20240808111647->20240808111648*");

Second, the two argument VolumePkg::transform(src, tgt) function now additionally searches for multi-transform paths between the source and target volumes. Single-transform paths (what the previous implementation returned) are returned as their original transform type. Multi-transform paths are returned as a new, unsimplified CompositeTransform. Paths are returned in order of increasing length and may incorporate inverse transforms which help satisfy the mapping. The returned identifiers follow the form used by the new VolumePkg::transform(id) implementation:

auto paths = vpkg.transform("a", "d");
std::cout << "paths:\n";
for(auto [id, tfm] : paths) {
    std::cout << " - " << id << "\n";
}
/*
paths:
 - 20240808111644                                  // single-transform
 - 20240808111645*                                 // single-transform (inverted)
 - 20240808111646->20240808111647->20240808111648  // multi-transform path
*/

Other changes