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 <stdlib.h>
00044 #include "mensagem.h"
00045 #include "memvirtu.h"
00046 #include "lowparam.h"
00047 #include "lowmacro.h"
00048 #include "lowsolid.h"
00049 #include "eulerops.h"
00050 #include "mancommd.h"
00051 #include "vectorop.h"
00052 #include "curvgeom.h"
00053 #include "shpshape.h"
00054 #include "lowgeome.h"
00055
00056 #ifdef __curved_env__
00057
00058 #ifdef __Extended_Version
00059 void MSD_execEvaluateCurvePolyline(void)
00060 {
00061 int sn, fn, v1, v2, nsegm;
00062 char sname[20];
00063
00064 while (5 != sscanf(restbuf, "%s %d %d %d %d", sname, &fn, &v1, &v2, &nsegm))
00065 {
00066 printf("EVAL_POLYLINE: sname fn v1 v2 nsegm\n");
00067 if (!lineins("? "))
00068 {
00069 return;
00070 }
00071 }
00072 if ((sn = MSD_getSolidIdFromName(sname)) == ERROR)
00073 {
00074 fprintf(stderr, MEN_NaoEncontrouSolidNome, NAM_EvalEdge, sname);
00075 return;
00076 }
00077 MSD_highEvaluateCurvePolyline(sn, fn, v1, v2, nsegm);
00078 }
00079
00080 int MSD_highEvaluateCurvePolyline(Id sn, Id fn, Id v1, Id v2, int nsegm)
00081 {
00082 SPTYPE s;
00083 FPTYPE f;
00084 HPTYPE he;
00085
00086 if ((s = MSD_getSolid(sn)) == SNIL)
00087 {
00088 fprintf(stderr, MEN_NaoEncontrouSolido, NAM_EvalEdge, sn);
00089 return(ERROR);
00090 }
00091 if ((f = MSD_getFace(s, fn)) == FNIL)
00092 {
00093 fprintf(stderr, MEN_NaoEncontrouFace, NAM_EvalEdge, fn, sn);
00094 return(ERROR);
00095 }
00096 if (MSD_getEdge(f, v1, v2, &he) == LNIL)
00097 {
00098 fprintf(stderr, MEN_NaoEncontrouArestaV, NAM_EvalEdge, v1, v2, sn);
00099 return(ERROR);
00100 }
00101 if (nsegm < 2)
00102 {
00103 fprintf(stderr, MEN_NumeroDeSegmentosInvalido, NAM_EvalEdge);
00104 return(ERROR);
00105 }
00106 MSD_lowEvaluateCurvePolyline(he, nsegm);
00107 MSD_lowSetNormal(s, TRUE);
00108 MSD_lowSetEdgeAngle(s);
00109 MSD_lowSetInfo(s);
00110
00111 if (TraceBoundaryStructure())
00112 {
00113 fprintf(stderr, "eval: *** aborted ***\n", NAM_EvalEdge);
00114 exit(1);
00115 }
00116
00117 return(SUCCESS);
00118 }
00119
00120 #endif
00121
00122 void MSD_lowEvaluateCurvePolyline(HPTYPE he, int nsegm)
00123 {
00124 CURVE *cu;
00125 LPOINT *p;
00126 int j;
00127 real del, del2, del3, x, y, z, deltax, delta2x, delta3x,
00128 deltay, delta2y, delta3y, deltaz, delta2z, delta3z;
00129 vector MGx, MGy, MGz, coefx, coefy, coefz;
00130
00131 #ifndef __VIRTUAL_MEM
00132 VTYPE v;
00133 #else
00134 VPTYPE v;
00135 #endif
00136
00137 maxv = MSD_getMaxVertexId(SheSSolids(FacFShell(LooLFace(HalWLoop(he)))));
00138 cu = HalCurv(he);
00139
00140 #ifndef __VIRTUAL_MEM
00141 veccopy(v.vcoord, cu->lpnt->pnt);
00142 if (MSD_lowVtxVtxContainment(&v, HalVtx(he)) == 0)
00143 {
00144 he = mate(he);
00145 }
00146 #else
00147 v = MSD_getMemVirtual(VERTEX);
00148 veccopy(VerVCoord(v), cu->lpnt->pnt);
00149 if (MSD_lowVtxVtxContainment(v, HalVtx(he)) == 0)
00150 {
00151 he = mate(he);
00152 }
00153 MSD_putMemVirtual(v, VERTEX);
00154 #endif
00155 he = HalNxt(he);
00156
00157 p = cu->lpnt;
00158 del = 1 / (real)nsegm;
00159
00160 Mc[0][0] = -1.0;
00161 Mc[0][1] = 3.0;
00162 Mc[0][2] = -3.0;
00163 Mc[0][3] = 1.0;
00164 Mc[1][0] = 3.0;
00165 Mc[1][1] = -6.0;
00166 Mc[1][2] = 3.0;
00167 Mc[1][3] = 0.0;
00168 Mc[2][0] = -3.0;
00169 Mc[2][1] = 3.0;
00170 Mc[2][2] = 0.0;
00171 Mc[2][3] = 0.0;
00172 Mc[3][0] = 1.0;
00173 Mc[3][1] = 0.0;
00174 Mc[3][2] = 0.0;
00175 Mc[3][3] = 0.0;
00176
00177 mattranspose(Mc, Mc);
00178
00179 MGx[0] = p->pnt[0];
00180 MGx[1] = p->pnxt->pnt[0];
00181 MGx[2] = p->pnxt->pnxt->pnt[0];
00182 MGx[3] = p->pnxt->pnxt->pnxt->pnt[0];
00183 vecmult(coefx, MGx, Mc);
00184
00185 MGy[0] = p->pnt[1];
00186 MGy[1] = p->pnxt->pnt[1];
00187 MGy[2] = p->pnxt->pnxt->pnt[1];
00188 MGy[3] = p->pnxt->pnxt->pnxt->pnt[1];
00189 vecmult(coefy, MGy, Mc);
00190
00191 MGz[0] = p->pnt[2];
00192 MGz[1] = p->pnxt->pnt[2];
00193 MGz[2] = p->pnxt->pnxt->pnt[2];
00194 MGz[3] = p->pnxt->pnxt->pnxt->pnt[2];
00195 vecmult(coefz, MGz, Mc);
00196
00197 del2 = del * del;
00198 del3 = del2 * del;
00199
00200 x = coefx[3];
00201 deltax = coefx[0] * del3 + coefx[1] * del2 + coefx[2] * del;
00202 delta2x = 6 * coefx[0] * del3 + 2 * coefx[1] * del2;
00203 delta3x = 6 * coefx[0] * del3;
00204
00205 y = coefy[3];
00206 deltay = coefy[0] * del3 + coefy[1] * del2 + coefy[2] * del;
00207 delta2y = 6 * coefy[0] * del3 + 2 * coefy[1] * del2;
00208 delta3y = 6 * coefy[0] * del3;
00209
00210 z = coefz[3];
00211 deltaz = coefz[0] * del3 + coefz[1] * del2 + coefz[2] * del;
00212 delta2z = 6 * coefz[0] * del3 + 2 * coefz[1] * del2;
00213 delta3z = 6 * coefz[0] * del3;
00214
00215 for (j = 1; j <= nsegm - 1; j++)
00216 {
00217 x += deltax;
00218 deltax += delta2x;
00219 delta2x += delta3x;
00220
00221 y += deltay;
00222 deltay += delta2y;
00223 delta2y += delta3y;
00224
00225 z += deltaz;
00226 deltaz += delta2z;
00227 delta2z += delta3z;
00228
00229 MSD_lowMEV(mate(HalPrv(he)), he, ++maxv, x, y, z);
00230 MSD_lowSetCurveAtributeToEdge(HalPrv(he), cu);
00231 }
00232 }
00233
00234 #endif