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 <string.h>
00043 #include "memvirtu.h"
00044 #include "lowparam.h"
00045 #include "lowmacro.h"
00046 #include "lowsolid.h"
00047 #include "eulerops.h"
00048 #include "lowgeome.h"
00049 #include "vectorop.h"
00050 #include "shpshape.h"
00051 #include "splsplit.h"
00052
00053 void MSD_lowSplitGenerate(SPTYPE s, vector SP)
00054 {
00055 DPTYPE d;
00056 EPTYPE e;
00057 HPTYPE hh;
00058 VPTYPE v1;
00059 VPTYPE v2;
00060 double d1, d2, t, x, y, z;
00061 int s1, s2;
00062
00063 #ifdef TRACE_SPLIT
00064 int i;
00065
00066 fprintf(trace, "*************************************************\n");
00067 fprintf(trace, "* *\n");
00068 fprintf(trace, "* SETSPLITGENERATE *\n");
00069 fprintf(trace, "* *\n");
00070 fprintf(trace, "*************************************************\n");
00071 fprintf(trace, "\n");
00072 #endif
00073
00074 spl_nvtx = 0;
00075 for (AllShellsSolid(s, d))
00076 {
00077 for (AllEdgesShell(d, e))
00078 {
00079 #ifdef TRACE_SPLIT1
00080 fprintf(trace, "\n");
00081 fprintf(trace, "*** SplitGenerate - Aresta ***\n");
00082 trace_e(e);
00083 #endif
00084 v1 = HalVtx(EdgHe1(e));
00085 v2 = HalVtx(EdgHe2(e));
00086 s1 = comp((d1 = MSD_lowDistancePlanePoint(SP, v1)), 0.0, EPS);
00087 s2 = comp((d2 = MSD_lowDistancePlanePoint(SP, v2)), 0.0, EPS);
00088 if (((s1 == -1) && (s2 == 1)) || ((s1 == 1) && (s2 == -1)))
00089 {
00090 #ifdef TRACE_SPLIT1
00091 fprintf(trace, "*** Ocorre interseccao aresta-superficie\n");
00092 #endif
00093 t = d1 / (d1 - d2);
00094 x = VerVCoord(v1)[0] + t * (VerVCoord(v2)[0] - VerVCoord(v1)[0]);
00095 y = VerVCoord(v1)[1] + t * (VerVCoord(v2)[1] - VerVCoord(v1)[1]);
00096 z = VerVCoord(v1)[2] + t * (VerVCoord(v2)[2] - VerVCoord(v1)[2]);
00097 MSD_lowMEV(EdgHe1(e), (hh = HalNxt(EdgHe2(e))), maxv++, x, y, z);
00098 MSD_lowAddSplitOnVertex(HalVtx(HalPrv(hh)));
00099 }
00100 else
00101 {
00102 #ifdef TRACE_SPLIT1
00103 if (s1 == 0)
00104 {
00105 fprintf(trace, "*** Ocorre interseccao vertice-superficie\n");
00106 trace_v(v1);
00107 MSD_lowAddSplitOnVertex(v1);
00108 }
00109 #else
00110 if (s1 == 0)
00111 {
00112 MSD_lowAddSplitOnVertex(v1);
00113 }
00114 #endif
00115 #ifdef TRACE_SPLIT1
00116 if (s2 == 0)
00117 {
00118 fprintf(trace, "*** Ocorre interseccao vertice-superficie\n");
00119 trace_v(v2);
00120 MSD_lowAddSplitOnVertex(v2);
00121 }
00122 #else
00123 if (s2 == 0)
00124 {
00125 MSD_lowAddSplitOnVertex(v2);
00126 }
00127 #endif
00128 }
00129 }
00130 }
00131
00132 #ifdef TRACE_SPLIT
00133 fprintf(trace, "*** setsplitgenerate *** - nvtx = %3i\n", spl_nvtx);
00134 fprintf(trace, "*** estrutura soov ***\n");
00135 for (i = 0; i < spl_nvtx; i++)
00136 {
00137 trace_v(SplSoov(i));
00138 }
00139 #endif
00140 }
00141
00142 void MSD_lowAddSplitOnVertex(VPTYPE v)
00143 {
00144 int i;
00145
00146 for (i = 0; i < spl_nvtx; i++)
00147 #ifdef TRACE_SPLIT1
00148 {
00149 if (SplSoov(i) == v)
00150 {
00151 fprintf(trace,
00152 "*** Nao foi acrescentado a estrutura - (soov) repetido\n");
00153 return;
00154 }
00155 }
00156 #else
00157 {
00158 if (SplSoov(i) == v)
00159 {
00160 return;
00161 }
00162 }
00163 #endif
00164
00165 SplSoov(spl_nvtx) = v;
00166 spl_nvtx++;
00167 }