00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <math.h>
00043 #include "memvirtu.h"
00044 #include "lowparam.h"
00045 #include "lowmacro.h"
00046 #include "lowsolid.h"
00047 #include "vectorop.h"
00048 #include "disdispl.h"
00049
00050 int MSD_lowIsInsideFace(vector pos, FPTYPE xfptr, HPTYPE *ei)
00051 {
00052 LPTYPE lptr;
00053 int opi, op;
00054
00055 if ((op = MSD_lowIsInsideLoop(pos, FacFLOut(xfptr), ei)) != DONTSHOW)
00056 {
00057 for (AllLoopsFace(xfptr, lptr))
00058 {
00059 if (lptr != FacFLOut(xfptr))
00060 {
00061 opi = MSD_lowIsInsideLoop(pos, lptr, ei);
00062 if (opi == _VISIBLE)
00063 {
00064 return(DONTSHOW);
00065 }
00066 if (opi == INVISIBLE)
00067 {
00068 return(INVISIBLE);
00069 }
00070 }
00071 }
00072 }
00073 return(op);
00074 }
00075
00076 int MSD_lowIsInsideLoop(vector pos, LPTYPE lptr, HPTYPE *ei)
00077 {
00078 static char chktable[9][9] =
00079 {
00080 { 0, 0, 1, 0, 2, 1, 0, 0, 3 },
00081 { 0, 0, 1, 0, 2, 1, 0, 2, 1 },
00082 { 1, 1, 0, 1, 2, 0, 3, 0, 0 },
00083 { 0, 0, 1, 0, 2, 2, 0, 0, 0 },
00084 { 2, 2, 2, 2, 2, 2, 2, 2, 2 },
00085 { 1, 1, 0, 2, 2, 0, 0, 0, 0 },
00086 { 0, 0, 3, 0, 2, 0, 0, 0, 0 },
00087 { 0, 2, 0, 0, 2, 0, 0, 0, 0 },
00088 { 3, 1, 0, 0, 2, 0, 0, 0, 0 }
00089 };
00090
00091 HPTYPE efim;
00092 HPTYPE eptr;
00093 VPTYPE xv;
00094 real n1, n2, n3, po, x10, x11, x20, x21;
00095 real pos2l, pos2r, pos2b, pos2t, xpoint;
00096 int idx1, idx2, count, chkidx1, chkidx2;
00097
00098 n1 = fabs(FacFeq(LooLFace(lptr))[0]);
00099 n2 = fabs(FacFeq(LooLFace(lptr))[1]);
00100 n3 = fabs(FacFeq(LooLFace(lptr))[2]);
00101 idx1 = (n1 >= n2 && n1 >= n3) ? 1 : 0;
00102 idx2 = ((n1 >= n2 && n1 >= n3) || n2 >= n3) ? 2 : 1;
00103 pos2l = (pos[idx1]) - abseps;
00104 pos2r = (pos[idx1]) + abseps;
00105 pos2b = (po = pos[idx2]) - abseps;
00106 pos2t = (pos[idx2]) + abseps;
00107
00108 *ei = LooLEdg(lptr);
00109 xv = HalVtx(*ei);
00110 x10 = VerVCoord(xv)[idx1];
00111 x11 = VerVCoord(xv)[idx2];
00112 chkidx1 = (x10 > pos2r) ? 0 : ((x10 < pos2l) ? 6 : 3);
00113 chkidx1 += (x11 > pos2t) ? 0 : ((x11 < pos2b) ? 2 : 1);
00114 efim = eptr = HalNxt(*ei);
00115 count = 0;
00116 do
00117 {
00118 x20 = x10;
00119 x21 = x11;
00120 chkidx2 = chkidx1;
00121 xv = HalVtx(eptr);
00122 chkidx1 = ((x10 = VerVCoord(xv)[idx1]) > pos2r) ? 0 : ((x10 < pos2l) ? 6 : 3);
00123 chkidx1 += ((x11 = VerVCoord(xv)[idx2]) > pos2t) ? 0 : ((x11 < pos2b) ? 2 : 1);
00124 switch (chktable[chkidx1][chkidx2])
00125 {
00126 case 1:
00127 ++count;
00128 break;
00129
00130 case 2:
00131 return(INVISIBLE);
00132
00133 case 3:
00134 xpoint = x10 + (po - x11) / (x21 - x11) * (x20 - x10);
00135 if (xpoint > pos2r)
00136 {
00137 ++count;
00138 }
00139 else
00140 if (xpoint < pos2l)
00141 {
00142 ;
00143 }
00144 else
00145 {
00146 return(INVISIBLE);
00147 }
00148 }
00149 *ei = eptr;
00150 } while ((eptr = HalNxt(eptr)) != efim);
00151 return((count & 1) ? _VISIBLE : DONTSHOW);
00152 }