Revision: 56614
http://sourceforge.net/p/brlcad/code/56614
Author: brlcad
Date: 2013-08-06 02:48:37 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
apply kesha's sf patch #165 that performs a code reduction in libbn's plot
inteface code. 70 line reduction overall. looks good.
Modified Paths:
--------------
brlcad/trunk/src/libbn/plot3.c
Modified: brlcad/trunk/src/libbn/plot3.c
===================================================================
--- brlcad/trunk/src/libbn/plot3.c 2013-08-06 02:25:28 UTC (rev 56613)
+++ brlcad/trunk/src/libbn/plot3.c 2013-08-06 02:48:37 UTC (rev 56614)
@@ -77,7 +77,87 @@
/*#define putsi(a) putc(a&0377, plotfp); putc((a>>8)&0377, plotfp)*/
#define putsi(a) putc(a, plotfp); putc((a>>8), plotfp)
+/* Making a common pd_3 to be used in pd_3cont and pd_3move */
+void
+pd_3(register FILE *plotfp, double x, double y, double z, char c)
+{
+ size_t ret;
+ double in[3];
+ unsigned char out[3*8+1];
+ if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
+ in[0] = x;
+ in[1] = y;
+ in[2] = z;
+ htond(&out[1], (unsigned char *)in, 3);
+
+ out[0] = c;
+ ret = fwrite(out, 1, 3*8+1, plotfp);
+ if (ret != 3*8+1) {
+ perror("fwrite");
+ }
+ } else {
+ fprintf(plotfp, "%c %g %g %g\n", c, x, y, z);
+ }
+}
+
+/* Making a common pdv_3 to be used in pdv_3cont and pdv_3move */
+void
+pdv_3(register FILE *plotfp, const fastf_t *pt, char c)
+{
+ size_t ret;
+ unsigned char out[3*8+1];
+
+ if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
+ htond(&out[1], (unsigned char *)pt, 3);
+
+ out[0] = c;
+ ret = fwrite(out, 1, 3*8+1, plotfp);
+ if (ret != 3*8+1) {
+ perror("fwrite");
+ }
+ } else {
+ fprintf(plotfp, "%c %g %g %g\n", c, V3ARGS(pt));
+ }
+}
+
+/* Making a common pd to be used in pd_cont and pd_move */
+void
+pd(register FILE *plotfp, double x, double y, char c)
+{
+ size_t ret;
+ double in[2];
+ unsigned char out[2*8+1];
+
+ if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
+ in[0] = x;
+ in[1] = y;
+ htond(&out[1], (unsigned char *)in, 2);
+
+ out[0] = c;
+ ret = fwrite(out, 1, 2*8+1, plotfp);
+ if (ret != 2*8+1) {
+ perror("fwrite");
+ }
+ } else {
+ fprintf(plotfp, "%c %g %g\n", c, x, y);
+ }
+}
+
+/* Making a common pl_3 to be used in pl_3cont and pl_3move */
+void
+pl_3(register FILE *plotfp, int x, int y, int z, char c)
+{
+ if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
+ putc( c, plotfp);
+ putsi(x);
+ putsi(y);
+ putsi(z);
+ } else {
+ fprintf(plotfp, "%c %d %d %d\n", c, x, y, z);
+ }
+}
+
/*
* These interfaces provide the standard UNIX-Plot functionality
*/
@@ -284,40 +364,19 @@
void
pl_3point(register FILE *plotfp, int x, int y, int z)
{
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- putc('P', plotfp);
- putsi(x);
- putsi(y);
- putsi(z);
- } else {
- fprintf(plotfp, "P %d %d %d\n", x, y, z);
- }
+ pl_3(plotfp, x, y, z, 'P'); /* calling common function pl_3 */
}
void
pl_3move(register FILE *plotfp, int x, int y, int z)
{
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- putc('M', plotfp);
- putsi(x);
- putsi(y);
- putsi(z);
- } else {
- fprintf(plotfp, "M %d %d %d\n", x, y, z);
- }
+ pl_3(plotfp, x, y, z, 'M'); /* calling common function pl_3 */}
}
void
pl_3cont(register FILE *plotfp, int x, int y, int z)
{
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- putc('N', plotfp);
- putsi(x);
- putsi(y);
- putsi(z);
- } else {
- fprintf(plotfp, "N %d %d %d\n", x, y, z);
- }
+ pl_3(plotfp, x, y, z, 'N'); /* calling common function pl_3 */
}
void
@@ -370,23 +429,7 @@
void
pd_point(register FILE *plotfp, double x, double y)
{
- size_t ret;
- double in[2];
- unsigned char out[2*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- htond(&out[1], (unsigned char *)in, 2);
-
- out[0] = 'x';
- ret = fwrite(out, 1, 2*8+1, plotfp);
- if (ret != 2*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "x %g %g\n", x, y);
- }
+ pd( plotfp, x, y, 'x'); /* calling common function pd */
}
void
@@ -418,45 +461,13 @@
void
pd_move(register FILE *plotfp, double x, double y)
{
- size_t ret;
- double in[2];
- unsigned char out[2*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- htond(&out[1], (unsigned char *)in, 2);
-
- out[0] = 'o';
- ret = fwrite(out, 1, 2*8+1, plotfp);
- if (ret != 2*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "o %g %g\n", x, y);
- }
+ pd( plotfp, x, y, 'o'); /* calling common function pd */
}
void
pd_cont(register FILE *plotfp, double x, double y)
{
- size_t ret;
- double in[2];
- unsigned char out[2*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- htond(&out[1], (unsigned char *)in, 2);
-
- out[0] = 'q';
- ret = fwrite(out, 1, 2*8+1, plotfp);
- if (ret != 2*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "q %g %g\n", x, y);
- }
+ pd( plotfp, x, y, 'q'); /* calling common function pd */
}
void
@@ -593,127 +604,37 @@
void
pdv_3point(register FILE *plotfp, const fastf_t *pt)
{
- size_t ret;
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- htond(&out[1], (unsigned char *)pt, 3);
-
- out[0] = 'X';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "X %g %g %g\n", V3ARGS(pt));
- }
+ pdv_3(plotfp, pt, 'X'); /* calling common fuction pdv_3 */
}
void
pd_3point(register FILE *plotfp, double x, double y, double z)
{
- size_t ret;
- double in[3];
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- in[2] = z;
- htond(&out[1], (unsigned char *)in, 3);
-
- out[0] = 'X';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "X %g %g %g\n", x, y, z);
- }
+ pd_3(plotfp, x, y, z, 'X'); /* calling common fuction pd_3 */
}
void
pdv_3move(register FILE *plotfp, const fastf_t *pt)
{
- size_t ret;
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- htond(&out[1], (unsigned char *)pt, 3);
-
- out[0] = 'O';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "O %g %g %g\n", V3ARGS(pt));
- }
+ pdv_3(plotfp, pt, 'O'); /* calling common fuction pdv_3 */
}
void
pd_3move(register FILE *plotfp, double x, double y, double z)
{
- size_t ret;
- double in[3];
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- in[2] = z;
- htond(&out[1], (unsigned char *)in, 3);
-
- out[0] = 'O';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "O %g %g %g\n", x, y, z);
- }
+ pd_3(plotfp, x, y, z, 'O'); /* calling common fuction pd_3 */
}
void
pdv_3cont(register FILE *plotfp, const fastf_t *pt)
{
- size_t ret;
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- htond(&out[1], (unsigned char *)pt, 3);
-
- out[0] = 'Q';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "Q %g %g %g\n", V3ARGS(pt));
- }
+ pdv_3(plotfp, pt, 'Q'); /* calling common fuction pdv_3 */
}
void
pd_3cont(register FILE *plotfp, double x, double y, double z)
{
- size_t ret;
- double in[3];
- unsigned char out[3*8+1];
-
- if (pl_outputMode == PL_OUTPUT_MODE_BINARY) {
- in[0] = x;
- in[1] = y;
- in[2] = z;
- htond(&out[1], (unsigned char *)in, 3);
-
- out[0] = 'Q';
- ret = fwrite(out, 1, 3*8+1, plotfp);
- if (ret != 3*8+1) {
- perror("fwrite");
- }
- } else {
- fprintf(plotfp, "Q %g %g %g\n", x, y, z);
- }
+ pd_3(plotfp, x, y, z, 'Q'); /* calling common fuction pd_3 */
}
void
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits