-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDeltaTet.c
412 lines (355 loc) · 13.5 KB
/
DeltaTet.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
/* ************************************************************************
** If two sets of two apices have the same code, each AA and BB edge can be
** cut by a stratigraphic level, and each point can be projected like the
** Gamma codes onto the AA-BB break plane, which is a trapezoid. Intersecting
** projected points from each side of the break plane will divide the break
** plane up into little trapezoids which can then be split into triangles
**
**
** * - stratigraphic layer intersections
** X - break plane intersections
** + - projection of strat layer onto break plane
** A........*.........A.........*........A
** . . + . . + .
** . . + . . + .
** . . + . . + .
** . . + . . + .
** XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
** . + . . + . .
** . + . . + . .
** . + . . + . .
** . + .. + ..
** B...*..............B..............*...A
**
**
** break plane with two projected strat intersections
** ..............+......................
** . + .
** . + .
** . + .
** . + .
** . + .
** . + .
** . + .
** . + .
** . + .
** +++++++++++++++++++++++++++++++++++++
** . + .
** ..............+......................
**
**
**
*************************************************************************** */
#include "xvt.h"
#include "noddy.h"
#include "allSurf.h"
extern COLOR layerColor;
extern long connect;
extern THREED_VIEW_OPTIONS threedViewOptions;
extern char clayer[81];/*global array for current layer name*/
extern LAYER_PROPERTIES *renderLayer ();
/* External Functions */
#if XVT_CC_PROTO
extern double distanceToContact (double, double, double, OBJECT *);
extern void allDrawPlane(double [4][3]);
extern OBJECT *SetCLayer(unsigned char *, unsigned char *, int, int);
#else
extern double distanceToContact ();
extern void allDrawPlane();
extern OBJECT *SetCLayer();
#endif
#if XVT_CC_PROTO
int DeltaFindEdgeMids(double [8][3], TETINFO *);
int DeltaFindMids(double, double [8], double [8][3], TETINFO *, int [8], int , int *);
int DeltaCalcPlanes(TETINFO *, int, int);
int DeltaBreakPlane( TETINFO *, int [8], double [8][3]);
double MidVal(double,double, double);
#else
int DeltaFindEdgeMids();
int DeltaFindMids();
int DeltaCalcPlanes();
int DeltaBreakPlane();
double MidVal();
#endif
double dbreakmids[9][2][3][3];
double dbreakdel[9][2];
double dEdgeMids[4][3];
/*
** calculate strat surfaces if 2 sets of 2 corners of tet are part of same
** contiguous volume
*/
void
#if XVT_CC_PROTO
DeltaCode(double Values[8], double Points[8][3],
int SeqCode[8], TETINFO *t)
#else
DeltaCode(Values, Points, SeqCode, t)
double Values[8], Points[8][3];
int SeqCode[8];
TETINFO *t;
#endif
{
unsigned int flavor;
int index,NMids,nn;
double level;
OBJECT *event;
int numEvents = countObjects(NULL_WIN);
LAYER_PROPERTIES *properties;
int rockCode;
t->pC=1;
t->pC2=1;
if (t->TetCode==101) /* work out which vertex is different */
{
t->GoodPts[0]=TETAPICES[t->tinc][0];
t->GoodPts[1]=TETAPICES[t->tinc][2];
t->GoodPts[2]=TETAPICES[t->tinc][1];
t->GoodPts[3]=TETAPICES[t->tinc][3];
t->ExCode=TETAPICES[t->tinc][0];
t->InCode=TETAPICES[t->tinc][1];
}
else if(t->TetCode==11)
{
t->GoodPts[0]=TETAPICES[t->tinc][0];
t->GoodPts[1]=TETAPICES[t->tinc][1];
t->GoodPts[2]=TETAPICES[t->tinc][2];
t->GoodPts[3]=TETAPICES[t->tinc][3];
t->ExCode=TETAPICES[t->tinc][0];
t->InCode=TETAPICES[t->tinc][2];
}
else if(t->TetCode==110)
{
t->GoodPts[0]=TETAPICES[t->tinc][0];
t->GoodPts[1]=TETAPICES[t->tinc][3];
t->GoodPts[2]=TETAPICES[t->tinc][1];
t->GoodPts[3]=TETAPICES[t->tinc][2];
t->ExCode=TETAPICES[t->tinc][0];
t->InCode=TETAPICES[t->tinc][1];
}
else
printf("oops delta\n");
DeltaFindEdgeMids(Points,t);
for(nn=0;nn<2;nn++)
{
/* get strat info */
taste(numEvents,(unsigned char *) &(t->cypher[SeqCode[t->GoodPts[2*nn]]][0]),&flavor,&index);
/* if all same value exit (too hard to deal with!) */
if (Values[TETAPICES[t->tinc][0]]==Values[TETAPICES[t->tinc][1]] &&
Values[TETAPICES[t->tinc][0]]==Values[TETAPICES[t->tinc][2]] &&
Values[TETAPICES[t->tinc][0]]==Values[TETAPICES[t->tinc][3]])
return;
if (!(event = (OBJECT *) nthObject (NULL_WIN, index)))
return;
if (flavor != IGNEOUS_STRAT)
{
event->generalData = 0;
while (properties = renderLayer(event, index))
{
NMids=0;
level = properties->height;
layerColor=XVT_MAKE_COLOR(properties->color.red,
properties->color.green,
properties->color.blue);
/*sprintf(clayer,"S%02dL%02d%04d", index, event->generalData-1,
SeqCode[t->GoodPts[2*nn]]);*/
rockCode=getStratRock (index, event->generalData-1)-1;
sprintf(clayer,"S_%02d_%02d_%03d_%03d_%03d", index, event->generalData-1,SeqCode[t->GoodPts[2*nn]],rockCode,rockCode-1);
DeltaFindMids(level, Values, Points, t, SeqCode, nn, &NMids);
DeltaCalcPlanes(t, nn, NMids); /* draw strat surfaces */
}
}
}
DeltaBreakPlane(t, SeqCode, Points); /* draw break surfaces */
}
int
#if XVT_CC_PROTO
DeltaFindEdgeMids(double Points[8][3], TETINFO *t)
#else
DeltaFindEdgeMids(Points, t)
double Points[8][3];
TETINFO *t;
#endif
{
int mm;
for(mm=0;mm<3;mm++)
dEdgeMids[0][mm]=MidVal(Points[t->GoodPts[0]][mm],Points[t->GoodPts[2]][mm],0.5);
for(mm=0;mm<3;mm++)
dEdgeMids[1][mm]=MidVal(Points[t->GoodPts[0]][mm],Points[t->GoodPts[3]][mm],0.5);
for(mm=0;mm<3;mm++)
dEdgeMids[2][mm]=MidVal(Points[t->GoodPts[1]][mm],Points[t->GoodPts[2]][mm],0.5);
for(mm=0;mm<3;mm++)
dEdgeMids[3][mm]=MidVal(Points[t->GoodPts[1]][mm],Points[t->GoodPts[3]][mm],0.5);
return (TRUE);
}
int
#if XVT_CC_PROTO
DeltaFindMids(double level, double Values[8], double Points[8][3],
TETINFO *t, int SeqCode[8], int nn, int *NMids)
#else
DeltaFindMids(level, Values, Points, t, SeqCode, nn, NMids)
double level, Values[8], Points[8][3];
TETINFO *t;
int SeqCode[8], nn, *NMids;
#endif
{
int mm,nomids;
static int pairs[2][4]={0,2,1,3,0,1,2,3};
double delcon;
if(nn==0)
nomids=t->pC;
else
nomids=t->pC2;
if(Values[t->GoodPts[2*nn]] < level && Values[t->GoodPts[(2*nn)+1]] > level ||
Values[t->GoodPts[2*nn]] > level && Values[t->GoodPts[(2*nn)+1]] < level )
{
delcon=(level-Values[t->GoodPts[2*nn]])
/ (Values[t->GoodPts[(2*nn)+1]]-Values[t->GoodPts[2*nn]]);
dbreakdel[nomids][nn]=delcon;
for(mm=0;mm<3;mm++)
{
dbreakmids[nomids][nn][0][mm]=MidVal(dEdgeMids[pairs[nn][0]][mm],dEdgeMids[pairs[nn][1]][mm],delcon);
dbreakmids[nomids][nn][1][mm]=MidVal(dEdgeMids[pairs[nn][2]][mm],dEdgeMids[pairs[nn][3]][mm],delcon);
dbreakmids[nomids][nn][2][mm]=MidVal(Points[t->GoodPts[2*nn]][mm],Points[t->GoodPts[(2*nn)+1]][mm],delcon);
}
if(nn==0)
t->pC++;
else
t->pC2++;
*NMids=TRUE;
}
return (TRUE);
}
/*
** draw strat surfaces
*/
int
#if XVT_CC_PROTO
DeltaCalcPlanes(TETINFO *t, int nn, int NMids)
#else
DeltaCalcPlanes(t, nn, NMids)
TETINFO *t;
int nn, NMids;
#endif
{
int mm,nomids;
double conlist[4][3];
if (nn==0)
nomids=t->pC-1;
else
nomids=t->pC2-1;
if(NMids>0)
{
for(mm=0;mm<3;mm++)
{
conlist[0][mm]=dbreakmids[nomids][nn][0][mm];
conlist[1][mm]=dbreakmids[nomids][nn][1][mm];
conlist[2][mm]=dbreakmids[nomids][nn][2][mm];
}
allDrawPlane(conlist);
}
return (TRUE);
}
/*
** draw break plane
*/
int
#if XVT_CC_PROTO
DeltaBreakPlane( TETINFO *t, int SeqCode[8], double Points[8][3])
#else
DeltaBreakPlane(t, SeqCode)
TETINFO *t;
int SeqCode[8];
double Points[8][3];
#endif
{
OBJECT *object,*Inevent,*Exevent;
int Inindex,Exindex;
unsigned int pflavor=0;
double conlist[4][3];
int mm, nn, pp;
LAYER_PROPERTIES *inLayer,*exLayer;
int ExeventIndex,IneventIndex;
int numEvents = countObjects(NULL_WIN);
int break_code;
unsigned int InrockType,ExrockType;
int inRock, exRock;
int lDiff,eventCode,rock1,rock2;
STRATIGRAPHY_OPTIONS *InstratOptions,*ExstratOptions;
int sMax,sMin;
/*if (!(object = SetCLayer((unsigned char *) &(t->cypher[SeqCode[t->InCode]]),
(unsigned char *) &(t->cypher[SeqCode[t->ExCode]]),
SeqCode[t->InCode], SeqCode[t->ExCode])))
{
return (FALSE);
}*/
taste(numEvents, t->cypher[SeqCode[t->InCode]], &InrockType, &IneventIndex);
taste(numEvents, t->cypher[SeqCode[t->ExCode]], &ExrockType, &ExeventIndex);
inLayer=whichLayer(IneventIndex, Points[t->InCode][0], Points[t->InCode][1], Points[t->InCode][2]);
exLayer=whichLayer(ExeventIndex, Points[t->ExCode][0], Points[t->ExCode][1], Points[t->ExCode][2]);
break_code = lastdiff((unsigned char *) &(t->cypher[SeqCode[t->InCode]]),
(unsigned char *) &(t->cypher[SeqCode[t->ExCode]]));
//sprintf(clayer,"BD_%03d_%c%c_%c%c",break_code,inLayer->unitName[0],inLayer->unitName[1],exLayer->unitName[0],exLayer->unitName[1]);
whichRock( Points[t->InCode][0],Points[t->InCode][1],Points[t->InCode][2], &inRock, &IneventIndex);
whichRock( Points[t->ExCode][0],Points[t->ExCode][1],Points[t->ExCode][2], &exRock, &ExeventIndex);
whatDiff(Points[t->InCode][0],Points[t->InCode][1],Points[t->InCode][2],
Points[t->ExCode][0],Points[t->ExCode][1],Points[t->ExCode][2],&lDiff,&eventCode,&rock1,&rock2);
taste(numEvents, (unsigned char *) &(t->cypher[SeqCode[t->InCode]]), &pflavor, &Inindex);
taste(numEvents, (unsigned char *) &(t->cypher[SeqCode[t->ExCode]]), &pflavor, &Exindex);
sMax=getStratMax (Inindex);
if(Inindex-1>=0)
sMin=getStratMax (Inindex-1);
else
sMin=0;
if (Inevent = (OBJECT *) nthObject (NULL_WIN, Inindex))
if((Inevent->shape == STRATIGRAPHY) || (Inevent->shape == UNCONFORMITY))
inRock=sMin+sMax-inRock+1;
sMax=getStratMax (Exindex);
if(Exindex-1>=0)
sMin=getStratMax (Exindex-1);
else
sMin=0;
if (Exevent = (OBJECT *) nthObject (NULL_WIN, Exindex))
if((Exevent->shape == STRATIGRAPHY) || (Exevent->shape == UNCONFORMITY))
exRock=sMin+sMax-exRock+1;
if(inRock < exRock)
if(SeqCode[t->InCode]< SeqCode[t->ExCode])
sprintf(clayer,"B_%03d_%03d_%03d_%03d_%03d_%03d",break_code,eventCode,SeqCode[t->InCode], SeqCode[t->ExCode],inRock,exRock);
else
sprintf(clayer,"B_%03d_%03d_%03d_%03d_%03d_%03d",break_code,eventCode,SeqCode[t->ExCode], SeqCode[t->InCode], inRock,exRock);
else
if(SeqCode[t->InCode]< SeqCode[t->ExCode])
sprintf(clayer,"B_%03d_%03d_%03d_%03d_%03d_%03d",break_code,eventCode,SeqCode[t->InCode], SeqCode[t->ExCode],exRock,inRock);
else
sprintf(clayer,"B_%03d_%03d_%03d_%03d_%03d_%03d",break_code,eventCode, SeqCode[t->ExCode],SeqCode[t->InCode],exRock,inRock);
for(mm=0;mm<3;mm++)
{
dbreakmids[0][0][0][mm]=dEdgeMids[0][mm];
dbreakmids[0][0][1][mm]=dEdgeMids[1][mm];
dbreakmids[t->pC][0][0][mm]=dEdgeMids[2][mm];
dbreakmids[t->pC][0][1][mm]=dEdgeMids[3][mm];
dbreakmids[0][1][0][mm]=dEdgeMids[0][mm];
dbreakmids[0][1][1][mm]=dEdgeMids[2][mm];
dbreakmids[t->pC2][1][0][mm]=dEdgeMids[1][mm];
dbreakmids[t->pC2][1][1][mm]=dEdgeMids[3][mm];
}
dbreakdel[0][0]=0;
dbreakdel[0][1]=0;
dbreakdel[t->pC][0]=1.0;
dbreakdel[t->pC2][1]=1.0;
for (pp = 0; pp < t->pC; pp++)
{
for (nn = 0; nn < t->pC2; nn++)
{
for (mm = 0; mm < 3; mm++)
{
conlist[0][mm]=MidVal(dbreakmids[pp][0][0][mm],dbreakmids[pp][0][1][mm],dbreakdel[nn][1]);
conlist[1][mm]=MidVal(dbreakmids[pp][0][0][mm],dbreakmids[pp][0][1][mm],dbreakdel[nn+1][1]);
conlist[2][mm]=MidVal(dbreakmids[pp+1][0][0][mm],dbreakmids[pp+1][0][1][mm],dbreakdel[nn][1]);
}
allDrawPlane(conlist);
for(mm=0;mm<3;mm++)
conlist[0][mm]=MidVal(dbreakmids[pp+1][0][0][mm],dbreakmids[pp+1][0][1][mm],dbreakdel[nn+1][1]);
allDrawPlane(conlist);
}
}
return (TRUE);
}