// zfinder.cc - tool for use with Zygo's MetroPro package, // a component of the "restitch" extensions // to the standard stitch application. // // purpose: Reads in a standard coords.crd file from the MetroPro // stitch script, and writes it out with the z coordinate // adjusted relative to the mean z-height in each frame. // // author: richard.t.jones at uconn.edu // version: November 12, 2011 #include #include #include #include #include "MetroProMap.h" #define REWRITE_ABSOLUTE_TO_LOCAL_PATHS 1 // this must be half the scan distance of the original stitching run double zdelta = 50e-3/MetroProMap::inches2mm; void usage() { std::cerr << "Usage: zfinder [-zshift ] " << std::endl << " where =floating point offset in z with units," << std::endl << " eg. -0.115mm or 0.00176in, and is a text" << std::endl << " file in .crd format, as in \"coords.crd\"." << std::endl; } int main(int argc, char *argv[]) { double zshift = 0; if (argc == 1) { usage(); exit(1); } for (int arg=1; arg> x >> y >> z; std::ifstream dfile(dfilename.c_str()); if (! dfile.is_open()) { std::cerr << "Error - unable to open data file " << dfilename << std::endl; exit(2); } MetroProMap map; dfile >> map; double zave = map.getAverageHeight(0); double zmin = map.getMinimumHeight(0); double zmax = map.getMaximumHeight(0); double zmid = (zmin+zmax)/2; if (zshift) { if (zshift > 0 && zmin+zshift < zmax) { std::cerr << "Warning: zshift is not sufficient" << " to exclude original surface in frame " << frame << std::endl << " zmin,zave,zmax = " << (zmin+z-zdelta)*MetroProMap::inches2mm << "," << (zave+z-zdelta)*MetroProMap::inches2mm << "," << (zmax+z-zdelta)*MetroProMap::inches2mm << " mm" << std::endl; } else if (zshift > 0 && zmin+zshift < zmax-zdelta) { std::cerr << "Warning: zshift may not be sufficient" << " to exclude original surface in frame " << frame << std::endl << " zmin,zave,zmax = " << (zmin+z-zdelta)*MetroProMap::inches2mm << "," << (zave+z-zdelta)*MetroProMap::inches2mm << "," << (zmax+z-zdelta)*MetroProMap::inches2mm << " mm" << std::endl; } else if (zshift < 0 && zmax+zshift > zmin) { std::cerr << "Warning: zshift is not sufficient" << " to exclude original surface in frame " << frame << std::endl << " zmin,zave,zmax = " << (zmin+z-zdelta)*MetroProMap::inches2mm << "," << (zave+z-zdelta)*MetroProMap::inches2mm << "," << (zmax+z-zdelta)*MetroProMap::inches2mm << " mm" << std::endl; } else if (zshift < 0 && zmax+zshift > zmin-zdelta) { std::cerr << "Warning: zshift may not be sufficient" << " to exclude original surface in frame " << frame << std::endl << " zmin,zave,zmax = " << (zmin+z-zdelta)*MetroProMap::inches2mm << "," << (zave+z-zdelta)*MetroProMap::inches2mm << "," << (zmax+z-zdelta)*MetroProMap::inches2mm << " mm" << std::endl; } } std::cout << std::setprecision(8) << x << " " << y << " " << z+zmid-zdelta+zshift << " # x y and z position in inches" << std::endl; } } return 0; }