Skip to content

Commit 129d26b

Browse files
author
Michel Kuhlmann
committed
enabling coordinate-axis switch
1 parent 68afb8f commit 129d26b

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

bin/2dmTransform

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
#!/usr/bin/env julia
22
# | Transform a 2dm-mesh (currently translation and scaling)
3-
# TODO: rotation, centering bbox
3+
# TODO: rotation, centering bbox
44
using ArgParse
55
using SurfaceMesh
66

77
function parseCmd(args)
88
s = ArgParseSettings("Transform a 2dm-mesh: " *
99
"translation, scaling: ")
1010
@add_arg_table s begin
11-
"--transX"
11+
"--transX", "-x"
1212
arg_type = FloatingPoint
1313
default = 0.0
1414
help = "Translation in x"
15-
"--transY"
15+
"--transY", "-y"
1616
arg_type = FloatingPoint
1717
default = 0.0
1818
help = "Translation in x"
19-
"--transZ"
19+
"--transZ", "-z"
2020
arg_type = FloatingPoint
2121
default = 0.0
2222
help = "Translation in x"
23-
"--scale"
23+
"--scale", "-s"
2424
arg_type = FloatingPoint
2525
default = 1.0
2626
help = "Scaling factor"
27+
"--coords_order", "-c"
28+
arg_type = String
29+
default = "1:2:3"
30+
help = "Coordinate axis order"
2731
"mesh-file"
2832
help = "mesh (2dm)-file"
2933
end
@@ -36,6 +40,7 @@ openMesh(f::Nothing) = STDIN
3640
function main()
3741
args = parseCmd(ARGS)
3842
con = openMesh(args["mesh-file"])
43+
cco = int(split(args["coords_order"], ":"))
3944
while true
4045
l = readline(con)
4146
if l == ""
@@ -50,7 +55,7 @@ function main()
5055
vn =
5156
(v + Vertex(args["transX"], args["transY"], args["transZ"])) *
5257
args["scale"]
53-
(vn1, vn2, vn3) = round(vn, 3)
58+
(vn1, vn2, vn3) = round(vn, 3)[cco]
5459
write("ND $(int(i)) $vn1 $vn2 $vn3\n")
5560
end
5661
end

doc/2dmTransform.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@ Transforming nodes of 2dm-mesh.
1010
./bin/2dmTransform -h
1111
```
1212

13-
usage: 2dmTransform [--transX TRANSX] [--transY TRANSY]
14-
[--transZ TRANSZ] [--scale SCALE] [-h] [mesh-file]
13+
usage: 2dmTransform [-x TRANSX] [-y TRANSY] [-z TRANSZ] [-s SCALE]
14+
[-c COORDS_ORDER] [-h] [mesh-file]
1515

1616
Transform a 2dm-mesh: translation, scaling:
1717

1818
positional arguments:
19-
mesh-file mesh (2dm)-file
19+
mesh-file mesh (2dm)-file
2020

2121
optional arguments:
22-
--transX TRANSX Translation in x (type: FloatingPoint, default:
23-
0.0)
24-
--transY TRANSY Translation in x (type: FloatingPoint, default:
25-
0.0)
26-
--transZ TRANSZ Translation in x (type: FloatingPoint, default:
27-
0.0)
28-
--scale SCALE Scaling factor (type: FloatingPoint, default: 1.0)
29-
-h, --help show this help message and exit
22+
-x, --transX TRANSX Translation in x (type: FloatingPoint,
23+
default: 0.0)
24+
-y, --transY TRANSY Translation in x (type: FloatingPoint,
25+
default: 0.0)
26+
-z, --transZ TRANSZ Translation in x (type: FloatingPoint,
27+
default: 0.0)
28+
-s, --scale SCALE Scaling factor (type: FloatingPoint, default:
29+
1.0)
30+
-c, --coords_order COORDS_ORDER
31+
Coordinate axis order (default: 1:2:3)
32+
-h, --help show this help message and exit
3033

3134
Results are printed to `stdout`. Hence redirection is necassary; eg:
3235

0 commit comments

Comments
 (0)