about summary refs log tree commit diff
path: root/generator
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-11-11 03:26:45 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-11-11 03:26:45 +0000
commitf9f10df590ec8d05ff5ce4afc5ff5e110ccb761b (patch)
treed8b1603c186d0dc2507fe32075fca33d64b3e15e /generator
parent6162deed3cdafeaa962d9e7f27ade37f380c0795 (diff)
downloadnetpbm-mirror-f9f10df590ec8d05ff5ce4afc5ff5e110ccb761b.tar.gz
netpbm-mirror-f9f10df590ec8d05ff5ce4afc5ff5e110ccb761b.tar.xz
netpbm-mirror-f9f10df590ec8d05ff5ce4afc5ff5e110ccb761b.zip
Add -offset option for use with -test
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2306 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator')
-rw-r--r--generator/pamcrater.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/generator/pamcrater.c b/generator/pamcrater.c
index d61ce548..3a5afd8f 100644
--- a/generator/pamcrater.c
+++ b/generator/pamcrater.c
@@ -64,6 +64,7 @@ struct CmdlineInfo {
     unsigned int randomseed;
     unsigned int test;
     unsigned int radius;
+    int          offset;
 };
 
 
@@ -81,7 +82,7 @@ parseCommandLine(int argc, const char ** const argv,
     optStruct3 opt;
     unsigned int option_def_index;
 
-    unsigned int numberSpec, heightSpec, widthSpec, radiusSpec;
+    unsigned int numberSpec, heightSpec, widthSpec, radiusSpec, offsetSpec;
 
     MALLOCARRAY_NOFAIL(option_def, 100);
 
@@ -98,6 +99,8 @@ parseCommandLine(int argc, const char ** const argv,
             &cmdlineP->test,       0);
     OPTENT3(0,   "radius",     OPT_UINT,    &cmdlineP->radius,
             &radiusSpec,           0);
+    OPTENT3(0,   "offset",     OPT_INT,     &cmdlineP->offset,
+            &offsetSpec,           0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -122,6 +125,9 @@ parseCommandLine(int argc, const char ** const argv,
     if (cmdlineP->width == 0)
         pm_error("-width must be positive");
 
+    if (!offsetSpec)
+        cmdlineP->offset=0;
+
     if (cmdlineP->test) {
         if (!radiusSpec)
             pm_error("With -test, you must specify -radius");
@@ -139,6 +145,9 @@ parseCommandLine(int argc, const char ** const argv,
         if (radiusSpec)
             pm_error("-radius is meaningful only with -test");
 
+        if (offsetSpec)
+            pm_error("-offset is meaningful only with -test");
+
         if (!numberSpec)
             cmdlineP->number = 50000;
 
@@ -373,7 +382,9 @@ genCraters(struct CmdlineInfo const cmdline) {
     
     if (cmdline.test)
         plopCrater(&pam, terrain,
-                   pam.width/2, pam.height/2, (double) cmdline.radius);
+                   pam.width/2 + cmdline.offset,
+                   pam.height/2 + cmdline.offset,
+                   (double) cmdline.radius);
     else {
         unsigned int const ncraters = cmdline.number; /* num of craters */
         unsigned int l;