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 "mensagem.h"
00043 #include "memvirtu.h"
00044 #include "lowmacro.h"
00045 #include "lowparam.h"
00046 #include "lowsolid.h"
00047 #include "eulerops.h"
00048 #include "mancommd.h"
00049 #include "curvgeom.h"
00050
00051 #ifdef __curved_env__
00052
00053
00054 #ifdef __Extended_Version
00055 void MSD_execSetCurveAtributeToEdge(void)
00056 {
00057 int sn, tag, fn, v1, v2;
00058 char sname[20];
00059
00060 while (5 != sscanf(restbuf, "%s %d %d %d %d", sname, &tag, &fn, &v1, &v2))
00061 {
00062 printf("PUTCTAG: sname tag fn v1 v2 \n");
00063 if (!lineins("? "))
00064 {
00065 return;
00066 }
00067 }
00068 if ((sn = MSD_getSolidIdFromName(sname)) == ERROR)
00069 {
00070 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_PutCTag, sname);
00071 return;
00072 }
00073 MSD_highSetCurveAtributeToEdge(sn, tag, fn, v1, v2);
00074 }
00075
00076 #endif
00077
00078 int MSD_highSetCurveAtributeToEdge(Id sn, Id tag, Id fn, Id v1, Id v2)
00079 {
00080 SPTYPE s;
00081 FPTYPE fac;
00082 HPTYPE hptr;
00083 CURVE *curv;
00084
00085 if ((s = MSD_getSolid(sn)) == SNIL)
00086 {
00087 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_PutCTag, sn);
00088 return(ERROR);
00089 }
00090 if ((fac = MSD_getFace(s, fn)) == FNIL)
00091 {
00092 fprintf(stderr, MEN_NaoEncontrouFace, NAM_PutCTag, fn, sn);
00093 return(ERROR);
00094 }
00095 if (MSD_getEdge(fac, v1, v2, &hptr) == LNIL)
00096 {
00097 fprintf(stderr, MEN_NaoEncontrouArestaV, NAM_PutCTag, v1, v2, sn);
00098 return(ERROR);
00099 }
00100 if ((curv = MSD_getCurve(s, tag)) == (CURVE *)NIL)
00101 {
00102 fprintf(stderr, MEN_NaoEncontrouTag, NAM_PutCTag, tag, sn);
00103 return(ERROR);
00104 }
00105 MSD_lowSetCurveAtributeToEdge(hptr, curv);
00106 return(SUCCESS);
00107 }
00108
00109 int MSD_highSetCurveAtribute(Id sn, Id tag, Id fn, Id v1, Id v2)
00110 {
00111 SPTYPE s;
00112 FPTYPE fac;
00113 HPTYPE hptr;
00114 CURVE *curv;
00115
00116 if ((s = MSD_getSolid(sn)) == SNIL)
00117 {
00118 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_PutCTag, sn);
00119 return(ERROR);
00120 }
00121 if ((fac = MSD_getFace(s, fn)) == FNIL)
00122 {
00123 fprintf(stderr, MEN_NaoEncontrouFace, NAM_PutCTag, fn, sn);
00124 return(ERROR);
00125 }
00126 if (MSD_getEdge(fac, v1, v2, &hptr) == LNIL)
00127 {
00128 fprintf(stderr, MEN_NaoEncontrouArestaV, NAM_PutCTag, v1, v2, sn);
00129 return(ERROR);
00130 }
00131 if ((curv = MSD_getCurve(s, tag)) == (CURVE *)NIL)
00132 {
00133 fprintf(stderr, MEN_NaoEncontrouTag, NAM_PutCTag, tag, sn);
00134 return(ERROR);
00135 }
00136 MSD_lowSetCurveAtribute(hptr, curv);
00137 return(SUCCESS);
00138 }
00139
00140
00141 int MSD_lowSetCurveAtributeToEdge(HPTYPE he, CURVE *tag)
00142 {
00143 MSD_lowSetCurveAtribute(he, tag);
00144 MSD_lowSetCurveAtribute(mate(he), tag);
00145 return(SUCCESS);
00146 }
00147
00148
00149 int MSD_lowSetCurveAtribute(HPTYPE he, CURVE *t)
00150 {
00151 SPTYPE s;
00152 FPTYPE f;
00153 CURVE *old;
00154 Id fid, v1d, v2d, cid;
00155
00156 if (t == (old = HalCurv(he)))
00157 {
00158 return(ERROR);
00159 }
00160 f = LooLFace(HalWLoop(he));
00161 HalCurv(he) = t;
00162
00163 if (Gdoinversion)
00164 {
00165 s = SheSSolids(FacFShell(f));
00166 fid = FacFaceNo(f);
00167 v1d = VerVertexNo(HalVtx(he));
00168 v2d = VerVertexNo(HalVtx(HalNxt(he)));
00169 cid = old == (CURVE *)NIL ? -1 : old->tagno;
00170 MSD_lowAddEulerOp(s, SETCTAG, fid, v1d, v2d, cid, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00171 }
00172 if (Gdodirect)
00173 {
00174 s = SheSSolids(FacFShell(f));
00175 fid = FacFaceNo(f);
00176 v1d = VerVertexNo(HalVtx(he));
00177 v2d = VerVertexNo(HalVtx(HalNxt(he)));
00178 cid = t->tagno;
00179 MSD_lowAddEulerOpRedo(s, SETCTAG, fid, v1d, v2d, cid, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0);
00180 }
00181
00182 if (old != (CURVE *)NIL)
00183 {
00184 if ((--old->times_used) == 0)
00185 {
00186 MSD_lowCurveDeleteElement(old, SheSSolids(FacFShell(f)));
00187 }
00188 }
00189 if (t != (CURVE *)NIL)
00190 {
00191 t->times_used++;
00192 }
00193 return(SUCCESS);
00194 }
00195
00196 int MSD_execStructSETCTAG(EulerOp *op)
00197 {
00198 Id sid, id1, id2, id3, id4;
00199
00200 sid = op->solidno;
00201 id1 = op->ip1;
00202 id2 = op->ip2;
00203 id3 = op->ip3;
00204 id4 = op->ip4;
00205 return(MSD_highSetCurveAtribute(sid, id1, id2, id3, id4));
00206 }
00207
00208 void MSD_printStructSETCTAG(FILE *f, EulerOp *op)
00209 {
00210 Id ids, id1, id2, id3, id4;
00211 int com;
00212
00213 ids = op->solidno;
00214 id1 = op->ip1;
00215 id2 = op->ip2;
00216 id3 = op->ip3;
00217 id4 = op->ip4;
00218 com = op->CommandCount;
00219 fprintf(f, "setctag %d %d %d %d %d\n", ids, com, id1, id2, id3, id4);
00220 }
00221
00222 int MSD_readStructSETCTAG(FILE *f, EulerOp *op)
00223 {
00224 int solidno, ip1, ip2, ip3, ip4, com;
00225
00226 if (fscanf(f, "%d %d %d %d %d\n", &solidno, &com, &ip1, &ip2, &ip3, &ip4) != 5)
00227 {
00228 return(ERROR);
00229 }
00230 op->solidno = solidno;
00231 op->CommandCount = com;
00232 op->ip1 = ip1;
00233 op->ip2 = ip2;
00234 op->ip3 = ip3;
00235 op->ip4 = ip4;
00236 op->ip5 = 0;
00237 op->ip6 = 0;
00238 op->ip7 = 0;
00239 op->ip8 = 0;
00240 op->fp1 = 0.0;
00241 op->fp2 = 0.0;
00242 op->fp3 = 0.0;
00243 op->fp4 = 0.0;
00244 return(SUCCESS);
00245 }
00246
00247 int MSD_modifyStructSETCTAG(EulerOp *op)
00248 {
00249 return(SUCCESS);
00250 }
00251
00252 #endif