Moves the definitions of pltr0f and pltr2f (both declared in plplot.h)
from the sccont.c files of the FORTRAN bindings into plcont.c.
---
bindings/f77/sccont.c | 197 -------------------------------------------------
bindings/f95/sccont.c | 197 -------------------------------------------------
src/plcont.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+), 394 deletions(-)
diff --git a/bindings/f77/sccont.c b/bindings/f77/sccont.c
index 5e96c23..3b277f9 100644
--- a/bindings/f77/sccont.c
+++ b/bindings/f77/sccont.c
@@ -25,203 +25,6 @@
#include "plstubs.h"
/*----------------------------------------------------------------------*\
- * pltr0f()
- *
- * Identity transformation for plots from Fortran.
- * Only difference from C-language identity function (pltr0) is that the
- * Fortran paradigm for array index is used, i.e. starting at 1.
- \*----------------------------------------------------------------------*/
-
-void
-pltr0f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
-{
- *tx = x + 1.0;
- *ty = y + 1.0;
-}
-
-/*----------------------------------------------------------------------*\
- * pltr2f()
- *
- * Does linear interpolation from doubly dimensioned coord arrays
- * (row dominant, i.e. Fortran ordering).
- *
- * This routine includes lots of checks for out of bounds. This would
- * occur occasionally due to a bug in the contour plotter that is now fixed.
- * If an out of bounds coordinate is obtained, the boundary value is provided
- * along with a warning. These checks should stay since no harm is done if
- * if everything works correctly.
- \*----------------------------------------------------------------------*/
-
-void
-pltr2f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
-{
- PLINT ul, ur, vl, vr;
- PLFLT du, dv;
- PLFLT xll, xlr, xrl, xrr;
- PLFLT yll, ylr, yrl, yrr;
- PLFLT xmin, xmax, ymin, ymax;
-
- PLcGrid *cgrid = (PLcGrid *) pltr_data;
- PLFLT *xg = cgrid->xg;
- PLFLT *yg = cgrid->yg;
- PLINT nx = cgrid->nx;
- PLINT ny = cgrid->ny;
-
- ul = (PLINT) x;
- ur = ul + 1;
- du = x - ul;
-
- vl = (PLINT) y;
- vr = vl + 1;
- dv = y - vl;
-
- xmin = 0;
- xmax = nx - 1;
- ymin = 0;
- ymax = ny - 1;
-
- if ( x < xmin || x > xmax || y < ymin || y > ymax )
- {
- plwarn( "pltr2f: Invalid coordinates" );
-
- if ( x < xmin )
- {
- if ( y < ymin )
- {
- *tx = *xg;
- *ty = *yg;
- }
- else if ( y > ymax )
- {
- *tx = *( xg + ( ny - 1 ) * nx );
- *ty = *( yg + ( ny - 1 ) * nx );
- }
- else
- {
- ul = 0;
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
- }
- else if ( x > xmax )
- {
- if ( y < ymin )
- {
- *tx = *( xg + ( nx - 1 ) );
- *ty = *( yg + ( nx - 1 ) );
- }
- else if ( y > ymax )
- {
- *tx = *( xg + ( nx - 1 ) + ( ny - 1 ) * nx );
- *ty = *( yg + ( nx - 1 ) + ( ny - 1 ) * nx );
- }
- else
- {
- ul = nx - 1;
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
- }
- else
- {
- if ( y < ymin )
- {
- vl = 0;
- xll = *( xg + ul + vl * nx );
- xrl = *( xg + ur + vl * nx );
- yll = *( yg + ul + vl * nx );
- yrl = *( yg + ur + vl * nx );
-
- *tx = xll * ( 1 - du ) + xrl * ( du );
- *ty = yll * ( 1 - du ) + yrl * ( du );
- }
- else if ( y > ymax )
- {
- vr = ny - 1;
- xlr = *( xg + ul + vr * nx );
- xrr = *( xg + ur + vr * nx );
- ylr = *( yg + ul + vr * nx );
- yrr = *( yg + ur + vr * nx );
-
- *tx = xlr * ( 1 - du ) + xrr * ( du );
- *ty = ylr * ( 1 - du ) + yrr * ( du );
- }
- }
- }
-
-/* Normal case.
- * Look up coordinates in row-dominant array.
- * Have to handle right boundary specially -- if at the edge, we'd
- * better not reference the out of bounds point. */
-
- else
- {
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
-
-/* ur is out of bounds */
-
- if ( ur == nx && vr < ny )
- {
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
-
-/* vr is out of bounds */
-
- else if ( ur < nx && vr == ny )
- {
- xrl = *( xg + ur + vl * nx );
- yrl = *( yg + ur + vl * nx );
-
- *tx = xll * ( 1 - du ) + xrl * ( du );
- *ty = yll * ( 1 - du ) + yrl * ( du );
- }
-
-/* both ur and vr are out of bounds */
-
- else if ( ur == nx && vr == ny )
- {
- *tx = xll;
- *ty = yll;
- }
-
-/* everything in bounds */
-
- else
- {
- xrl = *( xg + ur + vl * nx );
- xlr = *( xg + ul + vr * nx );
- xrr = *( xg + ur + vr * nx );
-
- yrl = *( yg + ur + vl * nx );
- ylr = *( yg + ul + vr * nx );
- yrr = *( yg + ur + vr * nx );
-/* INDENT OFF */
- *tx = xll * ( 1 - du ) * ( 1 - dv ) + xlr * ( 1 - du ) * ( dv ) +
- xrl * ( du ) * ( 1 - dv ) + xrr * ( du ) * ( dv );
-
- *ty = yll * ( 1 - du ) * ( 1 - dv ) + ylr * ( 1 - du ) * ( dv ) +
- yrl * ( du ) * ( 1 - dv ) + yrr * ( du ) * ( dv );
-/* INDENT ON */
- }
- }
-}
-
-/*----------------------------------------------------------------------*\
* Contour plotter front-ends.
* These specify the row-dominant function evaluator in the plfcont
* argument list. NO TRANSPOSE IS NECESSARY. The routines are as follows:
diff --git a/bindings/f95/sccont.c b/bindings/f95/sccont.c
index 0fe87f6..dfa2e80 100644
--- a/bindings/f95/sccont.c
+++ b/bindings/f95/sccont.c
@@ -25,203 +25,6 @@
#include "plstubs.h"
/*----------------------------------------------------------------------*\
- * pltr0f()
- *
- * Identity transformation for plots from Fortran.
- * Only difference from C-language identity function (pltr0) is that the
- * Fortran paradigm for array index is used, i.e. starting at 1.
- \*----------------------------------------------------------------------*/
-
-void
-pltr0f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
-{
- *tx = x + 1.0;
- *ty = y + 1.0;
-}
-
-/*----------------------------------------------------------------------*\
- * pltr2f()
- *
- * Does linear interpolation from doubly dimensioned coord arrays
- * (row dominant, i.e. Fortran ordering).
- *
- * This routine includes lots of checks for out of bounds. This would
- * occur occasionally due to a bug in the contour plotter that is now fixed.
- * If an out of bounds coordinate is obtained, the boundary value is provided
- * along with a warning. These checks should stay since no harm is done if
- * if everything works correctly.
- \*----------------------------------------------------------------------*/
-
-void
-pltr2f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
-{
- PLINT ul, ur, vl, vr;
- PLFLT du, dv;
- PLFLT xll, xlr, xrl, xrr;
- PLFLT yll, ylr, yrl, yrr;
- PLFLT xmin, xmax, ymin, ymax;
-
- PLcGrid *cgrid = (PLcGrid *) pltr_data;
- PLFLT *xg = cgrid->xg;
- PLFLT *yg = cgrid->yg;
- PLINT nx = cgrid->nx;
- PLINT ny = cgrid->ny;
-
- ul = (PLINT) x;
- ur = ul + 1;
- du = x - ul;
-
- vl = (PLINT) y;
- vr = vl + 1;
- dv = y - vl;
-
- xmin = 0;
- xmax = nx - 1;
- ymin = 0;
- ymax = ny - 1;
-
- if ( x < xmin || x > xmax || y < ymin || y > ymax )
- {
- plwarn( "pltr2f: Invalid coordinates" );
-
- if ( x < xmin )
- {
- if ( y < ymin )
- {
- *tx = *xg;
- *ty = *yg;
- }
- else if ( y > ymax )
- {
- *tx = *( xg + ( ny - 1 ) * nx );
- *ty = *( yg + ( ny - 1 ) * nx );
- }
- else
- {
- ul = 0;
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
- }
- else if ( x > xmax )
- {
- if ( y < ymin )
- {
- *tx = *( xg + ( nx - 1 ) );
- *ty = *( yg + ( nx - 1 ) );
- }
- else if ( y > ymax )
- {
- *tx = *( xg + ( nx - 1 ) + ( ny - 1 ) * nx );
- *ty = *( yg + ( nx - 1 ) + ( ny - 1 ) * nx );
- }
- else
- {
- ul = nx - 1;
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
- }
- else
- {
- if ( y < ymin )
- {
- vl = 0;
- xll = *( xg + ul + vl * nx );
- xrl = *( xg + ur + vl * nx );
- yll = *( yg + ul + vl * nx );
- yrl = *( yg + ur + vl * nx );
-
- *tx = xll * ( 1 - du ) + xrl * ( du );
- *ty = yll * ( 1 - du ) + yrl * ( du );
- }
- else if ( y > ymax )
- {
- vr = ny - 1;
- xlr = *( xg + ul + vr * nx );
- xrr = *( xg + ur + vr * nx );
- ylr = *( yg + ul + vr * nx );
- yrr = *( yg + ur + vr * nx );
-
- *tx = xlr * ( 1 - du ) + xrr * ( du );
- *ty = ylr * ( 1 - du ) + yrr * ( du );
- }
- }
- }
-
-/* Normal case.
- * Look up coordinates in row-dominant array.
- * Have to handle right boundary specially -- if at the edge, we'd
- * better not reference the out of bounds point. */
-
- else
- {
- xll = *( xg + ul + vl * nx );
- yll = *( yg + ul + vl * nx );
-
-/* ur is out of bounds */
-
- if ( ur == nx && vr < ny )
- {
- xlr = *( xg + ul + vr * nx );
- ylr = *( yg + ul + vr * nx );
-
- *tx = xll * ( 1 - dv ) + xlr * ( dv );
- *ty = yll * ( 1 - dv ) + ylr * ( dv );
- }
-
-/* vr is out of bounds */
-
- else if ( ur < nx && vr == ny )
- {
- xrl = *( xg + ur + vl * nx );
- yrl = *( yg + ur + vl * nx );
-
- *tx = xll * ( 1 - du ) + xrl * ( du );
- *ty = yll * ( 1 - du ) + yrl * ( du );
- }
-
-/* both ur and vr are out of bounds */
-
- else if ( ur == nx && vr == ny )
- {
- *tx = xll;
- *ty = yll;
- }
-
-/* everything in bounds */
-
- else
- {
- xrl = *( xg + ur + vl * nx );
- xlr = *( xg + ul + vr * nx );
- xrr = *( xg + ur + vr * nx );
-
- yrl = *( yg + ur + vl * nx );
- ylr = *( yg + ul + vr * nx );
- yrr = *( yg + ur + vr * nx );
-/* INDENT OFF */
- *tx = xll * ( 1 - du ) * ( 1 - dv ) + xlr * ( 1 - du ) * ( dv ) +
- xrl * ( du ) * ( 1 - dv ) + xrr * ( du ) * ( dv );
-
- *ty = yll * ( 1 - du ) * ( 1 - dv ) + ylr * ( 1 - du ) * ( dv ) +
- yrl * ( du ) * ( 1 - dv ) + yrr * ( du ) * ( dv );
-/* INDENT ON */
- }
- }
-}
-
-/*----------------------------------------------------------------------*\
* Contour plotter front-ends.
* These specify the row-dominant function evaluator in the plfcont
* argument list. NO TRANSPOSE IS NECESSARY. The routines are as follows:
diff --git a/src/plcont.c b/src/plcont.c
index 4c3ef6d..08f17c4 100644
--- a/src/plcont.c
+++ b/src/plcont.c
@@ -1261,3 +1261,200 @@ pltr2p( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, PLPointer pltr_data )
}
}
}
+
+/*----------------------------------------------------------------------*\
+ * pltr0f()
+ *
+ * Identity transformation for plots from Fortran.
+ * Only difference from C-language identity function (pltr0) is that the
+ * Fortran paradigm for array index is used, i.e. starting at 1.
+ \*----------------------------------------------------------------------*/
+
+void
+pltr0f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
+{
+ *tx = x + 1.0;
+ *ty = y + 1.0;
+}
+
+/*----------------------------------------------------------------------*\
+ * pltr2f()
+ *
+ * Does linear interpolation from doubly dimensioned coord arrays
+ * (row dominant, i.e. Fortran ordering).
+ *
+ * This routine includes lots of checks for out of bounds. This would
+ * occur occasionally due to a bug in the contour plotter that is now fixed.
+ * If an out of bounds coordinate is obtained, the boundary value is provided
+ * along with a warning. These checks should stay since no harm is done if
+ * if everything works correctly.
+ \*----------------------------------------------------------------------*/
+
+void
+pltr2f( PLFLT x, PLFLT y, PLFLT *tx, PLFLT *ty, void *pltr_data )
+{
+ PLINT ul, ur, vl, vr;
+ PLFLT du, dv;
+ PLFLT xll, xlr, xrl, xrr;
+ PLFLT yll, ylr, yrl, yrr;
+ PLFLT xmin, xmax, ymin, ymax;
+
+ PLcGrid *cgrid = (PLcGrid *) pltr_data;
+ PLFLT *xg = cgrid->xg;
+ PLFLT *yg = cgrid->yg;
+ PLINT nx = cgrid->nx;
+ PLINT ny = cgrid->ny;
+
+ ul = (PLINT) x;
+ ur = ul + 1;
+ du = x - ul;
+
+ vl = (PLINT) y;
+ vr = vl + 1;
+ dv = y - vl;
+
+ xmin = 0;
+ xmax = nx - 1;
+ ymin = 0;
+ ymax = ny - 1;
+
+ if ( x < xmin || x > xmax || y < ymin || y > ymax )
+ {
+ plwarn( "pltr2f: Invalid coordinates" );
+
+ if ( x < xmin )
+ {
+ if ( y < ymin )
+ {
+ *tx = *xg;
+ *ty = *yg;
+ }
+ else if ( y > ymax )
+ {
+ *tx = *( xg + ( ny - 1 ) * nx );
+ *ty = *( yg + ( ny - 1 ) * nx );
+ }
+ else
+ {
+ ul = 0;
+ xll = *( xg + ul + vl * nx );
+ yll = *( yg + ul + vl * nx );
+ xlr = *( xg + ul + vr * nx );
+ ylr = *( yg + ul + vr * nx );
+
+ *tx = xll * ( 1 - dv ) + xlr * ( dv );
+ *ty = yll * ( 1 - dv ) + ylr * ( dv );
+ }
+ }
+ else if ( x > xmax )
+ {
+ if ( y < ymin )
+ {
+ *tx = *( xg + ( nx - 1 ) );
+ *ty = *( yg + ( nx - 1 ) );
+ }
+ else if ( y > ymax )
+ {
+ *tx = *( xg + ( nx - 1 ) + ( ny - 1 ) * nx );
+ *ty = *( yg + ( nx - 1 ) + ( ny - 1 ) * nx );
+ }
+ else
+ {
+ ul = nx - 1;
+ xll = *( xg + ul + vl * nx );
+ yll = *( yg + ul + vl * nx );
+ xlr = *( xg + ul + vr * nx );
+ ylr = *( yg + ul + vr * nx );
+
+ *tx = xll * ( 1 - dv ) + xlr * ( dv );
+ *ty = yll * ( 1 - dv ) + ylr * ( dv );
+ }
+ }
+ else
+ {
+ if ( y < ymin )
+ {
+ vl = 0;
+ xll = *( xg + ul + vl * nx );
+ xrl = *( xg + ur + vl * nx );
+ yll = *( yg + ul + vl * nx );
+ yrl = *( yg + ur + vl * nx );
+
+ *tx = xll * ( 1 - du ) + xrl * ( du );
+ *ty = yll * ( 1 - du ) + yrl * ( du );
+ }
+ else if ( y > ymax )
+ {
+ vr = ny - 1;
+ xlr = *( xg + ul + vr * nx );
+ xrr = *( xg + ur + vr * nx );
+ ylr = *( yg + ul + vr * nx );
+ yrr = *( yg + ur + vr * nx );
+
+ *tx = xlr * ( 1 - du ) + xrr * ( du );
+ *ty = ylr * ( 1 - du ) + yrr * ( du );
+ }
+ }
+ }
+
+/* Normal case.
+ * Look up coordinates in row-dominant array.
+ * Have to handle right boundary specially -- if at the edge, we'd
+ * better not reference the out of bounds point. */
+
+ else
+ {
+ xll = *( xg + ul + vl * nx );
+ yll = *( yg + ul + vl * nx );
+
+/* ur is out of bounds */
+
+ if ( ur == nx && vr < ny )
+ {
+ xlr = *( xg + ul + vr * nx );
+ ylr = *( yg + ul + vr * nx );
+
+ *tx = xll * ( 1 - dv ) + xlr * ( dv );
+ *ty = yll * ( 1 - dv ) + ylr * ( dv );
+ }
+
+/* vr is out of bounds */
+
+ else if ( ur < nx && vr == ny )
+ {
+ xrl = *( xg + ur + vl * nx );
+ yrl = *( yg + ur + vl * nx );
+
+ *tx = xll * ( 1 - du ) + xrl * ( du );
+ *ty = yll * ( 1 - du ) + yrl * ( du );
+ }
+
+/* both ur and vr are out of bounds */
+
+ else if ( ur == nx && vr == ny )
+ {
+ *tx = xll;
+ *ty = yll;
+ }
+
+/* everything in bounds */
+
+ else
+ {
+ xrl = *( xg + ur + vl * nx );
+ xlr = *( xg + ul + vr * nx );
+ xrr = *( xg + ur + vr * nx );
+
+ yrl = *( yg + ur + vl * nx );
+ ylr = *( yg + ul + vr * nx );
+ yrr = *( yg + ur + vr * nx );
+/* INDENT OFF */
+ *tx = xll * ( 1 - du ) * ( 1 - dv ) + xlr * ( 1 - du ) * ( dv ) +
+ xrl * ( du ) * ( 1 - dv ) + xrr * ( du ) * ( dv );
+
+ *ty = yll * ( 1 - du ) * ( 1 - dv ) + ylr * ( 1 - du ) * ( dv ) +
+ yrl * ( du ) * ( 1 - dv ) + yrr * ( du ) * ( dv );
+/* INDENT ON */
+ }
+ }
+}
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel