83 if ( (d+epsilon) > 0 )
89 static void add(
const double *p,
double *dest,
unsigned int tstride,
unsigned int &pcount)
91 char *d = (
char *) dest;
92 d = d + pcount*tstride;
98 assert( pcount <= 4 );
103 static void intersect(
const double *p1,
const double *p2,
double *split,
const double *
plane)
111 dir[0] = p2[0] - p1[0];
112 dir[1] = p2[1] - p1[1];
113 dir[2] = p2[2] - p1[2];
116 double dot2 = dp1 -
plane[3];
118 double t = -(
plane[3] + dot2 ) / dot1;
120 split[0] = (dir[0]*t)+p1[0];
121 split[1] = (dir[1]*t)+p1[1];
122 split[2] = (dir[2]*t)+p1[2];
151 polygon(
const double *p1,
const double *p2,
const double *p3)
164 if ( index < 0 ) index+=
mVcount;
171 for (
int i=0; i<count; i++)
205 int out_c = 0, in_c = 0;
208 ptA = poly->
Vertex (count - 1);
210 for (
int i = -1; ++i < count;)
220 outpts[out_c++] = inpts[in_c++] = v;
222 outpts[out_c++] = ptB;
230 outpts[out_c++] = inpts[in_c++] = v;
235 outpts[out_c++] = inpts[in_c++] = ptB;
240 front.
set(&outpts[0], out_c);
241 back.
set(&inpts[0], in_c);
245 const double *triangle,
246 unsigned int tstride,
249 unsigned int &fcount,
251 unsigned int &bcount)
257 const char *tsource = (
const char *) triangle;
260 const double *p1 = (
const double *) (tsource);
261 const double *p2 = (
const double *) (tsource+tstride);
262 const double *p3 = (
const double *) (tsource+tstride*2);
269 if ( r1 == r2 && r1 == r3 )
273 add(p1,front,tstride,fcount);
274 add(p2,front,tstride,fcount);
275 add(p3,front,tstride,fcount);
279 add(p1,back,tstride,bcount);
280 add(p2,back,tstride,bcount);
281 add(p3,back,tstride,bcount);
293 for (
int i=0; i<pfront.
mVcount; i++)
298 for (
int i=0; i<pback.
mVcount; i++)
305 if ( fcount == 0 && bcount )
308 if ( bcount == 0 && fcount )