11#include "FgCommand.hpp"
13#include "FgSerial.hpp"
14#include "FgFileSystem.hpp"
15#include "FgTestUtils.hpp"
25cmdSplice(CLArgs
const & args)
28 "<shape>.fg <color>.fg <result>.fg"
30 Face3 shape(syn.next());
31 Face3 color(syn.next());
32 color.coord.ts(0,0) = shape.coord.ts(0,0);
33 color.coord.ts(0,1) = shape.coord.ts(0,1);
34 color.save(syn.next());
38cmdList(CLArgs
const & args)
41 "<face>.fg [(<index> <value>)+]\n"
42 " <face>.fg - will be modified if additional valid arguments are supplied\n"
43 " <index> - coordinate index (starts at 0)\n"
44 " <value> - value to set that coordinate index to"
48 string fgfile = syn.next();
52 Floats coord = face.coord.getVector();
55 size_t idx = syn.nextAs<
size_t>();
56 float val = syn.nextAs<
float>();
57 if (idx >= coord.size())
58 fgThrow(
"Face coordinate index out of range",toStr(idx));
61 face.coord.setVector(coord);
64 fgout << fgnl <<
"Face Coordinate:" << fgpush;
65 for (
size_t ii=0; ii<coord.size(); ++ii)
66 fgout << fgnl << toStrDigits(ii,3) <<
": " << coord[ii];
70exportFace(CLArgs
const & args)
72 Syntax syn(args,
"<face>.fg <base>\n"
73 " Export respective face sub-space coordinates to space-separated-value text files:\n"
74 " <base>_shape_symm.txt\n"
75 " <base>_shape_asym.txt\n"
76 " <base>_color_symm.txt\n"
77 " <base>_color_asym.txt (usually empty - ignore)"
79 Face3 face(syn.next());
80 string base(syn.next());
81 for (uint mm=0; mm<2; ++mm) {
82 string mode = (mm == 0) ?
"shape" :
"color";
83 for (uint ss=0; ss<2; ++ss) {
84 string symm = (ss == 0) ?
"symm" :
"asym";
86 for (
float v : face.coord.ts(mm,ss))
87 data += std::to_string(v) +
" ";
88 saveRaw(data,base+
"_"+mode+
"_"+symm+
".txt");
94importFace(CLArgs
const & args)
96 Syntax syn(args,
"<base> <face>.fg\n"
97 " Read face coordinate from the following space-separated-value text files:\n"
98 " <base>_shape_symm.txt\n"
99 " <base>_shape_asym.txt\n"
100 " <base>_color_symm.txt\n"
101 " <base>_color_asym.txt (usually empty - ignore)"
104 string base(syn.next());
105 for (uint mm=0; mm<2; ++mm) {
106 string mode = (mm == 0) ?
"shape" :
"color";
107 for (uint ss=0; ss<2; ++ss) {
108 string symm = (ss == 0) ?
"symm" :
"asym";
109 string data = loadRawString(base+
"_"+mode+
"_"+symm+
".txt");
110 Strings toks = splitWhitespace(data);
111 face.coord.ts(mm,ss).clear();
112 for (
string const & tok : toks)
113 face.coord.ts(mm,ss).push_back(std::stof(tok));
116 face.save(syn.next());
129 {cmdSplice,
"splice",
"Splice shape and color sub-coordinates"},
130 {cmdList,
"list",
"List or set individual coordinates"},
131 {exportFace,
"export",
"Export face coordinates to .txt"},
132 {importFace,
"import",
"Import face coordinates from .txt"},
void cmd3Coord(CLArgs const &)