21#include <lal/LALStdlib.h>
22#include <lal/LALConstants.h>
23#include <lal/TwoDMesh.h>
27#define TWODMESHPLOTC_MAXOBJ 797
31typedef struct tagMeshMacroParamStruc {
131 if (
params->autoscale ) {
144 "%%%%Creator: LALPlotTwoDMesh()\n"
145 "%%%%Title: mesh.ps\n"
146 "%%%%BoundingBox: %i %i %i %i\n"
147 "%%%%EndComments\n\n",
156 if (
params->plotPoints[
i] > 0 )
158 "/point%u { gsave currentpoint translate %f %f scale\n"
159 " auto auto scale %f rotate\n"
160 " newpath 0 0 %u 0 360 arc closepath fill grestore }"
164 else if (
params->plotPoints[
i] < 0 )
166 "/point%u { gsave currentpoint translate %f %f scale\n"
167 " auto auto scale %f rotate\n"
168 " newpath 0 0 r%u 0 360 arc closepath stroke grestore }"
179 "/ellipse { gsave currentpoint translate rotate scale\n"
180 " newpath 0 0 1 0 360 arc closepath stroke grestore } def\n" );
187 "/tile { gsave currentpoint translate 3 copy\n"
188 " dup 4 1 roll exch 4 1 roll moveto sub 0 exch rlineto\n"
189 " 2 copy add neg 4 3 roll -2 mul exch rlineto\n"
190 " sub neg 0 exch rlineto closepath stroke grestore } def\n" );
195 "/xyclip { %f %f moveto %f %f lineto %f %f lineto\n"
196 " %f %f lineto closepath clip } def\n",
203 if (
params->nBoundary >= 2 ) {
207 if ( yBound == NULL ) {
214 for (
i = 0;
i <
params->nBoundary - 1;
i++ ) {
232 "%f %f moveto\n", nMacro, x0, yBound[1] );
234 for (
i = 1;
i <
params->nBoundary - 1;
i++ ) {
236 fprintf( stream,
"%f %f lineto\n",
x, yBound[2 *
i + 1] );
243 "%f %f moveto\n", ++nMacro,
x, yBound[2 *
i + 1] );
248 fprintf( stream,
"%f %f lineto\n",
x, yBound[2 *
i + 1] );
249 fprintf( stream,
"%f %f lineto\n",
x, yBound[2 *
i] );
255 fprintf( stream,
"%f %f lineto\n",
x, yBound[2 *
i] );
262 "%f %f moveto\n", ++nMacro,
x, yBound[2 *
i] );
268 "stroke } def\n", x0, yBound[1] );
275 macroParams.
nObj = 0;
276 macroParams.
level = 0;
285 ¯oParams ),
stat );
290 if ( macroParams.
nObj > 0 ) {
295 if (
params->autoscale ) {
298 if ( ( xScaleFac == 0.0 ) && ( yScaleFac == 0.0 ) ) {
301 xScaleFac = ( bBox[2] - bBox[0] ) / xScaleFac;
302 yScaleFac = ( bBox[3] - bBox[1] ) / yScaleFac;
303 if ( yScaleFac < xScaleFac ) {
304 xScaleFac = yScaleFac;
306 params->xScale *= xScaleFac;
307 params->yScale *= xScaleFac;
308 for (
i = 0;
i < 4;
i++ ) {
311 fprintf( stream,
"/auto %f def\n", 1.0 / xScaleFac );
313 fprintf( stream,
"/auto 1 def\n" );
318 bBox[0] =
params->bBox[0];
319 bBox[2] =
params->bBox[2];
321 bBox[0] =
params->bBox[2];
322 bBox[2] =
params->bBox[0];
325 bBox[3] =
params->bBox[3];
326 bBox[1] =
params->bBox[1];
328 bBox[3] =
params->bBox[1];
329 bBox[1] =
params->bBox[3];
334 fprintf( stream,
"\n0 setlinewidth 0 setgray\n" );
337 fprintf( stream,
"%i %i moveto %i %i lineto %i %i lineto\n"
338 "%i %i lineto closepath clip newpath\n",
356 "gsave %f %f translate %f rotate %f %f scale",
360 fprintf( stream,
" xyclip\n" );
364 for (
i = 0;
i < nMacro;
i++ ) {
365 fprintf( stream,
"boundary%u\n",
i );
367 for (
i = 0;
i < macroParams.
nMacro;
i++ ) {
370 fprintf( stream,
"showpage grestore\n" );
375 fprintf( stream,
"\n%%%%EOF\n" );
376 if (
params->autoscale ) {
405 void *metricParams = NULL;
416 if ( ( rLevel =
params->level ) >=
params->plotParams->nLevels ) {
422 plotPoints = (
params->plotParams->plotPoints[rLevel] != 0 );
423 plotTiles =
params->plotParams->plotTiles[rLevel];
424 plotEllipses =
params->plotParams->plotEllipses[rLevel];
425 plotAny = ( plotPoints || plotTiles || plotEllipses );
426 if ( plotEllipses ) {
428 metricParams =
params->plotParams->
params[rLevel].metricParams;
433 while ( mesh != NULL ) {
436 fprintf( stream,
"%f %f moveto", mesh->
x, mesh->
y );
438 fprintf( stream,
" point%u", rLevel );
443 fprintf( stream,
" %f %f %f tile", mesh->
dx, mesh->
dy[0],
455 if ( plotEllipses ) {
465 position[0] = mesh->
x;
466 position[1] = mesh->
y;
468 metricParams ),
stat );
476 if ( term1 > term2 ) {
478 lambda = term1 * sqrt( 1.0 + term2 * term2 );
481 lambda = term2 * sqrt( 1.0 + term1 * term1 );
483 if ( lambda <= 0.0 ) {
487 axes[0] = sqrt( mThresh / lambda );
492 if ( term1 > term2 ) {
494 lambda = term1 * sqrt( 1.0 + term2 * term2 );
497 lambda = term2 * sqrt( 1.0 + term1 * term1 );
499 if ( lambda <= 0.0 ) {
503 axes[1] = sqrt( mThresh / lambda );
528 "\n/mesh%u {\n", ++(
params->nMacro ) );
534 if ( ( mesh->
subMesh != NULL ) &&
535 ( rLevel < params->plotParams->nLevels - 1 ) ) {
557 ( (
x >
params->clipBox[0] ) && ( x < params->clipBox[2] ) &&
558 (
y >
params->clipBox[1] ) && ( y < params->clipBox[3] ) ) ) {
563 if (
params->bBox[0] > xp ) {
566 if (
params->bBox[2] < xp ) {
569 if (
params->bBox[1] > yp ) {
572 if (
params->bBox[3] < yp ) {
void getMetric(LALStatus *, meshREAL g[3], meshREAL skypos[2], void *params)
#define ABORT(statusptr, code, mesg)
#define ENDFAIL(statusptr)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define BEGINFAIL(statusptr)
static void AdjustBBox(REAL4 x, REAL4 y, TwoDMeshPlotStruc *params)
static void LALMakeMeshMacro(LALStatus *stat, FILE *stream, TwoDMeshNode *mesh, MeshMacroParamStruc *params)
#define TWODMESHPLOTC_MAXOBJ
#define TWODMESHPLOTH_ENOPLOT
#define TWODMESHPLOTH_EMEM
#define TWODMESHPLOTH_MSGEMETRIC
#define TWODMESHPLOTH_MSGEMEM
#define TWODMESHPLOTH_EMETRIC
#define TWODMESHPLOTH_YMARG
Distance from bottom of page to plotting area (points)
#define TWODMESHPLOTH_ENUL
#define TWODMESHPLOTH_MSGENUL
#define TWODMESHPLOTH_MSGENOPLOT
#define TWODMESHPLOTH_XSIZE
Horizontal size of plotting area (points = )
#define TWODMESHPLOTH_XMARG
Distance from left of page to plotting area (points)
#define TWODMESHPLOTH_YSIZE
Vertical size of plotting area (points)
void LALPlotTwoDMesh(LALStatus *stat, FILE *stream, TwoDMeshNode *mesh, TwoDMeshPlotStruc *params)
Plots a hierarchical mesh of templates on an 2-dimensional parameter space.
TwoDMeshPlotStruc * plotParams
This structure represents a single node in a linked list of mesh points, specified in the coordinate ...
struct tagTwoDMeshNode * next
The next mesh point in the linked list; NULL if this is the tail.
REAL4 dx
The half-width of the tile centred on the mesh point.
struct tagTwoDMeshNode * subMesh
The head of a linked list of fine mesh points within the rectangular area spanned by this mesh point ...
REAL4 dy[2]
The heights of the two right-hand corners of the tile, relative to the mesh point.
REAL4 y
The coordinates of the mesh point.
This structure stores parameters specifying how to plot a PostScript diagram of the parameter mesh.