aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-03-13 15:54:06 +0100
committerThomas White <taw@physics.org>2019-03-13 15:54:06 +0100
commit611eb719079c150a5e8db8196c21a2a08b0c6d6a (patch)
treeb1218ae1f1d3e7fff08876fbb78c2b9b9dbbfcb2 /src
parent4d6b5ac83e0bd4929661dfb2c5580da7a2aa4a63 (diff)
cell_tool --transform: Write output cell
Diffstat (limited to 'src')
-rw-r--r--src/cell_tool.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/cell_tool.c b/src/cell_tool.c
index 5e11eddb..95d5d3bc 100644
--- a/src/cell_tool.c
+++ b/src/cell_tool.c
@@ -335,7 +335,8 @@ static int uncenter(UnitCell *cell, const char *out_file)
}
-static int transform(UnitCell *cell, const char *trans_str)
+static int transform(UnitCell *cell, const char *trans_str,
+ const char *out_file)
{
RationalMatrix *trans;
UnitCell *nc;
@@ -358,6 +359,16 @@ static int transform(UnitCell *cell, const char *trans_str)
"it's just that I don't (yet) know how to work out what "
"it is.\n");
+ if ( out_file != NULL ) {
+ FILE *fh = fopen(out_file, "w");
+ if ( fh == NULL ) {
+ ERROR("Failed to open '%s'\n", out_file);
+ return 1;
+ }
+ write_cell(nc, fh);
+ fclose(fh);
+ }
+
return 0;
}
@@ -370,8 +381,8 @@ static int cell_choices(UnitCell *cell)
}
if ( cell_get_unique_axis(cell) == 'b' ) {
- transform(cell, "-a-c,b,a");
- transform(cell, "c,b,-a-c");
+ transform(cell, "-a-c,b,a", NULL);
+ transform(cell, "c,b,-a-c", NULL);
} else {
ERROR("Sorry, --cell-choices only supports unique axis b.\n");
return 1;
@@ -552,7 +563,7 @@ int main(int argc, char *argv[])
if ( mode == CT_UNCENTER ) return uncenter(cell, out_file);
if ( mode == CT_RINGS ) return all_rings(cell, sym, rmax);
if ( mode == CT_COMPARE ) return comparecells(cell, comparecell, ltl, atl);
- if ( mode == CT_TRANSFORM ) return transform(cell, trans_str);
+ if ( mode == CT_TRANSFORM ) return transform(cell, trans_str, out_file);
if ( mode == CT_CHOICES ) return cell_choices(cell);
return 1;