Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1327 lines
32 KiB

  1. //
  2. // Copyright (c) 1997-1999 Microsoft Corporation.
  3. //
  4. #include "stdafx.h"
  5. #include "vdata.h"
  6. #include "extfunc.h"
  7. #include "ttfstruc.h"
  8. /* Smooth sort */
  9. #define SMOOTH 0x8000
  10. #define NOSMOOTH 0x4000
  11. #define BACKWARD 0x2000 /* NOSMOOTH is forward vector */
  12. #define FOREWARD 0x1000 /* NOSMOOTH is backward vector*/
  13. /* Curve Type */
  14. #define SPLINE_ATR 0x0001
  15. /* Smoothing anchor Point */
  16. #define SMOOTHANCHOR 0x0080
  17. /* Smoothing anchor point is based 90degree Rule */
  18. /* for turning */
  19. #define TURN_OU 1 /* �� */
  20. #define TURN_TOTSU 2 /* �� */
  21. #define sign(n) (n < 0 ? 1 : 0)
  22. #define LONGMIN 5
  23. int SmoothVector(int lstHdl,int tmpLst,int xinMesh,int yinMesh, int outMesh,struct SMOOTHPRM *prm,int fp);
  24. static int BindVector(int inLst,int outLst);
  25. static int BindPoint(int inLst,int outLst);
  26. static int DetectNoSmooth(int lsthdl);
  27. static void turnsort(struct VDATA *vp);
  28. static void generalsmooth(struct VDATA *vp);
  29. static int isturn(struct VDATA *vp);
  30. static int islong(struct VDATA *vp);
  31. static void longline(struct VDATA *vp);
  32. static int ZoomPoint(int lstHdl,int xinMesh,int yinMesh, int outMesh,int uFp);
  33. static int preproc1(int inLst,int outLst);
  34. static int diveachside(struct VDATA *vp,int outLst);
  35. static int divoneside(struct VDATA *vp,int outLst);
  36. static int divVec( int ilst, int olst, int divN);
  37. static int Smooth1(int inLst,int outLst,int weight1,int weight2,int weight3);
  38. static int Smooth2(int inLst,int outLst);
  39. int searchanchor(int sn,struct VDATA *sp,struct VDATA * *ep,int lim);
  40. static int smooth1sub(struct VDATA *vp,int np,int outLst,int w1,int w2,int w3);
  41. static int smooth2sub(struct VDATA *vp,int np,int outLst);
  42. int RemoveFp(int lstHdl,int outMesh,int uFp);
  43. static int BindLinears(int inLst,int outLst);
  44. static int DelZeroVec(int inLst,int outLst);
  45. int toTTFFrame(int lstH,struct BBX *bbx);
  46. static int lightSub(int inLst,int outLst);
  47. int SmoothLight(int ioLst,int tmpLst,int width,int height, int oWidth,int ufpVal);
  48. int ConvMesh(int lstH,int inMesh,int outMesh);
  49. static int
  50. straightCurve( int iLst, int oLst)
  51. {
  52. struct VHEAD *vhd;
  53. struct VDATA *vp;
  54. struct vecdata rel, nxtrel;
  55. int np;
  56. int sts;
  57. struct vecdata svd;
  58. if ( (sts = VDGetHead( iLst, &vhd))!=0)
  59. goto RET;
  60. VDNew(oLst);
  61. while ( vhd->next!=NIL) {
  62. /* No point data is not Allowed */
  63. /* Set Origin */
  64. vp = vhd->headp;
  65. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  66. goto RET;
  67. vp=vp->next;
  68. for ( np = 1; np < vhd->nPoints; np++,vp = vp->next) {
  69. if ( vp->vd.atr & SPLINE_ATR) {
  70. rel.x = vp->vd.x - vp->prev->vd.x;
  71. rel.y = vp->vd.y - vp->prev->vd.y;
  72. nxtrel.x= vp->next->vd.x - vp->vd.x;
  73. nxtrel.y= vp->next->vd.y - vp->vd.y;
  74. if ((long)rel.x*nxtrel.y==(long)rel.y*nxtrel.x){
  75. vp = vp->next;
  76. np++;
  77. svd = vp->vd;
  78. svd.atr &= ~SPLINE_ATR;
  79. if ((sts = VDSetData(oLst, &svd))!=0)
  80. goto RET;
  81. }
  82. else {
  83. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  84. goto RET;
  85. vp = vp->next;
  86. np++;
  87. if ( np >= vhd->nPoints)
  88. break;
  89. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  90. goto RET;
  91. }
  92. }
  93. else {
  94. if ((sts = VDSetData(oLst, &vp->vd))!=0)
  95. goto RET;
  96. }
  97. }
  98. if(VDClose( oLst))
  99. goto RET;
  100. vhd = vhd->next;
  101. }
  102. return 0;
  103. RET:
  104. return -1;
  105. }
  106. /***********************************************************************
  107. * Smoothing Main
  108. */
  109. /* */ int
  110. /* */ SmoothVector(
  111. /* */ int lstHdl,
  112. /* */ int tmpLst,
  113. /* */ int xinMesh, /* Input Mesh Size*/
  114. /* */ int yinMesh,
  115. /* */ int outMesh, /* Output Mesh size */
  116. /* */ struct SMOOTHPRM *prm,
  117. /* */ int fp) /* Fixed Point sft-val */
  118. /*
  119. * reuturns : 0, -1
  120. * Remarks : ̃W[̓͂́A֊sǒʂ̃xN^
  121. * @_ƂB
  122. * @o͂́Ao̓bVɍA_͍ŁA
  123. * @x[XCAxAO͒Ȃ
  124. ***********************************************************************/
  125. {
  126. int sts;
  127. if ( (sts = BindPoint( lstHdl, tmpLst))<0)
  128. goto RET;
  129. if ( (sts = DetectNoSmooth( tmpLst))<0)
  130. goto RET;
  131. if ( (sts = ZoomPoint( tmpLst, xinMesh, yinMesh, outMesh, fp))<0)
  132. goto RET;
  133. if ( (sts = preproc1( tmpLst, lstHdl))<0)
  134. goto RET;
  135. /* */
  136. if ( prm->UseConic) {
  137. if ( sts = divVec( lstHdl, tmpLst, 2))
  138. goto RET;
  139. if ( (sts = Smooth1( tmpLst, lstHdl, 1, 2, 1))<0)
  140. goto RET;
  141. if ( (sts = Smooth2( lstHdl, tmpLst))<0)
  142. goto RET;
  143. if ( sts = FitConic(tmpLst,lstHdl, prm->SmoothLevel, fp))
  144. goto RET;
  145. }
  146. else {
  147. if ( (sts = Smooth1( lstHdl, tmpLst, 1, 2, 1))<0)
  148. goto RET;
  149. if ( (sts = Smooth2( tmpLst, lstHdl))<0)
  150. goto RET;
  151. }
  152. if ( (sts = DelZeroVec( lstHdl, tmpLst))<0)
  153. goto RET;
  154. if ( (sts = straightCurve( tmpLst, lstHdl))<0)
  155. goto RET;
  156. if ( (sts = DelZeroVec( lstHdl, tmpLst))<0)
  157. goto RET;
  158. sts = BindLinears( tmpLst, lstHdl);
  159. RET:
  160. return sts;
  161. }
  162. /***********************************************************************
  163. * Bind Same Direction Unit Vector
  164. */
  165. /* */ static int
  166. /* */ BindVector(
  167. /* */ int inLst, /* Absolute Coordinate */
  168. /* */ int outLst) /* Relative one */
  169. /*
  170. * reuturns : 0, -1
  171. ***********************************************************************/
  172. {
  173. struct VHEAD *vhd;
  174. struct VDATA *vp;
  175. struct vecdata rel, nxtrel;
  176. int np;
  177. int sts;
  178. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  179. goto RET;
  180. VDNew(outLst);
  181. nxtrel.atr = 1;
  182. while ( vhd->next!=NIL) {
  183. /* No point data is not Allowed */
  184. /* Set Origin */
  185. vp = vhd->headp;
  186. if ((sts = VDSetData(outLst, &vp->vd))!=0)
  187. goto RET;
  188. rel.x = rel.y = 0;
  189. for ( np = 0; np < vhd->nPoints; np++,vp = vp->next) {
  190. nxtrel.x = vp->next->vd.x - vp->vd.x;
  191. nxtrel.y = vp->next->vd.y - vp->vd.y;
  192. if ( rel.x==0 && rel.y ==0)
  193. rel = nxtrel;
  194. else {
  195. if ( rel.y==0 && nxtrel.y==0)
  196. rel.x += nxtrel.x;
  197. else if ( rel.x == 0 && nxtrel.x==0)
  198. rel.y += nxtrel.y;
  199. else {
  200. if ((sts=VDSetData(outLst, &rel))!=0)
  201. goto RET;
  202. rel = nxtrel;
  203. }
  204. }
  205. }
  206. if ( rel.x!=0 || rel.y!=0) {
  207. if ((sts=VDSetData(outLst, &rel))!=0)
  208. goto RET;
  209. }
  210. vhd = vhd->next;
  211. if ((sts = VDClose(outLst))!=0)
  212. goto RET;
  213. }
  214. RET:
  215. return( sts);
  216. }
  217. /***********************************************************************
  218. * Bind Same Direction Unit Vector(Absolute Coodinate Version)
  219. * Only for short vector ( dont care SPLINE )
  220. */
  221. /* */ static int
  222. /* */ BindPoint(
  223. /* */ int inLst, /* Absolute Coordinate */
  224. /* */ int outLst) /* .. */
  225. /*
  226. * reuturns : 0, -1
  227. ***********************************************************************/
  228. {
  229. struct VHEAD *vhd;
  230. struct VDATA *vp;
  231. struct vecdata lastvd;
  232. int np;
  233. int sts;
  234. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  235. goto RET;
  236. VDNew(outLst);
  237. while ( vhd->next!=NIL) {
  238. /* No point data is not Allowed */
  239. /* Set Origin */
  240. vp = vhd->headp;
  241. if ((sts = VDSetData(outLst, &vp->vd))!=0)
  242. goto RET;
  243. lastvd = vp->vd;
  244. for ( np = 0; np < vhd->nPoints; np++,vp = vp->next) {
  245. if (vp->next->vd.x != lastvd.x && vp->next->vd.y != lastvd.y) {
  246. if ((sts=VDSetData(outLst, &vp->vd))!=0)
  247. goto RET;
  248. lastvd = vp->vd;
  249. }
  250. }
  251. vhd = vhd->next;
  252. if ((sts = VDClose(outLst))!=0)
  253. goto RET;
  254. }
  255. RET:
  256. return( sts);
  257. }
  258. /***********************************************************************
  259. * Detect Corner and edge
  260. */
  261. /* */ static int
  262. /* */ DetectNoSmooth(
  263. /* */ int lsthdl) /* Absolute Coordinate */
  264. /*
  265. * returns : 0, -1
  266. ***********************************************************************/
  267. {
  268. struct VHEAD *vhd;
  269. int sts;
  270. struct VDATA *vp;
  271. int np;
  272. if ( (sts = VDGetHead( lsthdl, &vhd))!=0)
  273. goto RET;
  274. while ( vhd->next != NIL) {
  275. vp = vhd->headp;
  276. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  277. if ( isturn( vp) )
  278. turnsort(vp);
  279. else if (islong (vp))
  280. longline( vp);
  281. else /* based on general rule */
  282. generalsmooth(vp);
  283. }
  284. vhd = vhd->next;
  285. }
  286. RET:
  287. return sts;
  288. }
  289. /***********************************************************************
  290. * Judge smooth or not at Turning Part
  291. */
  292. /* */ static void
  293. /* */ turnsort(
  294. /* */ struct VDATA *vp)
  295. /*
  296. * returns : none
  297. ***********************************************************************/
  298. {
  299. struct vecdata cur, prev1, prev2, next1, next2;
  300. cur.x = vp->vd.x-vp->prev->vd.x;
  301. cur.y = vp->vd.y-vp->prev->vd.y;
  302. prev1.x = vp->prev->vd.x-vp->prev->prev->vd.x;
  303. prev1.y = vp->prev->vd.y-vp->prev->prev->vd.y;
  304. prev2.x = vp->prev->prev->vd.x-vp->prev->prev->prev->vd.x;
  305. prev2.y = vp->prev->prev->vd.y-vp->prev->prev->prev->vd.y;
  306. next1.x = vp->next->vd.x - vp->vd.x;
  307. next1.y = vp->next->vd.y - vp->vd.y;
  308. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  309. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  310. if ( cur.x) {
  311. if ( abs(next1.y) > 1)
  312. vp->vd.atr |= NOSMOOTH ;
  313. else if ( sign( cur.x) == sign( next2.x))
  314. vp->vd.atr |= SMOOTH | BACKWARD;
  315. else
  316. vp->vd.atr |= NOSMOOTH;
  317. if ( abs(prev1.y) > 1)
  318. vp->prev->vd.atr |= NOSMOOTH ;
  319. else if (sign(cur.x)==sign(prev2.x))
  320. vp->prev->vd.atr |= SMOOTH | FOREWARD;
  321. else
  322. vp->prev->vd.atr |= NOSMOOTH ;
  323. }
  324. else {
  325. if ( abs(next1.x) > 1)
  326. vp->vd.atr |= NOSMOOTH ;
  327. else if ( sign( cur.y) == sign( next2.y))
  328. vp->vd.atr |= SMOOTH | BACKWARD;
  329. else
  330. vp->vd.atr |= NOSMOOTH;
  331. if ( abs(prev1.x) > 1)
  332. vp->prev->vd.atr |= NOSMOOTH ;
  333. else if (sign(cur.y)==sign(prev2.y))
  334. vp->prev->vd.atr |= SMOOTH | FOREWARD;
  335. else
  336. vp->prev->vd.atr |= NOSMOOTH;
  337. }
  338. return;
  339. }
  340. /***********************************************************************
  341. * Judge Smooth or not with general rule
  342. */
  343. /* */ static void
  344. /* */ generalsmooth( struct VDATA *vp)
  345. /*
  346. * returns : none
  347. ***********************************************************************/
  348. {
  349. struct vecdata prev2, prev1, cur, next1, next2, next3;
  350. cur.x = vp->vd.x- vp->prev->vd.x;
  351. cur.y = vp->vd.y- vp->prev->vd.y;
  352. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  353. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  354. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  355. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  356. next1.x = vp->next->vd.x - vp->vd.x;
  357. next1.y = vp->next->vd.y - vp->vd.y;
  358. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  359. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  360. next3.x = vp->next->next->next->vd.x - vp->next->next->vd.x;
  361. next3.y = vp->next->next->next->vd.y - vp->next->next->vd.y;
  362. if ( cur.y) {
  363. if ( abs(next1.x)>1 && abs(cur.y)>1) {
  364. if ( sign(cur.y) == sign(next1.x)
  365. && abs(next2.y)==1
  366. && abs(prev1.x)==1
  367. && sign(cur.y)==sign(prev2.y)
  368. && sign(next1.x)==sign( next3.x))
  369. ;
  370. else
  371. vp->vd.atr |= NOSMOOTH;
  372. }
  373. }
  374. else {
  375. if ( abs(next1.y)>1 && abs(cur.x)>1) {
  376. if ( sign(cur.x) != sign(next1.y)
  377. && abs(next2.x)==1
  378. && abs(prev1.y)==1
  379. && sign(cur.x)==sign(prev2.x)
  380. && sign(next1.y)==sign( next3.y))
  381. ;
  382. else
  383. vp->vd.atr |= NOSMOOTH;
  384. }
  385. }
  386. return;
  387. }
  388. /***********************************************************************
  389. * Judge turning
  390. */
  391. /* */ static int
  392. /* */ isturn( struct VDATA *vp) /* Absolute */
  393. /*
  394. * retuns
  395. ***********************************************************************/
  396. {
  397. int turnSort;
  398. struct vecdata prev, cur, next;
  399. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  400. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  401. cur.x = vp->vd.x - vp->prev->vd.x;
  402. cur.y = vp->vd.y - vp->prev->vd.y;
  403. next.x = vp->next->vd.x - vp->vd.x;
  404. next.y = vp->next->vd.y - vp->vd.y;
  405. if ( prev.x !=0) {
  406. if ( sign(prev.x )!=sign(next.x )) {
  407. if (sign(next.x ) ==sign(cur.y))
  408. turnSort = TURN_TOTSU;
  409. else
  410. turnSort = TURN_OU;
  411. }
  412. else turnSort = 0;
  413. }
  414. else {
  415. if ( sign(prev.y )!=sign(next.y )) {
  416. if (sign(next.y ) ==sign(cur.x))
  417. turnSort = TURN_OU;
  418. else
  419. turnSort = TURN_TOTSU;
  420. }
  421. else turnSort = 0;
  422. }
  423. return turnSort;
  424. }
  425. /***********************************************************************
  426. * judge Long Line or Not
  427. */
  428. /* */ static int
  429. /* */ islong( struct VDATA *vp)
  430. /*
  431. * returns : 0, 1
  432. ***********************************************************************/
  433. {
  434. struct vecdata cur, prev1, prev2, next1, next2;
  435. int sts;
  436. cur.x = vp->vd.x - vp->prev->vd.x;
  437. cur.y = vp->vd.y - vp->prev->vd.y;
  438. if ( abs(cur.x)<= LONGMIN && abs(cur.y) <= LONGMIN)
  439. return( 0);
  440. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  441. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  442. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  443. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  444. next1.x = vp->next->vd.x - vp->vd.x;
  445. next1.y = vp->next->vd.y - vp->vd.y;
  446. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  447. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  448. if ( cur.x) {
  449. if ( (sign(cur.x) != sign(next2.x)
  450. || abs(next1.y)>1
  451. || ( abs(next1.y)==1 && abs(cur.x)/2 > abs(next2.x)))
  452. && (sign(cur.x) != sign(prev2.x)
  453. || abs(prev1.y)>1
  454. || ( abs(prev1.y)==1 && abs(cur.x)/2 > abs(prev2.x))))
  455. sts = 1;
  456. /* 94.11.09 */
  457. else if ( abs(cur.x) > 2 && (abs(next1.y)>2 || abs(prev1.y)>2))
  458. sts = 1;
  459. /* */
  460. else sts = 0;
  461. }
  462. else {
  463. if ( (sign(cur.y) != sign(next2.y)
  464. || abs(next1.x)>1
  465. || ( abs(next1.x)==1 && abs(cur.y)/2 > abs(next2.y)))
  466. && (sign(cur.y) != sign(prev2.y)
  467. || abs(prev1.x)>1
  468. || ( abs(prev1.x)==1 && abs(cur.y)/2 > abs(prev2.y))))
  469. sts = 1;
  470. /* 94.11.09 */
  471. else if ( abs(cur.y) > 2 && (abs(next1.x)>2 || abs(prev1.x)>2))
  472. sts = 1;
  473. /* */
  474. else sts = 0;
  475. }
  476. return sts;
  477. }
  478. /***********************************************************************
  479. * judge Long Line or Not
  480. */
  481. /* */ static void
  482. /* */ longline( struct VDATA *vp)
  483. /*
  484. * returns : 0, 1
  485. ***********************************************************************/
  486. {
  487. struct vecdata cur, prev1, prev2, next1, next2;
  488. prev2.x = vp->prev->prev->vd.x - vp->prev->prev->prev->vd.x;
  489. prev2.y = vp->prev->prev->vd.y - vp->prev->prev->prev->vd.y;
  490. prev1.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  491. prev1.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  492. cur.x = vp->vd.x - vp->prev->vd.x;
  493. cur.y = vp->vd.y - vp->prev->vd.y;
  494. next1.x = vp->next->vd.x - vp->vd.x;
  495. next1.y = vp->next->vd.y - vp->vd.y;
  496. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  497. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  498. if ( cur.x) {
  499. /* �O�� */
  500. if ( abs(next1.y)!=1 || sign(cur.x)!=sign(next2.x))
  501. vp->vd.atr |= NOSMOOTH;
  502. else if ( abs( next2.x) ==1 && sign(cur.x)==sign(next1.y))
  503. vp->vd.atr |= NOSMOOTH;
  504. else
  505. vp->vd.atr |= NOSMOOTH | BACKWARD;
  506. /* ���� */
  507. if ( abs(prev1.y)!=1 || sign(cur.x)!=sign(prev2.x))
  508. vp->prev->vd.atr |= NOSMOOTH;
  509. else if ( abs( prev2.x) ==1&& sign(cur.x)!=sign(prev1.y))
  510. vp->prev->vd.atr |= NOSMOOTH;
  511. else
  512. vp->prev->vd.atr |= NOSMOOTH | FOREWARD;
  513. }
  514. else {
  515. /* �O�� */
  516. if ( abs(next1.x)!=1 || sign(cur.y)!=sign(next2.y))
  517. vp->vd.atr |= NOSMOOTH;
  518. else if ( abs( next2.y) ==1 && sign(cur.y)!=sign(next1.x))
  519. vp->vd.atr |= NOSMOOTH;
  520. else
  521. vp->vd.atr |= NOSMOOTH | BACKWARD;
  522. /* ���� */
  523. if ( abs(prev1.x)!=1 || sign(cur.y)!=sign(prev2.y))
  524. vp->prev->vd.atr |= NOSMOOTH;
  525. else if ( abs( prev2.y) ==1&& sign(cur.y)==sign(prev1.x))
  526. vp->prev->vd.atr |= NOSMOOTH;
  527. else
  528. vp->prev->vd.atr |= NOSMOOTH | FOREWARD;
  529. }
  530. }
  531. /***********************************************************************
  532. * Zoom for fixed point
  533. */
  534. /* */ static int
  535. /* */ ZoomPoint(
  536. /* */ int lstHdl, /* List Handle to proccess */
  537. /* */ int xinMesh, /* INPut Dot Mesh */
  538. /* */ int yinMesh,
  539. /* */ int outMesh, /* output mesh (256) */
  540. /* */ int uFp) /* Under Fixed Point Value */
  541. /*
  542. * returns : none
  543. * remarks : ʂ̍WńA(128,128)[=outMesh/2]_ɈړA
  544. * @UFp|lł
  545. ***********************************************************************/
  546. {
  547. struct VHEAD *vhd;
  548. int sts;
  549. struct VDATA *vp;
  550. int np;
  551. int center;
  552. center = outMesh/2*uFp;
  553. if ( (sts = VDGetHead( lstHdl, &vhd))!=0)
  554. goto RET;
  555. while ( vhd->next != NIL) {
  556. vp = vhd->headp;
  557. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  558. vp->vd.x =(short)((long)vp->vd.x*outMesh*uFp/xinMesh)-center;
  559. vp->vd.y =(short)((long)vp->vd.y*outMesh*uFp/yinMesh)-center;
  560. }
  561. vhd = vhd->next;
  562. }
  563. RET:
  564. return sts;
  565. }
  566. /***********************************************************************
  567. * Pre-Proc1 of smoothing( divide long vector )
  568. */
  569. /* */ static int
  570. /* */ preproc1( int inLst, int outLst)
  571. /*
  572. * returns : 0. -1
  573. ***********************************************************************/
  574. {
  575. struct VHEAD *vhd;
  576. int sts;
  577. struct VDATA *vp;
  578. int np;
  579. struct vecdata vd;
  580. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  581. goto RET;
  582. VDNew( outLst);
  583. while ( vhd->next != NIL) {
  584. vp = vhd->headp;
  585. for ( np = 0; np < vhd->nPoints; ) {
  586. if ( vp->vd.atr & FOREWARD) {
  587. if ( vp->next->vd.atr& BACKWARD) {
  588. if ((sts = diveachside( vp, outLst))<0)
  589. goto RET;
  590. np++;
  591. vp = vp->next;
  592. }
  593. else {
  594. if ((sts=divoneside(vp, outLst))<0)
  595. goto RET;
  596. }
  597. }
  598. else if ((vp->vd.atr & BACKWARD)
  599. && (vp->prev->vd.atr & FOREWARD)==0){
  600. if ( (sts = divoneside( vp, outLst))<0)
  601. goto RET;
  602. }
  603. else { /* only copy */
  604. vd = vp->vd;
  605. if ( vp->vd.atr & NOSMOOTH)
  606. vd.atr = SMOOTHANCHOR;
  607. if ((sts=VDSetData( outLst, &vd))<0)
  608. goto RET;
  609. }
  610. np++;
  611. vp = vp->next;
  612. }
  613. if ( (sts = VDClose( outLst))<0)
  614. break;
  615. vhd = vhd->next;
  616. }
  617. RET:
  618. return sts;
  619. }
  620. /***********************************************************************
  621. * Divide Vector from each side( for PreProc)
  622. */
  623. /* */ static int
  624. /* */ diveachside( struct VDATA *vp, int outLst)
  625. /*
  626. * returns : 0, -1
  627. ***********************************************************************/
  628. {
  629. struct vecdata prev, cur, next1, next2, next3;
  630. struct vecdata div1, div2;
  631. int sts;
  632. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  633. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  634. cur.x = vp->vd.x - vp->prev->vd.x;
  635. cur.y = vp->vd.y - vp->prev->vd.y;
  636. next1.x = vp->next->vd.x - vp->vd.x;
  637. next1.y = vp->next->vd.y - vp->vd.y;
  638. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  639. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  640. next3.x = vp->next->next->next->vd.x - vp->next->next->vd.x;
  641. next3.y = vp->next->next->next->vd.y - vp->next->next->vd.y;
  642. sts = 0;
  643. if ( next1.x) {
  644. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  645. goto RET;
  646. div1.y = vp->vd.y;
  647. div2.y = vp->vd.y;
  648. div1.atr = SMOOTHANCHOR;
  649. div2.atr = SMOOTHANCHOR;
  650. if ( abs(prev.x) + abs( next3.x) <= abs(next1.x)) {
  651. div1.x = vp->vd.x + prev.x;
  652. if ( (sts = VDSetData( outLst, &div1))<0)
  653. goto RET;
  654. div2.x = vp->next->vd.x - next3.x;
  655. if ( (sts = VDSetData( outLst, &div2))<0)
  656. goto RET;
  657. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  658. goto RET;
  659. }
  660. else {
  661. div1.x = (short)((long)next1.x*abs(prev.x)/abs(prev.x + next3.x));
  662. if ( div1.x != 0) {
  663. div1.x += vp->vd.x;
  664. if ( (sts = VDSetData( outLst, &div1))<0)
  665. goto RET;
  666. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  667. goto RET;
  668. }
  669. else {
  670. div1.x = vp->next->vd.x;
  671. div1.y = vp->next->vd.y;
  672. if ( (sts = VDSetData( outLst, &div1))<0)
  673. goto RET;
  674. }
  675. }
  676. }
  677. else {
  678. div1.x = vp->vd.x;
  679. div2.x = vp->vd.x;
  680. div1.atr = SMOOTHANCHOR;
  681. div2.atr = SMOOTHANCHOR;
  682. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  683. goto RET;
  684. if ( abs(prev.y) + abs( next3.y) <= abs(next1.y)) {
  685. // div1.y = vp->vd.y + prev.y;
  686. div1.y = vp->vd.y + prev.y/2;
  687. if ( (sts = VDSetData( outLst, &div1))<0)
  688. goto RET;
  689. // div2.y = vp->next->vd.y - next3.y;
  690. div2.y = vp->next->vd.y - next3.y/2;
  691. if ( (sts = VDSetData( outLst, &div2))<0)
  692. goto RET;
  693. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  694. goto RET;
  695. }
  696. else {
  697. div1.y = (short)((long)next1.y*abs(prev.y)/abs(prev.y + next3.y));
  698. if ( div1.y!=0) {
  699. div1.y += vp->vd.y;
  700. if ( (sts = VDSetData( outLst, &div1))<0)
  701. goto RET;
  702. if ( (sts = VDSetData( outLst, &vp->next->vd))<0)
  703. goto RET;
  704. }
  705. else {
  706. div1.x = vp->next->vd.x;
  707. div1.y = vp->next->vd.y;
  708. if ( (sts = VDSetData( outLst, &div1))<0)
  709. goto RET;
  710. }
  711. }
  712. }
  713. RET:
  714. return( sts);
  715. }
  716. /***********************************************************************
  717. *
  718. */
  719. /* */ static int
  720. /* */ divoneside(
  721. /* */ struct VDATA *vp,
  722. /* */ int outLst)
  723. /*
  724. *
  725. ***********************************************************************/
  726. {
  727. struct vecdata prev, cur, next1, next2;
  728. struct vecdata div1;
  729. int sts;
  730. sts = 0;
  731. div1.atr = SMOOTHANCHOR;
  732. if ( vp->vd.atr & FOREWARD) {
  733. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  734. goto RET;
  735. prev.x = vp->prev->vd.x - vp->prev->prev->vd.x;
  736. prev.y = vp->prev->vd.y - vp->prev->prev->vd.y;
  737. cur.x = vp->vd.x - vp->prev->vd.x;
  738. cur.y = vp->vd.y - vp->prev->vd.y;
  739. next1.x = vp->next->vd.x - vp->vd.x;
  740. next1.y = vp->next->vd.y - vp->vd.y;
  741. if ( vp->vd.x == vp->prev->vd.x) {
  742. if ( abs(prev.x) < abs(next1.x)) {
  743. div1.y = vp->vd.y;
  744. // div1.x = vp->vd.x + prev.x;
  745. div1.x = vp->vd.x + prev.x/2;
  746. if ( (sts = VDSetData( outLst, &div1))<0)
  747. goto RET;
  748. }
  749. }
  750. else {
  751. if ( abs(prev.y) < abs(next1.y)) {
  752. div1.x = vp->vd.x;
  753. // div1.y = vp->vd.y + prev.y;
  754. div1.y = vp->vd.y + prev.y/2;
  755. if ( (sts = VDSetData( outLst, &div1))<0)
  756. goto RET;
  757. }
  758. }
  759. }
  760. else {
  761. cur.x = vp->vd.x - vp->prev->vd.x;
  762. cur.y = vp->vd.y - vp->prev->vd.y;
  763. next2.x = vp->next->next->vd.x - vp->next->vd.x;
  764. next2.y = vp->next->next->vd.y - vp->next->vd.y;
  765. if ( vp->vd.x == vp->next->vd.x) {
  766. if ( abs(cur.x) > abs(next2.x)) {
  767. // div1.x = vp->vd.x - next2.x;
  768. div1.x = vp->vd.x - next2.x/2;
  769. div1.y = vp->vd.y;
  770. if ( (sts = VDSetData( outLst, &div1))<0)
  771. goto RET;
  772. }
  773. }
  774. else {
  775. if ( abs(cur.y) > abs(next2.y)) {
  776. div1.x = vp->vd.x;
  777. // div1.y = vp->vd.y - next2.y;
  778. div1.y = vp->vd.y - next2.y/2;
  779. if ( (sts = VDSetData( outLst, &div1))<0)
  780. goto RET;
  781. }
  782. }
  783. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  784. goto RET;
  785. }
  786. RET:
  787. return( sts);
  788. }
  789. /***********************************************************************
  790. * Smoothing 1
  791. */
  792. /* */ static int
  793. /* */ Smooth1( int inLst,
  794. /* */ int outLst,
  795. /* */ int weight1, /* Waight of Smoothing Form.*/
  796. /* */ int weight2,
  797. /* */ int weight3 )
  798. /*
  799. * returns : 0, -1
  800. ***********************************************************************/
  801. {
  802. struct VHEAD *vhd;
  803. int sts;
  804. struct VDATA *svp, *evp;
  805. int sp, ep;
  806. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  807. goto RET;
  808. VDNew( outLst);
  809. while ( vhd->next != NIL) {
  810. svp = vhd->headp;
  811. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  812. while(sp <vhd->nPoints) {
  813. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  814. if ((sts=smooth1sub( svp, ep-sp,outLst,weight1, weight2, weight3))<0)
  815. goto RET;
  816. if ( ep >= vhd->nPoints)
  817. break;
  818. sp = ep;
  819. svp = evp;
  820. }
  821. }
  822. vhd = vhd->next;
  823. if ( (sts = VDClose( outLst)) < 0)
  824. break;
  825. }
  826. RET:
  827. return sts;
  828. }
  829. /***********************************************************************
  830. * Smoothing 2 ( mabiki)
  831. */
  832. /* */ static int
  833. /* */ Smooth2( int inLst, int outLst )
  834. /*
  835. * returns : 0, -1
  836. ***********************************************************************/
  837. {
  838. struct VHEAD *vhd;
  839. int sts;
  840. struct VDATA *svp, *evp;
  841. int sp, ep;
  842. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  843. goto RET;
  844. VDNew( outLst);
  845. while ( vhd->next != NIL) {
  846. svp = vhd->headp;
  847. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  848. while(sp <vhd->nPoints) {
  849. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  850. if ((sts=smooth2sub( svp, ep-sp,outLst))<0)
  851. goto RET;
  852. if ( ep >= vhd->nPoints)
  853. break;
  854. sp = ep;
  855. svp = evp;
  856. }
  857. }
  858. vhd = vhd->next;
  859. if ( (sts = VDClose( outLst)) < 0)
  860. break;
  861. }
  862. RET:
  863. return sts;
  864. }
  865. /***********************************************************************
  866. * Search Smoothing Anchor Point
  867. */
  868. /* */ int
  869. /* */ searchanchor(
  870. /* */ int sn,
  871. /* */ struct VDATA *sp,
  872. /* */ struct VDATA **ep,
  873. /* */ int lim)
  874. /*
  875. *
  876. ***********************************************************************/
  877. {
  878. while ( lim-- > 0) {
  879. if (sp->vd.atr & SMOOTHANCHOR) {
  880. *ep = sp;
  881. return sn;
  882. }
  883. sp = sp->next;
  884. sn++;
  885. }
  886. return( sn);
  887. }
  888. /***********************************************************************
  889. * Smooth1 body
  890. */
  891. /* */ static int
  892. /* */ smooth1sub(
  893. /* */ struct VDATA *vp,
  894. /* */ int np,
  895. /* */ int outLst,
  896. /* */ int w1, /* Waight of Smoothing Form.*/
  897. /* */ int w2,
  898. /* */ int w3)
  899. /*
  900. * returns : 0, -1
  901. ***********************************************************************/
  902. {
  903. int pcnt,
  904. sts;
  905. struct vecdata vd;
  906. int base;
  907. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  908. goto RET;
  909. np--;
  910. vp = vp->next;
  911. base = w1 + w2 + w3;
  912. for ( pcnt = 0; pcnt < np; pcnt++, vp= vp->next) {
  913. vd.x = (vp->prev->vd.x*w1 + vp->vd.x*w2 + vp->next->vd.x*w3)/base;
  914. vd.y = (vp->prev->vd.y*w1 + vp->vd.y*w2 + vp->next->vd.y*w3)/base;
  915. vd.atr = vp->vd.atr;
  916. if ( (sts = VDSetData( outLst, &vd))<0)
  917. break;
  918. }
  919. RET:
  920. return( sts);
  921. }
  922. /***********************************************************************
  923. * Smooth2 body ( mabiki body)
  924. */
  925. /* */ static int
  926. /* */ smooth2sub(
  927. /* */ struct VDATA *vp,
  928. /* */ int np,
  929. /* */ int outLst)
  930. /*
  931. * returns : 0, -1
  932. ***********************************************************************/
  933. {
  934. int pcnt,
  935. sts;
  936. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  937. goto RET;
  938. np--;
  939. vp = vp->next;
  940. for ( pcnt = 0; pcnt < np; pcnt++, vp= vp->next) {
  941. if ( np < 3 || pcnt % 2 == 0) {
  942. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  943. break;
  944. }
  945. }
  946. RET:
  947. return( sts);
  948. }
  949. /***********************************************************************
  950. * Remove Fixed Point
  951. */
  952. /* */ int
  953. /* */ RemoveFp(
  954. /* */ int lstHdl, /* List Handle to proccess */
  955. /* */ int outMesh, /* output mesh */
  956. /* */ int uFp) /* Under Fixed Point Value */
  957. /*
  958. * returns : none
  959. * remarks : X[YBȌʂ̍WńAUFpŊČ_
  960. * (128,128) [=outMesh/2]Ɉړlł
  961. ***********************************************************************/
  962. {
  963. struct VHEAD *vhd;
  964. int sts;
  965. struct VDATA *vp;
  966. int center;
  967. int np;
  968. center = outMesh/2;
  969. if ( (sts = VDGetHead( lstHdl, &vhd))!=0)
  970. goto RET;
  971. while ( vhd->next != NIL) {
  972. vp = vhd->headp;
  973. for ( np = 0; np < vhd->nPoints; np++, vp = vp->next) {
  974. vp->vd.x = vp->vd.x / uFp+center;
  975. if ( vp->vd.x < 0) vp->vd.x = 0;
  976. else if ( vp->vd.x >= outMesh) vp->vd.x = outMesh-1;
  977. vp->vd.y = vp->vd.y / uFp+center;
  978. if ( vp->vd.y < 0) vp->vd.y = 0;
  979. else if ( vp->vd.y >= outMesh) vp->vd.y = outMesh-1;
  980. }
  981. vhd = vhd->next;
  982. }
  983. RET:
  984. return sts;
  985. }
  986. /***********************************************************************
  987. * Bind same direction vector
  988. */
  989. /* */ static int
  990. /* */ BindLinears( int inLst, int outLst)
  991. /*
  992. ***********************************************************************/
  993. {
  994. struct VHEAD *vhd;
  995. int sts;
  996. struct VDATA *vp;
  997. int np;
  998. struct vecdata rel1, rel2;
  999. VDNew( outLst);
  1000. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1001. goto RET;
  1002. while ( vhd->next != NIL) {
  1003. vp = vhd->headp;
  1004. /* Origin */
  1005. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1006. goto RET;
  1007. vp = vp->next;
  1008. for ( np = 1; np < vhd->nPoints; np++, vp = vp->next) {
  1009. if ( np+1 >= vhd->nPoints) {
  1010. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1011. goto RET;
  1012. break;
  1013. }
  1014. else if ( vp->vd.atr&SPLINE_ATR) {
  1015. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1016. goto RET;
  1017. /* End Point */
  1018. vp = vp->next;
  1019. np++;
  1020. if ( np >= vhd->nPoints)
  1021. break;
  1022. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1023. goto RET;
  1024. }
  1025. else {
  1026. rel1.x = vp->next->vd.x - vp->vd.x;
  1027. rel1.y = vp->next->vd.y - vp->vd.y;
  1028. rel2.x = vp->vd.x - vp->prev->vd.x;
  1029. rel2.y = vp->vd.y - vp->prev->vd.y;
  1030. if ( (vp->next->vd.atr & SPLINE_ATR )
  1031. || (long)rel1.x*rel2.y != (long)rel1.y*rel2.x) {
  1032. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1033. goto RET;
  1034. }
  1035. }
  1036. }
  1037. if ( (sts = VDClose( outLst))<0)
  1038. goto RET;
  1039. vhd = vhd->next;
  1040. }
  1041. RET:
  1042. return( sts);
  1043. }
  1044. /***********************************************************************
  1045. * Deleate Zero Vector ( about Non Curve Part)
  1046. */
  1047. /* */ static int
  1048. /* */ DelZeroVec( int inLst, int outLst)
  1049. /*
  1050. ***********************************************************************/
  1051. {
  1052. struct VHEAD *vhd;
  1053. int sts;
  1054. struct VDATA *vp;
  1055. int np;
  1056. VDNew( outLst);
  1057. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1058. goto RET;
  1059. while ( vhd->next != NIL) {
  1060. vp = vhd->headp;
  1061. /* Origin */
  1062. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1063. goto RET;
  1064. vp = vp->next;
  1065. for ( np = 1; np < vhd->nPoints; np++, vp = vp->next) {
  1066. if ( vp->vd.atr&SPLINE_ATR) {
  1067. /* Control Point */
  1068. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1069. goto RET;
  1070. /* End Point */
  1071. vp = vp->next;
  1072. np++;
  1073. if ( np >= vhd->nPoints)
  1074. break;
  1075. if ( (sts = VDSetData( outLst, &vp->vd))<0)
  1076. goto RET;
  1077. }
  1078. else {
  1079. if ( vp->vd.x != vp->prev->vd.x
  1080. || vp->vd.y != vp->prev->vd.y) {
  1081. if ((sts=VDSetData( outLst, &vp->vd))<0)
  1082. goto RET;
  1083. }
  1084. }
  1085. }
  1086. if ( (sts = VDClose( outLst))<0)
  1087. goto RET;
  1088. vhd = vhd->next;
  1089. }
  1090. RET:
  1091. return( sts);
  1092. }
  1093. /* X |Y
  1094. * O------------ +-|------+
  1095. * | | | | |
  1096. * | | ---> | | |
  1097. * | | -----+-------------X
  1098. * |-------+ O-|------+
  1099. * |Y |
  1100. */
  1101. int
  1102. toTTFFrame( int lstH, struct BBX *bbx)
  1103. {
  1104. struct VHEAD *vhd;
  1105. struct VDATA *vp;
  1106. int np;
  1107. int sts;
  1108. short mesh;
  1109. if ( (sts = VDGetHead( lstH, &vhd))!=0)
  1110. goto RET;
  1111. if ( (sts = VDGetNCont( lstH))<=0)
  1112. goto RET;
  1113. mesh = bbx->xMax - bbx->xMin+1;
  1114. if ( mesh > bbx->yMax - bbx->yMin)
  1115. mesh = bbx->yMax - bbx->yMin+1;
  1116. while ( vhd->next != NIL) {
  1117. vp = vhd->headp;
  1118. np = vhd->nPoints;
  1119. while ( np-->0) {
  1120. vp->vd.x += (short)bbx->xMin;
  1121. vp->vd.y = (mesh - 1) - vp->vd.y + bbx->yMin;
  1122. /* Limit in BBX */
  1123. if ( vp->vd.x > bbx->xMax)
  1124. vp->vd.x = (short)bbx->xMax;
  1125. else if (vp->vd.x < bbx->xMin)
  1126. vp->vd.x = (short)bbx->xMin;
  1127. if ( vp->vd.y > bbx->yMax)
  1128. vp->vd.y = (short)bbx->yMax;
  1129. else if (vp->vd.y < bbx->yMin)
  1130. vp->vd.y = (short)bbx->yMin;
  1131. vp = vp->next;
  1132. }
  1133. vhd = vhd->next;
  1134. }
  1135. sts = 0;
  1136. RET:
  1137. return sts;
  1138. }
  1139. static int
  1140. lightSub( int inLst, int outLst)
  1141. {
  1142. struct VHEAD *vhd;
  1143. int sts;
  1144. struct VDATA *svp, *evp;
  1145. int sp, ep;
  1146. if ( (sts = VDGetHead( inLst, &vhd))!=0)
  1147. goto RET;
  1148. VDNew( outLst);
  1149. while ( vhd->next != NIL) {
  1150. svp = vhd->headp;
  1151. if ((sp=searchanchor(0,svp,&svp,vhd->nPoints))<vhd->nPoints){
  1152. while(sp <vhd->nPoints) {
  1153. ep = searchanchor(sp+1, svp->next,&evp, vhd->nPoints);
  1154. if ((sts=smooth1sub( svp, ep-sp,outLst,1, 2, 1))<0)
  1155. goto RET;
  1156. if ( ep >= vhd->nPoints)
  1157. break;
  1158. sp = ep;
  1159. svp = evp;
  1160. }
  1161. }
  1162. vhd = vhd->next;
  1163. if ( (sts = VDClose( outLst)) < 0)
  1164. break;
  1165. }
  1166. RET:
  1167. return sts;
  1168. }
  1169. static int
  1170. divVec( int ilst, int olst, int divN)
  1171. {
  1172. struct VHEAD *vhd;
  1173. struct VDATA *vp;
  1174. struct vecdata rel, vd;
  1175. int np;
  1176. int n;
  1177. if ( VDGetHead( ilst, &vhd)!=0)
  1178. goto RET;
  1179. VDNew( olst);
  1180. while ( vhd->next != NIL) {
  1181. vp = vhd->headp;
  1182. np = vhd->nPoints;
  1183. while ( np-->0) {
  1184. if (VDSetData(olst, &vp->vd))
  1185. goto RET;
  1186. rel.x = vp->next->vd.x - vp->vd.x;
  1187. rel.y = vp->next->vd.y - vp->vd.y;
  1188. vd.atr = 0;
  1189. for ( n=1; n<divN; n++) {
  1190. vd.x = vp->vd.x+rel.x*n/divN;
  1191. vd.y = vp->vd.y+rel.y*n/divN;
  1192. if (VDSetData(olst, &vd))
  1193. goto RET;
  1194. }
  1195. vp = vp->next;
  1196. }
  1197. vhd = vhd->next;
  1198. VDClose( olst);
  1199. }
  1200. return 0;
  1201. RET:
  1202. return -1;
  1203. }
  1204. int
  1205. SmoothLight( int ioLst, int tmpLst, int width, int height, int oWidth, int ufpVal)
  1206. {
  1207. int sts;
  1208. if ( (sts = BindPoint( ioLst, tmpLst))<0)
  1209. goto RET;
  1210. if ( (sts = DetectNoSmooth( tmpLst))<0)
  1211. goto RET;
  1212. if ( (sts = ZoomPoint( tmpLst, width, height, oWidth, ufpVal))<0)
  1213. goto RET;
  1214. if ( (sts = preproc1( tmpLst, ioLst))<0)
  1215. goto RET;
  1216. if ( sts = divVec( ioLst, tmpLst, 2))
  1217. goto RET;
  1218. if ( lightSub( tmpLst, ioLst))
  1219. goto RET;
  1220. if ( lightSub( ioLst, tmpLst))
  1221. goto RET;
  1222. if ( RemoveFp( tmpLst, oWidth, ufpVal))
  1223. goto RET;
  1224. if ( (sts = DelZeroVec( tmpLst, ioLst))<0)
  1225. goto RET;
  1226. return 0;
  1227. RET:
  1228. return -1;
  1229. }
  1230. int
  1231. ConvMesh( int lstH, int inMesh, int outMesh)
  1232. {
  1233. struct VHEAD *vhd;
  1234. struct VDATA *vp;
  1235. int np;
  1236. int sts;
  1237. if ( inMesh==outMesh)
  1238. return 0;
  1239. if ( (sts = VDGetHead( lstH, &vhd))!=0)
  1240. goto RET;
  1241. if ( (sts = VDGetNCont( lstH))<=0)
  1242. goto RET;
  1243. while ( vhd->next != NIL) {
  1244. vp = vhd->headp;
  1245. np = vhd->nPoints;
  1246. while ( np-->0) {
  1247. vp->vd.x = (int)((long)vp->vd.x*outMesh/inMesh);
  1248. vp->vd.y = (int)((long)vp->vd.y*outMesh/inMesh);
  1249. vp = vp->next;
  1250. }
  1251. vhd = vhd->next;
  1252. }
  1253. sts = 0;
  1254. RET:
  1255. return sts;
  1256. }
  1257. /* EOF */