diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b43525..47893e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.5) project(triangle) +find_package(X11) + +if(X11_FOUND) + option(BUILD_SHOWME "Build showme executable" OFF) +endif() option(BUILD_EXECUTABLE "Build triangle executable" OFF) option(BUILD_LIBRARY "Build libtriangle library" ON) @@ -23,3 +28,14 @@ if(BUILD_EXECUTABLE) endif() set_target_properties(triangle_exec PROPERTIES OUTPUT_NAME triangle) endif() + +if(X11_FOUND) + if(BUILD_SHOWME) + include_directories(${X11_INCLUDE_DIR}) + add_executable(showme_exec showme.cpp) + target_compile_definitions(showme_exec PRIVATE) + target_link_libraries(showme_exec ${X11_LIBRARIES}) + set_target_properties(showme_exec PROPERTIES OUTPUT_NAME showme) + endif() +endif() + diff --git a/showme.c b/showme.cpp similarity index 77% rename from showme.c rename to showme.cpp index c0294cb..963a64f 100644 --- a/showme.c +++ b/showme.cpp @@ -107,7 +107,7 @@ /* A necessary forward declaration. */ -int load_image(); +int load_image(int inc, int image); Display *display; int screen; @@ -198,7 +198,7 @@ char adjfilename[2][FILENAMESIZE]; char vnodefilename[2][FILENAMESIZE]; char vedgefilename[2][FILENAMESIZE]; -char *colorname[] = {"aquamarine", "red", "green yellow", "magenta", +const char* const colorname[] = {"aquamarine", "red", "green yellow", "magenta", "yellow", "green", "orange", "blue", "white", "sandy brown", "cyan", "moccasin", "cadet blue", "coral", "cornflower blue", "sky blue", @@ -231,521 +231,372 @@ void syntax() 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"); + printf(R"(Show Me +A Display Program for Meshes and More. +Version 1.6 + +Copyright 1996 Jonathan Richard Shewchuk (bugs/comments to jrs@cs.cmu.edu) +School of Computer Science / Carnegie Mellon University +5000 Forbes Avenue / Pittsburgh, Pennsylvania 15213-3891 +Created as part of the Archimedes project (tools for parallel FEM). +Supported in part by NSF Grant CMS-9318163 and an NSERC 1967 Scholarship. +There is no warranty whatsoever. Use at your own risk. +)"); #ifdef SINGLE - printf("This executable is compiled for single precision arithmetic.\n\n\n"); + printf("This executable is compiled for single precision arithmetic.\n\n"); #else - printf("This executable is compiled for double precision arithmetic.\n\n\n"); + printf("This executable is compiled for double precision arithmetic.\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"); - printf(" ele: Loads an .ele file (and associated .node file).\n"); - printf(" edge: Loads an .edge file (and associated .node file).\n"); - printf( -" part: Loads a .part file (and associated .node and .ele files).\n"); - printf( -" adj: Loads an .adj file (and associated .node, .ele, and .part files).\n"); - printf(" voro: Loads a .v.node and .v.edge file for a Voronoi diagram.\n"); - printf("\n"); - printf( -" Each row represents a different iteration number of the geometry files.\n"); - printf( -" For a full explanation of iteration numbers, read the instructions for\n"); - printf( -" Triangle. Briefly, iteration numbers are used to allow a user to easily\n" -); - printf( -" represent a sequence of related triangulations. Iteration numbers are\n"); - printf( -" used in the names of geometry files; for instance, mymesh.3.ele is a\n"); - printf( -" triangle file with iteration number three, and mymesh.ele has an implicit\n" -); - printf(" iteration number of zero.\n\n"); - printf( -" The control buttons at the right end of each row display the two\n"); - printf( -" iterations currently under view. These buttons can be clicked to\n"); - printf( -" increase or decrease the iteration numbers, and thus conveniently view\n"); - printf(" a sequence of meshes.\n\n"); - printf( -" Show Me keeps each file in memory after loading it, but you can force\n"); - printf( -" Show Me to reread a set of files (for one iteration number) by reclicking\n" -); - printf( -" the button that corresponds to the current image. This is convenient if\n" -); - printf(" you have changed a geometry file.\n\n"); - printf("File Formats:\n\n"); - printf( -" All files may contain comments prefixed by the character '#'. Points,\n"); - printf( -" segments, holes, triangles, edges, and subdomains must be numbered\n"); - printf( -" consecutively, starting from either 1 or 0. Whichever you choose, all\n"); - printf( -" input files must be consistent (for any single iteration number); if the\n" -); - printf( -" nodes are numbered from 1, so must be all other objects. Show Me\n"); - printf( -" automatically detects your choice while reading a .node (or .poly) file.\n" -); - printf(" Examples of these file formats are given below.\n\n"); - printf(" .node files:\n"); - printf( -" First line: <# of points> <# of attributes>\n"); - printf( -" <# of boundary markers (0 or 1)>\n" -); - printf( -" Remaining lines: [attributes] [boundary marker]\n"); - printf("\n"); - printf( -" The attributes, which are typically floating-point values of physical\n"); - printf( -" quantities (such as mass or conductivity) associated with the nodes of\n" -); - printf( -" a finite element mesh, are ignored by Show Me. Show Me also ignores\n"); - printf( -" boundary markers. See the instructions for Triangle to find out what\n"); - printf(" attributes and boundary markers are.\n\n"); - printf(" .poly files:\n"); - printf( -" First line: <# of points> <# of attributes>\n"); - printf( -" <# of boundary markers (0 or 1)>\n" -); - printf( -" Following lines: [attributes] [boundary marker]\n"); - printf(" One line: <# of segments> <# of boundary markers (0 or 1)>\n"); - printf( -" Following lines: [boundary marker]\n"); - printf(" One line: <# of holes>\n"); - printf(" Following lines: \n"); - printf(" [Optional additional lines that are ignored]\n\n"); - printf( -" A .poly file represents a Planar Straight Line Graph (PSLG), an idea\n"); - printf( -" familiar to computational geometers. By definition, a PSLG is just a\n"); - printf( -" list of points and edges. A .poly file also contains some additional\n"); - printf(" information.\n\n"); - printf( -" The first section lists all the points, and is identical to the format\n" -); - printf( -" of .node files. <# of points> may be set to zero to indicate that the\n" -); - printf( -" points are listed in a separate .node file; .poly files produced by\n"); - printf( -" Triangle always have this format. When Show Me reads such a file, it\n"); - printf(" also reads the corresponding .node file.\n\n"); - printf( -" The second section lists the segments. Segments are edges whose\n"); - printf( -" presence in a triangulation produced from the PSLG is enforced. Each\n"); - printf( -" segment is specified by listing the indices of its two endpoints. This\n" -); - printf( -" means that its endpoints must be included in the point list. Each\n"); - printf( -" segment, like each point, may have a boundary marker, which is ignored\n" -); - printf(" by Show Me.\n\n"); - printf( -" The third section lists holes and concavities that are desired in any\n"); - printf( -" triangulation generated from the PSLG. Holes are specified by\n"); - printf(" identifying a point inside each hole.\n\n"); - printf(" .ele files:\n"); - printf( -" First line: <# of triangles> <# of attributes>\n"); - printf( -" Remaining lines: ... [attributes]\n" -); - printf("\n"); - printf( -" Points are indices into the corresponding .node file. Show Me ignores\n" -); - printf( -" all but the first three points of each triangle; these should be the\n"); - printf( -" corners listed in counterclockwise order around the triangle. The\n"); - printf(" attributes are ignored by Show Me.\n\n"); - printf(" .edge files:\n"); - printf(" First line: <# of edges> <# of boundary markers (0 or 1)>\n"); - printf( -" Following lines: [boundary marker]\n"); - printf("\n"); - printf( -" Endpoints are indices into the corresponding .node file. The boundary\n" -); - printf(" markers are ignored by Show Me.\n\n"); - printf( -" In Voronoi diagrams, one also finds a special kind of edge that is an\n"); - printf( -" infinite ray with only one endpoint. For these edges, a different\n"); - printf(" format is used:\n\n"); - printf(" -1 \n\n"); - printf( -" The `direction' is a floating-point vector that indicates the direction\n" -); - printf(" of the infinite ray.\n\n"); - printf(" .part files:\n"); - printf(" First line: <# of triangles> <# of subdomains>\n"); - printf(" Remaining lines: \n\n"); - printf( -" The set of triangles is partitioned by a .part file; each triangle is\n"); - printf(" mapped to a subdomain.\n\n"); - printf(" .adj files:\n"); - printf(" First line: <# of subdomains>\n"); - printf(" Remaining lines: \n\n"); - printf( -" An .adj file represents adjacencies between subdomains (presumably\n"); - printf(" computed by a partitioner). The first line is followed by\n"); - printf( -" (subdomains X subdomains) lines, each containing one entry of the\n"); - printf( -" adjacency matrix. A nonzero entry indicates that two subdomains are\n"); - printf(" adjacent (share a point).\n\n"); - printf("Example:\n\n"); - printf( -" Here is a sample file `box.poly' describing a square with a square hole:\n" -); - printf("\n"); - printf( -" # A box with eight points in 2D, no attributes, no boundary marker.\n"); - printf(" 8 2 0 0\n"); - printf(" # Outer box has these vertices:\n"); - printf(" 1 0 0\n"); - printf(" 2 0 3\n"); - printf(" 3 3 0\n"); - printf(" 4 3 3\n"); - printf(" # Inner square has these vertices:\n"); - printf(" 5 1 1\n"); - printf(" 6 1 2\n"); - printf(" 7 2 1\n"); - printf(" 8 2 2\n"); - printf(" # Five segments without boundary markers.\n"); - printf(" 5 0\n"); - printf(" 1 1 2 # Left side of outer box.\n"); - printf(" 2 5 7 # Segments 2 through 5 enclose the hole.\n"); - printf(" 3 7 8\n"); - printf(" 4 8 6\n"); - printf(" 5 6 5\n"); - printf(" # One hole in the middle of the inner square.\n"); - printf(" 1\n"); - printf(" 1 1.5 1.5\n\n"); - printf( -" After this PSLG is triangulated by Triangle, the resulting triangulation\n" -); - printf( -" consists of a .node and .ele file. Here is the former, `box.1.node',\n"); - printf(" which duplicates the points of the PSLG:\n\n"); - printf(" 8 2 0 0\n"); - printf(" 1 0 0\n"); - printf(" 2 0 3\n"); - printf(" 3 3 0\n"); - printf(" 4 3 3\n"); - printf(" 5 1 1\n"); - printf(" 6 1 2\n"); - printf(" 7 2 1\n"); - printf(" 8 2 2\n"); - printf(" # Generated by triangle -pcBev box\n"); - printf("\n"); - printf(" Here is the triangulation file, `box.1.ele'.\n"); - printf("\n"); - printf(" 8 3 0\n"); - printf(" 1 1 5 6\n"); - printf(" 2 5 1 3\n"); - printf(" 3 2 6 8\n"); - printf(" 4 6 2 1\n"); - printf(" 5 7 3 4\n"); - printf(" 6 3 7 5\n"); - printf(" 7 8 4 2\n"); - printf(" 8 4 8 7\n"); - printf(" # Generated by triangle -pcBev box\n\n"); - printf(" Here is the edge file for the triangulation, `box.1.edge'.\n\n"); - printf(" 16 0\n"); - printf(" 1 1 5\n"); - printf(" 2 5 6\n"); - printf(" 3 6 1\n"); - printf(" 4 1 3\n"); - printf(" 5 3 5\n"); - printf(" 6 2 6\n"); - printf(" 7 6 8\n"); - printf(" 8 8 2\n"); - printf(" 9 2 1\n"); - printf(" 10 7 3\n"); - printf(" 11 3 4\n"); - printf(" 12 4 7\n"); - printf(" 13 7 5\n"); - printf(" 14 8 4\n"); - printf(" 15 4 2\n"); - printf(" 16 8 7\n"); - printf(" # Generated by triangle -pcBev box\n"); - printf("\n"); - printf( -" Here's a file `box.1.part' that partitions the mesh into four subdomains.\n" -); - printf("\n"); - printf(" 8 4\n"); - printf(" 1 3\n"); - printf(" 2 3\n"); - printf(" 3 4\n"); - printf(" 4 4\n"); - printf(" 5 1\n"); - printf(" 6 1\n"); - printf(" 7 2\n"); - printf(" 8 2\n"); - printf(" # Generated by slice -s4 box.1\n\n"); - printf( -" Here's a file `box.1.adj' that represents the resulting adjacencies.\n"); - printf("\n"); - printf(" 4\n"); - printf(" 9\n"); - printf(" 2\n"); - printf(" 2\n"); - printf(" 0\n"); - printf(" 2\n"); - printf(" 9\n"); - printf(" 0\n"); - printf(" 2\n"); - printf(" 2\n"); - printf(" 0\n"); - printf(" 9\n"); - printf(" 2\n"); - printf(" 0\n"); - printf(" 2\n"); - printf(" 2\n"); - printf(" 9\n"); - printf("\n"); - printf("Display Speed:\n"); - printf("\n"); - printf( -" It is worthwhile to note that .edge files typically plot and print twice\n" -); - printf( -" as quickly as .ele files, because .ele files cause each internal edge to\n" -); - printf( -" be drawn twice. For the same reason, PostScript files created from edge\n" -); - printf(" sets are smaller than those created from triangulations.\n\n"); - printf("Show Me on the Web:\n\n"); - printf( -" To see an illustrated, updated version of these instructions, check out\n"); - printf("\n"); - printf(" http://www.cs.cmu.edu/~quake/showme.html\n"); - printf("\n"); - printf("A Brief Plea:\n"); - printf("\n"); - printf( -" If you use Show Me (or Triangle), and especially if you use it to\n"); - printf( -" accomplish real work, I would like very much to hear from you. A short\n"); - printf( -" letter or email (to jrs@cs.cmu.edu) describing how you use Show Me (and\n"); - printf( -" its sister programs) will mean a lot to me. The more people I know\n"); - printf( -" are using my programs, the more easily I can justify spending time on\n"); - printf( -" improvements, which in turn will benefit you. Also, I can put you\n"); - printf( -" on a list to receive email whenever new versions are available.\n"); - printf("\n"); - printf( -" If you use a PostScript file generated by Show Me in a publication,\n"); - printf(" please include an acknowledgment as well.\n\n"); + + printf(R"( +Show Me graphically displays the contents of geometric files, especially +those generated by Triangle, my two-dimensional quality mesh generator and +Delaunay triangulator. Show Me can also write images in PostScript form. +Show Me is also useful for checking the consistency of the files you create +as input to Triangle; Show Me does these checks more thoroughly than +Triangle does. The command syntax is: + +showme [-bfw_Qh] input_file + +The underscore indicates that a number should follow the -w switch. +input_file may be one of several types of file. It must have extension +.node, .poly, .ele, .edge, .part, or .adj. If no extension is provided, +Show Me will assume the extension .ele. A .node file represents a set of +points; a .poly file represents a Planar Straight Line Graph; an .ele file +(coupled with a .node file) represents the elements of a mesh or the +triangles of a triangulation; an .edge file (coupled with a .node file) +represents a set of edges; a .part file specifies a partition of a mesh; +and a .adj file represents the adjacency graph defined by a partition. + +Command Line Switches: + + -b Makes all PostScript output black and white. If this switch is not + selected, color PostScript is used for partitioned meshes and + adjacency graphs (.part and .adj files). + -f On color displays and in color PostScript, displays partitioned + meshes by filling triangles with color, rather than by coloring the + edges. This switch will result in a clearer picture if all + triangles are reasonably large, and a less clear picture if small + triangles are present. (There is also a button to toggle this + behavior.) + -w Followed by an integer, specifies the line width used in all + images. (There are also buttons to change the line width.) + -Q Quiet: Suppresses all explanation of what Show Me is doing, unless + an error occurs. + -h Help: Displays these instructions. + +Controls: + + To zoom in on an image, point at the location where you want a closer + look, and click the left mouse button. To zoom out, click the right + mouse button. In either case, the point you click on will be centered in + the window. If you want to know the coordinates of a point, click the + middle mouse button; the coordinates will be printed on the terminal you + invoked Show Me from. + + If you resize the window, the image will grow or shrink to match. + + There is a panel of control buttons at the bottom of the Show Me window: + + Quit: Shuts down Show Me. + <, >, ^, v: Moves the image in the indicated direction. + Reset: Unzooms and centers the image in the window. When you switch from + one image to another, the viewing region does not change, so you may + need to reset the new image to make it fully visible. This often is + the case when switching between Delaunay triangulations and their + corresponding Voronoi diagrams, as Voronoi vertices can be far from the + initial point set. + Width+, -: Increases or decreases the width of all lines and points. + Exp, +, -: These buttons appear only when you are viewing a partitioned + mesh (.part file). `Exp' toggles between an exploded and non-exploded + image of the mesh. The non-exploded image will not show the partition + on a black and white monitor. `+' and `-' allow you to adjust the + spacing between pieces of the mesh to better distinguish them. + Fill: This button appears only when you are viewing a partitioned mesh + (.part file). It toggles between color-filled triangles and colored + edges (as the -f switch does). Filled triangles look better when all + triangles are reasonably large; colored edges look better when there + are very small triangles present. + PS: Creates a PostScript file containing the image you are viewing. If + the -b switch is selected, all PostScript output will be black and + white; otherwise, .part.ps and .adj.ps files will be color, independent + of whether you are using a color monitor. Normally the output will + preserve the properties of the image you see on the screen, including + zoom and line width; however, if black and white output is selected (-b + switch), partitioned meshes will always be drawn exploded. The output + file name depends on the image being viewed. If you want several + different snapshots (zooming in on different parts) of the same object, + you'll have to rename each file after Show Me creates it so that it + isn't overwritten by the next snapshot. + EPS: Creates an encapsulated PostScript file, suitable for inclusion in + documents. Otherwise, this button is just like the PS button. (The + only difference is that .eps files lack a `showpage' command at the + end.) + + There are two nearly-identical rows of buttons that load different images + from disk. Each row contains the following buttons: + + node: Loads a .node file. + poly: Loads a .poly file (and possibly an associated .node file). + ele: Loads an .ele file (and associated .node file). + edge: Loads an .edge file (and associated .node file). + part: Loads a .part file (and associated .node and .ele files). + adj: Loads an .adj file (and associated .node, .ele, and .part files). + voro: Loads a .v.node and .v.edge file for a Voronoi diagram. + + Each row represents a different iteration number of the geometry files. + For a full explanation of iteration numbers, read the instructions for + Triangle. Briefly, iteration numbers are used to allow a user to easily + represent a sequence of related triangulations. Iteration numbers are + used in the names of geometry files; for instance, mymesh.3.ele is a + triangle file with iteration number three, and mymesh.ele has an implicit + iteration number of zero. + + The control buttons at the right end of each row display the two + iterations currently under view. These buttons can be clicked to + increase or decrease the iteration numbers, and thus conveniently view + a sequence of meshes. + + Show Me keeps each file in memory after loading it, but you can force + Show Me to reread a set of files (for one iteration number) by reclicking + the button that corresponds to the current image. This is convenient if + you have changed a geometry file. + +File Formats: + + All files may contain comments prefixed by the character '#'. Points, + segments, holes, triangles, edges, and subdomains must be numbered + consecutively, starting from either 1 or 0. Whichever you choose, all + input files must be consistent (for any single iteration number); if the + nodes are numbered from 1, so must be all other objects. Show Me + automatically detects your choice while reading a .node (or .poly) file. + Examples of these file formats are given below. + + .node files: + First line: <# of points> <# of attributes> + <# of boundary markers (0 or 1)> + Remaining lines: [attributes] [boundary marker] + + The attributes, which are typically floating-point values of physical + quantities (such as mass or conductivity) associated with the nodes of + a finite element mesh, are ignored by Show Me. Show Me also ignores + boundary markers. See the instructions for Triangle to find out what + attributes and boundary markers are. + + .poly files: + First line: <# of points> <# of attributes> + <# of boundary markers (0 or 1)> + Following lines: [attributes] [boundary marker] + One line: <# of segments> <# of boundary markers (0 or 1)> + Following lines: [boundary marker] + One line: <# of holes> + Following lines: + [Optional additional lines that are ignored] + + A .poly file represents a Planar Straight Line Graph (PSLG), an idea + familiar to computational geometers. By definition, a PSLG is just a + list of points and edges. A .poly file also contains some additional + information. + + The first section lists all the points, and is identical to the format + of .node files. <# of points> may be set to zero to indicate that the + points are listed in a separate .node file; .poly files produced by + Triangle always have this format. When Show Me reads such a file, it + also reads the corresponding .node file. + + The second section lists the segments. Segments are edges whose + presence in a triangulation produced from the PSLG is enforced. Each + segment is specified by listing the indices of its two endpoints. This + means that its endpoints must be included in the point list. Each + segment, like each point, may have a boundary marker, which is ignored + by Show Me. + + The third section lists holes and concavities that are desired in any + triangulation generated from the PSLG. Holes are specified by + identifying a point inside each hole. + + .ele files: + First line: <# of triangles> <# of attributes> + Remaining lines: ... [attributes] + + Points are indices into the corresponding .node file. Show Me ignores + all but the first three points of each triangle; these should be the + corners listed in counterclockwise order around the triangle. The + attributes are ignored by Show Me. + + .edge files: + First line: <# of edges> <# of boundary markers (0 or 1)> + Following lines: [boundary marker] + + Endpoints are indices into the corresponding .node file. The boundary + markers are ignored by Show Me. + + In Voronoi diagrams, one also finds a special kind of edge that is an + infinite ray with only one endpoint. For these edges, a different + format is used: + + -1 + + The `direction' is a floating-point vector that indicates the direction + of the infinite ray. + + .part files: + First line: <# of triangles> <# of subdomains> + Remaining lines: + + The set of triangles is partitioned by a .part file; each triangle is + mapped to a subdomain. + + .adj files: + First line: <# of subdomains> + Remaining lines: + + An .adj file represents adjacencies between subdomains (presumably + computed by a partitioner). The first line is followed by + (subdomains X subdomains) lines, each containing one entry of the + adjacency matrix. A nonzero entry indicates that two subdomains are + adjacent (share a point). + +Example: + + Here is a sample file `box.poly' describing a square with a square hole: + + # A box with eight points in 2D, no attributes, no boundary marker. + 8 2 0 0 + # Outer box has these vertices: + 1 0 0 + 2 0 3 + 3 3 0 + 4 3 3 + # Inner square has these vertices: + 5 1 1 + 6 1 2 + 7 2 1 + 8 2 2 + # Five segments without boundary markers. + 5 0 + 1 1 2 # Left side of outer box. + 2 5 7 # Segments 2 through 5 enclose the hole. + 3 7 8 + 4 8 6 + 5 6 5 + # One hole in the middle of the inner square. + 1 + 1 1.5 1.5 + + After this PSLG is triangulated by Triangle, the resulting triangulation + consists of a .node and .ele file. Here is the former, `box.1.node', + which duplicates the points of the PSLG: + + 8 2 0 0 + 1 0 0 + 2 0 3 + 3 3 0 + 4 3 3 + 5 1 1 + 6 1 2 + 7 2 1 + 8 2 2 + # Generated by triangle -pcBev box + + Here is the triangulation file, `box.1.ele'. + + 8 3 0 + 1 1 5 6 + 2 5 1 3 + 3 2 6 8 + 4 6 2 1 + 5 7 3 4 + 6 3 7 5 + 7 8 4 2 + 8 4 8 7 + # Generated by triangle -pcBev box + + Here is the edge file for the triangulation, `box.1.edge'. + + 16 0 + 1 1 5 + 2 5 6 + 3 6 1 + 4 1 3 + 5 3 5 + 6 2 6 + 7 6 8 + 8 8 2 + 9 2 1 + 10 7 3 + 11 3 4 + 12 4 7 + 13 7 5 + 14 8 4 + 15 4 2 + 16 8 7 + # Generated by triangle -pcBev box + + Here's a file `box.1.part' that partitions the mesh into four subdomains. + + 8 4 + 1 3 + 2 3 + 3 4 + 4 4 + 5 1 + 6 1 + 7 2 + 8 2 + # Generated by slice -s4 box.1 + + Here's a file `box.1.adj' that represents the resulting adjacencies. + + 4 + 9 + 2 + 2 + 0 + 2 + 9 + 0 + 2 + 2 + 0 + 9 + 2 + 0 + 2 + 2 + 9 + +Display Speed: + + It is worthwhile to note that .edge files typically plot and print twice + as quickly as .ele files, because .ele files cause each internal edge to + be drawn twice. For the same reason, PostScript files created from edge + sets are smaller than those created from triangulations. + +Show Me on the Web: + + To see an illustrated, updated version of these instructions, check out + + http://www.cs.cmu.edu/~quake/showme.html + +A Brief Plea: + + If you use Show Me (or Triangle), and especially if you use it to + accomplish real work, I would like very much to hear from you. A short + letter or email (to jrs@cs.cmu.edu) describing how you use Show Me (and + its sister programs) will mean a lot to me. The more people I know + are using my programs, the more easily I can justify spending time on + improvements, which in turn will benefit you. Also, I can put you + on a list to receive email whenever new versions are available. + + If you use a PostScript file generated by Show Me in a publication, + please include an acknowledgment as well. + +)"); exit(0); } -void set_filenames(filename, lowermeshnumber) -char *filename; -int lowermeshnumber; +void set_filenames(char* filename, int lowermeshnumber) { char numberstring[100]; int i; @@ -783,9 +634,7 @@ int lowermeshnumber; } } -void parsecommandline(argc, argv) -int argc; -char **argv; +void parsecommandline(int argc, char** argv) { int increment; int meshnumber; @@ -893,8 +742,7 @@ char **argv; set_filenames(filename, loweriteration); } -void free_inc(inc) -int inc; +void free_inc(int inc) { if (loaded[inc][NODE]) { free(nodeptr[inc]); @@ -928,8 +776,7 @@ int inc; } } -void move_inc(inc) -int inc; +void move_inc(int inc) { int i; @@ -974,8 +821,7 @@ int inc; firstnumber[inc] = -1; } -void unload_inc(inc) -int inc; +void unload_inc(int inc) { int i; @@ -995,10 +841,7 @@ void showme_init() unload_inc(1); } -char *readline(string, infile, infilename) -char *string; -FILE *infile; -char *infilename; +char *readline(char *string, FILE *infile, char *infilename) { char *result; @@ -1018,8 +861,7 @@ char *infilename; return result; } -char *findfield(string) -char *string; +char *findfield(char *string) { char *result; @@ -1039,16 +881,8 @@ char *string; return result; } -int load_node(fname, firstnumber, nodes, dim, ptr, xmin, ymin, xmax, ymax) -char *fname; -int *firstnumber; -int *nodes; -int *dim; -REAL **ptr; -REAL *xmin; -REAL *ymin; -REAL *xmax; -REAL *ymax; +int load_node(char *fname, int *firstnumber, int *nodes, int *dim, + REAL **ptr, REAL *xmin, REAL *ymin, REAL *xmax, REAL *ymax) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1182,22 +1016,10 @@ REAL *ymax; return 0; } -int load_poly(inc, fname, firstnumber, pnodes, dim, edges, holes, nodeptr, - edgeptr, holeptr, xmin, ymin, xmax, ymax) -int inc; -char *fname; -int *firstnumber; -int *pnodes; -int *dim; -int *edges; -int *holes; -REAL **nodeptr; -int **edgeptr; -REAL **holeptr; -REAL *xmin; -REAL *ymin; -REAL *xmax; -REAL *ymax; +int load_poly(int inc, char *fname, int *firstnumber, int *pnodes, + int *dim, int *edges, int *holes, + REAL **nodeptr, int **edgeptr, REAL **holeptr, + REAL *xmin, REAL *ymin, REAL *xmax, REAL *ymax) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1469,13 +1291,7 @@ REAL *ymax; return 0; } -int load_ele(fname, firstnumber, nodes, elems, corners, ptr) -char *fname; -int firstnumber; -int nodes; -int *elems; -int *corners; -int **ptr; +int load_ele(char *fname, int firstnumber, int nodes, int *elems, int *corners, int **ptr) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1557,13 +1373,7 @@ int **ptr; return 0; } -int load_edge(fname, firstnumber, nodes, edges, edgeptr, normptr) -char *fname; -int firstnumber; -int nodes; -int *edges; -int **edgeptr; -REAL **normptr; +int load_edge(char *fname, int firstnumber, int nodes, int *edges, int **edgeptr, REAL **normptr) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1678,18 +1488,8 @@ REAL **normptr; return 0; } -int load_part(fname, dim, firstnumber, elems, nodeptr, eleptr, parts, - partition, partcenter, partshift) -char *fname; -int dim; -int firstnumber; -int elems; -REAL *nodeptr; -int *eleptr; -int *parts; -int **partition; -REAL **partcenter; -REAL **partshift; +int load_part(char *fname, int dim, int firstnumber, int elems, REAL *nodeptr, int *eleptr, + int *parts, int **partition, REAL **partcenter, REAL **partshift) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1805,10 +1605,7 @@ REAL **partshift; return 0; } -int load_adj(fname, subdomains, ptr) -char *fname; -int *subdomains; -int **ptr; +int load_adj(char *fname, int *subdomains, int **ptr) { FILE *infile; char inputline[INPUTLINESIZE]; @@ -1843,11 +1640,7 @@ int **ptr; return 0; } -void findpartshift(parts, explosion, partcenter, partshift) -int parts; -REAL explosion; -REAL *partcenter; -REAL *partshift; +void findpartshift(int parts, REAL explosion, REAL *partcenter, REAL *partshift) { int i; @@ -1859,9 +1652,7 @@ REAL *partshift; } } -int load_image(inc, image) -int inc; -int image; +int load_image(int inc, int image) { int error; @@ -1934,9 +1725,7 @@ int image; return error; } -void choose_image(inc, image) -int inc; -int image; +void choose_image(int inc, int image) { if (!loaded[inc][image]) { if ((image == ELE) || (image == EDGE) || (image == PART) @@ -1969,11 +1758,7 @@ int image; current_image = image; } -Window make_button(name, x, y, width) -char *name; -int x; -int y; -int width; +Window make_button(const char* const name, int x, int y, int width) { XSetWindowAttributes attr; XSizeHints hints; @@ -2005,8 +1790,7 @@ int width; return button; } -void make_buttons(y) -int y; +void make_buttons(int y) { int i; @@ -2061,8 +1845,7 @@ int y; XMapWindow(display, epswin); } -void fill_button(button) -Window button; +void fill_button(Window button) { int x, y; unsigned int w, h, d, b; @@ -2191,9 +1974,7 @@ void draw_buttons() XDrawString(display, epswin, fontgc, 2, 13, "EPS", 3); } -void showme_window(argc, argv) -int argc; -char **argv; +void showme_window(int argc, char **argv) { XSetWindowAttributes attr; XSizeHints hints; @@ -2238,7 +2019,7 @@ char **argv; XSetStandardProperties(display, mainwindow, "Show Me", "showme", None, argv, argc, &hints); XChangeProperty(display, mainwindow, XA_WM_CLASS, XA_STRING, 8, - PropModeReplace, "showme\0Archimedes", 18); + PropModeReplace, (const unsigned char*)"showme\0Archimedes", 18); XClearWindow(display, mainwindow); XMapWindow(display, mainwindow); if ((windowdepth > 1) && @@ -2296,14 +2077,7 @@ char **argv; XFlush(display); } -void draw_node(nodes, dim, ptr, xscale, yscale, xoffset, yoffset) -int nodes; -int dim; -REAL *ptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void draw_node(int nodes, int dim, REAL *ptr, REAL xscale, REAL yscale, REAL xoffset, REAL yoffset) { int i; int index; @@ -2318,19 +2092,9 @@ REAL yoffset; } } -void draw_poly(nodes, dim, edges, holes, nodeptr, edgeptr, holeptr, - xscale, yscale, xoffset, yoffset) -int nodes; -int dim; -int edges; -int holes; -REAL *nodeptr; -int *edgeptr; -REAL *holeptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void draw_poly(int nodes, int dim, int edges, int holes, + REAL *nodeptr, int *edgeptr, REAL *holeptr, + REAL xscale, REAL yscale, REAL xoffset, REAL yoffset) { int i; int index; @@ -2372,18 +2136,8 @@ REAL yoffset; XSetForeground(display, linegc, showme_foreground); } -void draw_ele(inc, elems, corners, ptr, partition, shift, - xscale, yscale, xoffset, yoffset) -int inc; -int elems; -int corners; -int *ptr; -int *partition; -REAL *shift; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void draw_ele(int inc, int elems, int corners, int *ptr, int *partition, + REAL *shift, REAL xscale, REAL yscale, REAL xoffset, REAL yoffset) { int i, j; int index; @@ -2457,18 +2211,9 @@ REAL yoffset; XSetForeground(display, linegc, showme_foreground); } -void draw_edge(nodes, dim, edges, nodeptr, edgeptr, normptr, - xscale, yscale, xoffset, yoffset) -int nodes; -int dim; -int edges; -REAL *nodeptr; -int *edgeptr; -REAL *normptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void draw_edge(int nodes, int dim, int edges, + REAL *nodeptr, int *edgeptr, REAL *normptr, + REAL xscale, REAL yscale, REAL xoffset, REAL yoffset) { int i; int index; @@ -2526,16 +2271,7 @@ REAL yoffset; } } -void draw_adj(dim, subdomains, ptr, center, xscale, yscale, - xoffset, yoffset) -int dim; -int subdomains; -int *ptr; -REAL *center; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void draw_adj(int dim,int subdomains,int *ptr,REAL *center,REAL xscale,REAL yscale,REAL xoffset,REAL yoffset) { int i, j; REAL *point1, *point2; @@ -2566,13 +2302,7 @@ REAL yoffset; XSetForeground(display, linegc, showme_foreground); } -void draw(inc, image, xmin, ymin, xmax, ymax) -int inc; -int image; -REAL xmin; -REAL ymin; -REAL xmax; -REAL ymax; +void draw(int inc,int image,REAL xmin,REAL ymin,REAL xmax,REAL ymax) { draw_buttons(); XClearWindow(display, mainwindow); @@ -2651,10 +2381,7 @@ REAL ymax; } } -void addps(instring, outstring, eps) -char *instring; -char *outstring; -int eps; +void addps(char *instring,char *outstring,int eps) { strcpy(outstring, instring); if (eps) { @@ -2664,12 +2391,7 @@ int eps; } } -int print_head(fname, file, llcornerx, llcornery, eps) -char *fname; -FILE **file; -int llcornerx; -int llcornery; -int eps; +int print_head(char *fname, FILE **file,int llcornerx,int llcornery,int eps) { if (!quiet) { printf("Writing %s\n", fname); @@ -2704,16 +2426,7 @@ int eps; return 0; } -void print_node(nodefile, nodes, dim, ptr, xscale, yscale, - xoffset, yoffset) -FILE *nodefile; -int nodes; -int dim; -REAL *ptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void print_node(FILE *nodefile,int nodes,int dim,REAL *ptr,REAL xscale,REAL yscale,REAL xoffset,REAL yoffset) { int i; int index; @@ -2728,20 +2441,7 @@ REAL yoffset; } } -void print_poly(polyfile, nodes, dim, edges, holes, nodeptr, edgeptr, holeptr, - xscale, yscale, xoffset, yoffset) -FILE *polyfile; -int nodes; -int dim; -int edges; -int holes; -REAL *nodeptr; -int *edgeptr; -REAL *holeptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; +void print_poly(FILE *polyfile,int nodes,int dim,int edges,int holes,REAL *nodeptr,int *edgeptr,REAL *holeptr,REAL xscale,REAL yscale,REAL xoffset,REAL yoffset) { int i; int index; @@ -2768,24 +2468,10 @@ REAL yoffset; } } -void print_ele(elefile, nodes, dim, elems, corners, nodeptr, eleptr, - partition, shift, - xscale, yscale, xoffset, yoffset, llcornerx, llcornery) -FILE *elefile; -int nodes; -int dim; -int elems; -int corners; -REAL *nodeptr; -int *eleptr; -int *partition; -REAL *shift; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; -int llcornerx; -int llcornery; +void print_ele(FILE *elefile, int nodes, int dim, int elems, int corners, + REAL *nodeptr, int *eleptr, int *partition, REAL *shift, + REAL xscale, REAL yscale, REAL xoffset, REAL yoffset, + int llcornerx, int llcornery) { int i, j; int index, colorindex; @@ -2840,21 +2526,10 @@ int llcornery; } } -void print_edge(edgefile, nodes, dim, edges, nodeptr, edgeptr, normptr, - xscale, yscale, xoffset, yoffset, llcornerx, llcornery) -FILE *edgefile; -int nodes; -int dim; -int edges; -REAL *nodeptr; -int *edgeptr; -REAL *normptr; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; -int llcornerx; -int llcornery; +void print_edge(FILE *edgefile, int nodes, int dim, int edges, + REAL *nodeptr, int *edgeptr, REAL *normptr, + REAL xscale,REAL yscale, REAL xoffset,REAL yoffset, + int llcornerx, int llcornery) { int i; int index; @@ -2914,19 +2589,9 @@ int llcornery; } } -void print_adj(adjfile, dim, subdomains, ptr, center, xscale, yscale, - xoffset, yoffset, llcornerx, llcornery) -FILE *adjfile; -int dim; -int subdomains; -int *ptr; -REAL *center; -REAL xscale; -REAL yscale; -REAL xoffset; -REAL yoffset; -int llcornerx; -int llcornery; +void print_adj(FILE *adjfile, int dim, int subdomains, int *ptr, + REAL *center, REAL xscale, REAL yscale, REAL xoffset, REAL yoffset, + int llcornerx, int llcornery) { int i, j; REAL *point1, *point2; @@ -2976,14 +2641,7 @@ int llcornery; } } -void print(inc, image, xmin, ymin, xmax, ymax, eps) -int inc; -int image; -REAL xmin; -REAL ymin; -REAL xmax; -REAL ymax; -int eps; +void print(int inc, int image, REAL xmin, REAL ymin, REAL xmax, REAL ymax, int eps) { REAL xxscale, yyscale, xxoffset, yyoffset; char psfilename[FILENAMESIZE]; @@ -3097,9 +2755,7 @@ int eps; fclose(psfile); } -int main(argc, argv) -int argc; -char **argv; +int main(int argc, char **argv) { REAL xmin, ymin, xmax, ymax; REAL xptr, yptr, xspan, yspan; @@ -3179,14 +2835,14 @@ char **argv; draw(current_inc, current_image, xmin, ymin, xmax, ymax); } } else if (event.xany.window == exppluswin) { - if ((current_image == PART) && loaded[PART] && explode) { + if ((current_image == PART) && loaded[current_inc][PART] && explode) { explosion += 0.125; findpartshift(subdomains[current_inc], explosion, partcenter[current_inc], partshift[current_inc]); draw(current_inc, current_image, xmin, ymin, xmax, ymax); } } else if (event.xany.window == expminuswin) { - if ((current_image == PART) && loaded[PART] && explode && + if ((current_image == PART) && loaded[current_inc][PART] && explode && (explosion >= 0.125)) { explosion -= 0.125; findpartshift(subdomains[current_inc], explosion, @@ -3194,7 +2850,7 @@ char **argv; draw(current_inc, current_image, xmin, ymin, xmax, ymax); } } else if (event.xany.window == fillwin) { - if ((current_image == PART) && loaded[PART]) { + if ((current_image == PART) && loaded[current_inc][PART]) { fillelem = !fillelem; draw(current_inc, current_image, xmin, ymin, xmax, ymax); } @@ -3321,7 +2977,7 @@ char **argv; } else { xptr = ((REAL) event.xbutton.x - xoffset) / xscale; yptr = ((REAL) event.xbutton.y - yoffset) / yscale; - if ((current_image == PART) && loaded[PART] && explode) { + if ((current_image == PART) && loaded[current_inc][PART] && explode) { xptr = (xptr + partcenter[current_inc] [subdomains[current_inc] << 1] * explosion) / (1.0 + explosion);