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 #ifndef __UNIX_
00044 #include <stdlib.h>
00045 #endif
00046 #include "memvirtu.h"
00047 #include "lowparam.h"
00048 #include "lowmacro.h"
00049 #include "lowsolid.h"
00050 #include "eulerops.h"
00051 #include "lowgeome.h"
00052 #include "vectorop.h"
00053 #include "mancommd.h"
00054 #include "shpshape.h"
00055
00056 extern FILE *trace;
00057
00058 SPTYPE MSD_lowMakeRevolve(Id sn, XY *listvtx, int m, int n)
00059 {
00060 SPTYPE s;
00061 int flag = 1, GOld;
00062 static vector vect = { 0.0, 1.0, 0.0, 0.0 };
00063
00064 GOld = Gdoinversion;
00065 Gdoinversion = FALSE;
00066 CommandCount++;
00067 if ((s = MSD_lowMakePolygon(sn, listvtx, n, 2)) == SNIL)
00068 {
00069 flag = 0;
00070 }
00071 if (MSD_lowMakeRotationalSweep(s, m, 2, 0, vect) == ERROR)
00072 {
00073 flag = 0;
00074 }
00075 if (flag == 1)
00076 {
00077 MSD_lowSetNormal(s, TRUE);
00078 MSD_lowSetEdgeAngle(s);
00079 MSD_lowSetInfo(s);
00080 }
00081 if (flag == 0)
00082 {
00083 MSD_lowHardRemove(s);
00084 }
00085 if (flag == 1)
00086 {
00087 MSD_lowAddEulerOp(s, HARDREM, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00088 }
00089 Gdoinversion = GOld;
00090 return(flag == 0 ? SNIL : s);
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 char MSD_lowMakeRotationalSweep(SPTYPE s, int nfaces, int axs, int pln, vector vect)
00113 {
00114 FPTYPE tailf;
00115 FPTYPE headf;
00116 HPTYPE cfirst;
00117 HPTYPE last;
00118 HPTYPE scan;
00119 HPTYPE first;
00120 Id maxv, maxf;
00121 int cut_headf, cut_tailf, closed_figure;
00122 real phix, phiy, phiz;
00123 matrix m;
00124 vector v;
00125
00126 if ((closed_figure = MSD_lowMakeOpenRSweep(s, pln)) == 2)
00127 {
00128 return(ERROR);
00129 }
00130 scan = LooLEdg(FacFLoops(SheSFaces(SolSShells(s))));
00131 if ((cfirst = MSD_lowTouchWire(scan, &cut_tailf, pln)) == HNIL)
00132 {
00133 return(ERROR);
00134 }
00135 if ((last = MSD_lowTouchWire(HalNxt(cfirst), &cut_headf, pln)) == HNIL)
00136 {
00137 return(ERROR);
00138 }
00139
00140 maxv = MSD_getMaxVertexId(s);
00141 maxf = MSD_getMaxFaceId(s);
00142 MSD_lowMEF(HalNxt(cfirst), HalNxt(last), maxf++);
00143 MSD_lowFaceEq(HalWLoop(cfirst), FacFeq(LooLFace(HalWLoop(cfirst))));
00144 if (dot(FacFeq(LooLFace(HalWLoop(cfirst))), vect) < 0.0)
00145 {
00146 scan = cfirst;
00147 cfirst = last;
00148 last = scan;
00149 }
00150 MSD_lowKEF(HalNxt(cfirst), HalNxt(last));
00151 headf = SheSFaces(SolSShells(s));
00152 first = cfirst;
00153
00154 if ((mate(cfirst) != last) && (HalNxt(HalNxt(cfirst)) != last))
00155 {
00156 for (scan = HalNxt(HalNxt(cfirst)); scan != last; scan = HalNxt(scan))
00157 {
00158 if (comp(VerVCoord(HalVtx(scan))[pln], 0.0, EPS) == 0)
00159 {
00160 return(ERROR);
00161 }
00162 }
00163 }
00164
00165 matident(m);
00166 phix = axs == 0 ? 360.0 / (real)nfaces : 0.0;
00167 phiy = axs == 1 ? 360.0 / (real)nfaces : 0.0;
00168 phiz = axs == 2 ? 360.0 / (real)nfaces : 0.0;
00169 matrotat(m, phix, phiy, phiz);
00170
00171 first = cfirst;
00172 while (--nfaces)
00173 {
00174 vecmult(v, VerVCoord(HalVtx(HalNxt(cfirst))), m);
00175 MSD_lowMEV(HalNxt(cfirst), HalNxt(cfirst), maxv++, v[0], v[1], v[2]);
00176 scan = HalNxt(cfirst);
00177 while (scan != HalNxt(last))
00178 {
00179 vecmult(v, VerVCoord(HalVtx(HalPrv(scan))), m);
00180 MSD_lowMEV(HalPrv(scan), HalPrv(scan), maxv++, v[0], v[1], v[2]);
00181 MSD_lowMEF(HalPrv(HalPrv(scan)), HalNxt(scan), maxf++);
00182 scan = HalNxt(HalNxt(scan));
00183 scan = mate(scan);
00184 }
00185 last = scan;
00186 cfirst = HalNxt(HalNxt(cfirst));
00187 cfirst = mate(cfirst);
00188 }
00189 tailf = MSD_lowMEF(HalNxt(cfirst), mate(first), maxf++);
00190 while (cfirst != scan)
00191 {
00192 MSD_lowMEF(cfirst, HalNxt(HalNxt(HalNxt(cfirst))), maxf++);
00193 cfirst = HalPrv(mate(HalPrv(cfirst)));
00194 }
00195
00196 if (closed_figure == 1)
00197 {
00198 MSD_lowKFMRH(headf, tailf);
00199 MSD_lowLoopGlue(headf);
00200 }
00201 if (cut_headf == 1)
00202 {
00203 MSD_lowMakeFaceToPoint(headf);
00204 }
00205 if (cut_tailf == 1)
00206 {
00207 MSD_lowMakeFaceToPoint(tailf);
00208 }
00209 return(SUCCESS);
00210 }
00211
00212
00213 void MSD_lowMakeFaceToPoint(FPTYPE f)
00214 {
00215 HPTYPE he;
00216 HPTYPE henxt;
00217 LPTYPE l1;
00218 LPTYPE l2;
00219 int flag, drop;
00220
00221 he = LooLEdg(FacFLoops(f));
00222 if (HalEdg(he) != ENIL)
00223 {
00224 while (he != HalNxt(he))
00225 {
00226 henxt = HalNxt(he);
00227 MSD_lowKEV(henxt, mate(henxt));
00228 }
00229 MSD_lowKEF(mate(he), he);
00230 }
00231 else
00232 {
00233 for (AllLoopsFace(f, l1))
00234 {
00235 flag = 0;
00236 for (AllLoopsFace(f, l2))
00237 {
00238 if (l1 == l2)
00239 {
00240 continue;
00241 }
00242 drop = getdrop(FacFeq(f));
00243 if (MSD_lowLooVtxContainment(l1, HalVtx(LooLEdg(l2)), drop))
00244 {
00245 flag = 1;
00246 }
00247 }
00248 if (flag == 0)
00249 {
00250 FacFLOut(f) = l1;
00251 break;
00252 }
00253 }
00254 FacFLOut(f) = InnerLoop(f);
00255 }
00256 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 int MSD_lowMakeOpenRSweep(SPTYPE s, int pln)
00267 {
00268 HPTYPE scan;
00269 HPTYPE h;
00270
00271
00272 if (FacNextF(SheSFaces(SolSShells(s))) != FNIL)
00273 {
00274 h = LooLEdg(FacFLoops(SheSFaces(SolSShells(s))));
00275 if ((scan = MSD_lowTouchAxis(h, pln)) != HNIL)
00276 {
00277 if (comp(VerVCoord(HalVtx(HalNxt(scan)))[pln], 0.0, EPS) == 0)
00278 {
00279 MSD_lowKEF(scan, mate(scan));
00280 return(0);
00281 }
00282 if (comp(VerVCoord(HalVtx(HalPrv(scan)))[pln], 0.0, EPS) == 0)
00283 {
00284 MSD_lowKEF(HalPrv(scan), mate(HalPrv(scan)));
00285 return(0);
00286 }
00287 return(2);
00288 }
00289 else
00290 {
00291 maxv = MSD_getMaxVertexId(s);
00292 MSD_lowMEV(h, HalNxt(mate(h)), maxv++, VerVCoord(HalVtx(h))[0],
00293 VerVCoord(HalVtx(h))[1],
00294 VerVCoord(HalVtx(h))[2]);
00295 MSD_lowKEF(HalPrv(h), mate(HalPrv(h)));
00296 }
00297 return(1);
00298 }
00299 return(0);
00300 }
00301
00302 HPTYPE MSD_lowTouchAxis(HPTYPE eptr, int pln)
00303 {
00304 HPTYPE scan;
00305
00306 scan = eptr;
00307 do
00308 {
00309 if (comp(VerVCoord(HalVtx(scan))[pln], 0.0, EPS) == 0)
00310 {
00311 return(scan);
00312 }
00313 } while ((scan = HalNxt(scan)) != eptr);
00314 return(HNIL);
00315 }
00316
00317 HPTYPE MSD_lowTouchWire(HPTYPE eptr, int *cut, int pln)
00318 {
00319 *cut = 0;
00320 while (mate(eptr) != HalNxt(eptr))
00321 {
00322 eptr = HalNxt(eptr);
00323 }
00324 if (comp(VerVCoord(HalVtx(HalNxt(eptr)))[pln], 0.0, EPS) == 0)
00325 {
00326 while (comp(VerVCoord(HalVtx(eptr))[pln], 0.0, EPS) == 0)
00327 {
00328 eptr = HalPrv(eptr);
00329 MSD_lowKEV(mate(HalNxt(eptr)), HalNxt(eptr));
00330 }
00331 *cut = 1;
00332 }
00333 return(eptr);
00334 }