Revision: 41401
http://brlcad.svn.sourceforge.net/brlcad/?rev=41401&view=rev
Author: brlcad
Date: 2010-11-17 23:10:22 +0000 (Wed, 17 Nov 2010)
Log Message:
-----------
woot woot, this makes all of the fb tools compile strict on Mac. cleaned up
all warnings, style, indent, ws, etc.
Modified Paths:
--------------
brlcad/trunk/src/fb/polar-fb.c
brlcad/trunk/src/fb/rle-fb.c
brlcad/trunk/src/fb/spm-fb.c
Modified: brlcad/trunk/src/fb/polar-fb.c
===================================================================
--- brlcad/trunk/src/fb/polar-fb.c 2010-11-17 22:58:02 UTC (rev 41400)
+++ brlcad/trunk/src/fb/polar-fb.c 2010-11-17 23:10:22 UTC (rev 41401)
@@ -20,11 +20,8 @@
*/
/** @file polar-fb.c
*
- * This routine plots normalized polar functions on a frame buffer.
+ * This routine plots normalized polar functions on a frame buffer.
*
- * Author -
- * Paul J. Tanenbaum
- *
*/
#include "common.h"
@@ -35,53 +32,45 @@
#include "bu.h"
#include "fb.h"
+#include "vmath.h"
/* Program constants */
-#define High_Size 1024
-#define GRID_RHO_EPS 0.005
-#define GRID_THETA_EPS 0.2
+#define High_Size 1024
+#define GRID_RHO_EPS 0.005
+#define GRID_THETA_EPS 0.2
/* Color[] indices */
-#define C_BKGRND 0
-#define C_PERIM 1
-#define C_RAMP 2
-#define C_INTERIOR 2
-#define C_BLACK 3
-#define C_WHITE 4
-#define C_RED 5
-#define C_ORANGE 6
-#define C_YELLOW 7
-#define C_GREEN 8
-#define C_BLUE 9
+#define C_BKGRND 0
+#define C_PERIM 1
+#define C_RAMP 2
+#define C_INTERIOR 2
+#define C_BLACK 3
+#define C_WHITE 4
+#define C_RED 5
+#define C_ORANGE 6
+#define C_YELLOW 7
+#define C_GREEN 8
+#define C_BLUE 9
/* Interior filling codes */
-#define BI_EMPTY 0
-#define BI_CONSTANT 1
-#define BI_RINGS 2
-#define BI_WEDGES 3
-#define BI_RAMP 4
+#define BI_EMPTY 0
+#define BI_CONSTANT 1
+#define BI_RINGS 2
+#define BI_WEDGES 3
+#define BI_RAMP 4
/* Half codes */
-#define H_LEFT 1
-#define H_RIGHT -1
+#define H_LEFT 1
+#define H_RIGHT -1
/* Macros */
-#define npf_index(a) ((int) ((a) / Quantum + 0.5))
+#define npf_index(a) ((int) ((a) / Quantum + 0.5))
-#ifndef bool
-#define bool int
-#endif
-#ifndef TRUE
-#define TRUE (1)
-#endif
-#ifndef FALSE
-#define FALSE (0)
-#endif
/* Global variables */
-char *ProgName; /* To save argv[0] */
-char *ExplainOpts[] = {
+char *ProgName; /* To save argv[0] */
+char *ExplainOpts[] = {
" -F fbfile specifies frame-buffer file\n",
" -N h specifies FB height (pixels)\n",
" -S s specifies FB height and width (pixels)\n",
@@ -106,8 +95,8 @@
" -z side plots only one half of function ('l' or 'r')\n",
""
};
-double Deg2Rad; /* Factor to convert degrees to radians */
-RGBpixel Color[] = {
+double Deg2Rad; /* Factor to convert degrees to radians */
+RGBpixel Color[] = {
{ 255, 255, 255 }, /* Background */
{ 0, 0, 0 }, /* Perimeter */
{ 0, 0, 0 }, /* Interior or ramp top */
@@ -121,7 +110,7 @@
};
-bool
+int
LoadNPF (char *FileName, double *Table, int Quantum, double convert, double
arc_min, double arc_max)
/* Name of input file */
@@ -132,14 +121,14 @@
/* Last " " " */
{
- bool Warnings = 0; /* Have any warning messages been printed? */
- int angle;
- int gap_min; /* Used in composing warnings */
- int gap_max; /* " " " " */
- double theta, rho;
- FILE *fPtr;
+ int Warnings = 0; /* Have any warning messages been printed? */
+ int angle;
+ int gap_min; /* Used in composing warnings */
+ int gap_max; /* " " " " */
+ double theta, rho;
+ FILE *fPtr;
- /* N.B. - The possible values of Warnings and their meanings are:
+ /* N.B. - The possible values of Warnings and their meanings are:
*
* Value Meaning
* ------------------------------------------------------
@@ -151,8 +140,7 @@
/* Open the file, if necessary */
if (*FileName == '\0')
fPtr = stdin;
- else if ((fPtr = fopen(FileName, "rb")) == NULL)
- {
+ else if ((fPtr = fopen(FileName, "rb")) == NULL) {
(void) fprintf(stderr, "%s: Cannot open input file '%s'\n",
ProgName, FileName);
(void) bu_exit (1, NULL);
@@ -167,15 +155,13 @@
(fscanf(fPtr, "%lf", &rho) == 1))
{
theta *= convert;
- if ((theta < 0.0) || (npf_index(theta / Deg2Rad) * Quantum > 360))
- {
+ if ((theta < 0.0) || (npf_index(theta / Deg2Rad) * Quantum > 360)) {
(void) fprintf(stderr,
"Fatal: Theta out of range: %g %s\n",
- theta / convert, (convert == 1.0) ? "radians" :
"degrees");
+ theta / convert, (NEAR_ZERO(convert - 1.0,
SMALL_FASTF)) ? "radians" : "degrees");
Warnings = 2;
}
- if ((rho < 0.0) || (rho > 1.0))
- {
+ if ((rho < 0.0) || (rho > 1.0)) {
(void) fprintf(stderr, "Fatal: Rho out of range: %g\n", rho);
Warnings = 2;
}
@@ -188,19 +174,16 @@
/* Check the table for completeness */
gap_min = gap_max = -1;
- for (angle = floor(arc_min); angle < ceil(arc_max); angle+=Quantum)
- {
- if (*(Table + npf_index(angle)) == -1.0)
- {
+ for (angle = floor(arc_min); angle < ceil(arc_max); angle+=Quantum) {
+ /* if == -1 */
+ if (NEAR_ZERO(*(Table + npf_index(angle)) + 1.0, SMALL_FASTF)) {
*(Table + npf_index(angle)) = 0.0;
if (gap_min == -1)
gap_min = angle;
gap_max = angle;
Warnings = 1;
- } else
- {
- if (gap_min > -1)
- {
+ } else {
+ if (gap_min > -1) {
(void) fprintf(stderr, "Warning: No entry in input for ");
if (gap_max > gap_min)
(void) fprintf(stderr, "%d <= theta <= %d degrees\n",
@@ -212,8 +195,7 @@
}
}
- if (gap_min > -1)
- {
+ if (gap_min > -1) {
(void) fprintf(stderr, "Warning: No entry in input for ");
if (gap_max > gap_min)
(void) fprintf(stderr, "%d <= theta <= %d degrees\n",
@@ -231,15 +213,14 @@
int
OnGrid (double theta, double rho)
{
- int t;
- double squeeze; /* factor to squeeze the radii */
+ int t;
+ double squeeze; /* factor to squeeze the radii */
theta /= Deg2Rad;
squeeze = 1.0 / rho * GRID_THETA_EPS;
/* Determine whether the point is on a radius */
- for (t = 0; t < 360; t += 30)
- {
+ for (t = 0; t < 360; t += 30) {
if (fabs(theta - t) < squeeze)
return 1;
}
@@ -259,8 +240,7 @@
void
ArgCompat (int Interior)
{
- if (Interior != BI_RINGS)
- {
+ if (Interior != BI_RINGS) {
(void) fputs("Only one of -e, -i, -l, and -w may be specified\n",
stderr);
(void) bu_exit (1, NULL);
@@ -269,7 +249,7 @@
void
-Fill_Empty (unsigned char *fbbPtr, double rho, double npf_rho, int unit_r, int
merge)
+Fill_Empty (unsigned char *fbbPtr, double UNUSED(rho), double UNUSED(npf_rho),
int UNUSED(unit_r), int merge)
/* Pointer to within fbb */
/* Radius of current pixel */
@@ -281,10 +261,10 @@
if (! merge) {
COPYRGB(fbbPtr, Color[C_BKGRND]);
}
- }
+}
void
-Fill_Constant (unsigned char *fbbPtr, double rho, double npf_rho, int unit_r,
int merge)
+Fill_Constant (unsigned char *fbbPtr, double UNUSED(rho), double
UNUSED(npf_rho), int UNUSED(unit_r), int UNUSED(merge))
/* Pointer to within fbb */
/* Radius of current pixel */
@@ -294,10 +274,10 @@
{
COPYRGB(fbbPtr, Color[C_INTERIOR]);
- }
+}
void
-Fill_Ramp (unsigned char *fbbPtr, double rho, double npf_rho, int unit_r, int
merge)
+Fill_Ramp (unsigned char *fbbPtr, double rho, double UNUSED(npf_rho), int
unit_r, int UNUSED(merge))
/* Pointer to within fbb */
/* Radius of current pixel */
@@ -306,7 +286,7 @@
/* Overlay onto current FB contents? */
{
- RGBpixel ThisPix; /* Ramped color for current pixel */
+ RGBpixel ThisPix; /* Ramped color for current pixel */
ThisPix[RED] = ((double)Color[C_RAMP][RED]) * rho / unit_r +
255 * (1 - rho / unit_r);
@@ -315,10 +295,10 @@
ThisPix[BLU] = ((double)Color[C_RAMP][BLU]) * rho / unit_r +
255 * (1 - rho / unit_r);
COPYRGB(fbbPtr, ThisPix);
- }
+}
void
-Fill_Wedges (unsigned char *fbbPtr, double rho, double npf_rho, int unit_r,
int merge)
+Fill_Wedges (unsigned char *fbbPtr, double UNUSED(rho), double npf_rho, int
UNUSED(unit_r), int UNUSED(merge))
/* Pointer to within fbb */
/* Radius of current pixel */
@@ -327,20 +307,22 @@
/* Overlay onto current FB contents? */
{
- if (npf_rho > .8)
+ if (npf_rho > .8) {
COPYRGB(fbbPtr, Color[C_RED]);
- else if (npf_rho > .6)
+ } else if (npf_rho > .6) {
COPYRGB(fbbPtr, Color[C_ORANGE]);
- else if (npf_rho > .4)
+ } else if (npf_rho > .4) {
COPYRGB(fbbPtr, Color[C_YELLOW]);
- else if (npf_rho > .2)
+ } else if (npf_rho > .2) {
COPYRGB(fbbPtr, Color[C_GREEN]);
- else
+ } else {
COPYRGB(fbbPtr, Color[C_BLUE]);
+ }
}
+
void
-Fill_Rings (unsigned char *fbbPtr, double rho, double npf_rho, int unit_r, int
merge)
+Fill_Rings (unsigned char *fbbPtr, double rho, double UNUSED(npf_rho), int
unit_r, int UNUSED(merge))
/* Pointer to within fbb */
/* Radius of current pixel */
@@ -349,27 +331,27 @@
/* Overlay onto current FB contents? */
{
- if (rho / unit_r > .8)
+ if (rho / unit_r > .8) {
COPYRGB(fbbPtr, Color[C_RED]);
- else if (rho / unit_r > .6)
+ } else if (rho / unit_r > .6) {
COPYRGB(fbbPtr, Color[C_ORANGE]);
- else if (rho / unit_r > .4)
+ } else if (rho / unit_r > .4) {
COPYRGB(fbbPtr, Color[C_YELLOW]);
- else if (rho / unit_r > .2)
+ } else if (rho / unit_r > .2) {
COPYRGB(fbbPtr, Color[C_GREEN]);
- else
+ } else {
COPYRGB(fbbPtr, Color[C_BLUE]);
+ }
}
void
PrintUsage (int ShoOpts)
{
- char **oPtr; /* Pointer to option string */
+ char **oPtr; /* Pointer to option string */
(void) fprintf(stderr, "Usage: '%s [options] [file]'\n", ProgName);
- if (ShoOpts)
- {
+ if (ShoOpts) {
(void) fputs("Options:\n", stderr);
for (oPtr = ExplainOpts; **oPtr != '\0'; oPtr++)
(void) fputs(*oPtr, stderr);
@@ -381,41 +363,41 @@
int
main (int argc, char **argv)
{
- bool clr_fb = FALSE; /* Clear the frame buffer first? */
- bool draw_grid = TRUE; /* Plot the plolar axes? */
- bool merge = FALSE; /* Overlay data on current contents FB? */
- bool NoWarnings = FALSE; /* Abort if any irregular input? */
- bool perimeter = FALSE; /* Plot perimeter of function? */
- char *FB_Name; /* Name of frame-buffer file */
- char *FileName; /* Name of input file */
- char *Opt; /* Used in parsing command-line options */
- double angle_cvt; /* Factor to convert input units to radians */
- double arc_max = 360.0;/* Greatest value of theta to plot */
- double arc_min = 0.0; /* Least " " " " " */
- double npf_rho; /* Current entry in npf_tbl */
- double npf_tbl[360]; /* The function (in (theta, rho) pairs) */
- double rho, theta; /* Polar coordinates of current pixel */
- double twist = 0.0; /* Clockwise rotation of image (in degrees) */
- int ctr_x = -1; /* X-coord of plot center (in pixels) */
- int ctr_y = -1; /* Y- " " " " " */
- int fb_x_loc; /* X-coord of lower-left of plot (in
pixels) */
- int fb_y_loc; /* Y- " " " " " " "
" */
- int Half = 0; /* Plot only half of the function (L or
R) */
- int intensity; /* RGBpixel component read from command
line */
- int Interior; /* Manner of filling graph */
- int LineLength; /* Width of the plot (in pixels) */
- int Quantum = 1; /* Angular resolution of npf_tbl */
- int fb_width = 0; /* Width (in pixels) */
- int fb_height = 0; /* Height (in pixels) */
- int theta_index; /* Theta's index into npf_tbl */
- int unit_r = -1; /* Radius of unit circle (in pixels) */
- int x, y; /* Cartesian coordinates of current
pixel */
- int X, Y; /* Translated pixel */
- FBIO *fbPtr; /* Pointer to the frame-buffer file */
+ int clr_fb = 0; /* Clear the frame buffer first? */
+ int draw_grid = 1; /* Plot the plolar axes? */
+ int merge = 0; /* Overlay data on current contents FB? */
+ int NoWarnings = 0; /* Abort if any irregular input? */
+ int perimeter = 0; /* Plot perimeter of function? */
+ char *FB_Name; /* Name of frame-buffer file */
+ char *FileName; /* Name of input file */
+ char *Opt; /* Used in parsing command-line options */
+ double angle_cvt; /* Factor to convert input units to radians */
+ double arc_max = 360.0;/* Greatest value of theta to plot */
+ double arc_min = 0.0; /* Least " " " " " */
+ double npf_rho; /* Current entry in npf_tbl */
+ double npf_tbl[360]; /* The function (in (theta, rho) pairs) */
+ double rho, theta; /* Polar coordinates of current pixel */
+ double twist = 0.0; /* Clockwise rotation of image (in degrees) */
+ int ctr_x = -1; /* X-coord of plot center (in pixels) */
+ int ctr_y = -1; /* Y- " " " " " */
+ int fb_x_loc; /* X-coord of lower-left of plot (in pixels) */
+ int fb_y_loc; /* Y- " " " " " " " " */
+ int Half = 0; /* Plot only half of the function (L or R) */
+ int intensity; /* RGBpixel component read from command line */
+ int Interior; /* Manner of filling graph */
+ int LineLength; /* Width of the plot (in pixels) */
+ int Quantum = 1; /* Angular resolution of npf_tbl */
+ int fb_width = 0; /* Width (in pixels) */
+ int fb_height = 0; /* Height (in pixels) */
+ int theta_index; /* Theta's index into npf_tbl */
+ int unit_r = -1; /* Radius of unit circle (in pixels) */
+ int x, y; /* Cartesian coordinates of current pixel */
+ int Xprime, Yprime; /* Translated pixel */
+ FBIO *fbPtr; /* Pointer to the frame-buffer file */
unsigned char *fbb; /* Buffer for current line of frame
buffer */
unsigned char *fbbPtr; /* Pointer to within fbb */
- void (*Fill_Func)();
+ void (*Fill_Func)();
/* Initialize things */
ProgName = *argv;
@@ -427,22 +409,18 @@
/* Handle command-line options */
while ((--argc > 0) && ((*++argv)[0] == '-'))
for (Opt = argv[0] + 1; *Opt != '\0'; Opt++)
- switch (*Opt)
- {
+ switch (*Opt) {
case 'o': /* Translate the plot */
- if (argc < 3)
- {
+ if (argc < 3) {
(void) fputs("Illegal -o option\n", stderr);
goto error;
}
- if ((sscanf(argv[1], "%d", &ctr_x) != 1) || (ctr_x < 0))
- {
+ if ((sscanf(argv[1], "%d", &ctr_x) != 1) || (ctr_x < 0)) {
(void) fprintf(stderr, "Illegal -o value: %s\n",
argv[1]);
goto error;
}
- if ((sscanf(argv[2], "%d", &ctr_y) != 1) || (ctr_y < 0))
- {
+ if ((sscanf(argv[2], "%d", &ctr_y) != 1) || (ctr_y < 0)) {
(void) fprintf(stderr, "Illegal -o value: %s\n",
argv[2]);
goto error;
@@ -451,14 +429,12 @@
argc -= 2;
break;
case 'W': /* Scale the plot */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -W option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &fb_width) != 1)
- || (fb_width < 0))
- {
+ || (fb_width < 0)) {
(void) fprintf(stderr, "Illegal -W value: %s\n",
argv[1]);
goto error;
@@ -467,14 +443,12 @@
argc--;
break;
case 'N': /* Scale the plot */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -N option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &fb_height) != 1)
- || (fb_height < 0))
- {
+ || (fb_height < 0)) {
(void) fprintf(stderr, "Illegal -N value: %s\n",
argv[1]);
goto error;
@@ -483,14 +457,12 @@
argc--;
break;
case 'S': /* Scale the plot */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -S option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &fb_height) != 1)
- || (fb_height < 0))
- {
+ || (fb_height < 0)) {
(void) fprintf(stderr, "Illegal -S value: %s\n",
argv[1]);
goto error;
@@ -500,13 +472,11 @@
argc--;
break;
case 's': /* Scale the plot */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -s option\n", stderr);
goto error;
}
- if ((sscanf(argv[1], "%d", &unit_r) != 1) || (unit_r <= 0))
- {
+ if ((sscanf(argv[1], "%d", &unit_r) != 1) || (unit_r <= 0))
{
(void) fprintf(stderr, "Illegal -s value: %s\n",
argv[1]);
goto error;
@@ -515,14 +485,12 @@
argc--;
break;
case 'q': /* Angular resolution of npf_tbl */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -q option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &Quantum) != 1) ||
- (Quantum <= 0))
- {
+ (Quantum <= 0)) {
(void) fprintf(stderr, "Illegal -q value: %s\n",
argv[1]);
goto error;
@@ -531,26 +499,22 @@
argc--;
break;
case 'a': /* Display an arc of the function */
- if (argc < 3)
- {
+ if (argc < 3) {
(void) fputs("Illegal -a option\n", stderr);
goto error;
}
- if ((sscanf(argv[1], "%lf", &arc_min) != 1) || (arc_min <
0))
- {
+ if ((sscanf(argv[1], "%lf", &arc_min) != 1) || (arc_min <
0)) {
(void) fprintf(stderr, "Illegal -a value: %s\n",
argv[1]);
goto error;
}
if ((sscanf(argv[2], "%lf", &arc_max) != 1) ||
- (arc_max > 360))
- {
+ (arc_max > 360)) {
(void) fprintf(stderr, "Illegal -a value: %s\n",
argv[2]);
goto error;
}
- if (arc_max < arc_min)
- {
+ if (arc_max < arc_min) {
(void) fprintf(stderr, "Illegal -a values: %g > %g\n",
arc_min, arc_max);
goto error;
@@ -559,13 +523,11 @@
argc -= 2;
break;
case 't': /* Rotate the function */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -t option\n", stderr);
goto error;
}
- if (sscanf(argv[1], "%lf", &twist) != 1)
- {
+ if (sscanf(argv[1], "%lf", &twist) != 1) {
(void) fprintf(stderr, "Illegal -t value: %s\n",
argv[1]);
goto error;
@@ -575,14 +537,12 @@
argc--;
break;
case 'z': /* Plot only half of the function */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -z option\n", stderr);
goto error;
}
if ((argv[1][0] != 'l' && argv[1][0] != 'r') ||
- argv[1][1] != '\0')
- {
+ argv[1][1] != '\0') {
(void) fprintf(stderr, "Illegal -z value: %s\n",
argv[1]);
goto error;
@@ -592,30 +552,26 @@
argc--;
break;
case 'b': /* Specify the background color */
- if (argc < 4)
- {
+ if (argc < 4) {
(void) fputs("Illegal -b option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -b value: %s\n",
argv[1]);
goto error;
}
Color[C_BKGRND][RED] = intensity;
if ((sscanf(argv[2], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -b value: %s\n",
argv[2]);
goto error;
}
Color[C_BKGRND][GRN] = intensity;
if ((sscanf(argv[3], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -b value: %s\n",
argv[3]);
goto error;
@@ -627,30 +583,26 @@
case 'i': /* Plot with one interior color */
ArgCompat(Interior);
Interior = BI_CONSTANT;
- if (argc < 4)
- {
+ if (argc < 4) {
(void) fputs("Illegal -i option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -i value: %s\n",
argv[1]);
goto error;
}
Color[C_INTERIOR][RED] = intensity;
if ((sscanf(argv[2], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -i value: %s\n",
argv[2]);
goto error;
}
Color[C_INTERIOR][GRN] = intensity;
if ((sscanf(argv[3], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -i value: %s\n",
argv[3]);
goto error;
@@ -662,30 +614,26 @@
case 'l': /* Plot using a linear ramp */
ArgCompat(Interior);
Interior = BI_RAMP;
- if (argc < 4)
- {
+ if (argc < 4) {
(void) fputs("Illegal -l option\n", stderr);
goto error;
}
if ((sscanf(argv[1], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -l value: %s\n",
argv[1]);
goto error;
}
Color[C_RAMP][RED] = intensity;
if ((sscanf(argv[2], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -l value: %s\n",
argv[2]);
goto error;
}
Color[C_RAMP][GRN] = intensity;
if ((sscanf(argv[3], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -l value: %s\n",
argv[3]);
goto error;
@@ -695,34 +643,30 @@
argc -= 3;
break;
case 'm': /* Merge data with contents of FB */
- merge = TRUE;
+ merge = 1;
break;
case 'p': /* Plot the perimeter */
- perimeter = TRUE;
- if (argc < 4)
- {
+ perimeter = 1;
+ if (argc < 4) {
(void) fprintf(stderr, "Illegal -%c option\n", *Opt);
goto error;
}
if ((sscanf(argv[1], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -%c value: %s\n",
*Opt, argv[1]);
goto error;
}
Color[C_PERIM][RED] = intensity;
if ((sscanf(argv[2], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -%c value: %s\n",
*Opt, argv[2]);
goto error;
}
Color[C_PERIM][GRN] = intensity;
if ((sscanf(argv[3], "%d", &intensity) != 1) ||
- (intensity < 0) || (intensity > 255))
- {
+ (intensity < 0) || (intensity > 255)) {
(void) fprintf(stderr, "Illegal -%c value: %s\n",
*Opt, argv[3]);
goto error;
@@ -732,8 +676,7 @@
argc -= 3;
break;
case 'F': /* Name of frame-buffer file */
- if (argc < 2)
- {
+ if (argc < 2) {
(void) fputs("Illegal -F option\n", stderr);
goto error;
}
@@ -742,14 +685,14 @@
argc--;
break;
case 'c': /* Clear the FB initially */
- clr_fb = TRUE;
+ clr_fb = 1;
break;
case 'e': /* Plot empty interior */
ArgCompat(Interior);
Interior = BI_EMPTY;
break;
case 'g': /* Do not plot axes */
- draw_grid = FALSE;
+ draw_grid = 0;
break;
case 'h': /* High-res mode */
fb_width = fb_height = High_Size;
@@ -758,7 +701,7 @@
angle_cvt = 1.0;
break;
case 'n': /* Abort if any irregular input */
- NoWarnings = TRUE;
+ NoWarnings = 1;
break;
case 'w': /* Plot radius-colored wedges */
ArgCompat(Interior);
@@ -772,8 +715,7 @@
}
/* Determine source of input */
- switch (argc)
- {
+ switch (argc) {
case 0: /* Read stdin */
FileName="";
break;
@@ -838,8 +780,7 @@
fb_y_loc = ctr_y - unit_r;
/* Decide which Interior-filling routine to use */
- switch (Interior)
- {
+ switch (Interior) {
case BI_EMPTY:
Fill_Func = Fill_Empty;
break;
@@ -862,40 +803,36 @@
break;
}
- if ((fbb = (unsigned char *) malloc(fb_width * sizeof(RGBpixel))) == NULL)
- {
+ if ((fbb = (unsigned char *) malloc(fb_width * sizeof(RGBpixel))) == NULL)
{
(void) fputs("Ran out of memory\n", stderr);
(void) bu_exit (1, NULL);
}
/* Fill fbb */
- for (y = 0; y < 2 * unit_r; y++)
- {
+ for (y = 0; y < 2 * unit_r; y++) {
if (merge)
fb_read(fbPtr, fb_x_loc, fb_y_loc + y, fbb, LineLength);
- Y = y - unit_r;
- for (x = 0, fbbPtr = fbb; x < LineLength; x++,
fbbPtr+=sizeof(RGBpixel))
- {
- X = x + fb_x_loc - ctr_x;
+ Yprime = y - unit_r;
+ for (x = 0, fbbPtr = fbb; x < LineLength; x++,
fbbPtr+=sizeof(RGBpixel)) {
+ Xprime = x + fb_x_loc - ctr_x;
/* If this point is beyond the unit circle, then skip it */
- if ((rho = sqrt((double) (X * X) + (double) (Y * Y))) > unit_r)
- {
+ if ((rho = sqrt((double) (Xprime * Xprime) + (double) (Yprime *
Yprime))) > unit_r) {
if (! merge) {
COPYRGB(fbbPtr, Color[C_BKGRND]);
}
- continue;
+ continue;
}
/* Determine this point's "azimuth" (i.e., theta) */
- if (X == 0)
- theta = (Y > 0) ? M_PI : 0.0;
+ if (Xprime == 0)
+ theta = (Yprime > 0) ? M_PI : 0.0;
else
- theta = atan2((double) Y, (double) X) + M_PI_2;
+ theta = atan2((double) Yprime, (double) Xprime) + M_PI_2;
/* If this point is in the wrong half of the plot, skip it */
- if (Half && (Half * X > 0))
+ if (Half && (Half * Xprime > 0))
continue;
/* Rotate the point for display */
@@ -906,12 +843,11 @@
theta -= M_PI * 2;
/* If this point is outside the arc of interest, skip it */
- if ((theta < arc_min) || (theta > arc_max))
- {
+ if ((theta < arc_min) || (theta > arc_max)) {
if (! merge) {
COPYRGB(fbbPtr, Color[C_BKGRND]);
}
- continue;
+ continue;
}
/* Look up the value of the function for this value of theta */
@@ -923,25 +859,22 @@
*/
/* If this point is outside the function, color it BKGRND */
- if (rho > npf_rho * unit_r)
- {
+ if (rho > npf_rho * unit_r) {
if (! merge) {
COPYRGB(fbbPtr, Color[C_BKGRND]);
}
- }
- else
- {
+ } else {
(*Fill_Func)(fbbPtr, rho, npf_rho, unit_r, merge);
if (perimeter && (npf_rho - rho / unit_r < .02)) {
COPYRGB(fbbPtr, Color[C_PERIM]);
}
- }
+ }
if (draw_grid && OnGrid(theta, rho/unit_r)) {
COPYRGB(fbbPtr, Color[C_BLACK]);
}
- }
+ }
fb_write(fbPtr, fb_x_loc, fb_y_loc + y, fbb, LineLength);
}
Modified: brlcad/trunk/src/fb/rle-fb.c
===================================================================
--- brlcad/trunk/src/fb/rle-fb.c 2010-11-17 22:58:02 UTC (rev 41400)
+++ brlcad/trunk/src/fb/rle-fb.c 2010-11-17 23:10:22 UTC (rev 41401)
@@ -20,8 +20,8 @@
*/
/** @file rle-fb.c
*
- * Decode a Utah Raster Toolkit RLE image, and display on a
- * BRL libfb(3) framebuffer.
+ * Decode a Utah Raster Toolkit RLE image, and display on a
+ * BRL libfb(3) framebuffer.
*
*/
@@ -32,50 +32,47 @@
#include "bu.h"
#include "fb.h"
-
-/*
- * system installed RLE reports a re-define, so undef it to quell the
- * warning
- */
#include "rle.h"
-static FILE *infp;
-static char *infile;
-static int background[3];
-static int override_background;
+static FILE *infp;
+static char *infile;
-unsigned char *rows[4]; /* Character pointers for rle_getrow */
+static int background[3];
+static int override_background;
-static unsigned char *scan_buf; /* single scanline buffer */
-static ColorMap cmap;
+unsigned char *rows[4]; /* Character pointers for rle_getrow */
-static char *framebuffer = (char *)0;
-static int screen_width = 0;
-static int screen_height = 0;
-static int scr_xoff = 0;
-static int scr_yoff = 0;
+static unsigned char *scan_buf; /* single scanline buffer */
+static ColorMap cmap;
-static int crunch;
-static int overlay;
-static int r_debug;
+static char *framebuffer = (char *)0;
+static int screen_width = 0;
+static int screen_height = 0;
+static int scr_xoff = 0;
+static int scr_yoff = 0;
-static char usage[] = "\
+static int crunch;
+static int overlay;
+static int r_debug;
+
+static char usage[] = "\
Usage: rle-fb [-c -d -h -O] [-F framebuffer] [-C r/g/b]\n\
[-S squarescrsize] [-W scr_width] [-N scr_height]\n\
[-X scr_xoff] [-Y scr_yoff] [file.rle]\n\
";
+
/*
- * G E T _ A R G S
+ * G E T _ A R G S
*/
static int
get_args(int argc, char **argv)
{
- int c;
+ int c;
- while ( (c = bu_getopt( argc, argv, "cOdhs:S:w:W:n:N:C:F:X:Y:" )) != EOF )
{
- switch ( c ) {
+ while ((c = bu_getopt(argc, argv, "cOdhs:S:w:W:n:N:C:F:X:Y:")) != EOF) {
+ switch (c) {
case 'O':
overlay = 1;
break;
@@ -111,83 +108,83 @@
case 'Y':
scr_yoff = atoi(bu_optarg);
break;
- case 'C':
- {
+ case 'C': {
char *cp = bu_optarg;
int *conp = background;
/* premature null => atoi gives zeros */
- for ( c=0; c < 3; c++ ) {
+ for (c=0; c < 3; c++) {
*conp++ = atoi(cp);
- while ( *cp && *cp++ != '/' )
+ while (*cp && *cp++ != '/')
;
}
override_background = 1;
}
- break;
+ break;
default:
case '?':
- return 0;
+ return 0;
}
}
- if ( argv[bu_optind] != NULL ) {
- if ( (infp = fopen( (infile=argv[bu_optind]), "rb" )) == NULL ) {
+ if (argv[bu_optind] != NULL) {
+ if ((infp = fopen((infile=argv[bu_optind]), "rb")) == NULL) {
perror(infile);
- return 0;
+ return 0;
}
bu_optind++;
} else {
infile = "-";
}
- if ( argc > ++bu_optind )
- (void) fprintf( stderr, "rle-fb: excess arguments ignored\n" );
+ if (argc > ++bu_optind)
+ (void) fprintf(stderr, "rle-fb: excess arguments ignored\n");
- if ( isatty(fileno(infp)) )
+ if (isatty(fileno(infp)))
return 0;
- return 1;
+ return 1;
}
+
/*
- * M A I N
+ * M A I N
*/
int
main(int argc, char **argv)
{
- FBIO *fbp;
+ FBIO *fbp;
int i;
- int file_width; /* unclipped width of rectangle */
- int file_skiplen; /* # of pixels to skip on l.h.s. */
- int screen_xbase; /* screen X of l.h.s. of rectangle */
- int screen_xlen; /* clipped len of rectangle */
- int ncolors;
+ int file_width; /* unclipped width of rectangle */
+ int file_skiplen; /* # of pixels to skip on l.h.s. */
+ int screen_xbase; /* screen X of l.h.s. of rectangle */
+ int screen_xlen; /* clipped len of rectangle */
+ int ncolors;
infp = stdin;
- if ( !get_args( argc, argv ) ) {
+ if (!get_args(argc, argv)) {
(void)fputs(usage, stderr);
- bu_exit( 1, NULL );
+ bu_exit(1, NULL);
}
rle_dflt_hdr.rle_file = infp;
- if ( rle_get_setup( &rle_dflt_hdr ) < 0 ) {
+ if (rle_get_setup(&rle_dflt_hdr) < 0) {
fprintf(stderr, "rle-fb: Error reading setup information\n");
bu_exit(1, NULL);
}
- if (r_debug) {
- fprintf( stderr, "Image bounds\n\tmin %d %d\n\tmax %d %d\n",
- rle_dflt_hdr.xmin, rle_dflt_hdr.ymin,
- rle_dflt_hdr.xmax, rle_dflt_hdr.ymax );
+ if (r_debug) {
+ fprintf(stderr, "Image bounds\n\tmin %d %d\n\tmax %d %d\n",
+ rle_dflt_hdr.xmin, rle_dflt_hdr.ymin,
+ rle_dflt_hdr.xmax, rle_dflt_hdr.ymax);
fprintf(stderr, "%d color channels\n", rle_dflt_hdr.ncolors);
fprintf(stderr, "%d color map channels\n", rle_dflt_hdr.ncmap);
- if ( rle_dflt_hdr.alpha )
- fprintf( stderr, "Alpha Channel present in input, ignored.\n");
- for ( i=0; i < rle_dflt_hdr.ncolors; i++ )
+ if (rle_dflt_hdr.alpha)
+ fprintf(stderr, "Alpha Channel present in input, ignored.\n");
+ for (i=0; i < rle_dflt_hdr.ncolors; i++)
fprintf(stderr, "Background channel %d = %d\n",
- i, rle_dflt_hdr.bg_color[i] );
+ i, rle_dflt_hdr.bg_color[i]);
rle_debug(1);
}
- if ( rle_dflt_hdr.ncmap == 0 )
+ if (rle_dflt_hdr.ncmap == 0)
crunch = 0;
/* Only interested in R, G, & B */
@@ -197,28 +194,28 @@
ncolors = rle_dflt_hdr.ncolors > 3 ? 3 : rle_dflt_hdr.ncolors;
/* Optional switch of library to overlay mode */
- if ( overlay ) {
+ if (overlay) {
rle_dflt_hdr.background = 1; /* overlay */
override_background = 0;
}
/* Optional background color override */
- if ( override_background ) {
- for ( i=0; i<ncolors; i++ )
+ if (override_background) {
+ for (i=0; i<ncolors; i++)
rle_dflt_hdr.bg_color[i] = background[i];
}
file_width = rle_dflt_hdr.xmax - rle_dflt_hdr.xmin + 1;
/* If screen sizes not specified, try to display rectangle part > 0 */
- if ( screen_width == 0 ) {
+ if (screen_width == 0) {
screen_width = rle_dflt_hdr.xmax + 1;
- if ( scr_xoff > 0 )
+ if (scr_xoff > 0)
screen_width += scr_xoff;
}
- if ( screen_height == 0 ) {
+ if (screen_height == 0) {
screen_height = rle_dflt_hdr.ymax + 1;
- if ( scr_yoff > 0 )
+ if (scr_yoff > 0)
screen_height += scr_yoff;
}
@@ -232,66 +229,66 @@
rle_dflt_hdr.xmax -= screen_xbase;
rle_dflt_hdr.xmin = 0;
- if ( (fbp = fb_open( framebuffer, screen_width, screen_height )) ==
FBIO_NULL )
+ if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FBIO_NULL)
bu_exit(12, NULL);
/* Honor original screen size desires, if set, unless they shrank */
- if ( screen_width > 0 && fb_getwidth(fbp) < screen_width )
+ if (screen_width > 0 && fb_getwidth(fbp) < screen_width)
screen_width = fb_getwidth(fbp);
- if ( screen_height > 0 && fb_getheight(fbp) < screen_height )
+ if (screen_height > 0 && fb_getheight(fbp) < screen_height)
screen_height = fb_getheight(fbp);
/* Discard any scanlines which exceed screen height */
- if ( rle_dflt_hdr.ymax > screen_height-1 )
+ if (rle_dflt_hdr.ymax > screen_height-1)
rle_dflt_hdr.ymax = screen_height-1;
/* Clip left edge */
screen_xlen = rle_dflt_hdr.xmax + 1;
file_skiplen = 0;
- if ( screen_xbase < 0 ) {
+ if (screen_xbase < 0) {
file_skiplen = -screen_xbase;
screen_xbase = 0;
screen_xlen -= file_skiplen;
}
/* Clip right edge */
- if ( screen_xbase + screen_xlen > screen_width )
+ if (screen_xbase + screen_xlen > screen_width)
screen_xlen = screen_width - screen_xbase;
- if ( screen_xlen <= 0 ||
- rle_dflt_hdr.ymin > screen_height ||
- rle_dflt_hdr.ymax < 0 ) {
+ if (screen_xlen <= 0 ||
+ rle_dflt_hdr.ymin > screen_height ||
+ rle_dflt_hdr.ymax < 0) {
fprintf(stderr,
"rle-fb: Warning: RLE image rectangle entirely off screen\n");
goto done;
}
- scan_buf = (unsigned char *)malloc( sizeof(RGBpixel) * screen_width );
+ scan_buf = (unsigned char *)malloc(sizeof(RGBpixel) * screen_width);
- for ( i=0; i < ncolors; i++ )
+ for (i=0; i < ncolors; i++)
rows[i] = (unsigned char *)malloc((size_t)file_width);
- for (; i < 3; i++ )
+ for (; i < 3; i++)
rows[i] = rows[0]; /* handle monochrome images */
/*
- * Import Utah color map, converting to libfb format.
- * Check for old format color maps, where high 8 bits
- * were zero, and correct them.
- * XXX need to handle < 3 channels of color map, by replication.
+ * Import Utah color map, converting to libfb format.
+ * Check for old format color maps, where high 8 bits
+ * were zero, and correct them.
+ * XXX need to handle < 3 channels of color map, by replication.
*/
- if ( rle_dflt_hdr.ncmap > 0 ) {
+ if (rle_dflt_hdr.ncmap > 0) {
int maplen = (1 << rle_dflt_hdr.cmaplen);
int all = 0;
- for ( i=0; i<256; i++ ) {
+ for (i=0; i<256; i++) {
cmap.cm_red[i] = rle_dflt_hdr.cmap[i];
cmap.cm_green[i] = rle_dflt_hdr.cmap[i+maplen];
cmap.cm_blue[i] = rle_dflt_hdr.cmap[i+2*maplen];
all |= cmap.cm_red[i] | cmap.cm_green[i] |
cmap.cm_blue[i];
}
- if ( (all & 0xFF00) == 0 && (all & 0x00FF) != 0 ) {
- /* This is an old (Edition 2) color map.
- * Correct by shifting it left 8 bits.
+ if ((all & 0xFF00) == 0 && (all & 0x00FF) != 0) {
+ /* This is an old (Edition 2) color map.
+ * Correct by shifting it left 8 bits.
*/
- for ( i=0; i<256; i++ ) {
+ for (i=0; i<256; i++) {
cmap.cm_red[i] <<= 8;
cmap.cm_green[i] <<= 8;
cmap.cm_blue[i] <<= 8;
@@ -300,25 +297,25 @@
"rle-fb: correcting for old style colormap\n");
}
}
- if ( rle_dflt_hdr.ncmap > 0 && !crunch )
- (void)fb_wmap( fbp, &cmap );
+ if (rle_dflt_hdr.ncmap > 0 && !crunch)
+ (void)fb_wmap(fbp, &cmap);
else
- (void)fb_wmap( fbp, COLORMAP_NULL );
+ (void)fb_wmap(fbp, COLORMAP_NULL);
/* Handle any lines below zero in y. Decode and discard. */
- for ( i = rle_dflt_hdr.ymin; i < 0; i++ )
- rle_getrow( &rle_dflt_hdr, rows );
+ for (i = rle_dflt_hdr.ymin; i < 0; i++)
+ rle_getrow(&rle_dflt_hdr, rows);
- for (; i <= rle_dflt_hdr.ymax; i++) {
- unsigned char *pp = (unsigned char *)scan_buf;
- rle_pixel *rp = &(rows[0][file_skiplen]);
- rle_pixel *gp = &(rows[1][file_skiplen]);
- rle_pixel *bp = &(rows[2][file_skiplen]);
- int j;
+ for (; i <= rle_dflt_hdr.ymax; i++) {
+ unsigned char *pp = (unsigned char *)scan_buf;
+ rle_pixel *rp = &(rows[0][file_skiplen]);
+ rle_pixel *gp = &(rows[1][file_skiplen]);
+ rle_pixel *bp = &(rows[2][file_skiplen]);
+ int j;
- if ( overlay ) {
- fb_read( fbp, screen_xbase, i, scan_buf, screen_xlen );
- for ( j = 0; j < screen_xlen; j++ ) {
+ if (overlay) {
+ fb_read(fbp, screen_xbase, i, scan_buf, screen_xlen);
+ for (j = 0; j < screen_xlen; j++) {
*rp++ = *pp++;
*gp++ = *pp++;
*bp++ = *pp++;
@@ -329,29 +326,30 @@
bp = &(rows[2][file_skiplen]);
}
- rle_getrow(&rle_dflt_hdr, rows );
+ rle_getrow(&rle_dflt_hdr, rows);
/* Grumble, convert from Utah layout */
- if ( !crunch ) {
- for ( j = 0; j < screen_xlen; j++) {
+ if (!crunch) {
+ for (j = 0; j < screen_xlen; j++) {
*pp++ = *rp++;
*pp++ = *gp++;
*pp++ = *bp++;
}
} else {
- for ( j = 0; j < screen_xlen; j++) {
+ for (j = 0; j < screen_xlen; j++) {
*pp++ = cmap.cm_red[*rp++]>>8;
*pp++ = cmap.cm_green[*gp++]>>8;
*pp++ = cmap.cm_blue[*bp++]>>8;
}
}
- if ( fb_write( fbp, screen_xbase, i, scan_buf, screen_xlen ) !=
screen_xlen ) break;
+ if (fb_write(fbp, screen_xbase, i, scan_buf, screen_xlen) !=
screen_xlen) break;
}
- done:
- fb_close( fbp );
- bu_exit(0, NULL);
+done:
+ fb_close(fbp);
+ return 0;
}
+
/*
* Local Variables:
* mode: C
Modified: brlcad/trunk/src/fb/spm-fb.c
===================================================================
--- brlcad/trunk/src/fb/spm-fb.c 2010-11-17 22:58:02 UTC (rev 41400)
+++ brlcad/trunk/src/fb/spm-fb.c 2010-11-17 23:10:22 UTC (rev 41401)
@@ -32,31 +32,30 @@
#include "fb.h"
#include "spm.h"
-static FBIO *fbp;
-static char *framebuffer = NULL;
-static int scr_width = 0;
-static int scr_height = 0;
+static FBIO *fbp;
-static char *file_name;
-static int square = 0;
-static int vsize;
+static char *framebuffer = NULL;
+static int scr_width = 0;
+static int scr_height = 0;
-void spm_fb(spm_map_t *mapp);
-void spm_square(spm_map_t *mapp);
+static char *file_name;
+static int square = 0;
+static int vsize;
static char usage[] = "\
Usage: spm-fb [-h -s] [-F framebuffer]\n\
[-S squarescrsize] [-W scr_width] [-N scr_height]\n\
vsize [filename]\n";
+
int
get_args(int argc, char **argv)
{
int c;
- while ( (c = bu_getopt( argc, argv, "hF:sS:W:N:" )) != EOF ) {
- switch ( c ) {
+ while ((c = bu_getopt(argc, argv, "hF:sS:W:N:")) != EOF) {
+ switch (c) {
case 'h':
/* high-res */
scr_height = scr_width = 1024;
@@ -82,105 +81,109 @@
}
}
- if ( bu_optind >= argc )
+ if (bu_optind >= argc)
return 0; /* missing positional arg */
- vsize = atoi( argv[bu_optind++] );
+ vsize = atoi(argv[bu_optind++]);
- if ( bu_optind >= argc ) {
- if ( isatty(fileno(stdin)) )
+ if (bu_optind >= argc) {
+ if (isatty(fileno(stdin)))
return 0;
file_name = "-";
} else {
file_name = argv[bu_optind];
}
- if ( argc > ++bu_optind )
- (void)fprintf( stderr, "spm-fb: excess argument(s) ignored\n" );
+ if (argc > ++bu_optind)
+ (void)fprintf(stderr, "spm-fb: excess argument(s) ignored\n");
return 1; /* OK */
}
-/*
- * M A I N
- */
-int
-main(int argc, char **argv)
-{
- spm_map_t *mp;
- if ( !get_args( argc, argv ) ) {
- (void)fputs(usage, stderr);
- bu_exit( 1, NULL );
- }
-
- if ( (fbp = fb_open( framebuffer, scr_width, scr_height )) == FBIO_NULL )
- bu_exit(12, NULL);
- scr_width = fb_getwidth(fbp);
- scr_height = fb_getheight(fbp);
-
- mp = spm_init( vsize, sizeof(RGBpixel) );
- if ( mp == SPM_NULL || fbp == FBIO_NULL )
- bu_exit( 1, NULL );
-
- spm_load( mp, file_name );
-
- if ( square )
- spm_square( mp );
- else
- spm_fb( mp );
-
- spm_free( mp );
- fb_close( fbp );
- bu_exit(0, NULL);
-}
-
/*
- * S P M _ F B
+ * S P M _ F B
*
- * Displays a sphere map on a framebuffer.
+ * Displays a sphere map on a framebuffer.
*/
void
spm_fb(spm_map_t *mapp)
{
- int j;
+ int j;
- for ( j = 0; j < mapp->ny; j++ ) {
- fb_write( fbp, 0, j, mapp->xbin[j], mapp->nx[j] );
+ for (j = 0; j < mapp->ny; j++) {
+ fb_write(fbp, 0, j, mapp->xbin[j], mapp->nx[j]);
#ifdef NEVER
- for ( i = 0; i < mapp->nx[j]; i++ ) {
+ for (i = 0; i < mapp->nx[j]; i++) {
rgb[RED] = mapp->xbin[j][i*3];
rgb[GRN] = mapp->xbin[j][i*3+1];
rgb[BLU] = mapp->xbin[j][i*3+2];
- fb_write( fbp, i, j, (unsigned char *)rgb, 1 );
+ fb_write(fbp, i, j, (unsigned char *)rgb, 1);
}
#endif
}
}
+
/*
- * S P M _ S Q U A R E
+ * S P M _ S Q U A R E
*
- * Display a square sphere map on a framebuffer.
+ * Display a square sphere map on a framebuffer.
*/
void
spm_square(spm_map_t *mapp)
{
- int x, y;
- unsigned char *scanline;
+ int x, y;
+ unsigned char *scanline;
- scanline = (unsigned char *)malloc( scr_width * sizeof(RGBpixel) );
+ scanline = (unsigned char *)malloc(scr_width * sizeof(RGBpixel));
- for ( y = 0; y < scr_height; y++ ) {
- for ( x = 0; x < scr_width; x++ ) {
- spm_read( mapp, scanline[x],
- (double)x/(double)scr_width,
- (double)y/(double)scr_height );
+ for (y = 0; y < scr_height; y++) {
+ for (x = 0; x < scr_width; x++) {
+ spm_read(mapp, &scanline[x],
+ (double)x/(double)scr_width,
+ (double)y/(double)scr_height);
}
- if ( fb_write( fbp, 0, y, scanline, scr_width ) != scr_width ) break;
+ if (fb_write(fbp, 0, y, scanline, scr_width) != scr_width) break;
}
}
+
/*
+ * M A I N
+ */
+int
+main(int argc, char **argv)
+{
+ spm_map_t *mp;
+
+ if (!get_args(argc, argv)) {
+ (void)fputs(usage, stderr);
+ bu_exit(1, NULL);
+ }
+
+ if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == FBIO_NULL)
+ bu_exit(12, NULL);
+ scr_width = fb_getwidth(fbp);
+ scr_height = fb_getheight(fbp);
+
+ mp = spm_init(vsize, sizeof(RGBpixel));
+ if (mp == SPM_NULL || fbp == FBIO_NULL)
+ bu_exit(1, NULL);
+
+ spm_load(mp, file_name);
+
+ if (square)
+ spm_square(mp);
+ else
+ spm_fb(mp);
+
+ spm_free(mp);
+ fb_close(fbp);
+ return 0;
+}
+
+
+/*
* Local Variables:
* mode: C
* tab-width: 8
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits