Initial revision.
This commit is contained in:
parent
7ee54664b6
commit
e5cd4c5b9d
8 changed files with 17536 additions and 0 deletions
62
Triangle/A.poly
Normal file
62
Triangle/A.poly
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
29 2 1 0
|
||||||
|
1 0.200000 -0.776400 -0.57
|
||||||
|
2 0.220000 -0.773200 -0.55
|
||||||
|
3 0.245600 -0.756400 -0.51
|
||||||
|
4 0.277600 -0.702000 -0.53
|
||||||
|
5 0.488800 -0.207600 0.28
|
||||||
|
6 0.504800 -0.207600 0.30
|
||||||
|
7 0.740800 -0.739600 0
|
||||||
|
8 0.756000 -0.761200 -0.01
|
||||||
|
9 0.774400 -0.772400 0
|
||||||
|
10 0.800000 -0.776400 0.02
|
||||||
|
11 0.800000 -0.792400 0.01
|
||||||
|
12 0.579200 -0.792400 -0.21
|
||||||
|
13 0.579200 -0.776400 -0.2
|
||||||
|
14 0.621600 -0.771600 -0.15
|
||||||
|
15 0.633600 -0.762800 -0.13
|
||||||
|
16 0.639200 -0.744400 -0.1
|
||||||
|
17 0.620800 -0.684400 -0.06
|
||||||
|
18 0.587200 -0.604400 -0.01
|
||||||
|
19 0.360800 -0.604400 -0.24
|
||||||
|
20 0.319200 -0.706800 -0.39
|
||||||
|
21 0.312000 -0.739600 -0.43
|
||||||
|
22 0.318400 -0.761200 -0.44
|
||||||
|
23 0.334400 -0.771600 -0.44
|
||||||
|
24 0.371200 -0.776400 -0.41
|
||||||
|
25 0.371200 -0.792400 -0.42
|
||||||
|
26 0.374400 -0.570000 -0.2
|
||||||
|
27 0.574400 -0.570000 0
|
||||||
|
28 0.473600 -0.330800 0.14
|
||||||
|
29 0.200000 -0.792400 -0.59
|
||||||
|
29 0
|
||||||
|
1 29 1
|
||||||
|
2 1 2
|
||||||
|
3 2 3
|
||||||
|
4 3 4
|
||||||
|
5 4 5
|
||||||
|
6 5 6
|
||||||
|
7 6 7
|
||||||
|
8 7 8
|
||||||
|
9 8 9
|
||||||
|
10 9 10
|
||||||
|
11 10 11
|
||||||
|
12 11 12
|
||||||
|
13 12 13
|
||||||
|
14 13 14
|
||||||
|
15 14 15
|
||||||
|
16 15 16
|
||||||
|
17 16 17
|
||||||
|
18 17 18
|
||||||
|
19 18 19
|
||||||
|
20 19 20
|
||||||
|
21 20 21
|
||||||
|
22 21 22
|
||||||
|
23 22 23
|
||||||
|
24 23 24
|
||||||
|
25 24 25
|
||||||
|
26 25 29
|
||||||
|
27 26 27
|
||||||
|
28 27 28
|
||||||
|
29 28 26
|
||||||
|
1
|
||||||
|
1 0.47 -0.5
|
111
Triangle/Makefile
Normal file
111
Triangle/Makefile
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
# makefile for Triangle and Show Me
|
||||||
|
#
|
||||||
|
# Type "make" to compile Triangle and Show Me.
|
||||||
|
#
|
||||||
|
# After compiling, type "triangle -h" and "showme -h" to read instructions
|
||||||
|
# for using each of these programs.
|
||||||
|
#
|
||||||
|
# Type "make trilibrary" to compile Triangle as an object file (triangle.o).
|
||||||
|
#
|
||||||
|
# Type "make distclean" to delete all executable files.
|
||||||
|
|
||||||
|
# SRC is the directory in which the C source files are, and BIN is the
|
||||||
|
# directory where you want to put the executable programs. By default,
|
||||||
|
# both are the current directory.
|
||||||
|
|
||||||
|
SRC = ./
|
||||||
|
BIN = ./
|
||||||
|
|
||||||
|
# CC should be set to the name of your favorite C compiler.
|
||||||
|
|
||||||
|
CC = cc
|
||||||
|
|
||||||
|
# CSWITCHES is a list of all switches passed to the C compiler. I strongly
|
||||||
|
# recommend using the best level of optimization. I also strongly
|
||||||
|
# recommend timing each level of optimization to see which is the
|
||||||
|
# best. For instance, on my DEC Alpha using DEC's optimizing compiler,
|
||||||
|
# the -O2 switch generates a notably faster version of Triangle than the
|
||||||
|
# -O3 switch. Go figure.
|
||||||
|
#
|
||||||
|
# By default, Triangle and Show Me use double precision floating point
|
||||||
|
# numbers. If you prefer single precision, use the -DSINGLE switch.
|
||||||
|
# Double precision uses more memory, but improves the resolution of
|
||||||
|
# the meshes you can generate with Triangle. It also reduces the
|
||||||
|
# likelihood of a floating exception due to overflow. Also, it is
|
||||||
|
# much faster than single precision on 64-bit architectures like the
|
||||||
|
# DEC Alpha. I recommend double precision unless you want to generate
|
||||||
|
# a mesh for which you do not have enough memory to use double precision.
|
||||||
|
#
|
||||||
|
# If yours is not a Unix system, use the -DNO_TIMER switch to eliminate the
|
||||||
|
# Unix-specific timer code.
|
||||||
|
#
|
||||||
|
# If you are modifying Triangle, I recommend using the -DSELF_CHECK switch
|
||||||
|
# while you are debugging. Defining the SELF_CHECK symbol causes
|
||||||
|
# Triangle to include self-checking code. Triangle will execute more
|
||||||
|
# slowly, however, so be sure to remove this switch before compiling a
|
||||||
|
# production version.
|
||||||
|
#
|
||||||
|
# If the size of the Triangle binary is important to you, you may wish to
|
||||||
|
# generate a reduced version of Triangle. The -DREDUCED switch gets rid
|
||||||
|
# of all features that are primarily of research interest. Specifically,
|
||||||
|
# defining the REDUCED symbol eliminates the -i, -F, -s, and -C switches.
|
||||||
|
# The -DCDT_ONLY switch gets rid of all meshing algorithms above and beyond
|
||||||
|
# constrained Delaunay triangulation. Specifically, defining the CDT_ONLY
|
||||||
|
# symbol eliminates the -r, -q, -a, -S, and -s switches. The REDUCED and
|
||||||
|
# CDT_ONLY symbols may be particularly attractive when Triangle is called
|
||||||
|
# by another program that does not need all of Triangle's features; in
|
||||||
|
# this case, these switches should appear as part of "TRILIBDEFS" below.
|
||||||
|
#
|
||||||
|
# On some systems, you may need to include -I/usr/local/include and/or
|
||||||
|
# -L/usr/local/lib in the compiler options to ensure that the X include
|
||||||
|
# files and libraries that Show Me needs are found. If you get errors
|
||||||
|
# like "Can't find include file X11/Xlib.h", you need the former switch.
|
||||||
|
# Try compiling without them first; add them if that fails.
|
||||||
|
#
|
||||||
|
# An example CSWITCHES line is:
|
||||||
|
#
|
||||||
|
# CSWITCHES = -O -DNO_TIMER -I/usr/local/include -L/usr/local/lib
|
||||||
|
|
||||||
|
CSWITCHES = -O
|
||||||
|
|
||||||
|
# TRILIBDEFS is a list of definitions used to compile an object code version
|
||||||
|
# of Triangle (triangle.o) to be called by another program. The file
|
||||||
|
# "triangle.h" contains detailed information on how to call triangle.o.
|
||||||
|
#
|
||||||
|
# The -DTRILIBRARY should always be used when compiling Triangle into an
|
||||||
|
# object file.
|
||||||
|
#
|
||||||
|
# An example TRILIBDEFS line is:
|
||||||
|
#
|
||||||
|
# TRILIBDEFS = -DTRILIBRARY -DREDUCED -DCDT_ONLY
|
||||||
|
|
||||||
|
TRILIBDEFS = -DTRILIBRARY
|
||||||
|
|
||||||
|
# RM should be set to the name of your favorite rm (file deletion program).
|
||||||
|
|
||||||
|
RM = /bin/rm
|
||||||
|
|
||||||
|
# The action starts here.
|
||||||
|
|
||||||
|
all: $(BIN)triangle $(BIN)showme
|
||||||
|
|
||||||
|
trilibrary: $(BIN)triangle.o $(BIN)tricall
|
||||||
|
|
||||||
|
$(BIN)triangle: $(SRC)triangle.c
|
||||||
|
$(CC) $(CSWITCHES) -o $(BIN)triangle $(SRC)triangle.c -lm
|
||||||
|
|
||||||
|
$(BIN)tricall: $(BIN)tricall.c $(BIN)triangle.o
|
||||||
|
$(CC) $(CSWITCHES) -o $(BIN)tricall $(SRC)tricall.c \
|
||||||
|
$(BIN)triangle.o -lm
|
||||||
|
|
||||||
|
$(BIN)triangle.o: $(SRC)triangle.c $(SRC)triangle.h
|
||||||
|
$(CC) $(CSWITCHES) $(TRILIBDEFS) -c -o $(BIN)triangle.o \
|
||||||
|
$(SRC)triangle.c
|
||||||
|
|
||||||
|
$(BIN)showme: $(SRC)showme.c
|
||||||
|
$(CC) $(CSWITCHES) -o $(BIN)showme $(SRC)showme.c -lX11
|
||||||
|
|
||||||
|
clean: distclean
|
||||||
|
|
||||||
|
distclean:
|
||||||
|
$(RM) $(BIN)triangle $(BIN)triangle.o $(BIN)showme
|
181
Triangle/README
Normal file
181
Triangle/README
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
Triangle
|
||||||
|
A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.
|
||||||
|
Version 1.3
|
||||||
|
|
||||||
|
Show Me
|
||||||
|
A Display Program for Meshes and More.
|
||||||
|
Version 1.3
|
||||||
|
|
||||||
|
Copyright 1996 Jonathan Richard Shewchuk
|
||||||
|
School of Computer Science
|
||||||
|
Carnegie Mellon University
|
||||||
|
5000 Forbes Avenue
|
||||||
|
Pittsburgh, Pennsylvania 15213-3891
|
||||||
|
Please send bugs and comments to jrs@cs.cmu.edu
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
Triangle generates exact Delaunay triangulations, constrained Delaunay
|
||||||
|
triangulations, and quality conforming Delaunay triangulations. The
|
||||||
|
latter can be generated with no small angles, and are thus suitable for
|
||||||
|
finite element analysis. Show Me graphically displays the contents of
|
||||||
|
the geometric files used by Triangle. Show Me can also write images in
|
||||||
|
PostScript form.
|
||||||
|
|
||||||
|
Information on the algorithms used by Triangle, including complete
|
||||||
|
references, can be found in the comments at the beginning of the triangle.c
|
||||||
|
source file. Another listing of these references, with PostScript copies
|
||||||
|
of some of the papers, is available from the Web page
|
||||||
|
|
||||||
|
http://www.cs.cmu.edu/~quake/triangle.research.html
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
These programs may be freely redistributed under the condition that the
|
||||||
|
copyright notices (including the copy of this notice in the code comments
|
||||||
|
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.)
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
The files included in this distribution are:
|
||||||
|
|
||||||
|
README The file you're reading now.
|
||||||
|
triangle.c Complete C source code for Triangle.
|
||||||
|
showme.c Complete C source code for Show Me.
|
||||||
|
triangle.h Include file for calling Triangle from another program.
|
||||||
|
tricall.c Sample program that calls Triangle.
|
||||||
|
makefile Makefile for compiling Triangle and Show Me.
|
||||||
|
A.poly A sample data file.
|
||||||
|
|
||||||
|
Triangle and Show Me are each a single portable C file. The easiest way to
|
||||||
|
compile them is to edit and use the included makefile. Before compiling,
|
||||||
|
read the makefile, which describes your options, and edit it accordingly.
|
||||||
|
You should specify:
|
||||||
|
|
||||||
|
The source and binary directories.
|
||||||
|
|
||||||
|
The C compiler and level of optimization.
|
||||||
|
|
||||||
|
Do you want single precision or double? Do you want to leave out some of
|
||||||
|
Triangle's features to reduce the size of the executable file?
|
||||||
|
|
||||||
|
The "correct" directories for include files (especially X include files),
|
||||||
|
if necessary.
|
||||||
|
|
||||||
|
Once you've done this, type "make" to compile the programs. Alternatively,
|
||||||
|
the files are usually easy to compile without a makefile:
|
||||||
|
|
||||||
|
cc -O -o triangle triangle.c -lm
|
||||||
|
cc -O -o showme showme.c -lX11
|
||||||
|
|
||||||
|
On some systems, the C compiler won't be able to find the X include files
|
||||||
|
or libraries, and you'll need to specify an include path or library path:
|
||||||
|
|
||||||
|
cc -O -I/usr/local/include -o showme showme.c -L/usr/local/lib -lX11
|
||||||
|
|
||||||
|
However, on other systems (like my workstation), the latter incantation
|
||||||
|
will cause the wrong files to be read, and the Show Me mouse buttons won't
|
||||||
|
work properly in the main window. Hence, try the "-I" and "-L" switches
|
||||||
|
ONLY if the compiler fails without it. (If you're using the makefile, you
|
||||||
|
may edit it to add this switch.)
|
||||||
|
|
||||||
|
Some processors, possibly including Intel x86 family and Motorola 68xxx
|
||||||
|
family chips, are IEEE conformant but have extended length internal
|
||||||
|
floating-point registers that may defeat Triangle's exact arithmetic
|
||||||
|
routines by failing to cause enough roundoff error! Typically, there is
|
||||||
|
a way to set these internal registers so that they are rounded off to
|
||||||
|
IEEE single or double precision format. If you have such a processor,
|
||||||
|
you should check your C compiler or system manuals to find out how to
|
||||||
|
configure these internal registers to the precision you are using.
|
||||||
|
Otherwise, the exact arithmetic routines won't be exact at all.
|
||||||
|
Unfortunately, I don't have access to any such systems, and can't give
|
||||||
|
advice on how to configure them. These problems don't occur on any
|
||||||
|
workstations I am aware of. However, Triangle's exact arithmetic hasn't
|
||||||
|
a hope of working on machines like the Cray C90 or Y-MP, which are not
|
||||||
|
IEEE conformant and have inaccurate rounding.
|
||||||
|
|
||||||
|
Triangle and Show Me both produce their own documentation. Complete
|
||||||
|
instructions are printed by invoking each program with the `-h' switch:
|
||||||
|
|
||||||
|
triangle -h
|
||||||
|
showme -h
|
||||||
|
|
||||||
|
The instructions are long; you'll probably want to pipe the output to
|
||||||
|
`more' or `lpr' or redirect it to a file. Both programs give a short list
|
||||||
|
of command line options if they are invoked without arguments (that is,
|
||||||
|
just type `triangle' or `showme'). Alternatively, you may want to read
|
||||||
|
the instructions on the World Wide Web. The appropriate URLs are:
|
||||||
|
|
||||||
|
http://www.cs.cmu.edu/~quake/triangle.html
|
||||||
|
http://www.cs.cmu.edu/~quake/showme.html
|
||||||
|
|
||||||
|
Try out Triangle on the enclosed sample file, A.poly:
|
||||||
|
|
||||||
|
triangle -p A
|
||||||
|
showme A.poly &
|
||||||
|
|
||||||
|
Triangle will read the Planar Straight Line Graph defined by A.poly, and
|
||||||
|
write its constrained Delaunay triangulation to A.1.node and A.1.ele.
|
||||||
|
Show Me will display the figure defined by A.poly. There are two buttons
|
||||||
|
marked "ele" in the Show Me window; click on the top one. This will cause
|
||||||
|
Show Me to load and display the triangulation.
|
||||||
|
|
||||||
|
For contrast, try running
|
||||||
|
|
||||||
|
triangle -pq A
|
||||||
|
|
||||||
|
Now, click on the same "ele" button. A new triangulation will be loaded;
|
||||||
|
this one having no angles smaller than 20 degrees.
|
||||||
|
|
||||||
|
To see a Voronoi diagram, try this:
|
||||||
|
|
||||||
|
cp A.poly A.node
|
||||||
|
triangle -v A
|
||||||
|
|
||||||
|
Click the "ele" button again. You will see the Delaunay triangulation of
|
||||||
|
the points in A.poly, without the segments. Now click the top "voro" button.
|
||||||
|
You will see the Voronoi diagram corresponding to that Delaunay triangulation.
|
||||||
|
Click the "Reset" button to see the full extent of the diagram.
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
If you wish to call Triangle from another program, instructions for doing
|
||||||
|
so are contained in the file `triangle.h' (but read Triangle's regular
|
||||||
|
instructions first!). Also look at `tricall.c', which provides an example.
|
||||||
|
|
||||||
|
Type "make trilibrary" to create triangle.o, a callable object file.
|
||||||
|
Alternatively, the object file is usually easy to compile without a
|
||||||
|
makefile:
|
||||||
|
|
||||||
|
cc -DTRILIBRARY -O -c triangle.c
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
If you use 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 Triangle will mean a lot to
|
||||||
|
me. The more people I know are using this program, the more easily I can
|
||||||
|
justify spending time on improvements and on the three-dimensional
|
||||||
|
successor to Triangle, which in turn will benefit you. Also, I can put
|
||||||
|
you on a list to receive email whenever a new version of Triangle is
|
||||||
|
available.
|
||||||
|
|
||||||
|
If you use a mesh generated by Triangle or plotted by Show Me in a
|
||||||
|
publication, please include an acknowledgment as well.
|
||||||
|
|
||||||
|
|
||||||
|
Jonathan Richard Shewchuk
|
||||||
|
July 20, 1996
|
3
Triangle/depend
Normal file
3
Triangle/depend
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
showme.o: showme.c
|
||||||
|
triangle.o: triangle.c
|
||||||
|
tricall.o: tricall.c triangle.h
|
3384
Triangle/showme.c
Normal file
3384
Triangle/showme.c
Normal file
File diff suppressed because it is too large
Load diff
13232
Triangle/triangle.c
Normal file
13232
Triangle/triangle.c
Normal file
File diff suppressed because it is too large
Load diff
284
Triangle/triangle.h
Normal file
284
Triangle/triangle.h
Normal file
|
@ -0,0 +1,284 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* (triangle.h) */
|
||||||
|
/* */
|
||||||
|
/* Include file for programs that call Triangle. */
|
||||||
|
/* */
|
||||||
|
/* Accompanies Triangle Version 1.3 */
|
||||||
|
/* July 19, 1996 */
|
||||||
|
/* */
|
||||||
|
/* Copyright 1996 */
|
||||||
|
/* Jonathan Richard Shewchuk */
|
||||||
|
/* School of Computer Science */
|
||||||
|
/* Carnegie Mellon University */
|
||||||
|
/* 5000 Forbes Avenue */
|
||||||
|
/* Pittsburgh, Pennsylvania 15213-3891 */
|
||||||
|
/* jrs@cs.cmu.edu */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* How to call Triangle from another program */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* If you haven't read Triangle's instructions (run "triangle -h" to read */
|
||||||
|
/* them), you won't understand what follows. */
|
||||||
|
/* */
|
||||||
|
/* Triangle must be compiled into an object file (triangle.o) with the */
|
||||||
|
/* TRILIBRARY symbol defined (preferably by using the -DTRILIBRARY compiler */
|
||||||
|
/* switch). The makefile included with Triangle will do this for you if */
|
||||||
|
/* you run "make trilibrary". The resulting object file can be called via */
|
||||||
|
/* the procedure triangulate(). */
|
||||||
|
/* */
|
||||||
|
/* If the size of the object file is important to you, you may wish to */
|
||||||
|
/* generate a reduced version of triangle.o. The REDUCED symbol gets rid */
|
||||||
|
/* of all features that are primarily of research interest. Specifically, */
|
||||||
|
/* the -DREDUCED switch eliminates Triangle's -i, -F, -s, and -C switches. */
|
||||||
|
/* The CDT_ONLY symbol gets rid of all meshing algorithms above and beyond */
|
||||||
|
/* constrained Delaunay triangulation. Specifically, the -DCDT_ONLY switch */
|
||||||
|
/* eliminates Triangle's -r, -q, -a, -S, and -s switches. */
|
||||||
|
/* */
|
||||||
|
/* IMPORTANT: These definitions (TRILIBRARY, REDUCED, CDT_ONLY) must be */
|
||||||
|
/* made in the makefile or in triangle.c itself. Putting these definitions */
|
||||||
|
/* in this file will not create the desired effect. */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* The calling convention for triangulate() follows. */
|
||||||
|
/* */
|
||||||
|
/* void triangulate(triswitches, in, out, vorout) */
|
||||||
|
/* char *triswitches; */
|
||||||
|
/* struct triangulateio *in; */
|
||||||
|
/* struct triangulateio *out; */
|
||||||
|
/* struct triangulateio *vorout; */
|
||||||
|
/* */
|
||||||
|
/* `triswitches' is a string containing the command line switches you wish */
|
||||||
|
/* to invoke. No initial dash is required. Some suggestions: */
|
||||||
|
/* */
|
||||||
|
/* - You'll probably find it convenient to use the `z' switch so that */
|
||||||
|
/* points (and other items) are numbered from zero. This simplifies */
|
||||||
|
/* indexing, because the first item of any type always starts at index */
|
||||||
|
/* [0] of the corresponding array, whether that item's number is zero or */
|
||||||
|
/* one. */
|
||||||
|
/* - You'll probably want to use the `Q' (quiet) switch in your final code, */
|
||||||
|
/* but you can take advantage of Triangle's printed output (including the */
|
||||||
|
/* `V' switch) while debugging. */
|
||||||
|
/* - If you are not using the `q' or `a' switches, then the output points */
|
||||||
|
/* will be identical to the input points, except possibly for the */
|
||||||
|
/* boundary markers. If you don't need the boundary markers, you should */
|
||||||
|
/* use the `N' (no nodes output) switch to save memory. (If you do need */
|
||||||
|
/* boundary markers, but need to save memory, a good nasty trick is to */
|
||||||
|
/* set out->pointlist equal to in->pointlist before calling triangulate(),*/
|
||||||
|
/* so that Triangle overwrites the input points with identical copies.) */
|
||||||
|
/* - The `I' (no iteration numbers) and `g' (.off file output) switches */
|
||||||
|
/* have no effect when Triangle is compiled with TRILIBRARY defined. */
|
||||||
|
/* */
|
||||||
|
/* `in', `out', and `vorout' are descriptions of the input, the output, */
|
||||||
|
/* and the Voronoi output. If the `v' (Voronoi output) switch is not used, */
|
||||||
|
/* `vorout' may be NULL. `in' and `out' may never be NULL. */
|
||||||
|
/* */
|
||||||
|
/* Certain fields of the input and output structures must be initialized, */
|
||||||
|
/* as described below. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* The `triangulateio' structure. */
|
||||||
|
/* */
|
||||||
|
/* Used to pass data into and out of the triangulate() procedure. */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* Arrays are used to store points, triangles, markers, and so forth. In */
|
||||||
|
/* all cases, the first item in any array is stored starting at index [0]. */
|
||||||
|
/* However, that item is item number `1' unless the `z' switch is used, in */
|
||||||
|
/* which case it is item number `0'. Hence, you may find it easier to */
|
||||||
|
/* index points (and triangles in the neighbor list) if you use the `z' */
|
||||||
|
/* switch. Unless, of course, you're calling Triangle from a Fortran */
|
||||||
|
/* program. */
|
||||||
|
/* */
|
||||||
|
/* Description of fields (except the `numberof' fields, which are obvious): */
|
||||||
|
/* */
|
||||||
|
/* `pointlist': An array of point coordinates. The first point's x */
|
||||||
|
/* coordinate is at index [0] and its y coordinate at index [1], followed */
|
||||||
|
/* by the coordinates of the remaining points. Each point occupies two */
|
||||||
|
/* REALs. */
|
||||||
|
/* `pointattributelist': An array of point attributes. Each point's */
|
||||||
|
/* attributes occupy `numberofpointattributes' REALs. */
|
||||||
|
/* `pointmarkerlist': An array of point markers; one int per point. */
|
||||||
|
/* */
|
||||||
|
/* `trianglelist': An array of triangle corners. The first triangle's */
|
||||||
|
/* first corner is at index [0], followed by its other two corners in */
|
||||||
|
/* counterclockwise order, followed by any other nodes if the triangle */
|
||||||
|
/* represents a nonlinear element. Each triangle occupies */
|
||||||
|
/* `numberofcorners' ints. */
|
||||||
|
/* `triangleattributelist': An array of triangle attributes. Each */
|
||||||
|
/* triangle's attributes occupy `numberoftriangleattributes' REALs. */
|
||||||
|
/* `trianglearealist': An array of triangle area constraints; one REAL per */
|
||||||
|
/* triangle. Input only. */
|
||||||
|
/* `neighborlist': An array of triangle neighbors; three ints per */
|
||||||
|
/* triangle. Output only. */
|
||||||
|
/* */
|
||||||
|
/* `segmentlist': An array of segment endpoints. The first segment's */
|
||||||
|
/* endpoints are at indices [0] and [1], followed by the remaining */
|
||||||
|
/* segments. Two ints per segment. */
|
||||||
|
/* `segmentmarkerlist': An array of segment markers; one int per segment. */
|
||||||
|
/* */
|
||||||
|
/* `holelist': An array of holes. The first hole's x and y coordinates */
|
||||||
|
/* are at indices [0] and [1], followed by the remaining holes. Two */
|
||||||
|
/* REALs per hole. Input only, although the pointer is copied to the */
|
||||||
|
/* output structure for your convenience. */
|
||||||
|
/* */
|
||||||
|
/* `regionlist': An array of regional attributes and area constraints. */
|
||||||
|
/* The first constraint's x and y coordinates are at indices [0] and [1], */
|
||||||
|
/* followed by the regional attribute and index [2], followed by the */
|
||||||
|
/* maximum area at index [3], followed by the remaining area constraints. */
|
||||||
|
/* Four REALs per area constraint. Note that each regional attribute is */
|
||||||
|
/* used only if you select the `A' switch, and each area constraint is */
|
||||||
|
/* used only if you select the `a' switch (with no number following), but */
|
||||||
|
/* omitting one of these switches does not change the memory layout. */
|
||||||
|
/* Input only, although the pointer is copied to the output structure for */
|
||||||
|
/* your convenience. */
|
||||||
|
/* */
|
||||||
|
/* `edgelist': An array of edge endpoints. The first edge's endpoints are */
|
||||||
|
/* at indices [0] and [1], followed by the remaining edges. Two ints per */
|
||||||
|
/* edge. Output only. */
|
||||||
|
/* `edgemarkerlist': An array of edge markers; one int per edge. Output */
|
||||||
|
/* only. */
|
||||||
|
/* `normlist': An array of normal vectors, used for infinite rays in */
|
||||||
|
/* Voronoi diagrams. The first normal vector's x and y magnitudes are */
|
||||||
|
/* at indices [0] and [1], followed by the remaining vectors. For each */
|
||||||
|
/* finite edge in a Voronoi diagram, the normal vector written is the */
|
||||||
|
/* zero vector. Two REALs per edge. Output only. */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* Any input fields that Triangle will examine must be initialized. */
|
||||||
|
/* Furthermore, for each output array that Triangle will write to, you */
|
||||||
|
/* must either provide space by setting the appropriate pointer to point */
|
||||||
|
/* to the space you want the data written to, or you must initialize the */
|
||||||
|
/* pointer to NULL, which tells Triangle to allocate space for the results. */
|
||||||
|
/* The latter option is preferable, because Triangle always knows exactly */
|
||||||
|
/* how much space to allocate. The former option is provided mainly for */
|
||||||
|
/* people who need to call Triangle from Fortran code, though it also makes */
|
||||||
|
/* possible some nasty space-saving tricks, like writing the output to the */
|
||||||
|
/* same arrays as the input. */
|
||||||
|
/* */
|
||||||
|
/* Triangle will not free() any input or output arrays, including those it */
|
||||||
|
/* allocates itself; that's up to you. */
|
||||||
|
/* */
|
||||||
|
/* Here's a guide to help you decide which fields you must initialize */
|
||||||
|
/* before you call triangulate(). */
|
||||||
|
/* */
|
||||||
|
/* `in': */
|
||||||
|
/* */
|
||||||
|
/* - `pointlist' must always point to a list of points; `numberofpoints' */
|
||||||
|
/* and `numberofpointattributes' must be properly set. */
|
||||||
|
/* `pointmarkerlist' must either be set to NULL (in which case all */
|
||||||
|
/* markers default to zero), or must point to a list of markers. If */
|
||||||
|
/* `numberofpointattributes' is not zero, `pointattributelist' must */
|
||||||
|
/* point to a list of point attributes. */
|
||||||
|
/* - If the `r' switch is used, `trianglelist' must point to a list of */
|
||||||
|
/* triangles, and `numberoftriangles', `numberofcorners', and */
|
||||||
|
/* `numberoftriangleattributes' must be properly set. If */
|
||||||
|
/* `numberoftriangleattributes' is not zero, `triangleattributelist' */
|
||||||
|
/* must point to a list of triangle attributes. If the `a' switch is */
|
||||||
|
/* used (with no number following), `trianglearealist' must point to a */
|
||||||
|
/* list of triangle area constraints. `neighborlist' may be ignored. */
|
||||||
|
/* - If the `p' switch is used, `segmentlist' must point to a list of */
|
||||||
|
/* segments, `numberofsegments' must be properly set, and */
|
||||||
|
/* `segmentmarkerlist' must either be set to NULL (in which case all */
|
||||||
|
/* markers default to zero), or must point to a list of markers. */
|
||||||
|
/* - If the `p' switch is used without the `r' switch, then */
|
||||||
|
/* `numberofholes' and `numberofregions' must be properly set. If */
|
||||||
|
/* `numberofholes' is not zero, `holelist' must point to a list of */
|
||||||
|
/* holes. If `numberofregions' is not zero, `regionlist' must point to */
|
||||||
|
/* a list of region constraints. */
|
||||||
|
/* - If the `p' switch is used, `holelist', `numberofholes', */
|
||||||
|
/* `regionlist', and `numberofregions' is copied to `out'. (You can */
|
||||||
|
/* nonetheless get away with not initializing them if the `r' switch is */
|
||||||
|
/* used.) */
|
||||||
|
/* - `edgelist', `edgemarkerlist', `normlist', and `numberofedges' may be */
|
||||||
|
/* ignored. */
|
||||||
|
/* */
|
||||||
|
/* `out': */
|
||||||
|
/* */
|
||||||
|
/* - `pointlist' must be initialized (NULL or pointing to memory) unless */
|
||||||
|
/* the `N' switch is used. `pointmarkerlist' must be initialized */
|
||||||
|
/* unless the `N' or `B' switch is used. If `N' is not used and */
|
||||||
|
/* `in->numberofpointattributes' is not zero, `pointattributelist' must */
|
||||||
|
/* be initialized. */
|
||||||
|
/* - `trianglelist' must be initialized unless the `E' switch is used. */
|
||||||
|
/* `neighborlist' must be initialized if the `n' switch is used. If */
|
||||||
|
/* the `E' switch is not used and (`in->numberofelementattributes' is */
|
||||||
|
/* not zero or the `A' switch is used), `elementattributelist' must be */
|
||||||
|
/* initialized. `trianglearealist' may be ignored. */
|
||||||
|
/* - `segmentlist' must be initialized if the `p' or `c' switch is used, */
|
||||||
|
/* and the `P' switch is not used. `segmentmarkerlist' must also be */
|
||||||
|
/* initialized under these circumstances unless the `B' switch is used. */
|
||||||
|
/* - `edgelist' must be initialized if the `e' switch is used. */
|
||||||
|
/* `edgemarkerlist' must be initialized if the `e' switch is used and */
|
||||||
|
/* the `B' switch is not. */
|
||||||
|
/* - `holelist', `regionlist', `normlist', and all scalars may be ignored.*/
|
||||||
|
/* */
|
||||||
|
/* `vorout' (only needed if `v' switch is used): */
|
||||||
|
/* */
|
||||||
|
/* - `pointlist' must be initialized. If `in->numberofpointattributes' */
|
||||||
|
/* is not zero, `pointattributelist' must be initialized. */
|
||||||
|
/* `pointmarkerlist' may be ignored. */
|
||||||
|
/* - `edgelist' and `normlist' must both be initialized. */
|
||||||
|
/* `edgemarkerlist' may be ignored. */
|
||||||
|
/* - Everything else may be ignored. */
|
||||||
|
/* */
|
||||||
|
/* After a call to triangulate(), the valid fields of `out' and `vorout' */
|
||||||
|
/* will depend, in an obvious way, on the choice of switches used. Note */
|
||||||
|
/* that when the `p' switch is used, the pointers `holelist' and */
|
||||||
|
/* `regionlist' are copied from `in' to `out', but no new space is */
|
||||||
|
/* allocated; be careful that you don't free() the same array twice. On */
|
||||||
|
/* the other hand, Triangle will never copy the `pointlist' pointer (or any */
|
||||||
|
/* others); new space is allocated for `out->pointlist', or if the `N' */
|
||||||
|
/* switch is used, `out->pointlist' remains uninitialized. */
|
||||||
|
/* */
|
||||||
|
/* All of the meaningful `numberof' fields will be properly set; for */
|
||||||
|
/* instance, `numberofedges' will represent the number of edges in the */
|
||||||
|
/* triangulation whether or not the edges were written. If segments are */
|
||||||
|
/* not used, `numberofsegments' will indicate the number of boundary edges. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
struct triangulateio {
|
||||||
|
REAL *pointlist; /* In / out */
|
||||||
|
REAL *pointattributelist; /* In / out */
|
||||||
|
int *pointmarkerlist; /* In / out */
|
||||||
|
int numberofpoints; /* In / out */
|
||||||
|
int numberofpointattributes; /* In / out */
|
||||||
|
|
||||||
|
int *trianglelist; /* In / out */
|
||||||
|
REAL *triangleattributelist; /* In / out */
|
||||||
|
REAL *trianglearealist; /* In only */
|
||||||
|
int *neighborlist; /* Out only */
|
||||||
|
int numberoftriangles; /* In / out */
|
||||||
|
int numberofcorners; /* In / out */
|
||||||
|
int numberoftriangleattributes; /* In / out */
|
||||||
|
|
||||||
|
int *segmentlist; /* In / out */
|
||||||
|
int *segmentmarkerlist; /* In / out */
|
||||||
|
int numberofsegments; /* In / out */
|
||||||
|
|
||||||
|
REAL *holelist; /* In / pointer to array copied out */
|
||||||
|
int numberofholes; /* In / copied out */
|
||||||
|
|
||||||
|
REAL *regionlist; /* In / pointer to array copied out */
|
||||||
|
int numberofregions; /* In / copied out */
|
||||||
|
|
||||||
|
int *edgelist; /* Out only */
|
||||||
|
int *edgemarkerlist; /* Not used with Voronoi diagram; out only */
|
||||||
|
REAL *normlist; /* Used only with Voronoi diagram; out only */
|
||||||
|
int numberofedges; /* Out only */
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef ANSI_DECLARATORS
|
||||||
|
void triangulate(char *, struct triangulateio *, struct triangulateio *,
|
||||||
|
struct triangulateio *);
|
||||||
|
#else /* not ANSI_DECLARATORS */
|
||||||
|
void triangulate();
|
||||||
|
#endif /* not ANSI_DECLARATORS */
|
279
Triangle/tricall.c
Normal file
279
Triangle/tricall.c
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* (tricall.c) */
|
||||||
|
/* */
|
||||||
|
/* Example program that demonstrates how to call Triangle. */
|
||||||
|
/* */
|
||||||
|
/* Accompanies Triangle Version 1.3 */
|
||||||
|
/* July 19, 1996 */
|
||||||
|
/* */
|
||||||
|
/* This file is placed in the public domain (but the file that it calls */
|
||||||
|
/* is still copyrighted!) by */
|
||||||
|
/* Jonathan Richard Shewchuk */
|
||||||
|
/* School of Computer Science */
|
||||||
|
/* Carnegie Mellon University */
|
||||||
|
/* 5000 Forbes Avenue */
|
||||||
|
/* Pittsburgh, Pennsylvania 15213-3891 */
|
||||||
|
/* jrs@cs.cmu.edu */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* If SINGLE is defined when triangle.o is compiled, it should also be */
|
||||||
|
/* defined here. If not, it should not be defined here. */
|
||||||
|
|
||||||
|
/* #define SINGLE */
|
||||||
|
|
||||||
|
#ifdef SINGLE
|
||||||
|
#define REAL float
|
||||||
|
#else /* not SINGLE */
|
||||||
|
#define REAL double
|
||||||
|
#endif /* not SINGLE */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "triangle.h"
|
||||||
|
|
||||||
|
#ifndef _STDLIB_H_
|
||||||
|
extern void *malloc();
|
||||||
|
extern void free();
|
||||||
|
#endif /* _STDLIB_H_ */
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* report() Print the input or output. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void report(io, markers, reporttriangles, reportneighbors, reportsegments,
|
||||||
|
reportedges, reportnorms)
|
||||||
|
struct triangulateio *io;
|
||||||
|
int markers;
|
||||||
|
int reporttriangles;
|
||||||
|
int reportneighbors;
|
||||||
|
int reportsegments;
|
||||||
|
int reportedges;
|
||||||
|
int reportnorms;
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < io->numberofpoints; i++) {
|
||||||
|
printf("Point %4d:", i);
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
printf(" %.6g", io->pointlist[i * 2 + j]);
|
||||||
|
}
|
||||||
|
if (io->numberofpointattributes > 0) {
|
||||||
|
printf(" attributes");
|
||||||
|
}
|
||||||
|
for (j = 0; j < io->numberofpointattributes; j++) {
|
||||||
|
printf(" %.6g",
|
||||||
|
io->pointattributelist[i * io->numberofpointattributes + j]);
|
||||||
|
}
|
||||||
|
if (markers) {
|
||||||
|
printf(" marker %d\n", io->pointmarkerlist[i]);
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
if (reporttriangles || reportneighbors) {
|
||||||
|
for (i = 0; i < io->numberoftriangles; i++) {
|
||||||
|
if (reporttriangles) {
|
||||||
|
printf("Triangle %4d points:", i);
|
||||||
|
for (j = 0; j < io->numberofcorners; j++) {
|
||||||
|
printf(" %4d", io->trianglelist[i * io->numberofcorners + j]);
|
||||||
|
}
|
||||||
|
if (io->numberoftriangleattributes > 0) {
|
||||||
|
printf(" attributes");
|
||||||
|
}
|
||||||
|
for (j = 0; j < io->numberoftriangleattributes; j++) {
|
||||||
|
printf(" %.6g", io->triangleattributelist[i *
|
||||||
|
io->numberoftriangleattributes + j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
if (reportneighbors) {
|
||||||
|
printf("Triangle %4d neighbors:", i);
|
||||||
|
for (j = 0; j < 3; j++) {
|
||||||
|
printf(" %4d", io->neighborlist[i * 3 + j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportsegments) {
|
||||||
|
for (i = 0; i < io->numberofsegments; i++) {
|
||||||
|
printf("Segment %4d points:", i);
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
printf(" %4d", io->segmentlist[i * 2 + j]);
|
||||||
|
}
|
||||||
|
if (markers) {
|
||||||
|
printf(" marker %d\n", io->segmentmarkerlist[i]);
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportedges) {
|
||||||
|
for (i = 0; i < io->numberofedges; i++) {
|
||||||
|
printf("Edge %4d points:", i);
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
printf(" %4d", io->edgelist[i * 2 + j]);
|
||||||
|
}
|
||||||
|
if (reportnorms && (io->edgelist[i * 2 + 1] == -1)) {
|
||||||
|
for (j = 0; j < 2; j++) {
|
||||||
|
printf(" %.6g", io->normlist[i * 2 + j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (markers) {
|
||||||
|
printf(" marker %d\n", io->edgemarkerlist[i]);
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* main() Create and refine a mesh. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
struct triangulateio in, mid, out, vorout;
|
||||||
|
|
||||||
|
/* Define input points. */
|
||||||
|
|
||||||
|
in.numberofpoints = 4;
|
||||||
|
in.numberofpointattributes = 1;
|
||||||
|
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
|
||||||
|
in.pointlist[0] = 0.0;
|
||||||
|
in.pointlist[1] = 0.0;
|
||||||
|
in.pointlist[2] = 1.0;
|
||||||
|
in.pointlist[3] = 0.0;
|
||||||
|
in.pointlist[4] = 1.0;
|
||||||
|
in.pointlist[5] = 10.0;
|
||||||
|
in.pointlist[6] = 0.0;
|
||||||
|
in.pointlist[7] = 10.0;
|
||||||
|
in.pointattributelist = (REAL *) malloc(in.numberofpoints *
|
||||||
|
in.numberofpointattributes *
|
||||||
|
sizeof(REAL));
|
||||||
|
in.pointattributelist[0] = 0.0;
|
||||||
|
in.pointattributelist[1] = 1.0;
|
||||||
|
in.pointattributelist[2] = 11.0;
|
||||||
|
in.pointattributelist[3] = 10.0;
|
||||||
|
in.pointmarkerlist = (int *) malloc(in.numberofpoints * sizeof(int));
|
||||||
|
in.pointmarkerlist[0] = 0;
|
||||||
|
in.pointmarkerlist[1] = 2;
|
||||||
|
in.pointmarkerlist[2] = 0;
|
||||||
|
in.pointmarkerlist[3] = 0;
|
||||||
|
|
||||||
|
in.numberofsegments = 0;
|
||||||
|
in.numberofholes = 0;
|
||||||
|
in.numberofregions = 1;
|
||||||
|
in.regionlist = (REAL *) malloc(in.numberofregions * 4 * sizeof(REAL));
|
||||||
|
in.regionlist[0] = 0.5;
|
||||||
|
in.regionlist[1] = 5.0;
|
||||||
|
in.regionlist[2] = 7.0; /* Regional attribute (for whole mesh). */
|
||||||
|
in.regionlist[3] = 0.1; /* Area constraint that will not be used. */
|
||||||
|
|
||||||
|
printf("Input point set:\n\n");
|
||||||
|
report(&in, 1, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
/* Make necessary initializations so that Triangle can return a */
|
||||||
|
/* triangulation in `mid' and a voronoi diagram in `vorout'. */
|
||||||
|
|
||||||
|
mid.pointlist = (REAL *) NULL; /* Not needed if -N switch used. */
|
||||||
|
/* Not needed if -N switch used or number of point attributes is zero: */
|
||||||
|
mid.pointattributelist = (REAL *) NULL;
|
||||||
|
mid.pointmarkerlist = (int *) NULL; /* Not needed if -N or -B switch used. */
|
||||||
|
mid.trianglelist = (int *) NULL; /* Not needed if -E switch used. */
|
||||||
|
/* Not needed if -E switch used or number of triangle attributes is zero: */
|
||||||
|
mid.triangleattributelist = (REAL *) NULL;
|
||||||
|
mid.neighborlist = (int *) NULL; /* Needed only if -n switch used. */
|
||||||
|
/* Needed only if segments are output (-p or -c) and -P not used: */
|
||||||
|
mid.segmentlist = (int *) NULL;
|
||||||
|
/* Needed only if segments are output (-p or -c) and -P and -B not used: */
|
||||||
|
mid.segmentmarkerlist = (int *) NULL;
|
||||||
|
mid.edgelist = (int *) NULL; /* Needed only if -e switch used. */
|
||||||
|
mid.edgemarkerlist = (int *) NULL; /* Needed if -e used and -B not used. */
|
||||||
|
|
||||||
|
vorout.pointlist = (REAL *) NULL; /* Needed only if -v switch used. */
|
||||||
|
/* Needed only if -v switch used and number of attributes is not zero: */
|
||||||
|
vorout.pointattributelist = (REAL *) NULL;
|
||||||
|
vorout.edgelist = (int *) NULL; /* Needed only if -v switch used. */
|
||||||
|
vorout.normlist = (REAL *) NULL; /* Needed only if -v switch used. */
|
||||||
|
|
||||||
|
/* Triangulate the points. Switches are chosen to read and write a */
|
||||||
|
/* PSLG (p), preserve the convex hull (c), number everything from */
|
||||||
|
/* zero (z), assign a regional attribute to each element (A), and */
|
||||||
|
/* produce an edge list (e), a Voronoi diagram (v), and a triangle */
|
||||||
|
/* neighbor list (n). */
|
||||||
|
|
||||||
|
triangulate("pczAevn", &in, &mid, &vorout);
|
||||||
|
|
||||||
|
printf("Initial triangulation:\n\n");
|
||||||
|
report(&mid, 1, 1, 1, 1, 1, 0);
|
||||||
|
printf("Initial Voronoi diagram:\n\n");
|
||||||
|
report(&vorout, 0, 0, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
/* Attach area constraints to the triangles in preparation for */
|
||||||
|
/* refining the triangulation. */
|
||||||
|
|
||||||
|
/* Needed only if -r and -a switches used: */
|
||||||
|
mid.trianglearealist = (REAL *) malloc(mid.numberoftriangles * sizeof(REAL));
|
||||||
|
mid.trianglearealist[0] = 3.0;
|
||||||
|
mid.trianglearealist[1] = 1.0;
|
||||||
|
|
||||||
|
/* Make necessary initializations so that Triangle can return a */
|
||||||
|
/* triangulation in `out'. */
|
||||||
|
|
||||||
|
out.pointlist = (REAL *) NULL; /* Not needed if -N switch used. */
|
||||||
|
/* Not needed if -N switch used or number of attributes is zero: */
|
||||||
|
out.pointattributelist = (REAL *) NULL;
|
||||||
|
out.trianglelist = (int *) NULL; /* Not needed if -E switch used. */
|
||||||
|
/* Not needed if -E switch used or number of triangle attributes is zero: */
|
||||||
|
out.triangleattributelist = (REAL *) NULL;
|
||||||
|
|
||||||
|
/* Refine the triangulation according to the attached */
|
||||||
|
/* triangle area constraints. */
|
||||||
|
|
||||||
|
triangulate("prazBP", &mid, &out, (struct triangulateio *) NULL);
|
||||||
|
|
||||||
|
printf("Refined triangulation:\n\n");
|
||||||
|
report(&out, 0, 1, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
/* Free all allocated arrays, including those allocated by Triangle. */
|
||||||
|
|
||||||
|
free(in.pointlist);
|
||||||
|
free(in.pointattributelist);
|
||||||
|
free(in.pointmarkerlist);
|
||||||
|
free(in.regionlist);
|
||||||
|
free(mid.pointlist);
|
||||||
|
free(mid.pointattributelist);
|
||||||
|
free(mid.pointmarkerlist);
|
||||||
|
free(mid.trianglelist);
|
||||||
|
free(mid.triangleattributelist);
|
||||||
|
free(mid.trianglearealist);
|
||||||
|
free(mid.neighborlist);
|
||||||
|
free(mid.segmentlist);
|
||||||
|
free(mid.segmentmarkerlist);
|
||||||
|
free(mid.edgelist);
|
||||||
|
free(mid.edgemarkerlist);
|
||||||
|
free(vorout.pointlist);
|
||||||
|
free(vorout.pointattributelist);
|
||||||
|
free(vorout.edgelist);
|
||||||
|
free(vorout.normlist);
|
||||||
|
free(out.pointlist);
|
||||||
|
free(out.pointattributelist);
|
||||||
|
free(out.trianglelist);
|
||||||
|
free(out.triangleattributelist);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue