⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showme.c

📁 一个用于三角剖分的类.实用性非常好。对于需要从多边形
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************//*                                                                           *//*    ,d88^^o 888                                   o    o                   *//*    8888    888o^88,  o88^^o Y88b    o    /      d8b  d8b      o88^^8o     *//*    "Y88b   888  888 d888   b Y88b  d8b  /      d888bdY88b    d888  88b    *//*     "Y88b, 888  888 8888   8  Y888/Y88b/      / Y88Y Y888b   8888oo888    *//*    o  8888 888  888 q888   p   Y8/  Y8/      /   YY   Y888b  q888         *//*    "oo88P" 888  888  "88oo"     Y    Y      /          Y888b  "88oooo"    *//*                                                                           *//*  A Display Program for Meshes and More.                                   *//*  (showme.c)                                                               *//*                                                                           *//*  Version 1.6                                                              *//*  July 28, 2005                                                            *//*                                                                           *//*  Copyright 1996, 1998, 2005                                               *//*  Jonathan Richard Shewchuk                                                *//*  2360 Woolsey #H                                                          *//*  Berkeley, California  94705-1927                                         *//*  jrs@cs.berkeley.edu                                                      *//*                                                                           *//*  This program may be freely redistributed under the condition that the    *//*    copyright notices (including this entire header and the copyright      *//*    notice printed when the `-h' switch is selected) are not removed, and  *//*    no compensation is received.  Private, research, and institutional     *//*    use is free.  You may distribute modified versions of this code UNDER  *//*    THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT IN THE   *//*    SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH SOURCE   *//*    AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND CLEAR    *//*    NOTICE IS GIVEN OF THE MODIFICATIONS.  Distribution of this code as    *//*    part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT  *//*    WITH THE AUTHOR.  (If you are not directly supplying this code to a    *//*    customer, and you are instead telling them how they can obtain it for  *//*    free, then you are not required to make any arrangement with me.)      *//*                                                                           *//*  Hypertext instructions for Triangle are available on the Web at          *//*                                                                           *//*      http://www.cs.cmu.edu/~quake/showme.html                             *//*                                                                           *//*  Show Me was created as part of the Archimedes project in the School of   *//*    Computer Science at Carnegie Mellon University.  Archimedes is a       *//*    system for compiling parallel finite element solvers.  For further     *//*    information, see Anja Feldmann, Omar Ghattas, John R. Gilbert, Gary L. *//*    Miller, David R. O'Hallaron, Eric J. Schwabe, Jonathan R. Shewchuk,    *//*    and Shang-Hua Teng.  "Automated Parallel Solution of Unstructured PDE  *//*    Problems."  To appear in Communications of the ACM, we hope.           *//*                                                                           *//*  If you make any improvements to this code, please please please let me   *//*    know, so that I may obtain the improvements.  Even if you don't change *//*    the code, I'd still love to hear what it's being used for.             *//*                                                                           *//*  Disclaimer:  Neither I nor Carnegie Mellon warrant this code in any way  *//*    whatsoever.  Use at your own risk.                                     *//*                                                                           *//*****************************************************************************//* For single precision (which will save some memory and reduce paging),     *//*   write "#define SINGLE" below.                                           *//*                                                                           *//* For double precision (which will allow you to display triangulations of   *//*   a finer resolution), leave SINGLE undefined.                            *//* #define SINGLE */#ifdef SINGLE#define REAL float#else#define REAL double#endif/* Maximum number of characters in a file name (including the null).         */#define FILENAMESIZE 2048/* Maximum number of characters in a line read from a file (including the    *//*   null).                                                                  */#define INPUTLINESIZE 1024#define STARTWIDTH 414#define STARTHEIGHT 414#define MINWIDTH 50#define MINHEIGHT 50#define BUTTONHEIGHT 21#define BUTTONROWS 3#define PANELHEIGHT (BUTTONHEIGHT * BUTTONROWS)#define MAXCOLORS 64#define IMAGE_TYPES 7#define NOTHING -1#define NODE 0#define POLY 1#define ELE 2#define EDGE 3#define PART 4#define ADJ 5#define VORO 6#define STARTEXPLOSION 0.5#include <stdio.h>#include <stdlib.h>#include <string.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include <X11/Xatom.h>/* A necessary forward declaration.                                          */int load_image();Display *display;int screen;Window rootwindow;Window mainwindow;Window quitwin;Window leftwin;Window rightwin;Window upwin;Window downwin;Window resetwin;Window pswin;Window epswin;Window expwin;Window exppluswin;Window expminuswin;Window widthpluswin;Window widthminuswin;Window versionpluswin;Window versionminuswin;Window fillwin;Window nodewin[2];Window polywin[2];Window elewin[2];Window edgewin[2];Window partwin[2];Window adjwin[2];Window voronoiwin[2];int windowdepth;XEvent event;Colormap rootmap;XFontStruct *font;int width, height;int black, white;int showme_foreground;GC fontgc;GC blackfontgc;GC linegc;GC trianglegc;int colors[MAXCOLORS];XColor rgb[MAXCOLORS];int color;int start_image, current_image;int start_inc, current_inc;int loweriteration;int line_width;int loaded[2][IMAGE_TYPES];REAL xlo[2][IMAGE_TYPES], ylo[2][IMAGE_TYPES];REAL xhi[2][IMAGE_TYPES], yhi[2][IMAGE_TYPES];REAL xscale, yscale;REAL xoffset, yoffset;int zoom;int nodes[2], node_dim[2];REAL *nodeptr[2];int polynodes[2], poly_dim[2], polyedges[2], polyholes[2];REAL *polynodeptr[2], *polyholeptr[2];int *polyedgeptr[2];int elems[2], ele_corners[2];int *eleptr[2];int edges[2];int *edgeptr[2];REAL *normptr[2];int subdomains[2];int *partpart[2];REAL *partcenter[2], *partshift[2];int adjsubdomains[2];int *adjptr[2];int vnodes[2], vnode_dim[2];REAL *vnodeptr[2];int vedges[2];int *vedgeptr[2];REAL *vnormptr[2];int firstnumber[2];int quiet, fillelem, bw_ps, explode;REAL explosion;char filename[FILENAMESIZE];char nodefilename[2][FILENAMESIZE];char polyfilename[2][FILENAMESIZE];char elefilename[2][FILENAMESIZE];char edgefilename[2][FILENAMESIZE];char partfilename[2][FILENAMESIZE];char adjfilename[2][FILENAMESIZE];char vnodefilename[2][FILENAMESIZE];char vedgefilename[2][FILENAMESIZE];char *colorname[] = {"aquamarine", "red", "green yellow", "magenta",                     "yellow", "green", "orange", "blue",                     "white", "sandy brown", "cyan", "moccasin",                     "cadet blue", "coral", "cornflower blue", "sky blue",                     "firebrick", "forest green", "gold", "goldenrod",                     "gray", "hot pink", "chartreuse", "pale violet red",                     "indian red", "khaki", "lavender", "light blue",                     "light gray", "light steel blue", "lime green", "azure",                     "maroon", "medium aquamarine", "dodger blue", "honeydew",                     "medium orchid", "medium sea green", "moccasin",                     "medium slate blue", "medium spring green",                     "medium turquoise", "medium violet red",                     "orange red", "chocolate", "light goldenrod",                     "orchid", "pale green", "pink", "plum",                     "purple", "salmon", "sea green",                     "sienna", "slate blue", "spring green",                     "steel blue", "tan", "thistle", "turquoise",                     "violet", "violet red", "wheat",                     "yellow green"};void syntax(){  printf("showme [-bfw_Qh] input_file\n");  printf("    -b  Black and white PostScript (default is color).\n");  printf("    -f  Fill triangles of partitioned mesh with color.\n");  printf("    -w  Set line width to some specified number.\n");  printf("    -Q  Quiet:  No terminal output except errors.\n");  printf("    -h  Help:  Detailed instructions for Show Me.\n");  exit(0);}void info(){  printf("Show Me\n");  printf("A Display Program for Meshes and More.\n");  printf("Version 1.6\n\n");  printf("Copyright 1996 Jonathan Richard Shewchuk  (bugs/comments to jrs@cs.cmu.edu)\n");  printf("School of Computer Science / Carnegie Mellon University\n");  printf("5000 Forbes Avenue / Pittsburgh, Pennsylvania  15213-3891\n");  printf("Created as part of the Archimedes project (tools for parallel FEM).\n");  printf("Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship.\n");  printf("There is no warranty whatsoever.  Use at your own risk.\n");#ifdef SINGLE  printf("This executable is compiled for single precision arithmetic.\n\n\n");#else  printf("This executable is compiled for double precision arithmetic.\n\n\n");#endif  printf("Show Me graphically displays the contents of geometric files, especially\n");  printf("those generated by Triangle, my two-dimensional quality mesh generator and\n");  printf("Delaunay triangulator.  Show Me can also write images in PostScript form.\n");  printf("Show Me is also useful for checking the consistency of the files you create\n");  printf("as input to Triangle; Show Me does these checks more thoroughly than\n");  printf("Triangle does.  The command syntax is:\n\n");  printf("showme [-bfw_Qh] input_file\n\n");  printf("The underscore indicates that a number should follow the -w switch.\n");  printf("input_file may be one of several types of file.  It must have extension\n");  printf(".node, .poly, .ele, .edge, .part, or .adj.  If no extension is provided,\n");  printf("Show Me will assume the extension .ele.  A .node file represents a set of\n");  printf("points; a .poly file represents a Planar Straight Line Graph; an .ele file\n");  printf("(coupled with a .node file) represents the elements of a mesh or the\n");  printf("triangles of a triangulation; an .edge file (coupled with a .node file)\n");  printf("represents a set of edges; a .part file specifies a partition of a mesh;\n");  printf("and a .adj file represents the adjacency graph defined by a partition.\n");  printf("\n");  printf("Command Line Switches:\n");  printf("\n");  printf("    -b  Makes all PostScript output black and white.  If this switch is not\n");  printf("        selected, color PostScript is used for partitioned meshes and\n");  printf("        adjacency graphs (.part and .adj files).\n");  printf("    -f  On color displays and in color PostScript, displays partitioned\n");  printf("        meshes by filling triangles with color, rather than by coloring the\n");  printf("        edges.  This switch will result in a clearer picture if all\n");  printf("        triangles are reasonably large, and a less clear picture if small\n");  printf("        triangles are present.  (There is also a button to toggle this\n");  printf("        behavior.)\n");  printf("    -w  Followed by an integer, specifies the line width used in all\n");  printf("        images.  (There are also buttons to change the line width.)\n");  printf("    -Q  Quiet:  Suppresses all explanation of what Show Me is doing, unless\n");  printf("        an error occurs.\n");  printf("    -h  Help:  Displays these instructions.\n");  printf("\n");  printf("Controls:\n");  printf("\n");  printf("  To zoom in on an image, point at the location where you want a closer\n");  printf("  look, and click the left mouse button.  To zoom out, click the right\n");  printf("  mouse button.  In either case, the point you click on will be centered in\n");  printf("  the window.  If you want to know the coordinates of a point, click the\n");  printf("  middle mouse button; the coordinates will be printed on the terminal you\n");  printf("  invoked Show Me from.\n\n");  printf("  If you resize the window, the image will grow or shrink to match.\n");  printf("\n");  printf("  There is a panel of control buttons at the bottom of the Show Me window:\n");  printf("\n");  printf("  Quit:  Shuts down Show Me.\n");  printf("  <, >, ^, v:  Moves the image in the indicated direction.\n");  printf("  Reset: Unzooms and centers the image in the window.  When you switch from\n");  printf("    one image to another, the viewing region does not change, so you may\n");  printf("    need to reset the new image to make it fully visible.  This often is\n");  printf("    the case when switching between Delaunay triangulations and their\n");  printf("    corresponding Voronoi diagrams, as Voronoi vertices can be far from the\n");  printf("    initial point set.\n");  printf("  Width+, -:  Increases or decreases the width of all lines and points.\n");  printf("  Exp, +, -:  These buttons appear only when you are viewing a partitioned\n");  printf("    mesh (.part file).  `Exp' toggles between an exploded and non-exploded\n");  printf("    image of the mesh.  The non-exploded image will not show the partition\n");  printf("    on a black and white monitor.  `+' and `-' allow you to adjust the\n");  printf("    spacing between pieces of the mesh to better distinguish them.\n");  printf("  Fill:  This button appears only when you are viewing a partitioned mesh\n");  printf("    (.part file).  It toggles between color-filled triangles and colored\n");  printf("    edges (as the -f switch does).  Filled triangles look better when all\n");  printf("    triangles are reasonably large; colored edges look better when there\n");  printf("    are very small triangles present.\n");  printf("  PS:  Creates a PostScript file containing the image you are viewing.  If\n");  printf("    the -b switch is selected, all PostScript output will be black and\n");  printf("    white; otherwise, .part.ps and .adj.ps files will be color, independent\n");  printf("    of whether you are using a color monitor.  Normally the output will\n");  printf("    preserve the properties of the image you see on the screen, including\n");  printf("    zoom and line width; however, if black and white output is selected (-b\n");  printf("    switch), partitioned meshes will always be drawn exploded.  The output\n");  printf("    file name depends on the image being viewed.  If you want several\n");  printf("    different snapshots (zooming in on different parts) of the same object,\n");  printf("    you'll have to rename each file after Show Me creates it so that it\n");  printf("    isn't overwritten by the next snapshot.\n");  printf("  EPS:  Creates an encapsulated PostScript file, suitable for inclusion in\n");  printf("    documents.  Otherwise, this button is just like the PS button.  (The\n");  printf("    only difference is that .eps files lack a `showpage' command at the\n");  printf("    end.)\n\n");  printf("  There are two nearly-identical rows of buttons that load different images\n");  printf("  from disk.  Each row contains the following buttons:\n\n");  printf("  node:  Loads a .node file.\n");  printf("  poly:  Loads a .poly file (and possibly an associated .node file).\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -