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 #include "gphgraph.h"
00050
00051 int MSD_lowIsEdgeVisible(CTYPE *cptr, EPTYPE eptr)
00052 {
00053 int lfvisi, rfvisi;
00054 vector dir, edir, ev, sv, vfrom;
00055 FPTYPE lfptr;
00056 FPTYPE rfptr;
00057 VPTYPE svptr;
00058 VPTYPE evptr;
00059
00060 svptr = HalVtx(EdgHe1(eptr));
00061 evptr = HalVtx(EdgHe2(eptr));
00062 if (cptr->mode == 1)
00063 {
00064 veccopy(vfrom, VerVCoord(svptr));
00065 }
00066 else
00067 {
00068 veccopy(vfrom, cptr->ref);
00069 }
00070 vecminus(dir, cptr->eye, vfrom);
00071 normalize(dir);
00072 lfptr = LooLFace(HalWLoop(EdgHe1(eptr)));
00073 rfptr = LooLFace(HalWLoop(EdgHe2(eptr)));
00074 lfvisi = FacFVisi(lfptr);
00075 rfvisi = FacFVisi(rfptr);
00076 veccopy(ev, VerVCoord(evptr));
00077 veccopy(sv, VerVCoord(svptr));
00078 vecminus(edir, ev, sv);
00079 if ((lfvisi == _VISIBLE) && MSD_lowIsInvertedEdge(TRUE, dir, lfptr, edir))
00080 {
00081 return(DONTSHOW);
00082 }
00083 if ((rfvisi == _VISIBLE) && MSD_lowIsInvertedEdge(FALSE, dir, rfptr, edir))
00084 {
00085 return(DONTSHOW);
00086 }
00087 if ((lfvisi != rfvisi) && ((lfvisi == INVISIBLE) || (rfvisi == INVISIBLE)))
00088 {
00089 return(EdgAngle(eptr) > 0.0 ? _VISIBLE : INVISIBLE);
00090 }
00091 if ((cptr->smooth == 0) && (fabs(EdgAngle(eptr)) < angsmooth))
00092 {
00093 return(DONTSHOW);
00094 }
00095 if ((lfvisi == DONTSHOW) && (rfvisi == DONTSHOW))
00096 {
00097 return(INVISIBLE);
00098 }
00099 if ((EdgAngle(eptr) < 0.0) && ((lfvisi == DONTSHOW) || (rfvisi == DONTSHOW)))
00100 {
00101 return(INVISIBLE);
00102 }
00103 return(_VISIBLE);
00104 }
00105
00106 int MSD_lowIsFaceVisible(CTYPE *cptr, FPTYPE fptr)
00107 {
00108 real dis;
00109 vector feq;
00110
00111 veccopy(feq, FacFeq(fptr));
00112 if (cptr->mode == 1)
00113 {
00114 dis = dot(feq, cptr->eye) + feq[3];
00115 return(dis > abseps ? INVISIBLE : dis < -abseps ? DONTSHOW : _VISIBLE);
00116 }
00117 else
00118 {
00119 dis = dot(cptr->drot[2], feq);
00120 return(dis < -abseps ? INVISIBLE : dis > abseps ? DONTSHOW : _VISIBLE);
00121 }
00122 }
00123
00124 int MSD_lowIsInvertedEdge(int isleft, vector dir, FPTYPE fp, vector edir)
00125 {
00126 real det;
00127 vector direction;
00128
00129 if (normalize(edir) == TRUE)
00130 {
00131 det = dot(cross(direction, edir, FacFeq(fp)), dir);
00132 det = (isleft) ? det : -det;
00133 return(det < releps);
00134 }
00135 return(TRUE);
00136 }