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_lowClip3Dimension(vector v1, vector v2)
00051 {
00052 vector normal;
00053 real h0, v0;
00054
00055 if (MSD_lowCheckClipDisplay(v1, v2) == TRUE)
00056 {
00057 if (camptr->mode == 1)
00058 {
00059 normal[0] = camptr->scale;
00060 normal[1] = 0.0;
00061 normal[2] = 1.0;
00062 normalize(normal);
00063 if (MSD_lowClipingPlane(v1, v2, normal, 0.0))
00064 {
00065 normal[0] = -normal[0];
00066 if (MSD_lowClipingPlane(v1, v2, normal, 0.0))
00067 {
00068 normal[0] = 0.0;
00069 normal[1] = camptr->scale;
00070 normal[2] = xyratio;
00071 normalize(normal);
00072 if (MSD_lowClipingPlane(v1, v2, normal, 0.0))
00073 {
00074 normal[1] = -normal[1];
00075 if (MSD_lowClipingPlane(v1, v2, normal, 0.0))
00076 {
00077 return(TRUE);
00078 }
00079 }
00080 }
00081 }
00082 }
00083 else
00084 {
00085 h0 = camptr->cdis / camptr->scale;
00086 v0 = xyratio * h0;
00087 normal[0] = 1.0;
00088 normal[2] = normal[1] = 0.0;
00089 if (MSD_lowClipingPlane(v1, v2, normal, h0))
00090 {
00091 normal[0] = -1.0;
00092 if (MSD_lowClipingPlane(v1, v2, normal, h0))
00093 {
00094 normal[0] = 0.0;
00095 normal[1] = 1.0;
00096 if (MSD_lowClipingPlane(v1, v2, normal, v0))
00097 {
00098 normal[1] = -1.0;
00099 if (MSD_lowClipingPlane(v1, v2, normal, v0))
00100 {
00101 return(TRUE);
00102 }
00103 }
00104 }
00105 }
00106 }
00107 }
00108 return(FALSE);
00109 }
00110
00111 int MSD_lowCheckClipDisplay(vector t1, vector t2)
00112 {
00113 vector s;
00114 real eps10, t;
00115 real *tp;
00116
00117 eps10 = abseps * 10;
00118 if ((t1[2] > eps10) && (t2[2] > eps10))
00119 {
00120 return(TRUE);
00121 }
00122 if (!((t1[2] > eps10) || (t2[2] > eps10)))
00123 {
00124 return(FALSE);
00125 }
00126 if (fabs(t1[2] - t2[2]) < abseps)
00127 {
00128 return(FALSE);
00129 }
00130
00131 t = (eps10 - t1[2]) / (t2[2] - t1[2]);
00132 s[0] = t1[0] + t * (t2[0] - t1[0]);
00133 s[1] = t1[1] + t * (t2[1] - t1[1]);
00134 s[2] = eps10;
00135
00136 tp = (t1[2] > eps10) ? t2 : t1;
00137 veccopy(tp, s);
00138 return(TRUE);
00139 }
00140
00141 int MSD_lowClipingPlane(vector v1, vector v2, vector normal, real d)
00142 {
00143 real p1, p2;
00144 real *midp;
00145
00146 p1 = d + dot(normal, v1);
00147 p2 = d + dot(normal, v2);
00148 if ((p1 <= 0.0) && (p2 <= 0.0))
00149 {
00150 return(FALSE);
00151 }
00152 if ((p1 >= 0.0) && (p2 >= 0.0))
00153 {
00154 return(TRUE);
00155 }
00156 midp = (p1 >= 0.0) ? v2 : v1;
00157 calc_p(v2, v1, p1 / (p1 - p2), midp);
00158 return(TRUE);
00159 }
00160
00161 void MSD_lowEdgeClip(EPTYPE eptr)
00162 {
00163 vector sv, ev, svc, evc, sv2, ev2;
00164
00165 veccopy(sv, VerVCoord(HalVtx(EdgHe1(eptr))));
00166 veccopy(ev, VerVCoord(HalVtx(EdgHe2(eptr))));
00167 veccopy(svc, EdgSVClp3(eptr));
00168 veccopy(evc, EdgEVClp3(eptr));
00169 EdgEClp(eptr) = MSD_lowClipDisplayTransformation(sv, ev, svc, evc);
00170 if (EdgEClp(eptr) == TRUE)
00171 {
00172 veccopy(sv2, EdgSVClp2(eptr));
00173 veccopy(ev2, EdgEVClp2(eptr));
00174 MSD_lowExecDisplayTransformation(svc, evc, sv2, ev2);
00175 vec2cp(EdgSVClp2(eptr), sv2);
00176 vec2cp(EdgEVClp2(eptr), ev2);
00177 }
00178 veccopy(EdgSVClp3(eptr), svc);
00179 veccopy(EdgEVClp3(eptr), evc);
00180 }
00181
00182 void MSD_lowDetermineVisibility(CTYPE *cptr)
00183 {
00184 SPTYPE optr;
00185 DPTYPE dptr;
00186 FPTYPE fptr;
00187 EPTYPE eptr;
00188
00189 for (AllSolids(optr))
00190 {
00191 if (SolDsp(optr) != TRUE)
00192 {
00193 continue;
00194 }
00195 if (breakflg)
00196 {
00197 return;
00198 }
00199 for (AllShellsSolid(optr, dptr))
00200 {
00201 for (AllFacesShell(dptr, fptr))
00202 {
00203 FacFVisi(fptr) = MSD_lowIsFaceVisible(cptr, fptr);
00204 }
00205 }
00206 for (AllShellsSolid(optr, dptr))
00207 {
00208 for (AllEdgesShell(dptr, eptr))
00209 {
00210 EdgEVis(eptr) = MSD_lowIsEdgeVisible(cptr, eptr);
00211 MSD_lowEdgeClip(eptr);
00212 }
00213 }
00214 }
00215 }