geomcli 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -0
- package/dist/index.js +595 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -1
- package/.eslintignore +0 -17
- package/.eslintrc.cjs +0 -24
- package/.prettierignore +0 -15
- package/.prettierrc +0 -8
- package/src/geom_cli.ts +0 -550
- package/src/geom_write.ts +0 -136
- package/src/index.test.ts +0 -16
- package/src/index.ts +0 -6
- package/tsconfig.json +0 -14
- package/vitest.config.ts +0 -7
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { tGeomFunc, tParamVal, EFormat, tAllPageDef } from 'geometrix';
|
|
2
|
+
|
|
3
|
+
declare function geom_write(iPartName: string, fgeom: tGeomFunc, simTime: number, iParam: tParamVal, iFormat: EFormat, iFace?: string, iDir?: string, iFname?: string): Promise<string>;
|
|
4
|
+
|
|
5
|
+
declare function geom_cli(iArgs: string[], dList: tAllPageDef, outDir?: string): Promise<void>;
|
|
6
|
+
|
|
7
|
+
export { geom_cli, geom_write };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
// src/geom_write.ts
|
|
2
|
+
import {
|
|
3
|
+
fileBinContent,
|
|
4
|
+
fileTextContent,
|
|
5
|
+
fileSuffix,
|
|
6
|
+
fileBin,
|
|
7
|
+
createParamFile,
|
|
8
|
+
parseParamFile
|
|
9
|
+
} from "geometrix";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
function dateString() {
|
|
12
|
+
const re1 = /[-:]/g;
|
|
13
|
+
const re2 = /\..*$/;
|
|
14
|
+
const rDateStr = (/* @__PURE__ */ new Date()).toISOString().replace(re1, "").replace(re2, "").replace("T", "_");
|
|
15
|
+
return rDateStr;
|
|
16
|
+
}
|
|
17
|
+
function createDir(iDir) {
|
|
18
|
+
let rlog = "";
|
|
19
|
+
if (!fs.existsSync(iDir)) {
|
|
20
|
+
fs.mkdirSync(iDir, { recursive: true });
|
|
21
|
+
rlog += `info203: mkdir ${iDir}
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
return rlog;
|
|
25
|
+
}
|
|
26
|
+
async function write_binFile(fName, fContent) {
|
|
27
|
+
let rlog = "";
|
|
28
|
+
const buffer = await fContent.arrayBuffer();
|
|
29
|
+
const arrBufView = new DataView(buffer);
|
|
30
|
+
fs.writeFileSync(fName, arrBufView);
|
|
31
|
+
rlog += `info304: bin-file ${fName} has been written
|
|
32
|
+
`;
|
|
33
|
+
return rlog;
|
|
34
|
+
}
|
|
35
|
+
function write_textFile(fName, fContent) {
|
|
36
|
+
let rlog = "";
|
|
37
|
+
fs.writeFileSync(fName, fContent);
|
|
38
|
+
rlog += `info405: text-file ${fName} has been written
|
|
39
|
+
`;
|
|
40
|
+
return rlog;
|
|
41
|
+
}
|
|
42
|
+
function checkDirFName(iDir, fName) {
|
|
43
|
+
const reSlash = /\//;
|
|
44
|
+
if (reSlash.test(fName)) {
|
|
45
|
+
throw `err932: the filename ${fName} contains a slash '/'`;
|
|
46
|
+
}
|
|
47
|
+
if (iDir === "") {
|
|
48
|
+
throw `err074: geom_write output-directory is an empty string!`;
|
|
49
|
+
}
|
|
50
|
+
const fName2 = `${iDir}/${fName}`;
|
|
51
|
+
return fName2;
|
|
52
|
+
}
|
|
53
|
+
function writeParams(iPartName, idparams, oDir, oFileName) {
|
|
54
|
+
const re1 = /[-:]/g;
|
|
55
|
+
const re2 = /\..*$/;
|
|
56
|
+
const datestr = (/* @__PURE__ */ new Date()).toISOString().replace(re1, "").replace(re2, "").replace("T", "_");
|
|
57
|
+
let file_name = `px_${iPartName}_${datestr}.json`;
|
|
58
|
+
if (oFileName !== "") {
|
|
59
|
+
file_name = oFileName;
|
|
60
|
+
}
|
|
61
|
+
const paramNb = Object.keys(idparams).length;
|
|
62
|
+
const fName2 = checkDirFName(oDir, file_name);
|
|
63
|
+
let rlog = `Write ${paramNb} parameters in file ${fName2}
|
|
64
|
+
`;
|
|
65
|
+
const file_content = createParamFile(datestr, idparams, "Written by geom_cli");
|
|
66
|
+
rlog += createDir(oDir);
|
|
67
|
+
write_textFile(fName2, file_content);
|
|
68
|
+
return rlog;
|
|
69
|
+
}
|
|
70
|
+
function readParams(paramPath, printLog) {
|
|
71
|
+
let rParamVal = {};
|
|
72
|
+
if (paramPath !== "") {
|
|
73
|
+
let rlog = `Read parameter file ${paramPath}
|
|
74
|
+
`;
|
|
75
|
+
if (!fs.existsSync(paramPath)) {
|
|
76
|
+
throw `err533: file ${paramPath} doesn't exist!`;
|
|
77
|
+
}
|
|
78
|
+
const fContentStr = fs.readFileSync(paramPath, "utf8");
|
|
79
|
+
const [obj] = parseParamFile(fContentStr);
|
|
80
|
+
rlog += `file lastModif: ${obj.lastModif}
|
|
81
|
+
`;
|
|
82
|
+
rlog += `file comment: ${obj.comment}
|
|
83
|
+
`;
|
|
84
|
+
rlog += `info307: ${Object.keys(obj.pVal).length} parameters from file`;
|
|
85
|
+
rParamVal = obj.pVal;
|
|
86
|
+
if (printLog) {
|
|
87
|
+
console.log(rlog);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return rParamVal;
|
|
91
|
+
}
|
|
92
|
+
async function geom_write(iPartName, fgeom, simTime, iParam, iFormat, iFace = "", iDir = ".", iFname = "") {
|
|
93
|
+
let rlog = "";
|
|
94
|
+
const fSuffix = fileSuffix(iFormat);
|
|
95
|
+
const fBin = fileBin(iFormat);
|
|
96
|
+
let nFace = "all";
|
|
97
|
+
if (iFace !== "") {
|
|
98
|
+
nFace = iFace;
|
|
99
|
+
}
|
|
100
|
+
let fName = iFname;
|
|
101
|
+
if (fName === "") {
|
|
102
|
+
fName = iPartName + "_" + nFace + "_" + dateString() + fSuffix;
|
|
103
|
+
}
|
|
104
|
+
const fName2 = checkDirFName(iDir, fName);
|
|
105
|
+
rlog += createDir(iDir);
|
|
106
|
+
if (fBin) {
|
|
107
|
+
const fContent = await fileBinContent(fgeom, simTime, iParam, iFormat);
|
|
108
|
+
rlog += await write_binFile(fName2, fContent);
|
|
109
|
+
} else {
|
|
110
|
+
const fContent = fileTextContent(fgeom, iParam, nFace, iFormat);
|
|
111
|
+
rlog += write_textFile(fName2, fContent);
|
|
112
|
+
}
|
|
113
|
+
return rlog;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/geom_cli.ts
|
|
117
|
+
import { PType, EFormat as EFormat2, designParam, prefixLog, paramListToVal } from "geometrix";
|
|
118
|
+
import yargs from "yargs";
|
|
119
|
+
import { hideBin } from "yargs/helpers";
|
|
120
|
+
|
|
121
|
+
// package.json
|
|
122
|
+
var version = "0.5.14";
|
|
123
|
+
|
|
124
|
+
// src/geom_cli.ts
|
|
125
|
+
function get_design_array(dList) {
|
|
126
|
+
const rDesignArray = Object.keys(dList);
|
|
127
|
+
return rDesignArray;
|
|
128
|
+
}
|
|
129
|
+
function selectDesign(dList, selD) {
|
|
130
|
+
if (!Object.keys(dList).includes(selD)) {
|
|
131
|
+
console.log(`err918: design ${selD} is not defined`);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
return dList[selD];
|
|
135
|
+
}
|
|
136
|
+
function selectDesignN(dList, selD) {
|
|
137
|
+
const theD = selectDesign(dList, selD);
|
|
138
|
+
const dName = theD.pDef.partName;
|
|
139
|
+
return dName;
|
|
140
|
+
}
|
|
141
|
+
function parseModif(modif, printLog) {
|
|
142
|
+
const pVal = {};
|
|
143
|
+
const arrayLen = modif.length;
|
|
144
|
+
if (arrayLen % 2 === 1) {
|
|
145
|
+
throw `err903: length ${arrayLen} of modif string array is odd!`;
|
|
146
|
+
}
|
|
147
|
+
for (let i = 0; i < arrayLen / 2; i++) {
|
|
148
|
+
const valStr = modif[2 * i + 1];
|
|
149
|
+
const val = parseFloat(valStr);
|
|
150
|
+
if (isNaN(val)) {
|
|
151
|
+
throw `err908: ${valStr} is not a number!`;
|
|
152
|
+
}
|
|
153
|
+
pVal[modif[2 * i]] = val;
|
|
154
|
+
}
|
|
155
|
+
const pValLen = Object.keys(pVal).length;
|
|
156
|
+
if (printLog && pValLen > 0) {
|
|
157
|
+
const rlog = `info308: ${pValLen} parameters of modifier`;
|
|
158
|
+
console.log(rlog);
|
|
159
|
+
}
|
|
160
|
+
return pVal;
|
|
161
|
+
}
|
|
162
|
+
function computeGeom(dList, selD, paramPath, modif, printLog) {
|
|
163
|
+
const theD = selectDesign(dList, selD);
|
|
164
|
+
let rlog = `Compute design ${selD} (${theD.pDef.partName}):
|
|
165
|
+
`;
|
|
166
|
+
const dParam = designParam(theD.pDef);
|
|
167
|
+
try {
|
|
168
|
+
dParam.applyParamVal(readParams(paramPath, printLog));
|
|
169
|
+
dParam.applyParamVal(parseModif(modif, printLog));
|
|
170
|
+
} catch (emsg) {
|
|
171
|
+
console.log("err271: error while applying new parameters");
|
|
172
|
+
console.log(emsg);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
const simtime = 0;
|
|
176
|
+
const dGeom = theD.pGeom(simtime, dParam.getParamVal());
|
|
177
|
+
rlog += prefixLog(dGeom.logstr, dParam.partName);
|
|
178
|
+
if (dGeom.calcErr) {
|
|
179
|
+
rlog += `err907: Error while computing ${theD.pDef.partName}
|
|
180
|
+
`;
|
|
181
|
+
console.log(rlog);
|
|
182
|
+
process.exit(1);
|
|
183
|
+
} else {
|
|
184
|
+
rlog += `${theD.pDef.partName} successfully computed
|
|
185
|
+
`;
|
|
186
|
+
}
|
|
187
|
+
if (printLog) {
|
|
188
|
+
console.log(rlog);
|
|
189
|
+
}
|
|
190
|
+
return dGeom;
|
|
191
|
+
}
|
|
192
|
+
function get_figure_array(dList, selD, paramPath, modif) {
|
|
193
|
+
const dGeom = computeGeom(dList, selD, paramPath, modif, false);
|
|
194
|
+
const rfigN = Object.keys(dGeom.fig);
|
|
195
|
+
return rfigN;
|
|
196
|
+
}
|
|
197
|
+
function get_subdesign_array(dList, selD, paramPath, modif) {
|
|
198
|
+
const dGeom = computeGeom(dList, selD, paramPath, modif, false);
|
|
199
|
+
const subd = dGeom.sub;
|
|
200
|
+
return subd;
|
|
201
|
+
}
|
|
202
|
+
function get_subd(dList, selD, subdN, paramPath, modif, printLog) {
|
|
203
|
+
const theD = selectDesign(dList, selD);
|
|
204
|
+
const dGeom = computeGeom(dList, selD, paramPath, modif, printLog);
|
|
205
|
+
if (!Object.keys(dGeom.sub).includes(subdN)) {
|
|
206
|
+
console.log(`err207: sub-design ${subdN} not defined in partName ${theD.pDef.partName}`);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
const rSubd = dGeom.sub[subdN];
|
|
210
|
+
if (printLog) {
|
|
211
|
+
const rlog = `Subdesign ${subdN} (${rSubd.partName}) of ${selD} (${theD.pDef.partName}):
|
|
212
|
+
`;
|
|
213
|
+
console.log(rlog);
|
|
214
|
+
}
|
|
215
|
+
return rSubd;
|
|
216
|
+
}
|
|
217
|
+
var c_fileFormat = [
|
|
218
|
+
"json_param",
|
|
219
|
+
"svg_all_figures",
|
|
220
|
+
"dxf_all_figures",
|
|
221
|
+
"pax_all",
|
|
222
|
+
"scad_3d_openscad",
|
|
223
|
+
"js_3d_openjscad",
|
|
224
|
+
"zip_all"
|
|
225
|
+
];
|
|
226
|
+
function get_outopt_array(dList, selD, paramPath, modif) {
|
|
227
|
+
const rOutOpt = [];
|
|
228
|
+
const figN = get_figure_array(dList, selD, paramPath, modif);
|
|
229
|
+
const subdN = Object.keys(get_subdesign_array(dList, selD, paramPath, modif));
|
|
230
|
+
for (const figNi of figN) {
|
|
231
|
+
rOutOpt.push(`svg__${figNi}`);
|
|
232
|
+
}
|
|
233
|
+
for (const figNi of figN) {
|
|
234
|
+
rOutOpt.push(`dxf__${figNi}`);
|
|
235
|
+
}
|
|
236
|
+
for (const subdNi of subdN) {
|
|
237
|
+
rOutOpt.push(`json_sub_param_${subdNi}`);
|
|
238
|
+
}
|
|
239
|
+
for (const ffi of c_fileFormat) {
|
|
240
|
+
rOutOpt.push(`${ffi}`);
|
|
241
|
+
}
|
|
242
|
+
return rOutOpt;
|
|
243
|
+
}
|
|
244
|
+
function decompose_outopt(outopt) {
|
|
245
|
+
let rWrite = 2 /* eOTHERS */;
|
|
246
|
+
let rFormat = EFormat2.ePAX;
|
|
247
|
+
let rFace = "all";
|
|
248
|
+
let rSubD = "";
|
|
249
|
+
const reSvg = /^svg__/;
|
|
250
|
+
const reDxf = /^dxf__/;
|
|
251
|
+
const reSubP = /^json_sub_param_/;
|
|
252
|
+
if (outopt.match(reSvg)) {
|
|
253
|
+
rFace = outopt.replace(reSvg, "");
|
|
254
|
+
rFormat = EFormat2.eSVG;
|
|
255
|
+
rWrite = 2 /* eOTHERS */;
|
|
256
|
+
} else if (outopt.match(reDxf)) {
|
|
257
|
+
rFace = outopt.replace(reDxf, "");
|
|
258
|
+
rFormat = EFormat2.eDXF;
|
|
259
|
+
rWrite = 2 /* eOTHERS */;
|
|
260
|
+
} else if (outopt.match(reSubP)) {
|
|
261
|
+
rSubD = outopt.replace(reSubP, "");
|
|
262
|
+
rWrite = 1 /* eSUBDPARAMS */;
|
|
263
|
+
} else {
|
|
264
|
+
switch (outopt) {
|
|
265
|
+
case "json_param":
|
|
266
|
+
rWrite = 0 /* eEGOPARAMS */;
|
|
267
|
+
break;
|
|
268
|
+
case "svg_all_figures":
|
|
269
|
+
rFormat = EFormat2.eSVGALL;
|
|
270
|
+
rWrite = 2 /* eOTHERS */;
|
|
271
|
+
break;
|
|
272
|
+
case "dxf_all_figures":
|
|
273
|
+
rFormat = EFormat2.eDXFALL;
|
|
274
|
+
rWrite = 2 /* eOTHERS */;
|
|
275
|
+
break;
|
|
276
|
+
case "pax_all":
|
|
277
|
+
rFormat = EFormat2.ePAX;
|
|
278
|
+
rWrite = 2 /* eOTHERS */;
|
|
279
|
+
break;
|
|
280
|
+
case "scad_3d_openscad":
|
|
281
|
+
rFormat = EFormat2.eOPENSCAD;
|
|
282
|
+
rWrite = 2 /* eOTHERS */;
|
|
283
|
+
break;
|
|
284
|
+
case "js_3d_openjscad":
|
|
285
|
+
rFormat = EFormat2.eJSCAD;
|
|
286
|
+
rWrite = 2 /* eOTHERS */;
|
|
287
|
+
break;
|
|
288
|
+
case "zip_all":
|
|
289
|
+
rFormat = EFormat2.eZIP;
|
|
290
|
+
rWrite = 2 /* eOTHERS */;
|
|
291
|
+
break;
|
|
292
|
+
default:
|
|
293
|
+
rFormat = EFormat2.ePAX;
|
|
294
|
+
rWrite = 2 /* eOTHERS */;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const eFormat = { eWrite: rWrite, eFormat: rFormat, eFace: rFace, eSubdesign: rSubD };
|
|
298
|
+
return eFormat;
|
|
299
|
+
}
|
|
300
|
+
function list_designs(dList, detail) {
|
|
301
|
+
let rlog = "List of available designs:\n";
|
|
302
|
+
for (const [idx, dname] of get_design_array(dList).entries()) {
|
|
303
|
+
rlog += `${(idx + 1).toString().padStart(4, " ")} : ${dname}
|
|
304
|
+
`;
|
|
305
|
+
if (detail) {
|
|
306
|
+
rlog += ` ${dList[dname].pDef.partName}
|
|
307
|
+
`;
|
|
308
|
+
rlog += ` ${dList[dname].pTitle}
|
|
309
|
+
`;
|
|
310
|
+
rlog += ` ${dList[dname].pDescription}
|
|
311
|
+
`;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
console.log(rlog);
|
|
315
|
+
}
|
|
316
|
+
function list_parameters(dList, selD, paramPath, modif) {
|
|
317
|
+
const theD = selectDesign(dList, selD);
|
|
318
|
+
let rlog = `List of parameters of the design ${selD} (${theD.pDef.partName}):
|
|
319
|
+
`;
|
|
320
|
+
const dParam = designParam(theD.pDef);
|
|
321
|
+
try {
|
|
322
|
+
dParam.applyParamVal(readParams(paramPath, true));
|
|
323
|
+
dParam.applyParamVal(parseModif(modif, true));
|
|
324
|
+
} catch (emsg) {
|
|
325
|
+
console.log("err272: error while applying new parameters");
|
|
326
|
+
console.log(emsg);
|
|
327
|
+
process.exit(1);
|
|
328
|
+
}
|
|
329
|
+
const paramVal = dParam.getParamVal();
|
|
330
|
+
const nameLength = 20;
|
|
331
|
+
const unitLength = 8;
|
|
332
|
+
const nameLabel = "name".padEnd(nameLength, " ");
|
|
333
|
+
const unitLabel = "unit".padEnd(unitLength, " ");
|
|
334
|
+
rlog += ` # : ${nameLabel} current ${unitLabel} init min max step
|
|
335
|
+
`;
|
|
336
|
+
for (const [idx, pa] of theD.pDef.params.entries()) {
|
|
337
|
+
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
338
|
+
const pname = pa.name.padEnd(nameLength, " ");
|
|
339
|
+
const pcurr = paramVal[pa.name];
|
|
340
|
+
const pcurrP = pcurr.toString().padStart(6, " ");
|
|
341
|
+
const punit = pa.unit.padEnd(unitLength, " ");
|
|
342
|
+
const pinit = pa.init.toString().padStart(6, " ");
|
|
343
|
+
switch (pa.pType) {
|
|
344
|
+
case PType.eCheckbox:
|
|
345
|
+
rlog += `${idx2} : ${pname} checkbox ${pcurr} ${pa.init}
|
|
346
|
+
`;
|
|
347
|
+
break;
|
|
348
|
+
case PType.eDropdown:
|
|
349
|
+
rlog += `${idx2} : ${pname} ${pcurr} ${pa.init}`;
|
|
350
|
+
for (const [optI, optN] of pa.dropdown.entries()) {
|
|
351
|
+
rlog += ` ${optI}:${optN}`;
|
|
352
|
+
}
|
|
353
|
+
rlog += "\n";
|
|
354
|
+
break;
|
|
355
|
+
default:
|
|
356
|
+
rlog += `${idx2} : ${pname} ${pcurrP} ${punit} ${pinit} ${pa.min} ${pa.max} ${pa.step}
|
|
357
|
+
`;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
console.log(rlog);
|
|
361
|
+
}
|
|
362
|
+
function list_figures(dList, selD, paramPath, modif) {
|
|
363
|
+
const dPartName = selectDesignN(dList, selD);
|
|
364
|
+
const figN = get_figure_array(dList, selD, paramPath, modif);
|
|
365
|
+
let rlog = `List of figures of the design ${selD} (${dPartName}):
|
|
366
|
+
`;
|
|
367
|
+
for (const [idx, figNi] of figN.entries()) {
|
|
368
|
+
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
369
|
+
rlog += `${idx2} : ${figNi}
|
|
370
|
+
`;
|
|
371
|
+
}
|
|
372
|
+
console.log(rlog);
|
|
373
|
+
}
|
|
374
|
+
function list_subdesigns(dList, selD, paramPath, modif) {
|
|
375
|
+
const dPartName = selectDesignN(dList, selD);
|
|
376
|
+
const subdA = get_subdesign_array(dList, selD, paramPath, modif);
|
|
377
|
+
const subdN = Object.keys(subdA);
|
|
378
|
+
let rlog = `List of sub-designs of the design ${selD} (${dPartName}):
|
|
379
|
+
`;
|
|
380
|
+
for (const [idx, subdNi] of subdN.entries()) {
|
|
381
|
+
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
382
|
+
const subd = subdA[subdNi];
|
|
383
|
+
const ori = `[ ${subd.orientation[0]}, ${subd.orientation[1]}, ${subd.orientation[2]}]`;
|
|
384
|
+
const pos = `[ ${subd.position[0]}, ${subd.position[1]}, ${subd.position[2]}]`;
|
|
385
|
+
const subdNp = subdNi.padEnd(15, " ");
|
|
386
|
+
const subdPp = subd.partName.padEnd(15, " ");
|
|
387
|
+
rlog += `${idx2} : ${subdNp} ${subdPp} orientation: ${ori} position: ${pos}
|
|
388
|
+
`;
|
|
389
|
+
}
|
|
390
|
+
console.log(rlog);
|
|
391
|
+
}
|
|
392
|
+
function list_subd_parameters(dList, selD, subdN, paramPath, modif) {
|
|
393
|
+
const subdParam = get_subd(dList, selD, subdN, paramPath, modif, true).dparam;
|
|
394
|
+
const nameLength = 20;
|
|
395
|
+
const nameLabel = "name".padEnd(nameLength, " ");
|
|
396
|
+
let rlog = ` # : ${nameLabel} value init changed
|
|
397
|
+
`;
|
|
398
|
+
for (const [idx, ipaN] of Object.keys(subdParam).entries()) {
|
|
399
|
+
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
400
|
+
const paN = ipaN.padEnd(nameLength, " ");
|
|
401
|
+
const pa = subdParam[ipaN];
|
|
402
|
+
const paVal = pa.val.toString().padStart(6, " ");
|
|
403
|
+
const paInit = pa.init.toString().padStart(6, " ");
|
|
404
|
+
rlog += `${idx2} : ${paN} ${paVal} ${paInit} ${pa.chg ? "changed" : ""}
|
|
405
|
+
`;
|
|
406
|
+
}
|
|
407
|
+
console.log(rlog);
|
|
408
|
+
}
|
|
409
|
+
function list_outopt(dList, selD, paramPath, modif) {
|
|
410
|
+
const dPartName = selectDesignN(dList, selD);
|
|
411
|
+
let rlog = `List of outputs of the design ${selD} (${dPartName}):
|
|
412
|
+
`;
|
|
413
|
+
const outOpt = get_outopt_array(dList, selD, paramPath, modif);
|
|
414
|
+
for (const [idx, oneOpt] of outOpt.entries()) {
|
|
415
|
+
const idx2 = (idx + 1).toString().padStart(4, " ");
|
|
416
|
+
rlog += `${idx2} : ${oneOpt}
|
|
417
|
+
`;
|
|
418
|
+
}
|
|
419
|
+
console.log(rlog);
|
|
420
|
+
}
|
|
421
|
+
var cmd_write = false;
|
|
422
|
+
async function geom_cli(iArgs, dList, outDir = "output") {
|
|
423
|
+
const argv = yargs(hideBin(iArgs)).scriptName("geom_cli").version(version).usage("Usage: $0 <global-options> command <command-argument>").example([
|
|
424
|
+
["$0 list-designs", "list the available designs"],
|
|
425
|
+
["$0 list-designs-detailed", "list the available designs with detailed information"],
|
|
426
|
+
["$0 -d heliostat/rake compute-log", "compute and print the log"],
|
|
427
|
+
["$0 -d heliostat/swing list-outopt", "list possible output-format-options"],
|
|
428
|
+
["$0 -d heliostat/rod write zip_all", "write a zip file"]
|
|
429
|
+
]).option("design", {
|
|
430
|
+
alias: "d",
|
|
431
|
+
type: "string",
|
|
432
|
+
description: "design to be used by the command",
|
|
433
|
+
default: ""
|
|
434
|
+
}).option("param", {
|
|
435
|
+
alias: "p",
|
|
436
|
+
type: "string",
|
|
437
|
+
array: false,
|
|
438
|
+
description: "path to the input parameter file",
|
|
439
|
+
default: ""
|
|
440
|
+
}).option("modif", {
|
|
441
|
+
alias: "m",
|
|
442
|
+
nargs: 2,
|
|
443
|
+
type: "string",
|
|
444
|
+
description: "modify parameter values <paramName> <paramValue>",
|
|
445
|
+
default: ""
|
|
446
|
+
}).option("outDir", {
|
|
447
|
+
alias: "o",
|
|
448
|
+
type: "string",
|
|
449
|
+
description: "the path of the directory where to write the output files",
|
|
450
|
+
default: outDir
|
|
451
|
+
}).option("outFileName", {
|
|
452
|
+
type: "string",
|
|
453
|
+
description: "Rename the output filename",
|
|
454
|
+
default: ""
|
|
455
|
+
}).command(["list-designs", "list"], "list the available designs", {}, () => {
|
|
456
|
+
list_designs(dList, false);
|
|
457
|
+
}).command("list-designs-detailed", "list the available designs with details", {}, () => {
|
|
458
|
+
list_designs(dList, true);
|
|
459
|
+
}).command("list-parameters", "list the parameters of the selected design", {}, (argv2) => {
|
|
460
|
+
list_parameters(
|
|
461
|
+
dList,
|
|
462
|
+
argv2.design,
|
|
463
|
+
argv2.param,
|
|
464
|
+
argv2.modif
|
|
465
|
+
);
|
|
466
|
+
}).command("list-figures", "list the figures of the selected design", {}, (argv2) => {
|
|
467
|
+
list_figures(
|
|
468
|
+
dList,
|
|
469
|
+
argv2.design,
|
|
470
|
+
argv2.param,
|
|
471
|
+
argv2.modif
|
|
472
|
+
);
|
|
473
|
+
}).command("list-subdesigns", "list the subdesigns of the selected design", {}, (argv2) => {
|
|
474
|
+
list_subdesigns(
|
|
475
|
+
dList,
|
|
476
|
+
argv2.design,
|
|
477
|
+
argv2.param,
|
|
478
|
+
argv2.modif
|
|
479
|
+
);
|
|
480
|
+
}).command(
|
|
481
|
+
"list-subd-parameters <subdN>",
|
|
482
|
+
"list the parameters of subdesigns",
|
|
483
|
+
{},
|
|
484
|
+
(argv2) => {
|
|
485
|
+
list_subd_parameters(
|
|
486
|
+
dList,
|
|
487
|
+
argv2.design,
|
|
488
|
+
argv2.subdN,
|
|
489
|
+
argv2.param,
|
|
490
|
+
argv2.modif
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
).command("compute-log", "Compute and print the log without writing file", {}, (argv2) => {
|
|
494
|
+
computeGeom(
|
|
495
|
+
dList,
|
|
496
|
+
argv2.design,
|
|
497
|
+
argv2.param,
|
|
498
|
+
argv2.modif,
|
|
499
|
+
true
|
|
500
|
+
);
|
|
501
|
+
}).command(
|
|
502
|
+
"list-outopt",
|
|
503
|
+
"list the possible output format options of the selected design",
|
|
504
|
+
{},
|
|
505
|
+
(argv2) => {
|
|
506
|
+
list_outopt(
|
|
507
|
+
dList,
|
|
508
|
+
argv2.design,
|
|
509
|
+
argv2.param,
|
|
510
|
+
argv2.modif
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
).command("write <outopt>", "write the output format file", {}, () => {
|
|
514
|
+
cmd_write = true;
|
|
515
|
+
}).demandCommand(1).help().strict().parseSync();
|
|
516
|
+
if (cmd_write) {
|
|
517
|
+
const iOutDir = argv.outDir;
|
|
518
|
+
if (iOutDir === "") {
|
|
519
|
+
console.log("err638: option 'outDir' is set to empty string. Nothing written!");
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
522
|
+
const selD = argv.design;
|
|
523
|
+
const outopt = argv.outopt;
|
|
524
|
+
const paramPath = argv.param;
|
|
525
|
+
const paramModif = argv.modif;
|
|
526
|
+
const theD = selectDesign(dList, selD);
|
|
527
|
+
const outOpt = get_outopt_array(dList, selD, paramPath, paramModif);
|
|
528
|
+
if (!outOpt.includes(outopt)) {
|
|
529
|
+
console.log(`err639: outopt ${outopt} is not a valid option`);
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
532
|
+
let rlog = "";
|
|
533
|
+
const oOpt = decompose_outopt(outopt);
|
|
534
|
+
const dParam = designParam(theD.pDef);
|
|
535
|
+
try {
|
|
536
|
+
dParam.applyParamVal(readParams(paramPath, false));
|
|
537
|
+
dParam.applyParamVal(parseModif(paramModif, false));
|
|
538
|
+
} catch (emsg) {
|
|
539
|
+
console.log("err273: error while applying new parameters");
|
|
540
|
+
console.log(emsg);
|
|
541
|
+
process.exit(1);
|
|
542
|
+
}
|
|
543
|
+
computeGeom(dList, selD, paramPath, paramModif, true);
|
|
544
|
+
try {
|
|
545
|
+
if (oOpt.eWrite === 0 /* eEGOPARAMS */) {
|
|
546
|
+
rlog += writeParams(
|
|
547
|
+
dParam.partName,
|
|
548
|
+
dParam.getParamVal(),
|
|
549
|
+
iOutDir,
|
|
550
|
+
argv.outFileName
|
|
551
|
+
);
|
|
552
|
+
} else if (oOpt.eWrite === 1 /* eSUBDPARAMS */) {
|
|
553
|
+
const subD = get_subd(dList, selD, oOpt.eSubdesign, paramPath, paramModif, false);
|
|
554
|
+
rlog += writeParams(
|
|
555
|
+
subD.partName,
|
|
556
|
+
paramListToVal(subD.dparam),
|
|
557
|
+
iOutDir,
|
|
558
|
+
argv.outFileName
|
|
559
|
+
);
|
|
560
|
+
} else {
|
|
561
|
+
const simtime = 0;
|
|
562
|
+
rlog += await geom_write(
|
|
563
|
+
dParam.partName,
|
|
564
|
+
theD.pGeom,
|
|
565
|
+
simtime,
|
|
566
|
+
dParam.getParamVal(),
|
|
567
|
+
oOpt.eFormat,
|
|
568
|
+
// output-format
|
|
569
|
+
//EFormat.eSVG,
|
|
570
|
+
//EFormat.eDXF,
|
|
571
|
+
//EFormat.ePAX,
|
|
572
|
+
//EFormat.eOPENSCAD,
|
|
573
|
+
//EFormat.eJSCAD,
|
|
574
|
+
//EFormat.eZIP,
|
|
575
|
+
oOpt.eFace,
|
|
576
|
+
// selected-2d-face
|
|
577
|
+
iOutDir,
|
|
578
|
+
// output-directory
|
|
579
|
+
argv.outFileName
|
|
580
|
+
// output-filename
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
} catch (emsg) {
|
|
584
|
+
console.log("err279: error while writing file");
|
|
585
|
+
console.log(emsg);
|
|
586
|
+
process.exit(1);
|
|
587
|
+
}
|
|
588
|
+
console.log(rlog);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
export {
|
|
592
|
+
geom_cli,
|
|
593
|
+
geom_write
|
|
594
|
+
};
|
|
595
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/geom_write.ts","../src/geom_cli.ts","../package.json"],"sourcesContent":["// geom_write.ts\n\nimport type { tGeomFunc, tParamVal } from 'geometrix';\nimport {\n\tEFormat,\n\tfileBinContent,\n\tfileTextContent,\n\tfileSuffix,\n\tfileBin,\n\tcreateParamFile,\n\tparseParamFile\n} from 'geometrix';\nimport fs from 'fs';\n\nfunction dateString(): string {\n\tconst re1 = /[-:]/g;\n\tconst re2 = /\\..*$/;\n\tconst rDateStr = new Date().toISOString().replace(re1, '').replace(re2, '').replace('T', '_');\n\treturn rDateStr;\n}\n\nfunction createDir(iDir: string): string {\n\tlet rlog = '';\n\tif (!fs.existsSync(iDir)) {\n\t\tfs.mkdirSync(iDir, { recursive: true });\n\t\trlog += `info203: mkdir ${iDir}\\n`;\n\t}\n\treturn rlog;\n}\n\nasync function write_binFile(fName: string, fContent: Blob): Promise<string> {\n\tlet rlog = '';\n\tconst buffer = await fContent.arrayBuffer();\n\tconst arrBufView = new DataView(buffer);\n\tfs.writeFileSync(fName, arrBufView);\n\trlog += `info304: bin-file ${fName} has been written\\n`;\n\treturn rlog;\n}\n\nfunction write_textFile(fName: string, fContent: string): string {\n\tlet rlog = '';\n\tfs.writeFileSync(fName, fContent);\n\trlog += `info405: text-file ${fName} has been written\\n`;\n\treturn rlog;\n}\n\nfunction checkDirFName(iDir: string, fName: string): string {\n\tconst reSlash = /\\//;\n\tif (reSlash.test(fName)) {\n\t\tthrow `err932: the filename ${fName} contains a slash '/'`;\n\t}\n\tif (iDir === '') {\n\t\tthrow `err074: geom_write output-directory is an empty string!`;\n\t}\n\tconst fName2 = `${iDir}/${fName}`;\n\treturn fName2;\n}\n\nfunction writeParams(\n\tiPartName: string,\n\tidparams: tParamVal,\n\toDir: string,\n\toFileName: string\n): string {\n\tconst re1 = /[-:]/g;\n\tconst re2 = /\\..*$/;\n\tconst datestr = new Date().toISOString().replace(re1, '').replace(re2, '').replace('T', '_');\n\tlet file_name = `px_${iPartName}_${datestr}.json`;\n\tif (oFileName !== '') {\n\t\tfile_name = oFileName;\n\t}\n\tconst paramNb = Object.keys(idparams).length;\n\tconst fName2 = checkDirFName(oDir, file_name);\n\tlet rlog = `Write ${paramNb} parameters in file ${fName2}\\n`;\n\tconst file_content = createParamFile(datestr, idparams, 'Written by geom_cli');\n\trlog += createDir(oDir);\n\twrite_textFile(fName2, file_content);\n\treturn rlog;\n}\n\nfunction readParams(paramPath: string, printLog: boolean): tParamVal {\n\tlet rParamVal: tParamVal = {};\n\tif (paramPath !== '') {\n\t\tlet rlog = `Read parameter file ${paramPath}\\n`;\n\t\tif (!fs.existsSync(paramPath)) {\n\t\t\tthrow `err533: file ${paramPath} doesn't exist!`;\n\t\t}\n\t\tconst fContentStr = fs.readFileSync(paramPath, 'utf8');\n\t\tconst [obj] = parseParamFile(fContentStr);\n\t\t//const [obj, tlog] = parseParamFile(fContentStr);\n\t\t//rlog += tlog;\n\t\trlog += `file lastModif: ${obj.lastModif}\\n`;\n\t\trlog += `file comment: ${obj.comment}\\n`;\n\t\trlog += `info307: ${Object.keys(obj.pVal).length} parameters from file`;\n\t\trParamVal = obj.pVal;\n\t\tif (printLog) {\n\t\t\tconsole.log(rlog);\n\t\t}\n\t}\n\treturn rParamVal;\n}\n\nasync function geom_write(\n\tiPartName: string,\n\tfgeom: tGeomFunc,\n\tsimTime: number,\n\tiParam: tParamVal,\n\tiFormat: EFormat,\n\tiFace = '',\n\tiDir = '.',\n\tiFname = ''\n): Promise<string> {\n\tlet rlog = '';\n\tconst fSuffix = fileSuffix(iFormat);\n\tconst fBin = fileBin(iFormat);\n\tlet nFace = 'all';\n\tif (iFace !== '') {\n\t\tnFace = iFace;\n\t}\n\tlet fName = iFname;\n\tif (fName === '') {\n\t\tfName = iPartName + '_' + nFace + '_' + dateString() + fSuffix;\n\t}\n\tconst fName2 = checkDirFName(iDir, fName);\n\trlog += createDir(iDir);\n\tif (fBin) {\n\t\tconst fContent = await fileBinContent(fgeom, simTime, iParam, iFormat);\n\t\trlog += await write_binFile(fName2, fContent);\n\t} else {\n\t\tconst fContent = fileTextContent(fgeom, iParam, nFace, iFormat);\n\t\trlog += write_textFile(fName2, fContent);\n\t}\n\treturn rlog;\n}\n\nexport { geom_write, writeParams, readParams };\n","// geom_cli.ts\n\nimport type { tParamVal, tGeom, tSubDesign, tPageDef, tAllPageDef, tSubInst } from 'geometrix';\nimport { PType, EFormat, designParam, prefixLog, paramListToVal } from 'geometrix';\nimport { geom_write, writeParams, readParams } from './geom_write';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { version } from '../package.json';\n\nfunction get_design_array(dList: tAllPageDef): string[] {\n\tconst rDesignArray = Object.keys(dList);\n\treturn rDesignArray;\n}\n\nfunction selectDesign(dList: tAllPageDef, selD: string): tPageDef {\n\tif (!Object.keys(dList).includes(selD)) {\n\t\tconsole.log(`err918: design ${selD} is not defined`);\n\t\tprocess.exit(1);\n\t}\n\treturn dList[selD];\n}\n\nfunction selectDesignN(dList: tAllPageDef, selD: string): string {\n\tconst theD = selectDesign(dList, selD);\n\tconst dName = theD.pDef.partName;\n\treturn dName;\n}\n\nfunction parseModif(modif: string[], printLog: boolean): tParamVal {\n\tconst pVal: tParamVal = {};\n\tconst arrayLen = modif.length;\n\tif (arrayLen % 2 === 1) {\n\t\tthrow `err903: length ${arrayLen} of modif string array is odd!`;\n\t}\n\tfor (let i = 0; i < arrayLen / 2; i++) {\n\t\tconst valStr = modif[2 * i + 1];\n\t\tconst val = parseFloat(valStr);\n\t\tif (isNaN(val)) {\n\t\t\tthrow `err908: ${valStr} is not a number!`;\n\t\t}\n\t\tpVal[modif[2 * i]] = val;\n\t}\n\tconst pValLen = Object.keys(pVal).length;\n\tif (printLog && pValLen > 0) {\n\t\tconst rlog = `info308: ${pValLen} parameters of modifier`;\n\t\tconsole.log(rlog);\n\t}\n\treturn pVal;\n}\n\nfunction computeGeom(\n\tdList: tAllPageDef,\n\tselD: string,\n\tparamPath: string,\n\tmodif: string[],\n\tprintLog: boolean\n): tGeom {\n\tconst theD = selectDesign(dList, selD);\n\tlet rlog = `Compute design ${selD} (${theD.pDef.partName}):\\n`;\n\tconst dParam = designParam(theD.pDef);\n\ttry {\n\t\tdParam.applyParamVal(readParams(paramPath, printLog));\n\t\tdParam.applyParamVal(parseModif(modif, printLog));\n\t} catch (emsg) {\n\t\tconsole.log('err271: error while applying new parameters');\n\t\tconsole.log(emsg);\n\t\tprocess.exit(1);\n\t}\n\tconst simtime = 0;\n\tconst dGeom = theD.pGeom(simtime, dParam.getParamVal());\n\t//checkGeom(dGeom);\n\trlog += prefixLog(dGeom.logstr, dParam.partName);\n\tif (dGeom.calcErr) {\n\t\trlog += `err907: Error while computing ${theD.pDef.partName}\\n`;\n\t\tconsole.log(rlog);\n\t\tprocess.exit(1);\n\t} else {\n\t\trlog += `${theD.pDef.partName} successfully computed\\n`;\n\t}\n\tif (printLog) {\n\t\tconsole.log(rlog);\n\t}\n\treturn dGeom;\n}\n\nfunction get_figure_array(\n\tdList: tAllPageDef,\n\tselD: string,\n\tparamPath: string,\n\tmodif: string[]\n): string[] {\n\tconst dGeom = computeGeom(dList, selD, paramPath, modif, false);\n\tconst rfigN = Object.keys(dGeom.fig);\n\treturn rfigN;\n}\n\nfunction get_subdesign_array(\n\tdList: tAllPageDef,\n\tselD: string,\n\tparamPath: string,\n\tmodif: string[]\n): tSubDesign {\n\tconst dGeom = computeGeom(dList, selD, paramPath, modif, false);\n\tconst subd = dGeom.sub;\n\treturn subd;\n}\n\nfunction get_subd(\n\tdList: tAllPageDef,\n\tselD: string,\n\tsubdN: string,\n\tparamPath: string,\n\tmodif: string[],\n\tprintLog: boolean\n): tSubInst {\n\tconst theD = selectDesign(dList, selD);\n\tconst dGeom = computeGeom(dList, selD, paramPath, modif, printLog);\n\tif (!Object.keys(dGeom.sub).includes(subdN)) {\n\t\tconsole.log(`err207: sub-design ${subdN} not defined in partName ${theD.pDef.partName}`);\n\t\tprocess.exit(1);\n\t}\n\tconst rSubd = dGeom.sub[subdN];\n\tif (printLog) {\n\t\tconst rlog = `Subdesign ${subdN} (${rSubd.partName}) of ${selD} (${theD.pDef.partName}):\\n`;\n\t\tconsole.log(rlog);\n\t}\n\treturn rSubd;\n}\n\nconst c_fileFormat = [\n\t'json_param',\n\t'svg_all_figures',\n\t'dxf_all_figures',\n\t'pax_all',\n\t'scad_3d_openscad',\n\t'js_3d_openjscad',\n\t'zip_all'\n];\n\nfunction get_outopt_array(\n\tdList: tAllPageDef,\n\tselD: string,\n\tparamPath: string,\n\tmodif: string[]\n): string[] {\n\tconst rOutOpt: string[] = [];\n\tconst figN = get_figure_array(dList, selD, paramPath, modif);\n\tconst subdN = Object.keys(get_subdesign_array(dList, selD, paramPath, modif));\n\tfor (const figNi of figN) {\n\t\trOutOpt.push(`svg__${figNi}`);\n\t}\n\tfor (const figNi of figN) {\n\t\trOutOpt.push(`dxf__${figNi}`);\n\t}\n\tfor (const subdNi of subdN) {\n\t\trOutOpt.push(`json_sub_param_${subdNi}`);\n\t}\n\tfor (const ffi of c_fileFormat) {\n\t\trOutOpt.push(`${ffi}`);\n\t}\n\treturn rOutOpt;\n}\n\nenum EWrite {\n\teEGOPARAMS,\n\teSUBDPARAMS,\n\teOTHERS\n}\n\ninterface tEFormat {\n\teWrite: EWrite;\n\teFormat: EFormat;\n\teFace: string;\n\teSubdesign: string;\n}\n\nfunction decompose_outopt(outopt: string): tEFormat {\n\tlet rWrite = EWrite.eOTHERS;\n\tlet rFormat = EFormat.ePAX;\n\tlet rFace = 'all';\n\tlet rSubD = '';\n\tconst reSvg = /^svg__/;\n\tconst reDxf = /^dxf__/;\n\tconst reSubP = /^json_sub_param_/;\n\tif (outopt.match(reSvg)) {\n\t\trFace = outopt.replace(reSvg, '');\n\t\trFormat = EFormat.eSVG;\n\t\trWrite = EWrite.eOTHERS;\n\t} else if (outopt.match(reDxf)) {\n\t\trFace = outopt.replace(reDxf, '');\n\t\trFormat = EFormat.eDXF;\n\t\trWrite = EWrite.eOTHERS;\n\t} else if (outopt.match(reSubP)) {\n\t\trSubD = outopt.replace(reSubP, '');\n\t\trWrite = EWrite.eSUBDPARAMS;\n\t} else {\n\t\tswitch (outopt) {\n\t\t\tcase 'json_param':\n\t\t\t\trWrite = EWrite.eEGOPARAMS;\n\t\t\t\tbreak;\n\t\t\tcase 'svg_all_figures':\n\t\t\t\trFormat = EFormat.eSVGALL;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tcase 'dxf_all_figures':\n\t\t\t\trFormat = EFormat.eDXFALL;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tcase 'pax_all':\n\t\t\t\trFormat = EFormat.ePAX;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tcase 'scad_3d_openscad':\n\t\t\t\trFormat = EFormat.eOPENSCAD;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tcase 'js_3d_openjscad':\n\t\t\t\trFormat = EFormat.eJSCAD;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tcase 'zip_all':\n\t\t\t\trFormat = EFormat.eZIP;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\trFormat = EFormat.ePAX;\n\t\t\t\trWrite = EWrite.eOTHERS;\n\t\t}\n\t}\n\tconst eFormat: tEFormat = { eWrite: rWrite, eFormat: rFormat, eFace: rFace, eSubdesign: rSubD };\n\treturn eFormat;\n}\n\nfunction list_designs(dList: tAllPageDef, detail: boolean) {\n\tlet rlog = 'List of available designs:\\n';\n\tfor (const [idx, dname] of get_design_array(dList).entries()) {\n\t\trlog += `${(idx + 1).toString().padStart(4, ' ')} : ${dname}\\n`;\n\t\tif (detail) {\n\t\t\trlog += ` ${dList[dname].pDef.partName}\\n`;\n\t\t\trlog += ` ${dList[dname].pTitle}\\n`;\n\t\t\trlog += ` ${dList[dname].pDescription}\\n`;\n\t\t}\n\t}\n\tconsole.log(rlog);\n}\n\nfunction list_parameters(dList: tAllPageDef, selD: string, paramPath: string, modif: string[]) {\n\tconst theD = selectDesign(dList, selD);\n\tlet rlog = `List of parameters of the design ${selD} (${theD.pDef.partName}):\\n`;\n\tconst dParam = designParam(theD.pDef);\n\ttry {\n\t\tdParam.applyParamVal(readParams(paramPath, true));\n\t\tdParam.applyParamVal(parseModif(modif, true));\n\t} catch (emsg) {\n\t\tconsole.log('err272: error while applying new parameters');\n\t\tconsole.log(emsg);\n\t\tprocess.exit(1);\n\t}\n\tconst paramVal = dParam.getParamVal();\n\tconst nameLength = 20;\n\tconst unitLength = 8;\n\tconst nameLabel = 'name'.padEnd(nameLength, ' ');\n\tconst unitLabel = 'unit'.padEnd(unitLength, ' ');\n\trlog += ` # : ${nameLabel} current ${unitLabel} init min max step\\n`;\n\tfor (const [idx, pa] of theD.pDef.params.entries()) {\n\t\tconst idx2 = (idx + 1).toString().padStart(4, ' ');\n\t\tconst pname = pa.name.padEnd(nameLength, ' ');\n\t\tconst pcurr = paramVal[pa.name];\n\t\tconst pcurrP = pcurr.toString().padStart(6, ' ');\n\t\tconst punit = pa.unit.padEnd(unitLength, ' ');\n\t\tconst pinit = pa.init.toString().padStart(6, ' ');\n\t\tswitch (pa.pType) {\n\t\t\tcase PType.eCheckbox:\n\t\t\t\trlog += `${idx2} : ${pname} checkbox ${pcurr} ${pa.init}\\n`;\n\t\t\t\tbreak;\n\t\t\tcase PType.eDropdown:\n\t\t\t\trlog += `${idx2} : ${pname} ${pcurr} ${pa.init}`;\n\t\t\t\tfor (const [optI, optN] of pa.dropdown.entries()) {\n\t\t\t\t\trlog += ` ${optI}:${optN}`;\n\t\t\t\t}\n\t\t\t\trlog += '\\n';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\trlog += `${idx2} : ${pname} ${pcurrP} ${punit} ${pinit} ${pa.min} ${pa.max} ${pa.step}\\n`;\n\t\t}\n\t}\n\tconsole.log(rlog);\n}\n\nfunction list_figures(dList: tAllPageDef, selD: string, paramPath: string, modif: string[]) {\n\tconst dPartName = selectDesignN(dList, selD);\n\tconst figN = get_figure_array(dList, selD, paramPath, modif);\n\tlet rlog = `List of figures of the design ${selD} (${dPartName}):\\n`;\n\tfor (const [idx, figNi] of figN.entries()) {\n\t\tconst idx2 = (idx + 1).toString().padStart(4, ' ');\n\t\trlog += `${idx2} : ${figNi}\\n`;\n\t}\n\tconsole.log(rlog);\n}\n\nfunction list_subdesigns(dList: tAllPageDef, selD: string, paramPath: string, modif: string[]) {\n\tconst dPartName = selectDesignN(dList, selD);\n\tconst subdA = get_subdesign_array(dList, selD, paramPath, modif);\n\tconst subdN = Object.keys(subdA);\n\tlet rlog = `List of sub-designs of the design ${selD} (${dPartName}):\\n`;\n\tfor (const [idx, subdNi] of subdN.entries()) {\n\t\tconst idx2 = (idx + 1).toString().padStart(4, ' ');\n\t\tconst subd = subdA[subdNi];\n\t\tconst ori = `[ ${subd.orientation[0]}, ${subd.orientation[1]}, ${subd.orientation[2]}]`;\n\t\tconst pos = `[ ${subd.position[0]}, ${subd.position[1]}, ${subd.position[2]}]`;\n\t\tconst subdNp = subdNi.padEnd(15, ' ');\n\t\tconst subdPp = subd.partName.padEnd(15, ' ');\n\t\trlog += `${idx2} : ${subdNp} ${subdPp} orientation: ${ori} position: ${pos}\\n`;\n\t}\n\tconsole.log(rlog);\n}\n\nfunction list_subd_parameters(\n\tdList: tAllPageDef,\n\tselD: string,\n\tsubdN: string,\n\tparamPath: string,\n\tmodif: string[]\n) {\n\tconst subdParam = get_subd(dList, selD, subdN, paramPath, modif, true).dparam;\n\tconst nameLength = 20;\n\tconst nameLabel = 'name'.padEnd(nameLength, ' ');\n\tlet rlog = ` # : ${nameLabel} value init changed\\n`;\n\tfor (const [idx, ipaN] of Object.keys(subdParam).entries()) {\n\t\tconst idx2 = (idx + 1).toString().padStart(4, ' ');\n\t\tconst paN = ipaN.padEnd(nameLength, ' ');\n\t\tconst pa = subdParam[ipaN];\n\t\tconst paVal = pa.val.toString().padStart(6, ' ');\n\t\tconst paInit = pa.init.toString().padStart(6, ' ');\n\t\trlog += `${idx2} : ${paN} ${paVal} ${paInit} ${pa.chg ? 'changed' : ''}\\n`;\n\t}\n\tconsole.log(rlog);\n}\n\nfunction list_outopt(dList: tAllPageDef, selD: string, paramPath: string, modif: string[]) {\n\tconst dPartName = selectDesignN(dList, selD);\n\tlet rlog = `List of outputs of the design ${selD} (${dPartName}):\\n`;\n\tconst outOpt = get_outopt_array(dList, selD, paramPath, modif);\n\tfor (const [idx, oneOpt] of outOpt.entries()) {\n\t\tconst idx2 = (idx + 1).toString().padStart(4, ' ');\n\t\trlog += `${idx2} : ${oneOpt}\\n`;\n\t}\n\tconsole.log(rlog);\n}\n\nlet cmd_write = false;\nasync function geom_cli(iArgs: string[], dList: tAllPageDef, outDir = 'output') {\n\tconst argv = yargs(hideBin(iArgs))\n\t\t.scriptName('geom_cli')\n\t\t.version(version)\n\t\t.usage('Usage: $0 <global-options> command <command-argument>')\n\t\t.example([\n\t\t\t['$0 list-designs', 'list the available designs'],\n\t\t\t['$0 list-designs-detailed', 'list the available designs with detailed information'],\n\t\t\t['$0 -d heliostat/rake compute-log', 'compute and print the log'],\n\t\t\t['$0 -d heliostat/swing list-outopt', 'list possible output-format-options'],\n\t\t\t['$0 -d heliostat/rod write zip_all', 'write a zip file']\n\t\t])\n\t\t.option('design', {\n\t\t\talias: 'd',\n\t\t\ttype: 'string',\n\t\t\tdescription: 'design to be used by the command',\n\t\t\tdefault: ''\n\t\t})\n\t\t.option('param', {\n\t\t\talias: 'p',\n\t\t\ttype: 'string',\n\t\t\tarray: false,\n\t\t\tdescription: 'path to the input parameter file',\n\t\t\tdefault: ''\n\t\t})\n\t\t.option('modif', {\n\t\t\talias: 'm',\n\t\t\tnargs: 2,\n\t\t\ttype: 'string',\n\t\t\tdescription: 'modify parameter values <paramName> <paramValue>',\n\t\t\tdefault: ''\n\t\t})\n\t\t.option('outDir', {\n\t\t\talias: 'o',\n\t\t\ttype: 'string',\n\t\t\tdescription: 'the path of the directory where to write the output files',\n\t\t\tdefault: outDir\n\t\t})\n\t\t.option('outFileName', {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Rename the output filename',\n\t\t\tdefault: ''\n\t\t})\n\t\t.command(['list-designs', 'list'], 'list the available designs', {}, () => {\n\t\t\tlist_designs(dList, false);\n\t\t})\n\t\t.command('list-designs-detailed', 'list the available designs with details', {}, () => {\n\t\t\tlist_designs(dList, true);\n\t\t})\n\t\t.command('list-parameters', 'list the parameters of the selected design', {}, (argv) => {\n\t\t\t//console.log(argv)\n\t\t\tlist_parameters(\n\t\t\t\tdList,\n\t\t\t\targv.design as string,\n\t\t\t\targv.param as string,\n\t\t\t\targv.modif as string[]\n\t\t\t);\n\t\t})\n\t\t.command('list-figures', 'list the figures of the selected design', {}, (argv) => {\n\t\t\tlist_figures(\n\t\t\t\tdList,\n\t\t\t\targv.design as string,\n\t\t\t\targv.param as string,\n\t\t\t\targv.modif as string[]\n\t\t\t);\n\t\t})\n\t\t.command('list-subdesigns', 'list the subdesigns of the selected design', {}, (argv) => {\n\t\t\tlist_subdesigns(\n\t\t\t\tdList,\n\t\t\t\targv.design as string,\n\t\t\t\targv.param as string,\n\t\t\t\targv.modif as string[]\n\t\t\t);\n\t\t})\n\t\t.command(\n\t\t\t'list-subd-parameters <subdN>',\n\t\t\t'list the parameters of subdesigns',\n\t\t\t{},\n\t\t\t(argv) => {\n\t\t\t\tlist_subd_parameters(\n\t\t\t\t\tdList,\n\t\t\t\t\targv.design as string,\n\t\t\t\t\targv.subdN as string,\n\t\t\t\t\targv.param as string,\n\t\t\t\t\targv.modif as string[]\n\t\t\t\t);\n\t\t\t}\n\t\t)\n\t\t.command('compute-log', 'Compute and print the log without writing file', {}, (argv) => {\n\t\t\tcomputeGeom(\n\t\t\t\tdList,\n\t\t\t\targv.design as string,\n\t\t\t\targv.param as string,\n\t\t\t\targv.modif as string[],\n\t\t\t\ttrue\n\t\t\t);\n\t\t})\n\t\t.command(\n\t\t\t'list-outopt',\n\t\t\t'list the possible output format options of the selected design',\n\t\t\t{},\n\t\t\t(argv) => {\n\t\t\t\tlist_outopt(\n\t\t\t\t\tdList,\n\t\t\t\t\targv.design as string,\n\t\t\t\t\targv.param as string,\n\t\t\t\t\targv.modif as string[]\n\t\t\t\t);\n\t\t\t}\n\t\t)\n\t\t.command('write <outopt>', 'write the output format file', {}, () => {\n\t\t\tcmd_write = true;\n\t\t})\n\t\t.demandCommand(1)\n\t\t.help()\n\t\t.strict()\n\t\t.parseSync();\n\t//console.log(argv.$0);\n\t//console.log(argv.design);\n\t//console.log(argv.param);\n\t//console.log(argv.modif);\n\t//console.log(argv.outDir);\n\t//console.log(argv);\n\tif (cmd_write) {\n\t\tconst iOutDir = argv.outDir;\n\t\tif (iOutDir === '') {\n\t\t\tconsole.log(\"err638: option 'outDir' is set to empty string. Nothing written!\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconst selD = argv.design;\n\t\tconst outopt = argv.outopt as string;\n\t\tconst paramPath = argv.param;\n\t\tconst paramModif = argv.modif as unknown as string[];\n\t\tconst theD = selectDesign(dList, selD);\n\t\t// check if outopt is valid\n\t\tconst outOpt = get_outopt_array(dList, selD, paramPath, paramModif);\n\t\tif (!outOpt.includes(outopt)) {\n\t\t\tconsole.log(`err639: outopt ${outopt} is not a valid option`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\t// end of check of outopt\n\t\t//let rlog = `Write ${outopt} of ${selD} (${theD.pDef.partName}):\\n`;\n\t\tlet rlog = '';\n\t\tconst oOpt = decompose_outopt(outopt);\n\t\tconst dParam = designParam(theD.pDef);\n\t\ttry {\n\t\t\tdParam.applyParamVal(readParams(paramPath, false));\n\t\t\tdParam.applyParamVal(parseModif(paramModif, false));\n\t\t} catch (emsg) {\n\t\t\tconsole.log('err273: error while applying new parameters');\n\t\t\tconsole.log(emsg);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tcomputeGeom(dList, selD, paramPath, paramModif, true);\n\t\ttry {\n\t\t\tif (oOpt.eWrite === EWrite.eEGOPARAMS) {\n\t\t\t\trlog += writeParams(\n\t\t\t\t\tdParam.partName,\n\t\t\t\t\tdParam.getParamVal(),\n\t\t\t\t\tiOutDir,\n\t\t\t\t\targv.outFileName\n\t\t\t\t);\n\t\t\t} else if (oOpt.eWrite === EWrite.eSUBDPARAMS) {\n\t\t\t\tconst subD = get_subd(dList, selD, oOpt.eSubdesign, paramPath, paramModif, false);\n\t\t\t\trlog += writeParams(\n\t\t\t\t\tsubD.partName,\n\t\t\t\t\tparamListToVal(subD.dparam),\n\t\t\t\t\tiOutDir,\n\t\t\t\t\targv.outFileName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst simtime = 0;\n\t\t\t\trlog += await geom_write(\n\t\t\t\t\tdParam.partName,\n\t\t\t\t\ttheD.pGeom,\n\t\t\t\t\tsimtime,\n\t\t\t\t\tdParam.getParamVal(),\n\t\t\t\t\toOpt.eFormat, // output-format\n\t\t\t\t\t//EFormat.eSVG,\n\t\t\t\t\t//EFormat.eDXF,\n\t\t\t\t\t//EFormat.ePAX,\n\t\t\t\t\t//EFormat.eOPENSCAD,\n\t\t\t\t\t//EFormat.eJSCAD,\n\t\t\t\t\t//EFormat.eZIP,\n\t\t\t\t\toOpt.eFace, // selected-2d-face\n\t\t\t\t\tiOutDir, // output-directory\n\t\t\t\t\targv.outFileName // output-filename\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (emsg) {\n\t\t\tconsole.log('err279: error while writing file');\n\t\t\tconsole.log(emsg);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tconsole.log(rlog);\n\t}\n}\n\nexport { geom_cli };\n","{\n\t\"name\": \"geomcli\",\n\t\"version\": \"0.5.14\",\n\t\"description\": \"the nodejs companion library of geometrix\",\n\t\"private\": false,\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/charlyoleg2/parametrix.git\"\n\t},\n\t\"homepage\": \"https://github.com/charlyoleg2/parametrix/tree/main/pkg/geomcli#readme\",\n\t\"keywords\": [\n\t\t\"cad\",\n\t\t\"programmatic\",\n\t\t\"2D\",\n\t\t\"circle\",\n\t\t\"stroke\",\n\t\t\"arc\",\n\t\t\"gear\"\n\t],\n\t\"author\": \"charlyoleg\",\n\t\"tsup\": {\n\t\t\"entry\": [\n\t\t\t\"src/index.ts\"\n\t\t],\n\t\t\"format\": \"esm\",\n\t\t\"splitting\": false,\n\t\t\"dts\": true,\n\t\t\"sourcemap\": true,\n\t\t\"clean\": true\n\t},\n\t\"scripts\": {\n\t\t\"dev\": \"tsup --watch\",\n\t\t\"build\": \"tsup\",\n\t\t\"check\": \"tsc --noEmit\",\n\t\t\"pretty\": \"prettier --check .\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"lint\": \"eslint .\",\n\t\t\"test:unit\": \"vitest\",\n\t\t\"test:unit:once\": \"vitest --run\",\n\t\t\"ci\": \"run-s check build pretty lint test:unit:once\",\n\t\t\"clean\": \"shx rm -fr build dist node_modules\"\n\t},\n\t\"dependencies\": {\n\t\t\"geometrix\": \"^0.5.1\",\n\t\t\"yargs\": \"^17.7.2\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/yargs\": \"^17.0.32\",\n\t\t\"@typescript-eslint/eslint-plugin\": \"^6.16.0\",\n\t\t\"@typescript-eslint/parser\": \"^6.16.0\",\n\t\t\"eslint\": \"^8.56.0\",\n\t\t\"eslint-config-prettier\": \"^9.1.0\",\n\t\t\"npm-run-all\": \"^4.1.5\",\n\t\t\"prettier\": \"^3.1.1\",\n\t\t\"shx\": \"^0.3.4\",\n\t\t\"tsup\": \"^8.0.1\",\n\t\t\"typescript\": \"^5.3.3\",\n\t\t\"vitest\": \"^1.1.0\"\n\t},\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"types\": \"./dist/index.d.ts\",\n\t\t\t\"default\": \"./dist/index.js\"\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"!dist/**/*.test.*\",\n\t\t\"!dist/**/*.spec.*\"\n\t],\n\t\"types\": \"./dist/index.d.ts\",\n\t\"type\": \"module\"\n}\n"],"mappings":";AAGA;AAAA,EAEC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,QAAQ;AAEf,SAAS,aAAqB;AAC7B,QAAM,MAAM;AACZ,QAAM,MAAM;AACZ,QAAM,YAAW,oBAAI,KAAK,GAAE,YAAY,EAAE,QAAQ,KAAK,EAAE,EAAE,QAAQ,KAAK,EAAE,EAAE,QAAQ,KAAK,GAAG;AAC5F,SAAO;AACR;AAEA,SAAS,UAAU,MAAsB;AACxC,MAAI,OAAO;AACX,MAAI,CAAC,GAAG,WAAW,IAAI,GAAG;AACzB,OAAG,UAAU,MAAM,EAAE,WAAW,KAAK,CAAC;AACtC,YAAQ,kBAAkB,IAAI;AAAA;AAAA,EAC/B;AACA,SAAO;AACR;AAEA,eAAe,cAAc,OAAe,UAAiC;AAC5E,MAAI,OAAO;AACX,QAAM,SAAS,MAAM,SAAS,YAAY;AAC1C,QAAM,aAAa,IAAI,SAAS,MAAM;AACtC,KAAG,cAAc,OAAO,UAAU;AAClC,UAAQ,qBAAqB,KAAK;AAAA;AAClC,SAAO;AACR;AAEA,SAAS,eAAe,OAAe,UAA0B;AAChE,MAAI,OAAO;AACX,KAAG,cAAc,OAAO,QAAQ;AAChC,UAAQ,sBAAsB,KAAK;AAAA;AACnC,SAAO;AACR;AAEA,SAAS,cAAc,MAAc,OAAuB;AAC3D,QAAM,UAAU;AAChB,MAAI,QAAQ,KAAK,KAAK,GAAG;AACxB,UAAM,wBAAwB,KAAK;AAAA,EACpC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