Remove TriangleJRS. All tesselation is now done by CGAL.
This commit is contained in:
parent
65bcb00dee
commit
c016041337
23 changed files with 8 additions and 17998 deletions
9
README
9
README
|
@ -21,15 +21,6 @@ smaller chunks is much more doable though.
|
|||
Building the Tools
|
||||
==================
|
||||
|
||||
IMPORTANT: if you are compiling with gcc, I recommend that you compile
|
||||
the /Libs/TriangleJRS code without optimization (-O2). Optimization can
|
||||
lead to problems for some tiles. (Different numerical stability properties
|
||||
in the optimized code????) Usually I will go and remove the -O2 option (twice)
|
||||
from the Makefile after it has been generated from the Makefile.am file. Be
|
||||
warned that any time you change the Makefile.am, or rerun autogen.sh or
|
||||
configure, you will have to go back and fix this particular Makefile.
|
||||
|
||||
|
||||
These tools are primarily compiled and tested under Unix with the Gnu
|
||||
C/C++ compilers. I believe they also build and run on windows with
|
||||
Cygwin. If anyone has patches for supporting other platforms, I will
|
||||
|
|
|
@ -1146,70 +1146,6 @@ SOURCE=.\src\Lib\shapelib\shapefil.h
|
|||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Lib_TriangleJRS"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Lib\TriangleJRS\triangle.c
|
||||
|
||||
!IF "$(CFG)" == "TerraGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_TriangleJRS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "TerraGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_TriangleJRS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Lib\TriangleJRS\triangle.h
|
||||
|
||||
!IF "$(CFG)" == "TerraGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_TriangleJRS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "TerraGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_TriangleJRS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Lib\TriangleJRS\tri_support.c
|
||||
|
||||
!IF "$(CFG)" == "TerraGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_TriangleJRS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "TerraGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_TriangleJRS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\Lib\TriangleJRS\tri_support.h
|
||||
|
||||
!IF "$(CFG)" == "TerraGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_TriangleJRS"
|
||||
|
||||
!ELSEIF "$(CFG)" == "TerraGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_TriangleJRS"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Lib_vpf"
|
||||
|
|
|
@ -21,7 +21,6 @@ add_executable(genapts
|
|||
target_link_libraries(genapts
|
||||
Polygon Geometry
|
||||
Array Output poly2tri
|
||||
TriangleJRS
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
${GDAL_LIBRARY}
|
||||
|
|
|
@ -26,7 +26,6 @@ add_executable(genapts850
|
|||
target_link_libraries(genapts850
|
||||
Polygon Geometry
|
||||
Array Output poly2tri
|
||||
TriangleJRS
|
||||
${POCO_FOUNDATION}
|
||||
${POCO_NET}
|
||||
${GDAL_LIBRARY}
|
||||
|
|
|
@ -15,7 +15,6 @@ target_link_libraries(tg-construct
|
|||
Match
|
||||
Polygon Geometry
|
||||
Array landcover poly2tri
|
||||
TriangleJRS
|
||||
${GDAL_LIBRARY}
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
|
|
|
@ -6,10 +6,8 @@ add_subdirectory(Geometry)
|
|||
add_subdirectory(HGT)
|
||||
add_subdirectory(Output)
|
||||
add_subdirectory(Polygon)
|
||||
add_subdirectory(TriangleJRS)
|
||||
add_subdirectory(e00)
|
||||
add_subdirectory(landcover)
|
||||
add_subdirectory(poly2tri)
|
||||
add_subdirectory(shapelib)
|
||||
add_subdirectory(vpf)
|
||||
|
||||
|
|
|
@ -38,12 +38,6 @@
|
|||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#define REAL double
|
||||
extern "C" {
|
||||
#include <TriangleJRS/triangle.h>
|
||||
}
|
||||
#include <TriangleJRS/tri_support.h>
|
||||
|
||||
#include "contour_tree.hxx"
|
||||
#include "poly_support.hxx"
|
||||
#include "trinodes.hxx"
|
||||
|
@ -114,341 +108,6 @@ static bool intersects( Point3D p0, Point3D p1, double x, Point3D *result ) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// basic triangulation of a polygon with out adding points or
|
||||
// splitting edges, this should triangulate around interior holes.
|
||||
int polygon_tesselate( const TGPolygon &p,
|
||||
const point_list &extra_nodes,
|
||||
triele_list &elelist,
|
||||
point_list &out_pts,
|
||||
string tri_flags )
|
||||
{
|
||||
struct triangulateio in, out, vorout;
|
||||
int i;
|
||||
int success = 0;
|
||||
|
||||
// make sure all elements of these structs point to "NULL"
|
||||
zero_triangulateio( &in );
|
||||
zero_triangulateio( &out );
|
||||
zero_triangulateio( &vorout );
|
||||
|
||||
int counter, start, end;
|
||||
|
||||
// list of points
|
||||
double max_x = p.get_pt(0,0).x();
|
||||
|
||||
int total_pts = 0;
|
||||
int total_segments = 0;
|
||||
|
||||
for ( i = 0; i < p.contours(); ++i ) {
|
||||
total_pts += p.contour_size( i );
|
||||
}
|
||||
total_segments = total_pts;
|
||||
total_pts += extra_nodes.size();
|
||||
|
||||
in.numberofpoints = total_pts;
|
||||
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
|
||||
|
||||
counter = 0;
|
||||
for ( i = 0; i < p.contours(); ++i ) {
|
||||
point_list contour = p.get_contour( i );
|
||||
for ( int j = 0; j < (int)contour.size(); ++j ) {
|
||||
in.pointlist[2*counter] = contour[j].x();
|
||||
in.pointlist[2*counter + 1] = contour[j].y();
|
||||
/* remember largest x value of the polygon to
|
||||
* easily calc outside point
|
||||
*/
|
||||
if ( contour[j].x() > max_x ) {
|
||||
max_x = contour[j].x();
|
||||
}
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < (int)extra_nodes.size(); ++i ) {
|
||||
in.pointlist[2*counter] = extra_nodes[i].x();
|
||||
in.pointlist[2*counter + 1] = extra_nodes[i].y();
|
||||
++counter;
|
||||
}
|
||||
|
||||
/* set the node attribute to elevation data */
|
||||
in.numberofpointattributes = 1;
|
||||
in.pointattributelist = (REAL *) malloc(in.numberofpoints *
|
||||
in.numberofpointattributes *
|
||||
sizeof(REAL));
|
||||
counter = 0;
|
||||
for ( i = 0; i < p.contours(); ++i ) {
|
||||
point_list contour = p.get_contour( i );
|
||||
for ( int j = 0; j < (int)contour.size(); ++j ) {
|
||||
in.pointattributelist[counter] = contour[j].z();
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0; i < (int)extra_nodes.size(); ++i ) {
|
||||
in.pointattributelist[counter] = extra_nodes[i].z();
|
||||
++counter;
|
||||
}
|
||||
|
||||
in.pointmarkerlist = NULL;
|
||||
|
||||
// segment list
|
||||
in.numberofsegments = total_segments;
|
||||
in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int));
|
||||
counter = 0;
|
||||
start = 0;
|
||||
end = -1;
|
||||
|
||||
for ( i = 0; i < p.contours(); ++i ) {
|
||||
point_list contour = p.get_contour( i );
|
||||
start = end + 1;
|
||||
end = start + contour.size() - 1;
|
||||
for ( int j = 0; j < (int)contour.size() - 1; ++j ) {
|
||||
in.segmentlist[counter++] = j + start;
|
||||
in.segmentlist[counter++] = j + start + 1;
|
||||
}
|
||||
in.segmentlist[counter++] = end;
|
||||
in.segmentlist[counter++] = start;
|
||||
}
|
||||
|
||||
in.segmentmarkerlist = (int *) malloc(in.numberofsegments * sizeof(int));
|
||||
for ( i = 0; i < in.numberofsegments; ++i ) {
|
||||
in.segmentmarkerlist[i] = 0;
|
||||
}
|
||||
|
||||
// hole list
|
||||
in.numberofholes = 1;
|
||||
for ( i = 0; i < p.contours(); ++i ) {
|
||||
if ( p.get_hole_flag( i ) ) {
|
||||
++in.numberofholes;
|
||||
}
|
||||
}
|
||||
in.holelist = (REAL *) malloc(in.numberofholes * 2 * sizeof(REAL));
|
||||
|
||||
// outside of polygon
|
||||
counter = 0;
|
||||
in.holelist[counter++] = max_x + 1.0;
|
||||
in.holelist[counter++] = 0.0;
|
||||
|
||||
for ( i = 0; i < (int)p.contours(); ++i ) {
|
||||
if ( p.get_hole_flag( i ) ) {
|
||||
in.holelist[counter++] = p.get_point_inside(i).x();
|
||||
in.holelist[counter++] = p.get_point_inside(i).y();
|
||||
}
|
||||
}
|
||||
|
||||
// region list
|
||||
in.numberofregions = 0;
|
||||
in.regionlist = NULL;
|
||||
|
||||
// no triangle list
|
||||
in.numberoftriangles = 0;
|
||||
in.numberofcorners = 0;
|
||||
in.numberoftriangleattributes = 0;
|
||||
in.trianglelist = NULL;
|
||||
in.triangleattributelist = NULL;
|
||||
in.trianglearealist = NULL;
|
||||
in.neighborlist = NULL;
|
||||
|
||||
// no edge list
|
||||
in.numberofedges = 0;
|
||||
in.edgelist = NULL;
|
||||
in.edgemarkerlist = NULL;
|
||||
in.normlist = NULL;
|
||||
|
||||
// dump the results to screen
|
||||
// print_tri_data( &in );
|
||||
|
||||
// TEMPORARY
|
||||
// write_tri_data(&in);
|
||||
/* cout << "Press return to continue:";
|
||||
char junk;
|
||||
cin >> junk; */
|
||||
|
||||
// Triangulate the points. Switches are chosen to read and write
|
||||
// a PSLG (p), number everything from zero (z), and produce an
|
||||
// edge list (e), and a triangle neighbor list (n).
|
||||
// no new points on boundary (Y), no internal segment
|
||||
// splitting (YY), no quality refinement (q)
|
||||
// Quite (Q)
|
||||
success = triangulate( (char *)tri_flags.c_str(), &in, &out, &vorout );
|
||||
|
||||
// TEMPORARY
|
||||
// write_tri_data(&out);
|
||||
|
||||
// now copy the results back into the corresponding TGTriangle
|
||||
// structures
|
||||
|
||||
if (success >= 0) {
|
||||
|
||||
// triangles
|
||||
elelist.clear();
|
||||
int n1, n2, n3;
|
||||
double attribute;
|
||||
for ( i = 0; i < out.numberoftriangles; ++i ) {
|
||||
n1 = out.trianglelist[i * 3];
|
||||
n2 = out.trianglelist[i * 3 + 1];
|
||||
n3 = out.trianglelist[i * 3 + 2];
|
||||
if ( out.numberoftriangleattributes > 0 ) {
|
||||
attribute = out.triangleattributelist[i];
|
||||
} else {
|
||||
attribute = 0.0;
|
||||
}
|
||||
// cout << "triangle = " << n1 << " " << n2 << " " << n3 << endl;
|
||||
elelist.push_back( TGTriEle( n1, n2, n3, attribute ) );
|
||||
}
|
||||
|
||||
// output points
|
||||
out_pts.clear();
|
||||
double x, y, z;
|
||||
for ( i = 0; i < out.numberofpoints; ++i ) {
|
||||
x = out.pointlist[i * 2 ];
|
||||
y = out.pointlist[i * 2 + 1];
|
||||
z = out.pointattributelist[i];
|
||||
out_pts.push_back( Point3D(x, y, z) );
|
||||
}
|
||||
}
|
||||
|
||||
// free mem allocated to the "Triangle" structures
|
||||
free(in.pointlist);
|
||||
free(in.pointattributelist);
|
||||
free(in.pointmarkerlist);
|
||||
free(in.segmentlist);
|
||||
free(in.segmentmarkerlist);
|
||||
free(in.holelist);
|
||||
free(in.regionlist);
|
||||
free(out.pointlist);
|
||||
free(out.pointattributelist);
|
||||
free(out.pointmarkerlist);
|
||||
free(out.trianglelist);
|
||||
free(out.triangleattributelist);
|
||||
// free(out.trianglearealist);
|
||||
free(out.neighborlist);
|
||||
free(out.segmentlist);
|
||||
free(out.segmentmarkerlist);
|
||||
free(out.edgelist);
|
||||
free(out.edgemarkerlist);
|
||||
free(vorout.pointlist);
|
||||
free(vorout.pointattributelist);
|
||||
free(vorout.edgelist);
|
||||
free(vorout.normlist);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
// Alternate basic triangulation of a polygon with out adding points
|
||||
// or splitting edges and without regard for holes. Returns a polygon
|
||||
// with one contour per tesselated triangle. This is mostly just a
|
||||
// wrapper for the polygon_tesselate() function. Note, this routine
|
||||
// will modify the points_inside list for your polygon.
|
||||
|
||||
TGPolygon polygon_tesselate_alt( TGPolygon &p, bool verbose ) {
|
||||
TGPolygon result;
|
||||
point_list extra_nodes;
|
||||
result.erase();
|
||||
int i;
|
||||
|
||||
// Bail right away if polygon is empty
|
||||
if ( p.contours() == 0 ) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 1. Robustly find a point inside each contour that is not
|
||||
// inside any other contour
|
||||
calc_points_inside( p );
|
||||
|
||||
// 2. Do a final triangulation of the entire polygon
|
||||
triele_list trieles;
|
||||
point_list nodes;
|
||||
string flags;
|
||||
if (verbose) {
|
||||
flags = "pzenXYY";
|
||||
// flags = "pzqenXY"; // allow adding interior points
|
||||
} else {
|
||||
flags = "pzenXYYQ";
|
||||
// flags = "pzqenXYQ"; // allow adding interior points
|
||||
}
|
||||
|
||||
// check the input for nan point
|
||||
for (int c = 0; c < p.contours(); c++) {
|
||||
point_list contour = p.get_contour( c );
|
||||
for ( int d = 0; d < (int)contour.size(); ++d ) {
|
||||
if ( isnan( contour[d].x() ) || isnan( contour[d].y() ) ) {
|
||||
printf("Uh-oh - got nan before tesselation\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( polygon_tesselate( p, extra_nodes, trieles, nodes, flags ) >= 0 ) {
|
||||
// 3. Convert the tesselated output to a list of tringles.
|
||||
// basically a polygon with a contour for every triangle
|
||||
for ( i = 0; i < (int)trieles.size(); ++i ) {
|
||||
TGTriEle t = trieles[i];
|
||||
Point3D p1 = nodes[ t.get_n1() ];
|
||||
Point3D p2 = nodes[ t.get_n2() ];
|
||||
Point3D p3 = nodes[ t.get_n3() ];
|
||||
result.add_node( i, p1 );
|
||||
result.add_node( i, p2 );
|
||||
result.add_node( i, p3 );
|
||||
}
|
||||
}
|
||||
|
||||
// check the result for nan point
|
||||
for (int c = 0; c < result.contours(); c++) {
|
||||
point_list contour = result.get_contour( c );
|
||||
for ( int d = 0; d < (int)contour.size(); ++d ) {
|
||||
if ( isnan( contour[d].x() ) || isnan( contour[d].y() ) ) {
|
||||
printf("Uh-oh - got nan from tesselation\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TGPolygon polygon_tesselate_alt_with_extra( TGPolygon &p, const point_list& extra_nodes, bool verbose ) {
|
||||
TGPolygon result;
|
||||
result.erase();
|
||||
int i;
|
||||
|
||||
// Bail right away if polygon is empty
|
||||
if ( p.contours() == 0 ) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// 1. Robustly find a point inside each contour that is not
|
||||
// inside any other contour
|
||||
calc_points_inside( p );
|
||||
for ( i = 0; i < p.contours(); ++i );
|
||||
|
||||
// 2. Do a final triangulation of the entire polygon
|
||||
triele_list trieles;
|
||||
point_list nodes;
|
||||
string flags;
|
||||
if (verbose) {
|
||||
flags = "VVpzenXYY";
|
||||
} else {
|
||||
flags = "pzenXYYQ";
|
||||
}
|
||||
|
||||
if ( polygon_tesselate( p, extra_nodes, trieles, nodes, flags ) >= 0 ) {
|
||||
// 3. Convert the tesselated output to a list of tringles.
|
||||
// basically a polygon with a contour for every triangle
|
||||
for ( i = 0; i < (int)trieles.size(); ++i ) {
|
||||
TGTriEle t = trieles[i];
|
||||
Point3D p1 = nodes[ t.get_n1() ];
|
||||
Point3D p2 = nodes[ t.get_n2() ];
|
||||
Point3D p3 = nodes[ t.get_n3() ];
|
||||
result.add_node( i, p1 );
|
||||
result.add_node( i, p2 );
|
||||
result.add_node( i, p3 );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find all intersections of the given contour with the x-parallel line at
|
||||
|
|
|
@ -51,24 +51,9 @@ inline double triangle_area( const Point3D p1,
|
|||
}
|
||||
|
||||
|
||||
// basic triangulation of a polygon with out adding points or
|
||||
// splitting edges
|
||||
int polygon_tesselate( const TGPolygon &p,
|
||||
const point_list &extra_nodes,
|
||||
triele_list &elelist,
|
||||
point_list &out_pts,
|
||||
std::string flags );
|
||||
|
||||
// Alternate basic triangulation of a polygon with out adding points
|
||||
// or splitting edges and without regard for holes. Returns a polygon
|
||||
// with one contour per tesselated triangle. This is mostly just a
|
||||
// wrapper for the polygon_tesselate() function. Note, this routine
|
||||
// will modify the points_inside list for your polygon.
|
||||
TGPolygon polygon_tesselate_alt( TGPolygon &p, bool verbose );
|
||||
|
||||
TGPolygon polygon_tesselate_alt_with_extra( TGPolygon &p,
|
||||
const point_list &extra_nodes, bool verbose );
|
||||
|
||||
// with one contour per tesselated triangle.
|
||||
TGPolygon polygon_tesselate_alt_with_extra_cgal( TGPolygon &p,
|
||||
const point_list &extra_nodes, bool verbose );
|
||||
|
||||
|
|
1
src/Lib/TriangleJRS/.gitignore
vendored
1
src/Lib/TriangleJRS/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
test_triangle
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
|
||||
add_library(TriangleJRS STATIC
|
||||
tri_support.c
|
||||
tri_support.h
|
||||
triangle.c
|
||||
triangle.h
|
||||
)
|
||||
|
||||
set_target_properties(TriangleJRS PROPERTIES
|
||||
COMPILE_DEFINITIONS TRILIBRARY )
|
||||
|
||||
#add_executable(test_triangle test_triangle.c)
|
||||
|
||||
#target_link_libraries(test_triangle
|
||||
# TriangleJRS
|
||||
# )
|
|
@ -1,181 +0,0 @@
|
|||
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
|
File diff suppressed because it is too large
Load diff
|
@ -1,189 +0,0 @@
|
|||
/* a test of the Shewchuk triangulator (lib form) */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define REAL double
|
||||
#include "triangle.h"
|
||||
#include "tri_support.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
struct triangulateio in, out, vorout;
|
||||
char basename[256], nodefile[256], polyfile[256];
|
||||
FILE *fp;
|
||||
int count, dim, attr, bndmrkrs, end1, end2, boundmark;
|
||||
int i, counter;
|
||||
double x, y, z;
|
||||
char tri_options[256];
|
||||
int n1, n2, n3;
|
||||
|
||||
/* make sure all elements of these structs point to "NULL" */
|
||||
zero_triangulateio( &in );
|
||||
zero_triangulateio( &out );
|
||||
zero_triangulateio( &vorout );
|
||||
|
||||
/* get base name */
|
||||
if ( argc == 2 ) {
|
||||
strcpy( basename, argv[1] );
|
||||
} else {
|
||||
printf( "usage: %s base_name\n", argv[0] );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* generate file names
|
||||
*/
|
||||
|
||||
sprintf( nodefile, "%s.node", basename );
|
||||
sprintf( polyfile, "%s.poly", basename );
|
||||
|
||||
/*
|
||||
* load node file
|
||||
*/
|
||||
|
||||
if ( (fp = fopen( nodefile, "r" )) == NULL ) {
|
||||
printf( "cannot locate file: %s\n", nodefile );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* read in points */
|
||||
fscanf( fp, "%d %d %d %d\n", &count, &dim, &attr, &bndmrkrs );
|
||||
printf( "loading %d points\n", count );
|
||||
in.numberofpoints = count;
|
||||
in.numberofpointattributes = 1;
|
||||
in.pointlist = (REAL *) malloc(in.numberofpoints * 2 * sizeof(REAL));
|
||||
in.pointattributelist = (REAL *) malloc(in.numberofpoints *
|
||||
in.numberofpointattributes *
|
||||
sizeof(REAL));
|
||||
in.pointmarkerlist = NULL;
|
||||
|
||||
for ( i = 0; i < count; ++i ) {
|
||||
fscanf( fp, "%d %lf %lf %lf\n", &counter, &x, &y, &z );
|
||||
printf( " read = %d %.2f %.2f %.2f\n", counter, x, y, z );
|
||||
in.pointlist[2*counter] = x;
|
||||
in.pointlist[2*counter + 1] = y;
|
||||
in.pointattributelist[counter] = z;
|
||||
}
|
||||
fclose( fp );
|
||||
|
||||
/*
|
||||
* load poly file
|
||||
*/
|
||||
|
||||
if ( (fp = fopen( polyfile, "r" )) == NULL ) {
|
||||
printf( "cannot locate file: %s\n", polyfile );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* first line is ignored, points are specified in .node file */
|
||||
fscanf( fp, "%d %d %d %d\n", &count, &dim, &attr, &bndmrkrs );
|
||||
|
||||
/* read in segments */
|
||||
fscanf( fp, "%d %d\n", &count, &bndmrkrs );
|
||||
printf( "loading %d segments\n", count );
|
||||
in.numberofsegments = count;
|
||||
in.segmentlist = (int *) malloc(in.numberofsegments * 2 * sizeof(int));
|
||||
in.segmentmarkerlist = (int *) malloc(in.numberofsegments * sizeof(int));
|
||||
|
||||
for ( i = 0; i < count; ++i ) {
|
||||
fscanf( fp, "%d %d %d %d\n", &counter, &end1, &end2, &boundmark );
|
||||
printf( " read = %d %d %d %d\n", counter, end1, end2, boundmark );
|
||||
in.segmentlist[2*counter] = end1;
|
||||
in.segmentlist[2*counter + 1] = end2;
|
||||
in.segmentmarkerlist[counter] = boundmark;
|
||||
}
|
||||
|
||||
/* read in holes */
|
||||
fscanf( fp, "%d\n", &count );
|
||||
printf( "loading %d holes\n", count );
|
||||
in.numberofholes = count;
|
||||
in.holelist = (REAL *) malloc(in.numberofholes * 2 * sizeof(REAL));
|
||||
|
||||
for ( i = 0; i < count; ++i ) {
|
||||
fscanf( fp, "%d %lf %lf %lf\n", &counter, &x, &y, &z );
|
||||
printf( " read = %d %.2f %.2f %.2f\n", counter, x, y, z );
|
||||
in.holelist[2*counter] = x;
|
||||
in.holelist[2*counter + 1] = y;
|
||||
}
|
||||
|
||||
/* read in regions */
|
||||
/* number of regions is always zero for this example */
|
||||
fscanf( fp, "%d\n", &count );
|
||||
in.numberofregions = 0;
|
||||
in.regionlist = NULL;
|
||||
|
||||
fclose( fp );
|
||||
|
||||
/* no triangle list */
|
||||
in.numberoftriangles = 0;
|
||||
in.numberofcorners = 0;
|
||||
in.numberoftriangleattributes = 0;
|
||||
in.trianglelist = NULL;
|
||||
in.triangleattributelist = NULL;
|
||||
in.trianglearealist = NULL;
|
||||
in.neighborlist = NULL;
|
||||
|
||||
/* no edge list */
|
||||
in.numberofedges = 0;
|
||||
in.edgelist = NULL;
|
||||
in.edgemarkerlist = NULL;
|
||||
in.normlist = NULL;
|
||||
|
||||
/* dump the results */
|
||||
print_tri_data( &in );
|
||||
|
||||
/* Triangulate the points. Switches are chosen to read and write
|
||||
* a PSLG (p), number everything from zero (z), and produce an
|
||||
* edge list (e), and a triangle neighbor list (n). no new points
|
||||
* on boundary (Y), no internal segment splitting (YY), no quality
|
||||
* refinement (q) and Quite (Q)
|
||||
*/
|
||||
|
||||
strcpy( tri_options, "VVVpzYYenQ" );
|
||||
printf( "Triangulation with options = %s\n", tri_options );
|
||||
|
||||
triangulate( tri_options, &in, &out, &vorout );
|
||||
|
||||
zero_triangulateio( &out );
|
||||
zero_triangulateio( &vorout );
|
||||
|
||||
triangulate( tri_options, &in, &out, &vorout );
|
||||
|
||||
/* print resulting triangles */
|
||||
for ( i = 0; i < out.numberoftriangles; ++i ) {
|
||||
n1 = out.trianglelist[i * 3];
|
||||
n2 = out.trianglelist[i * 3 + 1];
|
||||
n3 = out.trianglelist[i * 3 + 2];
|
||||
if ( out.numberoftriangleattributes > 0 ) {
|
||||
z = out.triangleattributelist[i];
|
||||
} else {
|
||||
z = 0.0;
|
||||
}
|
||||
printf( "triangle %d = %d %d %d (%.2f)\n", i, n1, n2, n3, z );
|
||||
}
|
||||
|
||||
/* free mem allocated Floating point roundoff is of magnitude 1.1102230246251565e-16
|
||||
to the "Triangle" structures */
|
||||
free(in.pointlist);
|
||||
free(in.pointattributelist);
|
||||
free(in.pointmarkerlist);
|
||||
free(in.regionlist);
|
||||
free(out.pointlist);
|
||||
free(out.pointattributelist);
|
||||
free(out.pointmarkerlist);
|
||||
free(out.trianglelist);
|
||||
free(out.triangleattributelist);
|
||||
/* free(out.trianglearealist); */
|
||||
free(out.neighborlist);
|
||||
free(out.segmentlist);
|
||||
free(out.segmentmarkerlist);
|
||||
free(out.edgelist);
|
||||
free(out.edgemarkerlist);
|
||||
free(vorout.pointlist);
|
||||
free(vorout.pointattributelist);
|
||||
free(vorout.edgelist);
|
||||
free(vorout.normlist);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
// tri_support.c -- supporting routines for the triangulation library
|
||||
//
|
||||
// Written by Curtis Olson, started May 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// $Id: tri_support.c,v 1.4 2004-11-19 22:25:50 curt Exp $
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "tri_support.h"
|
||||
|
||||
|
||||
void zero_triangulateio( struct triangulateio *in ) {
|
||||
in->pointlist = NULL;
|
||||
in->pointattributelist = NULL;
|
||||
in->pointmarkerlist = NULL;
|
||||
in->numberofpoints = 0;
|
||||
in->numberofpointattributes = 0;
|
||||
|
||||
in->trianglelist = NULL;
|
||||
in->triangleattributelist = NULL;
|
||||
in->trianglearealist = NULL;
|
||||
in->neighborlist = NULL;
|
||||
in->numberoftriangles = 0;
|
||||
in->numberofcorners = 0;
|
||||
in->numberoftriangleattributes = 0;
|
||||
|
||||
in->segmentlist = NULL;
|
||||
in->segmentmarkerlist = NULL;
|
||||
in->numberofsegments = 0;
|
||||
|
||||
in->holelist = NULL;
|
||||
in->numberofholes = 0;
|
||||
|
||||
in->regionlist = NULL;
|
||||
in->numberofregions = 0;
|
||||
|
||||
in->edgelist = NULL;
|
||||
in->edgemarkerlist = NULL;
|
||||
in->normlist = NULL;
|
||||
in->numberofedges = 0;
|
||||
}
|
||||
|
||||
|
||||
void print_tri_data( struct triangulateio *out ) {
|
||||
int i, j;
|
||||
|
||||
printf( "NODES\n" );
|
||||
printf( "%d 2 %d 0\n",
|
||||
out->numberofpoints, out->numberofpointattributes);
|
||||
for ( i = 0; i < out->numberofpoints; ++i ) {
|
||||
printf( "%d %.13f %.13f %.2f\n",
|
||||
i, out->pointlist[2*i], out->pointlist[2*i + 1], 0.0);
|
||||
}
|
||||
|
||||
printf( "TRIANGLES\n" );
|
||||
printf( "%d %d 0\n", out->numberoftriangles, out->numberofcorners );
|
||||
for ( i = 0; i < out->numberoftriangles; ++i ) {
|
||||
printf( "%d ", i );
|
||||
for ( j = 0; j < out->numberofcorners; ++j ) {
|
||||
printf( "%d ", out->trianglelist[i * out->numberofcorners + j] );
|
||||
}
|
||||
for ( j = 0; j < out->numberoftriangleattributes; ++j ) {
|
||||
printf( "%.13f ",
|
||||
out->triangleattributelist[i
|
||||
* out->numberoftriangleattributes
|
||||
+ j]
|
||||
);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf( "SEGMENTS\n" );
|
||||
printf( "0 2 1 0\n" );
|
||||
printf( "%d 1\n", out->numberofsegments);
|
||||
for ( i = 0; i < out->numberofsegments; ++i ) {
|
||||
printf( "%d %d %d %d\n",
|
||||
i, out->segmentlist[2*i], out->segmentlist[2*i + 1],
|
||||
out->segmentmarkerlist[i] );
|
||||
}
|
||||
printf( "HOLES\n" );
|
||||
printf( "%d\n", out->numberofholes);
|
||||
for (i = 0; i < out->numberofholes; ++i) {
|
||||
printf( "%d %.13f %.13f\n",
|
||||
i, out->holelist[2*i], out->holelist[2*i + 1] );
|
||||
}
|
||||
printf( "REGIONS\n" );
|
||||
printf( "%d\n", out->numberofregions );
|
||||
for ( i = 0; i < out->numberofregions; ++i ) {
|
||||
printf( "%d %.13f %.13f %.13f\n",
|
||||
i, out->regionlist[4*i], out->regionlist[4*i + 1],
|
||||
out->regionlist[4*i + 2] );
|
||||
}
|
||||
|
||||
printf(" EDGES\n" );
|
||||
printf( "%d 1\n", out->numberofedges );
|
||||
for ( i = 0; i < out->numberofedges; ++i ) {
|
||||
printf( "%d %d %d %d\n", i, out->edgelist[2*i], out->edgelist[2*i + 1],
|
||||
out->edgemarkerlist[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void write_tri_data( struct triangulateio *out ) {
|
||||
int i, j;
|
||||
FILE *node, *ele, *fp;
|
||||
|
||||
node = fopen("tile.node", "w");
|
||||
fprintf(node, "%d 2 %d 0\n",
|
||||
out->numberofpoints, out->numberofpointattributes);
|
||||
for (i = 0; i < out->numberofpoints; ++i) {
|
||||
fprintf(node, "%d %.13f %.13f %.2f\n",
|
||||
i, out->pointlist[2*i], out->pointlist[2*i + 1], 0.0);
|
||||
}
|
||||
fclose(node);
|
||||
|
||||
ele = fopen("tile.ele", "w");
|
||||
fprintf(ele, "%d 3 0\n", out->numberoftriangles);
|
||||
for (i = 0; i < out->numberoftriangles; ++i) {
|
||||
fprintf(ele, "%d ", i);
|
||||
for (j = 0; j < out->numberofcorners; ++j) {
|
||||
fprintf(ele, "%d ", out->trianglelist[i * out->numberofcorners + j]);
|
||||
}
|
||||
for (j = 0; j < out->numberoftriangleattributes; ++j) {
|
||||
fprintf(ele, "%.13f ",
|
||||
out->triangleattributelist[i
|
||||
* out->numberoftriangleattributes
|
||||
+ j]
|
||||
);
|
||||
}
|
||||
fprintf(ele, "\n");
|
||||
}
|
||||
fclose(ele);
|
||||
|
||||
fp = fopen("tile.poly", "w");
|
||||
fprintf(fp, "0 2 1 0\n");
|
||||
fprintf(fp, "%d 1\n", out->numberofsegments);
|
||||
for (i = 0; i < out->numberofsegments; ++i) {
|
||||
fprintf(fp, "%d %d %d %d\n",
|
||||
i, out->segmentlist[2*i], out->segmentlist[2*i + 1],
|
||||
out->segmentmarkerlist[i] );
|
||||
}
|
||||
fprintf(fp, "%d\n", out->numberofholes);
|
||||
for (i = 0; i < out->numberofholes; ++i) {
|
||||
fprintf(fp, "%d %.13f %.13f\n",
|
||||
i, out->holelist[2*i], out->holelist[2*i + 1]);
|
||||
}
|
||||
fprintf(fp, "%d\n", out->numberofregions);
|
||||
for (i = 0; i < out->numberofregions; ++i) {
|
||||
fprintf(fp, "%d %.13f %.13f %.13f\n",
|
||||
i, out->regionlist[4*i], out->regionlist[4*i + 1],
|
||||
out->regionlist[4*i + 2]);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
// tri_support.h -- supporting routines for the triangulation library
|
||||
//
|
||||
// Written by Curtis Olson, started May 2000.
|
||||
//
|
||||
// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
//
|
||||
// $Id: tri_support.h,v 1.3 2004-11-19 22:25:50 curt Exp $
|
||||
|
||||
|
||||
#ifndef _TRI_SUPPORT_H
|
||||
#define _TRI_SUPPORT_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define REAL double
|
||||
#include "triangle.h"
|
||||
|
||||
|
||||
void zero_triangulateio( struct triangulateio *in );
|
||||
void print_tri_data( struct triangulateio *out );
|
||||
void write_tri_data( struct triangulateio *out );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _TRI_SUPPORT_H
|
||||
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,296 +0,0 @@
|
|||
/*****************************************************************************/
|
||||
/* */
|
||||
/* (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. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _SHEWCHUK_TRIANGLE_H
|
||||
#define _SHEWCHUK_TRIANGLE_H
|
||||
|
||||
|
||||
/* CLO: 3/21/99 - this could be done as a compile flag, but I always want
|
||||
this defined and I don't want to sprinkle extra stuff throughout the
|
||||
Makefile system if I don't have to. */
|
||||
#define ANSI_DECLARATORS 1
|
||||
|
||||
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
|
||||
int triangulate(char *, struct triangulateio *, struct triangulateio *,
|
||||
struct triangulateio *);
|
||||
#else /* not ANSI_DECLARATORS */
|
||||
int triangulate();
|
||||
#endif /* not ANSI_DECLARATORS */
|
||||
|
||||
|
||||
#endif /* SHEWCHUK TRIANGLE */
|
|
@ -4,7 +4,7 @@ add_executable(e00lines
|
|||
|
||||
target_link_libraries(e00lines
|
||||
e00
|
||||
Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||
Polygon Geometry Output poly2tri vpf
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ add_executable(ogr-decode ogr-decode.cxx)
|
|||
|
||||
target_link_libraries(ogr-decode
|
||||
${GDAL_LIBRARY}
|
||||
Polygon Geometry poly2tri TriangleJRS
|
||||
Polygon Geometry poly2tri
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ add_executable(photo
|
|||
photo.cxx)
|
||||
|
||||
target_link_libraries(photo
|
||||
Polygon Geometry Array Output poly2tri TriangleJRS
|
||||
Polygon Geometry Array Output poly2tri
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
add_executable(shape-decode shape-decode.cxx)
|
||||
|
||||
target_link_libraries(shape-decode
|
||||
shape Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||
shape Polygon Geometry Output poly2tri vpf
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ install(TARGETS shape-decode RUNTIME DESTINATION bin)
|
|||
add_executable(noaa-decode noaa-decode.cxx)
|
||||
|
||||
target_link_libraries(noaa-decode
|
||||
shape Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||
shape Polygon Geometry Output poly2tri vpf
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
add_executable(tgvpf tgvpf.cxx)
|
||||
|
||||
target_link_libraries(tgvpf
|
||||
Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||
Polygon Geometry Output poly2tri vpf
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
${RT_LIBRARY})
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
add_executable(tguserdef tguserdef.cxx)
|
||||
|
||||
target_link_libraries(tguserdef
|
||||
Polygon Geometry Output poly2tri TriangleJRS
|
||||
Polygon Geometry Output poly2tri
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue