1 | 0a1,10
|
---|
2 | > /*Notes for the Ice code:
|
---|
3 | > * to be able to compile Triangle within a mex function that can run within
|
---|
4 | > * matlab, we had to change the allocation routine trimalloc, as well as the
|
---|
5 | > * double precision activation in exactinit(); The rest is not changed.
|
---|
6 | > * We also created the ice_makefile to compile Triangle into a library. */
|
---|
7 | > #include <mat.h>
|
---|
8 | > #include <matrix.h>
|
---|
9 | > #define ANSI_DECLARATORS
|
---|
10 | > #define NO_TIMER
|
---|
11 | >
|
---|
12 | 347a358
|
---|
13 | > #ifndef _WIN_
|
---|
14 | 348a360
|
---|
15 | > #endif
|
---|
16 | 641d652
|
---|
17 | <
|
---|
18 | 817a829,922
|
---|
19 | > /*Some missing prototypes: */
|
---|
20 | > int scale_expansion_zeroelim(int elen, REAL *e, REAL b, REAL *h);
|
---|
21 | > int fast_expansion_sum_zeroelim(int elen, REAL *e, int flen, REAL *f, REAL *h);
|
---|
22 | > void poolzero(struct memorypool *pool);
|
---|
23 | > int triunsuitable(vertex triorg, vertex tridest, vertex triapex, REAL area);
|
---|
24 | > triangle *triangletraverse(struct mesh *m);
|
---|
25 | > void pooldeinit(struct memorypool *pool);
|
---|
26 | > void printtriangle(struct mesh *m, struct behavior *b, struct otri *t);
|
---|
27 | > VOID *poolalloc(struct memorypool *pool);
|
---|
28 | > void enqueuebadtriang(struct mesh *m, struct behavior *b,
|
---|
29 | > struct badtriang *badtri);
|
---|
30 | > void triangulatepolygon(struct mesh *m, struct behavior *b,
|
---|
31 | > struct otri *firstedge, struct otri *lastedge,
|
---|
32 | > int edgecount, int doflip, int triflaws);
|
---|
33 | > void triangledealloc(struct mesh *m, triangle *dyingtriangle);
|
---|
34 | > void unflip(struct mesh *m, struct behavior *b, struct otri *flipedge);
|
---|
35 | > void vertexmedian(vertex *sortarray, int arraysize, int median, int axis);
|
---|
36 | > REAL counterclockwiseadapt(vertex pa, vertex pb, vertex pc, REAL detsum);
|
---|
37 | > REAL incircleadapt(vertex pa, vertex pb, vertex pc, vertex pd, REAL permanent);
|
---|
38 | > void enqueuebadtri(struct mesh *m, struct behavior *b, struct otri *enqtri,
|
---|
39 | > REAL minedge, vertex enqapex, vertex enqorg, vertex enqdest);
|
---|
40 | > void alternateaxes(vertex *sortarray, int arraysize, int axis);
|
---|
41 | > REAL incircleadapt(vertex pa, vertex pb, vertex pc, vertex pd, REAL permanent);
|
---|
42 | > void maketriangle(struct mesh *m, struct behavior *b, struct otri *newotri);
|
---|
43 | > REAL counterclockwise(struct mesh *m, struct behavior *b,
|
---|
44 | > vertex pa, vertex pb, vertex pc);
|
---|
45 | > vertex vertextraverse(struct mesh *m);
|
---|
46 | > void mergehulls(struct mesh *m, struct behavior *b, struct otri *farleft,
|
---|
47 | > struct otri *innerleft, struct otri *innerright,
|
---|
48 | > struct otri *farright, int axis);
|
---|
49 | > REAL incircle(struct mesh *m, struct behavior *b,
|
---|
50 | > vertex pa, vertex pb, vertex pc, vertex pd);
|
---|
51 | > void poolrestart(struct memorypool *pool);
|
---|
52 | > void trifree(VOID *memptr);
|
---|
53 | > struct splaynode *splay(struct mesh *m, struct splaynode *splaytree,
|
---|
54 | > vertex searchpoint, struct otri *searchtri);
|
---|
55 | > void eventheapdelete(struct event **heap, int heapsize, int eventnum);
|
---|
56 | > void eventheapdelete(struct event **heap, int heapsize, int eventnum);
|
---|
57 | > void flip(struct mesh *m, struct behavior *b, struct otri *flipedge);
|
---|
58 | > void check4deadevent(struct otri *checktri, struct event **freeevents,
|
---|
59 | > struct event **eventheap, int *heapsize);
|
---|
60 | > REAL orient3d(struct mesh *m, struct behavior *b,
|
---|
61 | > vertex pa, vertex pb, vertex pc, vertex pd,
|
---|
62 | > REAL aheight, REAL bheight, REAL cheight, REAL dheight);
|
---|
63 | > REAL circletop(struct mesh *m, vertex pa, vertex pb, vertex pc, REAL ccwabc);
|
---|
64 | > void poolinit(struct memorypool *pool, int bytecount, int itemcount,
|
---|
65 | > int firstitemcount, int alignment);
|
---|
66 | > void eventheapinsert(struct event **heap, int heapsize, struct event *newevent);
|
---|
67 | > int rightofhyperbola(struct mesh *m, struct otri *fronttri, vertex newsite);
|
---|
68 | > void insertsubseg(struct mesh *m, struct behavior *b, struct otri *tri,
|
---|
69 | > int subsegmark);
|
---|
70 | > int scoutsegment(struct mesh *m, struct behavior *b, struct otri *searchtri,
|
---|
71 | > vertex endpoint2, int newmark);
|
---|
72 | > vertex getvertex(struct mesh *m, struct behavior *b, int number);
|
---|
73 | > void internalerror();
|
---|
74 | > unsigned long randomnation(unsigned int choices);
|
---|
75 | > struct splaynode *splayinsert(struct mesh *m, struct splaynode *splayroot,
|
---|
76 | > struct otri *newkey, vertex searchpoint);
|
---|
77 | > void delaunayfixup(struct mesh *m, struct behavior *b,
|
---|
78 | > struct otri *fixuptri, int leftside);
|
---|
79 | > void traversalinit(struct memorypool *pool);
|
---|
80 | > enum insertvertexresult insertvertex(struct mesh *m, struct behavior *b,
|
---|
81 | > vertex newvertex, struct otri *searchtri,
|
---|
82 | > struct osub *splitseg,
|
---|
83 | > int segmentflaws, int triflaws);
|
---|
84 | > void conformingedge(struct mesh *m, struct behavior *b,
|
---|
85 | > vertex endpoint1, vertex endpoint2, int newmark);
|
---|
86 | > enum finddirectionresult finddirection(struct mesh *m, struct behavior *b,
|
---|
87 | > struct otri *searchtri,
|
---|
88 | > vertex searchpoint);
|
---|
89 | > VOID *traverse(struct memorypool *pool);
|
---|
90 | > void deletevertex(struct mesh *m, struct behavior *b, struct otri *deltri);
|
---|
91 | > void pooldealloc(struct memorypool *pool, VOID *dyingitem);
|
---|
92 | > int checkseg4encroach(struct mesh *m, struct behavior *b,
|
---|
93 | > struct osub *testsubseg);
|
---|
94 | > void badsubsegdealloc(struct mesh *m, struct badsubseg *dyingseg);
|
---|
95 | > void vertexdealloc(struct mesh *m, vertex dyingvertex);
|
---|
96 | > void vertexsort(vertex *sortarray, int arraysize);
|
---|
97 | > void tallyencs(struct mesh *m, struct behavior *b);
|
---|
98 | > void splittriangle(struct mesh *m, struct behavior *b,
|
---|
99 | > struct badtriang *badtri);
|
---|
100 | > subseg *subsegtraverse(struct mesh *m);
|
---|
101 | > enum locateresult locate(struct mesh *m, struct behavior *b,
|
---|
102 | > vertex searchpoint, struct otri *searchtri);
|
---|
103 | > void writenodes(struct mesh *m, struct behavior *b, REAL **pointlist,
|
---|
104 | > REAL **pointattriblist, int **pointmarkerlist);
|
---|
105 | > void writevoronoi(struct mesh *m, struct behavior *b, REAL **vpointlist,
|
---|
106 | > REAL **vpointattriblist, int **vpointmarkerlist,
|
---|
107 | > int **vedgelist, int **vedgemarkerlist, REAL **vnormlist);
|
---|
108 | > void writeneighbors(struct mesh *m, struct behavior *b, int **neighborlist);
|
---|
109 | > void testtriangle(struct mesh *m, struct behavior *b, struct otri *testtri);
|
---|
110 | > void triangleinit(struct mesh *m);
|
---|
111 | >
|
---|
112 | >
|
---|
113 | 1408a1514
|
---|
114 | > void triexit(int status);
|
---|
115 | 1410d1515
|
---|
116 | < #ifdef ANSI_DECLARATORS
|
---|
117 | 1412,1416d1516
|
---|
118 | < #else /* not ANSI_DECLARATORS */
|
---|
119 | < void triexit(status)
|
---|
120 | < int status;
|
---|
121 | < #endif /* not ANSI_DECLARATORS */
|
---|
122 | <
|
---|
123 | 1421c1521
|
---|
124 | < #ifdef ANSI_DECLARATORS
|
---|
125 | ---
|
---|
126 | > VOID *trimalloc(int size);
|
---|
127 | 1423,1427d1522
|
---|
128 | < #else /* not ANSI_DECLARATORS */
|
---|
129 | < VOID *trimalloc(size)
|
---|
130 | < int size;
|
---|
131 | < #endif /* not ANSI_DECLARATORS */
|
---|
132 | <
|
---|
133 | 1431c1526,1527
|
---|
134 | < memptr = (VOID *) malloc((unsigned int) size);
|
---|
135 | ---
|
---|
136 | > //memptr = (VOID *) mxMalloc((unsigned int) size);
|
---|
137 | > memptr = (VOID *) malloc((unsigned int) size);
|
---|
138 | 1447c1543,1544
|
---|
139 | < free(memptr);
|
---|
140 | ---
|
---|
141 | > free(memptr);
|
---|
142 | > //mxFree(memptr);
|
---|
143 | 3665,3670c3762,3767
|
---|
144 | < void printtriangle(struct mesh *m, struct behavior *b, struct otri *t)
|
---|
145 | < #else /* not ANSI_DECLARATORS */
|
---|
146 | < void printtriangle(m, b, t)
|
---|
147 | < struct mesh *m;
|
---|
148 | < struct behavior *b;
|
---|
149 | < struct otri *t;
|
---|
150 | ---
|
---|
151 | > void printtriangle(struct mesh *m, struct behavior *b, struct otri *t){
|
---|
152 | > //#else /* not ANSI_DECLARATORS */
|
---|
153 | > //void printtriangle(m, b, t)
|
---|
154 | > //struct mesh *m;
|
---|
155 | > //struct behavior *b;
|
---|
156 | > //struct otri *t;
|
---|
157 | 3673c3770
|
---|
158 | < {
|
---|
159 | ---
|
---|
160 | > //{
|
---|
161 | 4910c5007
|
---|
162 | < _FPU_SETCW(cword);
|
---|
163 | ---
|
---|
164 | > //_FPU_SETCW(cword); //taken care of by Matlab
|
---|