Revision: 65249
http://sourceforge.net/p/brlcad/code/65249
Author: n_reed
Date: 2015-06-10 18:33:55 +0000 (Wed, 10 Jun 2015)
Log Message:
-----------
sync from trunk
Modified Paths:
--------------
brlcad/branches/brep-debug/src/libicv/crop.c
brlcad/branches/brep-debug/src/util/bwmod.c
Property Changed:
----------------
brlcad/branches/brep-debug/
brlcad/branches/brep-debug/src/libged/polyclip.cpp
Index: brlcad/branches/brep-debug
===================================================================
--- brlcad/branches/brep-debug 2015-06-10 18:10:45 UTC (rev 65248)
+++ brlcad/branches/brep-debug 2015-06-10 18:33:55 UTC (rev 65249)
Property changes on: brlcad/branches/brep-debug
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,4 ##
/brlcad/branches/cmake:43219
/brlcad/branches/gct:62423-62425
/brlcad/branches/osg:62110-62113
-/brlcad/trunk:61364-65244
+/brlcad/trunk:61364-65248
\ No newline at end of property
Index: brlcad/branches/brep-debug/src/libged/polyclip.cpp
===================================================================
--- brlcad/branches/brep-debug/src/libged/polyclip.cpp 2015-06-10 18:10:45 UTC
(rev 65248)
+++ brlcad/branches/brep-debug/src/libged/polyclip.cpp 2015-06-10 18:33:55 UTC
(rev 65249)
Property changes on: brlcad/branches/brep-debug/src/libged/polyclip.cpp
___________________________________________________________________
Modified: svn:mergeinfo
## -1,4 +1,4 ##
/brlcad/branches/bullet/src/libged/polyclip.cpp:62518
/brlcad/branches/gct/src/libged/polyclip.cpp:62423-62425
/brlcad/branches/osg/src/libged/polyclip.cpp:62110-62113
-/brlcad/trunk/src/libged/polyclip.cpp:61364-65244
+/brlcad/trunk/src/libged/polyclip.cpp:61364-65248
\ No newline at end of property
Modified: brlcad/branches/brep-debug/src/libicv/crop.c
===================================================================
--- brlcad/branches/brep-debug/src/libicv/crop.c 2015-06-10 18:10:45 UTC
(rev 65248)
+++ brlcad/branches/brep-debug/src/libicv/crop.c 2015-06-10 18:33:55 UTC
(rev 65249)
@@ -34,21 +34,32 @@
size_t row;
double *p, *in_data, *out_data;
size_t widthstep_in, widthstep_out, bytes_row; /**< */
+ int errorflag;
ICV_IMAGE_VAL_INT(img);
- if (xnum < 1)
- bu_exit(1, "icv_rect : ERROR: Horizontal Cut Size\n");
+ errorflag=0;
+ if (xnum < 1) {
+ fprintf(stderr,"icv_rect : ERROR: Horizontal Cut Size\n");
+ errorflag=1;
+ }
+ if (ynum < 1) {
+ fprintf(stderr,"icv_rect : ERROR: Vertical Cut Size\n");
+ errorflag=1;
+ }
+ if (errorflag) bu_exit(1,NULL);
- if (ynum < 1)
- bu_exit(1, "icv_rect : ERROR: Vertical Cut Size\n");
+ errorflag=0;
+ if (xorig+xnum > img->width) {
+ fprintf(stderr,"icv_rect : Cut not possible; input parameters exceed
the width.\n");
+ errorflag=1;
+ }
+ if (yorig+ynum > img->height) {
+ fprintf(stderr,"icv_rect : Cut not possible; input parameters exceed
the height.\n");
+ errorflag=1;
+ }
+ if (errorflag) bu_exit(1,NULL);
- if (xorig+xnum > img->width)
- bu_exit(1, "icv_rect : Cut not possible; input parameters exceed the
width.\n");
-
- if (yorig+ynum > img->height)
- bu_exit(1, "icv_rect : Cut not possible; input parameters exceed the
height.\n");
-
/* initialization of variables to insure cropping and copying */
widthstep_in = img->width*img->channels;
widthstep_out = xnum*img->channels;
Modified: brlcad/branches/brep-debug/src/util/bwmod.c
===================================================================
--- brlcad/branches/brep-debug/src/util/bwmod.c 2015-06-10 18:10:45 UTC (rev
65248)
+++ brlcad/branches/brep-debug/src/util/bwmod.c 2015-06-10 18:33:55 UTC (rev
65249)
@@ -69,8 +69,8 @@
*/
#define BUFLEN (8192*2) /* usually 2 pages of memory, 16KB */
-int numop = 0; /* number of operations */
-int op[256]; /* operations */
+int numop = 0; /* number of operations */
+int op[256]; /* operations */
double val[256]; /* arguments to operations */
unsigned char ibuf[BUFLEN]; /* input buffer */
@@ -78,26 +78,33 @@
int mapbuf[MAPBUFLEN]; /* translation buffer/lookup table */
int char_arith = 0;
-int
+void
checkpow(double x , double exponent)
{
- if (x > 0.0) return 1;
+ if (x > 0.0) {
+ return;
+ }
+
if (x < 0.0) {
double diff;
diff = exponent - (double)((int)exponent);
- if ( diff < 0.0 || diff > 0.0 ) {
- fprintf(stderr,"bwmod: negative number (%f) to non-integer power
(%f)\n",
- x,exponent);
- bu_exit (-1, NULL);
+ if (diff < 0.0 || diff > 0.0) {
+ fprintf(stderr,
+ "bwmod: negative number (%f) to non-integer power (%f)\n",
+ x, exponent);
+ bu_exit(-1, NULL);
}
- return 1;
}
-/* We have x == 0.0, and we accept that 0 to 0 power is 1. */
- if (exponent >= 0.0) return 1;
- fprintf(stderr,"bwmod: zero to negative power (%f)\n",exponent);
- bu_exit (-1, NULL);
+ /* We have x == 0.0, and we accept that 0 to 0 power is 1. */
+ if (exponent >= 0.0) {
+ return;
+ }
+
+ fprintf(stderr, "bwmod: zero to negative power (%f)\n", exponent);
+ bu_exit(-1, NULL);
}
+
int
get_args(int argc, char **argv)
{
@@ -106,82 +113,87 @@
while ((c = bu_getopt(argc, argv, "a:s:m:d:Ae:r:cS:O:M:X:Rth?")) != -1) {
switch (c) {
- case 'a':
- op[ numop ] = ADD;
- val[ numop++ ] = atof(bu_optarg);
- break;
- case 's':
- op[ numop ] = ADD;
- val[ numop++ ] = - atof(bu_optarg);
- break;
- case 'm':
- op[ numop ] = MULT;
- val[ numop++ ] = atof(bu_optarg);
- break;
- case 'd':
- d = atof(bu_optarg);
- if (ZERO(d)) {
- bu_exit(2, "bwmod: cannot divide by zero!\n");
- }
- op[ numop ] = MULT;
- val[ numop++ ] = 1.0 / d;
- break;
- case 'A':
- op[ numop ] = ABS;
-/* If using ABS, don't care what val[ numop ] is, but still must increment
numop.
- * (The following would increment numop AFTER it's used as "val" subscript.)
- */
-/* val[ numop++ ] = 0.0; */
- numop++;
- break;
- case 'e':
- op[ numop ] = POW;
- val[ numop++ ] = atof(bu_optarg);
- break;
- case 'r':
- d = atof(bu_optarg);
- if (ZERO(d)) {
- bu_exit(2, "bwmod: zero root!\n");
- }
- op[ numop ] = POW;
- val[ numop++ ] = 1.0 / d;
- break;
- case 'c':
- char_arith = !char_arith; break;
- case 'S':
- op[ numop ] = SHIFT;
- val[ numop++] = atof(bu_optarg);
- break;
- case 'M':
- op[ numop ] = AND;
- val[ numop++] = atof(bu_optarg);
- break;
- case 'O':
- op[ numop ] = OR;
- val[ numop++ ] = atof(bu_optarg);
- break;
- case 'X':
- op[ numop ] = XOR;
- val[ numop++ ] = atof(bu_optarg);
- break;
- case 'R':
- op[ numop ] = ROUND;
-/* See above remark for case 'A' (don't care about val[numop] but need
numop++).
- */
-/* val[ numop++ ] = 0.0; */
- numop++;
- case 't': /* Notice that -S truncates, so we internally use -S 0 */
- op[ numop ] = SHIFT;
- val[ numop++ ] = 0.0;
- break;
- default: /* '?' 'h' */
- return 0;
+ case 'a':
+ op[numop] = ADD;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 's':
+ op[numop] = ADD;
+ val[numop++] = - atof(bu_optarg);
+ break;
+ case 'm':
+ op[numop] = MULT;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'd':
+ d = atof(bu_optarg);
+ if (ZERO(d)) {
+ bu_exit(2, "bwmod: cannot divide by zero!\n");
+ }
+ op[numop] = MULT;
+ val[numop++] = 1.0 / d;
+ break;
+ case 'A':
+ op[numop] = ABS;
+ /* If using ABS, don't care what val[numop] is, but still
+ * must increment numop. (The following would increment
+ * numop AFTER it's used as "val" subscript.)
+ */
+ /* val[numop++] = 0.0; */
+ numop++;
+ break;
+ case 'e':
+ op[numop] = POW;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'r':
+ d = atof(bu_optarg);
+ if (ZERO(d)) {
+ bu_exit(2, "bwmod: zero root!\n");
+ }
+ op[numop] = POW;
+ val[numop++] = 1.0 / d;
+ break;
+ case 'c':
+ char_arith = !char_arith;
+ break;
+ case 'S':
+ op[numop] = SHIFT;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'M':
+ op[numop] = AND;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'O':
+ op[numop] = OR;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'X':
+ op[numop] = XOR;
+ val[numop++] = atof(bu_optarg);
+ break;
+ case 'R':
+ op[numop] = ROUND;
+ /* See above remark for case 'A' (don't care about
+ * val[numop] but need numop++).
+ */
+ /* val[numop++] = 0.0; */
+ numop++;
+ case 't':
+ /* Notice that -S truncates, so we internally use -S 0 */
+ op[numop] = SHIFT;
+ val[numop++] = 0.0;
+ break;
+ default: /* '?' 'h' */
+ return 0;
}
}
if (bu_optind >= argc) {
- if (isatty((int)fileno(stdin)))
+ if (isatty((int)fileno(stdin))) {
return 0;
+ }
file_name = hyphen;
} else {
char *ifname;
@@ -197,14 +209,16 @@
bu_free(ifname, "ifname alloc from bu_realpath");
}
- if (argc > ++bu_optind)
+ if (argc > ++bu_optind) {
fprintf(stderr, "bwmod: excess argument(s) ignored\n");
+ }
- return 1; /* OK */
+ return 1; /* OK */
}
-void mk_trans_tbl(void)
+void
+mk_trans_tbl(void)
{
int j, i, tmp, intval;
double d;
@@ -212,44 +226,79 @@
/* create translation map */
for (j = 0; j < MAPBUFLEN; ++j) {
d = j;
- for (i=0; i < numop; i++) {
+ for (i = 0; i < numop; i++) {
switch (op[i]) {
- case ADD : d += val[i]; break;
- case MULT: d *= val[i]; break;
- case POW : checkpow(d,val[i]);
- d = pow(d, val[i]); break;
- case ABS : if (d < 0.0) d = - d; break;
- case SHIFT: tmp=d; intval=(int)val[i];
- if (intval > 0 )
- tmp=tmp << intval;
- else if (intval < 0 )
- tmp=tmp >> (-intval);
- d=tmp;
- break;
- case OR : tmp=d; tmp |= (int)val[i]; d=tmp;break;
- case AND : tmp=d; tmp &= (int)val[i]; d=tmp;break;
- case XOR : tmp=d; tmp ^= (int)val[i]; d=tmp; break;
- /* case TRUNC: tmp=((int)d/(int)val[i])*(int)val[i]; d=tmp; break;
*/
- case ROUND:
- if (d > 0)
- d = (int)(d+0.5);
- else if (d < 0)
- d = (int)(d-0.5);
- break;
- default : fprintf(stderr, "%s: error in op\n", progname);
- bu_exit (-1, NULL);
- break;
+ case ADD :
+ d += val[i];
+ break;
+ case MULT:
+ d *= val[i];
+ break;
+ case POW :
+ checkpow(d, val[i]);
+ d = pow(d, val[i]);
+ break;
+ case ABS :
+ if (d < 0.0) {
+ d = - d;
+ }
+ break;
+ case SHIFT:
+ tmp = d;
+ intval = (int)val[i];
+ if (intval > 0) {
+ tmp = tmp << intval;
+ } else if (intval < 0) {
+ tmp = tmp >> (-intval);
+ }
+ d = tmp;
+ break;
+ case OR :
+ tmp = d;
+ tmp |= (int)val[i];
+ d = tmp;
+ break;
+ case AND :
+ tmp = d;
+ tmp &= (int)val[i];
+ d = tmp;
+ break;
+ case XOR :
+ tmp = d;
+ tmp ^= (int)val[i];
+ d = tmp;
+ break;
+ /* case TRUNC:
+ * tmp=((int)d/(int)val[i])*(int)val[i];
+ * d=tmp;
+ * break;
+ */
+ case ROUND:
+ if (d > 0) {
+ d = (int)(d + 0.5);
+ } else if (d < 0) {
+ d = (int)(d - 0.5);
+ }
+ break;
+ default :
+ fprintf(stderr, "%s: error in op\n", progname);
+ bu_exit(-1, NULL);
+ break;
}
}
if (d > 255.0) {
mapbuf[j] = 256;
} else if (d < 0.0) {
mapbuf[j] = -1;
- } else
+ } else {
mapbuf[j] = d + 0.5;
+ }
}
}
-void mk_char_trans_tbl(void)
+
+
+void
+mk_char_trans_tbl(void)
{
int j, i, intval;
signed char d;
@@ -257,34 +306,58 @@
/* create translation map */
for (j = 0; j < MAPBUFLEN; ++j) {
d = j;
- for (i=0; i < numop; i++) {
+ for (i = 0; i < numop; i++) {
switch (op[i]) {
- case ADD : d += val[i]; break;
- case MULT: d *= val[i]; break;
- case POW : checkpow((double)d,val[i]);
- d = pow((double)d, val[i]); break;
- case ABS : if (d < 0.0) d = - d; break;
- case SHIFT: intval = (int)val[i];
- if (intval > 0 )
- d=d << intval;
- else if (intval < 0 )
- d=d >> (-intval);
- break;
- case AND : d &= (int)val[i]; break;
- case OR : d |= (int)val[i]; break;
- case XOR : d ^= (int)val[i]; break;
- default : fprintf(stderr, "%s: error in op\n", progname);
- bu_exit (-1, NULL);
- /* TRUNC and ROUND do nothing because we already have integer
value */
- /* case TRUNC: */
- case ROUND:
- break;
+ case ADD :
+ d += val[i];
+ break;
+ case MULT:
+ d *= val[i];
+ break;
+ case POW :
+ checkpow((double)d, val[i]);
+ d = pow((double)d, val[i]);
+ break;
+ case ABS :
+ if (d < 0.0) {
+ d = - d;
+ }
+ break;
+ case SHIFT:
+ intval = (int)val[i];
+ if (intval > 0) {
+ d = d << intval;
+ } else if (intval < 0) {
+ d = d >> (-intval);
+ }
+ break;
+ case AND :
+ d &= (int)val[i];
+ break;
+ case OR :
+ d |= (int)val[i];
+ break;
+ case XOR :
+ d ^= (int)val[i];
+ break;
+ default :
+ fprintf(stderr, "%s: error in op\n", progname);
+ bu_exit(-1, NULL);
+ /* TRUNC and ROUND do nothing because we already have
+ * integer value
+ */
+ /* case TRUNC: */
+ case ROUND:
+ break;
}
}
mapbuf[j] = d & 0x0ff;
}
}
-int main(int argc, char **argv)
+
+
+int
+main(int argc, char **argv)
{
unsigned char *p, *q;
int tmp;
@@ -300,22 +373,25 @@
if (!get_args(argc, argv) || isatty((int)fileno(stdin))
|| isatty((int)fileno(stdout))) {
(void)fputs(usage, stderr);
- bu_exit (1, NULL);
+ bu_exit(1, NULL);
}
- if (char_arith)
+ if (char_arith) {
mk_char_trans_tbl();
- else
+ } else {
mk_trans_tbl();
+ }
- while ((n=read(0, (void *)ibuf, (unsigned)sizeof(ibuf))) > 0) {
+ while ((n = read(0, (void *)ibuf, (unsigned)sizeof(ibuf))) > 0) {
/* translate */
for (p = ibuf, q = &ibuf[n]; p < q; ++p) {
long i = *p;
- if (i < 0)
+ if (i < 0) {
i = 0;
- if (i >= MAPBUFLEN)
+ }
+ if (i >= MAPBUFLEN) {
*p = i = MAPBUFLEN;
+ }
tmp = mapbuf[i];
if (tmp > 255) {
@@ -332,7 +408,7 @@
if (write(1, (void *)ibuf, (unsigned)n) != n) {
fprintf(stderr, "%s: Error writing stdout\n",
progname);
- bu_exit (-1, NULL);
+ bu_exit(-1, NULL);
}
}
if (n < 0) {
@@ -340,12 +416,12 @@
}
if (clip_high != 0 || clip_low != 0) {
- fprintf(stderr, "bwmod: clipped %lu high, %lu low\n", (long
unsigned)clip_high, (long unsigned)clip_low);
+ fprintf(stderr, "bwmod: clipped %lu high, %lu low\n",
+ (long unsigned)clip_high, (long unsigned)clip_low);
}
return 0;
}
-
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits