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 <stdlib.h>
00043 #include "mensagem.h"
00044 #include "memvirtu.h"
00045 #include "lowparam.h"
00046 #include "lowmacro.h"
00047 #include "lowsolid.h"
00048 #include "eulerops.h"
00049 #include "lowgeome.h"
00050 #include "mancommd.h"
00051
00052 #ifdef __Extended_Version
00053 void MSD_execGlue(void)
00054 {
00055 int s1, s2;
00056
00057 while (sscanf(restbuf, "%d %d", &s1, &s2) != 2)
00058 {
00059 printf("glue: s1 s2\n");
00060 if (!lineins("? "))
00061 {
00062 return;
00063 }
00064 }
00065 MSD_highGlue(s1, s2);
00066 }
00067
00068 #endif
00069
00070 int MSD_highGlue(Id sn1, Id sn2)
00071 {
00072 SPTYPE s1;
00073 SPTYPE s2;
00074
00075 if ((s1 = MSD_getSolid(sn1)) == SNIL)
00076 {
00077 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_Glue, sn1);
00078 return(ERROR);
00079 }
00080 if ((s2 = MSD_getSolid(sn2)) == SNIL)
00081 {
00082 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_Glue, sn2);
00083 return(ERROR);
00084 }
00085 MSD_lowGlue(s1, s2);
00086 return(SUCCESS);
00087 }
00088
00089 void MSD_lowGlue(SPTYPE s1, SPTYPE s2)
00090 {
00091 DPTYPE d1;
00092 DPTYPE d2;
00093 FPTYPE f1;
00094 FPTYPE f2;
00095 FPTYPE f3;
00096 int flag1, flag2;
00097
00098 MSD_lowMerge(s1, s2);
00099 for (AllShellsSolid(s1, d1))
00100 {
00101 for (AllFacesShell(d1, f1))
00102 {
00103 d2 = d1;
00104 f2 = FacNextF(f1);
00105 for ( ; d2 != DNIL; d2 = SheNextD(d2),
00106 f2 = d2 != DNIL ? SheSFaces(d2) : FNIL)
00107 {
00108 for ( ; f2 != FNIL;)
00109 {
00110 if (MSD_lowFacFacOppositeEqs(f1, f2) &&
00111 MSD_lowFacFacIdentical(f1, f2))
00112 {
00113 f3 = FacNextF(f2);
00114 if (FacFShell(f1) == FacFShell(f2))
00115 {
00116 MSD_lowKFMRH(f1, f2);
00117 }
00118 else
00119 {
00120 MSD_lowKSFMR(f1, f2);
00121 }
00122 f2 = f3;
00123 MSD_lowLoopGlue(f1);
00124 }
00125 else
00126 {
00127 f2 = FacNextF(f2);
00128 }
00129 }
00130 }
00131 }
00132 }
00133
00134 for (AllShellsSolid(s1, d1))
00135 {
00136 for (f1 = SheSFaces(d1); f1;)
00137 {
00138 flag1 = 0;
00139 for (AllShellsSolid(s1, d2))
00140 {
00141 for (f2 = SheSFaces(d2); f2;)
00142 {
00143 flag2 = 0;
00144 if (f2 == f1)
00145 {
00146 f2 = FacNextF(f2);
00147 flag2 = 1;
00148 continue;
00149 }
00150 if (MSD_lowFacFacOppositeEqs(f1, f2))
00151 {
00152 if (MSD_lowFacFacContainment(f1, f2) == 1)
00153 {
00154 f3 = FacNextF(f2);
00155 flag2 = 1;
00156 if (FacFShell(f1) == FacFShell(f2))
00157 {
00158 MSD_lowKFMRH(f1, f2);
00159 }
00160 else
00161 {
00162 MSD_lowKSFMR(f1, f2);
00163 }
00164 f2 = f3;
00165 }
00166 else
00167 if (MSD_lowFacFacContainment(f2, f1) == 1)
00168 {
00169 f3 = FacNextF(f1);
00170 flag1 = 1;
00171 if (FacFShell(f1) == FacFShell(f2))
00172 {
00173 MSD_lowKFMRH(f2, f1);
00174 }
00175 else
00176 {
00177 MSD_lowKSFMR(f2, f1);
00178 }
00179 f1 = f3;
00180 }
00181 }
00182 if (flag2 == 0)
00183 {
00184 f2 = FacNextF(f2);
00185 }
00186 }
00187 }
00188 if (flag1 == 0)
00189 {
00190 f1 = FacNextF(f1);
00191 }
00192 }
00193 }
00194 }
00195
00196 void MSD_lowFaceGlue(SPTYPE s1, SPTYPE s2, FPTYPE f1, FPTYPE f2)
00197 {
00198 MSD_lowMerge(s1, s2);
00199 MSD_lowKSFMR(f1, f2);
00200 MSD_lowLoopGlue(f1);
00201 }
00202
00203 int MSD_lowLoopGlue(FPTYPE f)
00204 {
00205 HPTYPE h1;
00206 HPTYPE h2;
00207 HPTYPE h1next;
00208
00209 assert1(LooNextL(FacFLoops(f)) != LNIL);
00210 assert1(LooNextL(LooNextL(FacFLoops(f))) == LNIL);
00211
00212 h1 = LooLEdg(FacFLoops(f));
00213 h2 = LooLEdg(LooNextL(FacFLoops(f)));
00214 if ((h1 == HalNxt(h1)) && (h1 == HalPrv(h1)))
00215 {
00216 return(FALSE);
00217 }
00218 while (!MSD_lowVtxVtxContainment(HalVtx(h1), HalVtx(h2)))
00219 {
00220 h2 = HalNxt(h2);
00221 }
00222
00223 MSD_lowMEKR(h1, h2);
00224 MSD_lowKEV(HalPrv(h1), HalPrv(h2));
00225 while (HalNxt(h1) != h2)
00226 {
00227 h1next = HalNxt(h1);
00228 MSD_lowMEF(HalNxt(h1), HalPrv(h1), maxf++);
00229 assert(HalVtx(HalNxt(h1)) != HalVtx(mate(HalNxt(h1))));
00230 MSD_lowKEV(HalNxt(h1), mate(HalNxt(h1)));
00231 MSD_lowKEF(mate(h1), h1);
00232 h1 = h1next;
00233 }
00234 MSD_lowKEF(mate(h1), h1);
00235 return(SUCCESS);
00236 }