home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / VBasic / VLIB20.ZIP / DEMOPROC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-13  |  39.4 KB  |  1,470 lines

  1. /****************************************************************************
  2.  
  3.     PROGRAM:    Vlibdemo.exe
  4.  
  5.     PURPOSE:    To demonstrate the usage of Visualib(TM) functions.
  6.     
  7.     PROVIDER:   Visual Technology, Co.
  8.                 P.O.Box 901-413
  9.                 Kansas City, MO 64190
  10.                 Tel. (219) 289-0235
  11.                 Fax. (816) 746-6618
  12.     
  13.     DATE:        May, 1993
  14.  
  15. ****************************************************************************/
  16.  
  17. #include <windows.h>
  18. #include <stdlib.h>
  19. #include <math.h>
  20. #include "visualib.h"
  21. #include "menu.h"
  22. #include "vlibdemo.h"
  23. #include "demoproc.h"
  24.  
  25. HINSTANCE    hdllinst = 0;
  26.  
  27. int WINAPI LibMain (HINSTANCE hinst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  28. {
  29.     if (cbHeapSize != 0)
  30.         UnlockData (0);
  31.     hdllinst = hinst;
  32.     return (1);
  33. }
  34.  
  35. VOID WINAPI MinRoutine (int nParameter, LPSTR lpszParam2)
  36. {
  37.     
  38. }
  39.  
  40. int    WINAPI WEP (int nParameter)
  41. {
  42.     if (nParameter == WEP_SYSTEM_EXIT) {
  43.         return (1);
  44.     }
  45.     else if (nParameter == WEP_FREE_DLL) {
  46.         return (1);
  47.     }
  48.     else {
  49.         return (1);
  50.     }
  51. }
  52.  
  53. VOIDED    Prime2D (HDC hdc, int func)
  54. {
  55.     short    i;
  56.     double    x, y, a;
  57.  
  58.     PenColor (hdc, VL_WHITE);
  59.     DisplayViewerFrame (hdc, VL_CURRENT);
  60.     switch (func) {
  61.         case IDM_2DPRIME_LINE:
  62.             SetViewerName (VL_CURRENT, "2D Lines");
  63.             PenColor (hdc, VL_RED);
  64.             MoveTo2D (hdc, 0, 0);
  65.             LineTo2D (hdc, 1, 1);
  66.             RLineTo2D (hdc, -2, 0);
  67.             RLineTo2D (hdc, 0, -2);
  68.             RLineTo2D (hdc, 2, 0);
  69.             RLineTo2D (hdc, 0, 2);
  70.             RMoveTo2D (hdc, 1, 1);
  71.             LineTo2D (hdc, -2, 2);
  72.             PenColor (hdc, VL_BLUE);
  73.             MoveTo2H (hdc, 1, 1, 0.5f);
  74.             LineTo2H (hdc, 0, 1, 0);
  75.             LineTo2H (hdc, 0, 0, 1);
  76.             MoveTo2H (hdc, -1, 1, 0.5f);
  77.             LineTo2H (hdc, -1, 0, 0);
  78.             LineTo2H (hdc, 0, 0, 1);
  79.             MoveTo2H (hdc, -1, -1, 0.5f);
  80.             LineTo2H (hdc, 0, -1, 0);
  81.             LineTo2H (hdc, 0, 0, 1);
  82.             MoveTo2H (hdc, 1, -1, 0.5f);
  83.             LineTo2H (hdc, 1, 0, 0);
  84.             LineTo2H (hdc, 0, 0, 1);
  85.             PenColor (hdc, VL_GREEN);
  86.             Line2D (hdc, -15, 5, 15, 5);
  87.             Line2D (hdc, -15, -5, 15, -5);
  88.             Line2D (hdc, -5, -15, -5, 15);
  89.             Line2D (hdc, 5, -15, 5, 15);
  90.             Line2D (hdc, -15, 0, 0, 15);
  91.             Line2D (hdc, 15, 0, 0, 15);
  92.             Line2D (hdc, 0, -15, 15, 0);
  93.             Line2D (hdc, 0, -15, -15, 0);
  94.             PenColor (hdc, VL_YELLOW);
  95.             Line2H (hdc, -5, 5, 0.75f, 5, 5, 0.75f);
  96.             Line2H (hdc, -5, -5, 0.75f, 5, -5, 0.75f);
  97.             Line2H (hdc, -5, -5, 0.75f, -5, 5, 0.75f);
  98.             Line2H (hdc, 5, -5, 0.75f, 5, 5, 0.75f);
  99.             PenColor (hdc, VL_BROWN);
  100.             RLine2D (hdc, 2, 3, -5, -5);
  101.             break;
  102.         case IDM_2DPRIME_POLYLINE:
  103.         {
  104.             COORD    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  105.  
  106.             SetViewerName (VL_CURRENT, "2D PolyLines");
  107.             PenColor (hdc, VL_RED);
  108.             Polyline2D (hdc, VL_2D, poly, 4);
  109.             PushTransformation2D (NULL);
  110.             TranslateTo2D (3, 3);
  111.             ClosedPolyline2D (hdc, VL_2D, poly, 4);
  112.             TranslateTo2D (10, 0);
  113.             ClosedPolyline2D (hdc, VL_2D, poly, 4);
  114.             TranslateTo2D (10, -6);
  115.             ClosedPolyline2D (hdc, VL_2D, poly, 4);
  116.             TranslateTo2D (-10, -6);
  117.             ClosedPolyline2D (hdc, VL_2D, poly, 4);
  118.             TranslateTo2D (-10, 6);
  119.             ClosedPolyline2D (hdc, VL_2D, poly, 4);
  120.             PopTransformation2D (NULL);
  121.             LineTo2D (hdc, 0, 0);
  122.             break;
  123.         }
  124.         case IDM_2DPRIME_POINTER:
  125.             SetViewerName (VL_CURRENT, "2D Pointers");
  126.             PenColor (hdc, VL_YELLOW);
  127.             for (i = 0, a = 0; i < 12; i++, a += 0.5f) {
  128.                 x = 9 * cos (a);
  129.                 y = 5 * sin (a);
  130.                 Pointer2D (hdc, 0, 0, (real) x, (real) y, 1, 0.5f, VL_CLOSEDARROW);
  131.             }
  132.             break;
  133.  
  134.         case IDM_2DPRIME_MARK:
  135.             SetViewerName (VL_CURRENT, "2D Marks");
  136.             PenColor (hdc, VL_BLUE);
  137.             x = -9;
  138.             y = -6;
  139.             for (i = 0; i < 10; i++) {
  140.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_CIRCLEMARK);
  141.                 x += 2;
  142.             }
  143.             x = -9;
  144.             y = -4;
  145.             for (i = 0; i < 10; i++) {
  146.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_CROSSMARK);
  147.                 x += 2;
  148.             }
  149.             x = -9;
  150.             y = -2;
  151.             for (i = 0; i < 10; i++) {
  152.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_XMARK);
  153.                 x += 2;
  154.             }
  155.             x = -9;
  156.             y = 0;
  157.             for (i = 0; i < 10; i++) {
  158.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_TRIANGLEMARK);
  159.                 x += 2;
  160.             }
  161.             x = -9;
  162.             y = 2;
  163.             for (i = 0; i < 10; i++) {
  164.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_BOXMARK);
  165.                 x += 2;
  166.             }
  167.             x = -9;
  168.             y = 4;
  169.             for (i = 0; i < 10; i++) {
  170.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_DIAMONDMARK);
  171.                 x += 2;
  172.             }
  173.             x = -9;
  174.             y = 6;
  175.             for (i = 0; i < 10; i++) {
  176.                 Mark2D (hdc, (real) x, (real) y, i+2, i+2, VL_HEXAGONMARK);
  177.                 x += 2;
  178.             }
  179.             break;
  180.  
  181.         case IDM_2DPRIME_LABEL:
  182.             SetViewerName (VL_CURRENT, "2D Labels");
  183.             TextColor (hdc, VL_RED, VL_WHITE, OPAQUE);
  184.             PenColor (hdc, VL_GREEN);
  185.             SetTextAlign (hdc, TA_CENTER | TA_BASELINE);
  186.             Label2D (hdc, 0, 0, "Center & BaseLine");
  187.             Mark2D (hdc, 0, 0, 15, 5, VL_CROSSMARK);
  188.             SetTextAlign (hdc, TA_CENTER | TA_TOP);
  189.             Label2D (hdc, 0, 3, "Center & Top");
  190.             Mark2D (hdc, 0, 3, 15, 3, VL_CROSSMARK);
  191.             SetTextAlign (hdc, TA_CENTER | TA_BOTTOM);
  192.             Label2D (hdc, 0, -3, "Center & Bottom");
  193.             Mark2D (hdc, 0, -3, 15, 3, VL_CROSSMARK);
  194.  
  195.             SetTextAlign (hdc, TA_LEFT | TA_BASELINE);
  196.             Label2D (hdc, 3.5f, 0, "Left & BaseLine");
  197.             Mark2D (hdc, 3.5f, 0, 15, 5, VL_CROSSMARK);
  198.             SetTextAlign (hdc, TA_LEFT | TA_TOP);
  199.             Label2D (hdc, 3.5f, 3, "Left & Top");
  200.             Mark2D (hdc, 3.5f, 3, 15, 3, VL_CROSSMARK);
  201.             SetTextAlign (hdc, TA_LEFT | TA_BOTTOM);
  202.             Label2D (hdc, 3.5f, -3, "Left & Bottom");
  203.             Mark2D (hdc, 3.5f, -3, 15, 3, VL_CROSSMARK);
  204.  
  205.             SetTextAlign (hdc, TA_RIGHT | TA_BASELINE);
  206.             Label2D (hdc, -3.5f, 0, "Right & BaseLine");
  207.             Mark2D (hdc, -3.5f, 0, 15, 5, VL_CROSSMARK);
  208.             SetTextAlign (hdc, TA_RIGHT | TA_TOP);
  209.             Label2D (hdc, -3.5f, 3, "Right & Top");
  210.             Mark2D (hdc, -3.5f, 3, 15, 3, VL_CROSSMARK);
  211.             SetTextAlign (hdc, TA_RIGHT | TA_BOTTOM);
  212.             Label2D (hdc, -3.5f, -3, "Right & Bottom");
  213.             Mark2D (hdc, -3.5f, -3, 15, 3, VL_CROSSMARK);
  214.             break;
  215.         case IDM_2DPRIME_ARROW:
  216.             SetViewerName (VL_CURRENT, "3D Arrows");
  217.             break;
  218.         case IDM_2DPRIME_NET:
  219.         {
  220.             COORD    net[140];
  221.             short    i, j, index = 0;
  222.             real    x, y;
  223.             
  224.             PenColor (hdc, VL_BLUE);
  225.             y = -6.5f;
  226.             for (i = 0; i < 7; i++) {
  227.                 x = -9.5f;
  228.                 for (j = 0; j < 10; j++) {
  229.                     net[index++] = x + ((real) rand () / RAND_MAX);
  230.                     net[index++] = y + ((real) rand () / RAND_MAX);
  231.                     x += 2;
  232.                 }
  233.                 y += 2;
  234.             }
  235.             Net2D (hdc, VL_2D, (LPCOORD) net, 7, 10);
  236.             SetViewerName (VL_CURRENT, "2D Net");
  237.             break;
  238.         }
  239.     }
  240.     TextColor (hdc, VL_BLUE, VL_BLACK, TRANSPARENT);
  241.     DisplayViewerName (hdc, VL_CURRENT, FALSE);
  242. }
  243.  
  244. VOIDED    Prime3D (HDC hdc, int func)
  245. {
  246.     PenColor (hdc, VL_WHITE);
  247.     DisplayViewerFrame (hdc, VL_CURRENT);
  248.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  249.     switch (func) {
  250.         case IDM_3DPRIME_LINE:
  251.             SetViewerName (VL_CURRENT, "3D Lines");
  252.             PenColor (hdc, VL_RED);
  253.             MoveTo3D (hdc, 0, 0, 0);
  254.             LineTo3D (hdc, 10, 10, 0);
  255.             RLineTo3D (hdc, 0, -20, 0);
  256.             RLineTo3D (hdc, -20, 0, 0);
  257.             RLineTo3D (hdc, 0, 20, 0);
  258.             RLineTo3D (hdc, 20, 0, 0);
  259.             PenColor (hdc, VL_BLUE);
  260.             MoveTo3H (hdc, 1, 1, 0, 0.5f);
  261.             LineTo3H (hdc, 0, 1, 0, 0);
  262.             LineTo3H (hdc, 0, 0, 0, 1);
  263.             MoveTo3H (hdc, -1, 1, 0, 0.5f);
  264.             LineTo3H (hdc, -1, 0, 0, 0);
  265.             LineTo3H (hdc, 0, 0, 0, 1);
  266.             MoveTo3H (hdc, -1, -1, 0, 0.5f);
  267.             LineTo3H (hdc, 0, -1, 0, 0);
  268.             LineTo3H (hdc, 0, 0, 0, 1);
  269.             MoveTo3H (hdc, 1, -1, 0, 0.5f);
  270.             LineTo3H (hdc, 1, 0, 0, 0);
  271.             LineTo3H (hdc, 0, 0, 0, 1);
  272.             PenColor (hdc, VL_YELLOW);
  273.             MoveTo3D (hdc, 100, 100, 90);
  274.             LineTo3D (hdc, 10, 0, 0);
  275.             MoveTo3D (hdc, 100, 100, 90);
  276.             LineTo3D (hdc, 0, 10, 0);
  277.             MoveTo3D (hdc, 100, 100, 90);
  278.             LineTo3D (hdc, 0, 0, 10);
  279.             break;
  280.         case IDM_3DPRIME_POLYLINE:
  281.         {
  282.             COORD    poly[] = {-1, -1, -1, 1, 1, 1, 1, -1};
  283.  
  284.             SetViewerName (VL_CURRENT, "3D PolyLines");
  285.             PenColor (hdc, VL_RED);
  286.             Polyline3D (hdc, VL_2D, poly, 4);
  287.             PushTransformation3D (NULL);
  288.             Scale3D (5, 5, 5);
  289.             TranslateTo3D (3, 3, 0);
  290.             PenColor (hdc, VL_GREEN);
  291.             ClosedPolyline3D (hdc, VL_2D, poly, 4);
  292.             TranslateTo3D (10, 0, 0);
  293.             PenColor (hdc, VL_BLUE);
  294.             ClosedPolyline3D (hdc, VL_2D, poly, 4);
  295.             TranslateTo3D (10, -6, 0);
  296.             PenColor (hdc, VL_YELLOW);
  297.             ClosedPolyline3D (hdc, VL_2D, poly, 4);
  298.             TranslateTo3D (-10, -6, 0);
  299.             PenColor (hdc, VL_BROWN);
  300.             ClosedPolyline3D (hdc, VL_2D, poly, 4);
  301.             TranslateTo3D (-10, 6, 0);
  302.             PenColor (hdc, VL_WHITE);
  303.             ClosedPolyline3D (hdc, VL_2D, poly, 4);
  304.             PopTransformation3D (NULL);
  305.             LineTo3D (hdc, 0, 0, 0);
  306.             break;
  307.         }
  308.         case IDM_3DPRIME_POINTER:
  309.             SetViewerName (VL_CURRENT, "3D Pointers");
  310.             PenColor (hdc, VL_RED);
  311.             Pointer3D (hdc, 0, 0, 0, 20, 0, 0, 5, 3, VL_OPENARROW);
  312.             PenColor (hdc, VL_GREEN);
  313.             Pointer3D (hdc, 0, 0, 0, 0, 20, 0, 5, 3, VL_CLOSEDARROW);
  314.             PenColor (hdc, VL_BLUE);
  315.             Pointer3D (hdc, 0, 0, 0, 0, 0, 20, 5, 3, VL_CROSSMARK);
  316.             PenColor (hdc, VL_YELLOW);
  317.             Pointer3D (hdc, 0, 0, 0, -20, 0, 0, 5, 3, VL_HEXAGONMARK);
  318.             PenColor (hdc, VL_BROWN);
  319.             Pointer3D (hdc, 0, 0, 0, 0, -20, 0, 5, 3, VL_TRIANGLEMARK);
  320.             PenColor (hdc, VL_WHITE);
  321.             Pointer3D (hdc, 0, 0, 0, 0, 0, -20, 5, 3, VL_BOXMARK);
  322.             break;
  323.         case IDM_3DPRIME_MARK:
  324.             SetViewerName (VL_CURRENT, "3D Marks");
  325.             PenColor (hdc, VL_RED);
  326.             Mark3D (hdc, 0, 0, 0, 5, 5, VL_CROSSMARK);
  327.             PenColor (hdc, VL_GREEN);
  328.             Mark3D (hdc, 20, 0, 0, 5, 5, VL_HEXAGONMARK);
  329.             PenColor (hdc, VL_BLUE);
  330.             Mark3D (hdc, 0, 20, 0, 5, 5, VL_DIAMONDMARK);
  331.             PenColor (hdc, VL_WHITE);
  332.             Mark3D (hdc, 0, 0, 20, 5, 5, VL_TRIANGLEMARK);
  333.             break;
  334.         case IDM_3DPRIME_LABEL:
  335.         {
  336.             int    method;
  337.  
  338.              SetViewerName (VL_CURRENT, "3D Labels");
  339.             Scale3D (2, 2, 2);
  340.             method = ShadingOption (VL_CURRENT, VL_SHADINGMETHOD, VL_WIREFRAME);
  341.             PenColor (hdc, VL_GREEN);
  342.             Cube (hdc, 20, 20, 20);
  343.             ShadingOption (VL_CURRENT, VL_SHADINGMETHOD, method);
  344.             TextColor (hdc, VL_RED, VL_BLACK, TRANSPARENT);
  345.             SetTextAlign (hdc, TA_BOTTOM | TA_CENTER);
  346.             Label3D (hdc, -10, -10, 10, "Back Top");
  347.             SetTextAlign (hdc, TA_BASELINE | TA_CENTER);
  348.             Label3D (hdc, 10, 10, 10, "Front Top");
  349.             SetTextAlign (hdc, TA_TOP | TA_CENTER);
  350.             Label3D (hdc, 10, 10, -10, "Front Bottom");
  351.             SetTextAlign (hdc, TA_BASELINE | TA_RIGHT);
  352.             Label3D (hdc, 10, -10, 10, "Left Top");
  353.             Label3D (hdc, 10, -10, -10, "Left Bottom");
  354.             SetTextAlign (hdc, TA_BASELINE | TA_LEFT);
  355.             Label3D (hdc, -10, 10, 10, "Right Top");
  356.             Label3D (hdc, -10, 10, -10, "Right Bottom");
  357.             break;
  358.         }
  359.         case IDM_3DPRIME_ARROW:
  360.             SetViewerName (VL_CURRENT, "3D Arrows");
  361.             break;
  362.         case IDM_3DPRIME_NET:
  363.         {
  364.             COORD    net[210];
  365.             short    i, j, index = 0;
  366.             real    x, y;
  367.  
  368.             PushTransformation3D (NULL);
  369.             Scale3D (5, 5, 5);
  370.             PenColor (hdc, VL_BLUE);
  371.             y = -6.5f;
  372.             for (i = 0; i < 7; i++) {
  373.                 x = -9.5f;
  374.                 for (j = 0; j < 10; j++) {
  375.                     net[index++] = x + ((real) rand () / RAND_MAX);
  376.                     net[index++] = y + ((real) rand () / RAND_MAX);
  377.                     net[index++] = (real) rand () / RAND_MAX;
  378.                     x += 2;
  379.                 }
  380.                 y += 2;
  381.             }
  382.             Net3D (hdc, VL_3D, (LPCOORD) net, 7, 10);
  383.             PopTransformation3D (NULL);
  384.             SetViewerName (VL_CURRENT, "3D Net");
  385.             break;
  386.         }
  387.     }
  388.     TextColor (hdc, VL_BLUE, VL_BLACK, TRANSPARENT);
  389.     DisplayViewerName (hdc, VL_CURRENT, FALSE);
  390. }
  391.  
  392. VOIDED    DrawNgon (HDC hdc, int type)
  393. {
  394.     real    x, y, t, w, h;
  395.     short    i, j, n;
  396.  
  397.     y = -5, t = 0;
  398.     w = h = 1.75f;
  399.     for (i = 0; i < 3; i++) {
  400.         x = -7.5f;
  401.         for (j = 0; j < 4; j++) {
  402.             n = i * 4 + j;
  403.             PenColor (hdc, VL_RED + n);
  404.             BrushColor (hdc, VL_RED + j * 3 + i);
  405.             n += 3;
  406.             if (type == VL_THREED)
  407.                 Ngon3D (hdc, x, y, t, w, h, n);
  408.             else
  409.                 Ngon2D (hdc, x, y, t, w, h, n);
  410.             x += 5;
  411.         }
  412.         y += 5;
  413.     }
  414. }
  415.  
  416. VOIDED    DrawStar (HDC hdc, int type)
  417. {
  418.     real    x, y, t, w, h;
  419.     short    i, j, n;
  420.  
  421.     y = -5; t = 0; w = h = 1.75f;
  422.     for (i = 0; i < 3; i++) {
  423.         x = -7.5f;
  424.         for (j = 0; j < 4; j++) {
  425.             n = i * 4 + j;
  426.             PenColor (hdc, VL_RED + n);
  427.             BrushColor (hdc, VL_RED + j * 3 + i);
  428.             n += 3;
  429.             if (type == VL_THREED)
  430.                 Star3D (hdc, x, y, t, w, h, n);
  431.             else
  432.                 Star2D (hdc, x, y, t, w, h, n);
  433.             x += 5;
  434.         }
  435.         y += 5;
  436.     }
  437. }
  438.  
  439. VOIDED    DrawFlower (HDC hdc, int type)
  440. {
  441.     real    x, y, t, w, h, r;
  442.     short    i, j, n;
  443.  
  444.     y = -5; t = 0; w = h = 1.75f; r = 0.75f;
  445.     for (i = 0; i < 3; i++) {
  446.         x = -7.5f;
  447.         for (j = 0; j < 4; j++) {
  448.             n = i * 4 + j;
  449.             PenColor (hdc, VL_RED + n);
  450.             BrushColor (hdc, VL_RED + j * 3 + i);
  451.             n += 3;
  452.             if (type == VL_THREED)
  453.                 Flower3D (hdc, x, y, t, w, h, n, r);
  454.             else
  455.                 Flower2D (hdc, x, y, t, w, h, n, r);
  456.             x += 5;
  457.         }
  458.         y += 5;
  459.     }
  460. }
  461.  
  462. VOIDED    DrawWedge (HDC hdc, int type)
  463. {
  464.     real    x, y, t, w, h, a, b;
  465.     short    i, j, n;
  466.  
  467.     y = -5; t = 0;
  468.     a = 0; b = 30; w = h = 1.75f;
  469.     for (i = 0; i < 3; i++) {
  470.         x = -7.5f;
  471.         for (j = 0; j < 4; j++) {
  472.             n = i * 4 + j;
  473.             PenColor (hdc, VL_RED + n);
  474.             BrushColor (hdc, VL_RED + j * 3 + i);
  475.             if (type == VL_THREED)
  476.                 Wedge3D (hdc, x, y, t, w, h, a, b);
  477.             else
  478.                 Wedge2D (hdc, x, y, t, w, h, a, b);
  479.             x += 5;
  480.             b += 30;
  481.             t += 15;
  482.         }
  483.         y += 5;
  484.     }
  485. }
  486.  
  487. VOIDED    DrawDisk (HDC hdc, int type)
  488. {
  489.     real    x, y, t, w, h;
  490.     short    i, j, n;
  491.  
  492.     y = -5; t = 0;
  493.     w = 2; h = 0.2f;
  494.     for (i = 0; i < 3; i++) {
  495.         x = -7.5f;
  496.         for (j = 0; j < 4; j++) {
  497.             n = i * 4 + j;
  498.             PenColor (hdc, VL_RED + n);
  499.             BrushColor (hdc, VL_RED + j * 3 + i);
  500.             if (type == VL_THREED)
  501.                 Disk3D (hdc, x, y, t, w, h);
  502.             else
  503.                 Disk2D (hdc, x, y, t, w, h);
  504.             x += 5;
  505.             t += 15;
  506.             w -= 0.15f;
  507.             h += 0.15f;
  508.         }
  509.         y += 5;
  510.     }
  511. }
  512.  
  513. VOIDED    DrawRose (HDC hdc, int type)
  514. {
  515.     real    x, y, t, r;
  516.     short    i, j, m, n;
  517.  
  518.     y = -4; t = 0;
  519.     r = 2;
  520.     for (i = 0; i < 3; i++) {
  521.         x = -7.5f;
  522.         n = i + 1;
  523.         for (j = 0; j < 4; j++) {
  524.             switch (n) {
  525.                 case 1:
  526.                     m = j + 2;
  527.                     break;
  528.                 case 2:
  529.                     m = j * 2 + 1;
  530.                     break;
  531.                 case 3:
  532.                     m = j + 1 + j / 2;
  533.                     break;
  534.             }
  535.             PenColor (hdc, VL_RED + i * 4 + j);
  536.             BrushColor (hdc, VL_RED + j * 3 + i);
  537.             if (type == VL_THREED)
  538.                 Rose3D (hdc, x, y, t, r, m, n);
  539.             else
  540.                 Rose2D (hdc, x, y, t, r, m, n);
  541.             x += 5;
  542.             t += 15;
  543.         }
  544.         y += 4;
  545.     }
  546. }
  547.  
  548. VOIDED    DrawBox (HDC hdc, int type)
  549. {
  550.     real    x, y, t, w, h;
  551.     short    i, j, n;
  552.  
  553.     y = -5; t = 0;
  554.     w = 3; h = 0.6f;
  555.     for (i = 0; i < 3; i++) {
  556.         x = -7.5f;
  557.         for (j = 0; j < 4; j++) {
  558.             n = i * 4 + j;
  559.             PenColor (hdc, VL_RED + n);
  560.             BrushColor (hdc, VL_RED + j * 3 + i);
  561.             if (type == VL_THREED)
  562.                 Box3D (hdc, x, y, t, w, h);
  563.             else
  564.                 Box2D (hdc, x, y, t, w, h);
  565.             x += 5;
  566.             w -= 0.2f;
  567.             h += 0.2f;
  568.             t += 15;
  569.         }
  570.         y += 5;
  571.     }
  572. }
  573.  
  574. VOIDED    DrawBow (HDC hdc, int type)
  575. {
  576.     real    x, y, t, w, h, a, b;
  577.     short    i, j, n;
  578.  
  579.     y = -5; t = 0;
  580.     a = 0; b = 30; w = h = 1.75f;
  581.     for (i = 0; i < 3; i++) {
  582.         x = -7.5f;
  583.         for (j = 0; j < 4; j++) {
  584.             n = i * 4 + j;
  585.             PenColor (hdc, VL_RED + n);
  586.             BrushColor (hdc, VL_RED + j * 3 + i);
  587.             if (type == VL_THREED)
  588.                 Bow3D (hdc, x, y, a, w, h, a, b);
  589.             else
  590.                 Bow2D (hdc, x, y, a, w, h, a, b);
  591.             x += 5;
  592.             b += 30;
  593.             t += 15;
  594.         }
  595.         y += 5;
  596.     }
  597. }
  598.  
  599. VOIDED    DrawRing (HDC hdc, int type)
  600. {
  601.     real    x, y, t, w, h, a, b;
  602.     short    i, j, n;
  603.  
  604.     y = -5; t = 0;
  605.     a = 0; b = 30; w = h = 1;
  606.     for (i = 0; i < 3; i++) {
  607.         x = -7.5f;
  608.         for (j = 0; j < 4; j++) {
  609.             n = i * 4 + j;
  610.             PenColor (hdc, VL_RED + n);
  611.             BrushColor (hdc, VL_RED + j * 3 + i);
  612.             if (type == VL_THREED)
  613.                 Ring3D (hdc, x, y, a, w, h, a, b, 0.5f);
  614.             else
  615.                 Ring2D (hdc, x, y, a, w, h, a, b, 0.5f);
  616.             x += 5;
  617.             b += 30;
  618.             t += 15;
  619.         }
  620.         y += 5;
  621.     }
  622. }
  623.  
  624. VOIDED    DrawBezierCurve (HDC hdc, int type)
  625. {
  626.     COORD    point[40];
  627.  
  628.     point[0] = -8; point[1] = 3.5f;
  629.     point[2] = -5; point[3] = 6;
  630.     point[4] = -5; point[5] = 1;
  631.     point[6] = -2; point[7] = 3.5f;
  632.     PenColor (hdc, VL_WHITE);
  633.     if (type == VL_TWOD)
  634.         BezierCurve2D (hdc, VL_2D, point);
  635.     else
  636.         BezierCurve3D (hdc, VL_2D, point);
  637.     PenColor (hdc, VL_GREEN);
  638.     if (type == VL_TWOD)
  639.         Polyline2D (hdc, VL_2D, point, 4);
  640.     else
  641.         Polyline3D (hdc, VL_2D, point, 4);
  642.     PenColor (hdc, VL_WHITE);
  643.     if (type == VL_TWOD)
  644.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  645.     else
  646.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_HEXAGONMARK);
  647.  
  648.     point[0] = 2; point[1] = 3.5f;
  649.     point[2] = 5; point[3] = 6;
  650.     point[4] = 8; point[5] = 3.5f;
  651.     point[6] = 5; point[7] = 1;
  652.     PenColor (hdc, VL_WHITE);
  653.     if (type == VL_TWOD)
  654.         BezierCurve2D (hdc, VL_2D, point);
  655.     else
  656.         BezierCurve3D (hdc, VL_2D, point);
  657.     PenColor (hdc, VL_GREEN);
  658.     if (type == VL_TWOD)
  659.         Polyline2D (hdc, VL_2D, point, 4);
  660.     else
  661.         Polyline3D (hdc, VL_2D, point, 4);
  662.     PenColor (hdc, VL_WHITE);
  663.     if (type == VL_TWOD)
  664.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  665.     else
  666.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_CROSSMARK);
  667.  
  668.     point[0] = -8; point[1] = -3;
  669.     point[2] = -2; point[3] = -6;
  670.     point[4] = -2; point[5] = -1;
  671.     point[6] = -8; point[7] = -5;
  672.     PenColor (hdc, VL_WHITE);
  673.     if (type == VL_TWOD)
  674.         BezierCurve2D (hdc, VL_2D, point);
  675.     else
  676.         BezierCurve3D (hdc, VL_2D, point);
  677.     PenColor (hdc, VL_GREEN);
  678.     if (type == VL_TWOD)
  679.         Polyline2D (hdc, VL_2D, point, 4);
  680.     else
  681.         Polyline3D (hdc, VL_2D, point, 4);
  682.     PenColor (hdc, VL_WHITE);
  683.     if (type == VL_TWOD)
  684.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  685.     else
  686.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_XMARK);
  687.  
  688.     point[0] = 2; point[1] = -6;
  689.     point[2] = 5; point[3] = -1;
  690.     point[4] = 8; point[5] = -6;
  691.     point[6] = 2; point[7] = -6;
  692.     PenColor (hdc, VL_WHITE);
  693.     if (type == VL_TWOD)
  694.         BezierCurve2D (hdc, VL_2D, point);
  695.     else
  696.         BezierCurve3D (hdc, VL_2D, point);
  697.     PenColor (hdc, VL_GREEN);
  698.     if (type == VL_TWOD)
  699.         Polyline2D (hdc, VL_2D, point, 4);
  700.     else
  701.         Polyline3D (hdc, VL_2D, point, 4);
  702.     PenColor (hdc, VL_WHITE);
  703.     if (type == VL_TWOD)
  704.         PolyMark2D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  705.     else
  706.         PolyMark3D (hdc, VL_2D, point, 4, 4, 4, VL_DIAMONDMARK);
  707. }
  708.  
  709. VOIDED    DrawBSplineCurve (HDC hdc, int type)
  710. {
  711.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  712.     real    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  713.  
  714.     PenColor (hdc, VL_RED);
  715.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  716.     if (type == VL_TWOD)
  717.         Polyline2D (hdc, VL_2D, point, 8);
  718.     else
  719.         Polyline3D (hdc, VL_2D, point, 8);
  720.     PenColor (hdc, VL_BLUE);
  721.     if (type == VL_TWOD)
  722.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  723.     else
  724.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  725.     
  726.     PenColor (hdc, VL_GREEN);
  727.     if (type == VL_TWOD)
  728.         BSplineCurve2D (hdc, VL_2D, point, 8);
  729.     else
  730.         BSplineCurve3D (hdc, VL_2D, point, 8);
  731.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  732.     PenColor (hdc, VL_RED);
  733.     if (type == VL_TWOD)
  734.         Polyline2D (hdc, VL_2D, point, 8);
  735.     else
  736.         Polyline3D (hdc, VL_2D, point, 8);
  737.     PenColor (hdc, VL_BLUE);
  738.     if (type == VL_TWOD)
  739.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  740.     else
  741.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  742.     PenColor (hdc, VL_GREEN);
  743.     if (type == VL_TWOD)
  744.         SplineInterp2D (hdc, VL_2D, point, 8);
  745.     else
  746.         SplineInterp3D (hdc, VL_2D, point, 8);
  747.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  748.     PenColor (hdc, VL_RED);
  749.     if (type == VL_TWOD)
  750.         Polyline2D (hdc, VL_2D, point, 8);
  751.     else
  752.         Polyline3D (hdc, VL_2D, point, 8);
  753.  
  754.     PenColor (hdc, VL_BLUE);
  755.     if (type == VL_TWOD)
  756.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  757.     else
  758.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  759.     PenColor (hdc, VL_GREEN);
  760.     if (type == VL_TWOD)
  761.         BSplineCurveClosed2D (hdc, VL_2D, point, 8);
  762.     else
  763.         BSplineCurveClosed3D (hdc, VL_2D, point, 8);
  764.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  765.     PenColor (hdc, VL_RED);
  766.     if (type == VL_TWOD)
  767.         Polyline2D (hdc, VL_2D, point, 8);
  768.     else
  769.         Polyline3D (hdc, VL_2D, point, 8);
  770.     PenColor (hdc, VL_BLUE);
  771.     if (type == VL_TWOD)
  772.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  773.     else
  774.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  775.     PenColor (hdc, VL_GREEN);
  776.     if (type == VL_TWOD)
  777.         NURBSCurveClosed2D (hdc, VL_2D, point, 8, knot);
  778.     else
  779.         NURBSCurveClosed3D (hdc, VL_2D, point, 8, knot);
  780. }
  781.  
  782. VOIDED    DrawCatmullRomCurve (HDC hdc, int type)
  783. {
  784.     COORD    point[] = {0, 0, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 4, 1, 4, 0};
  785.  
  786.     TransfVertex (VL_2D, -8, -4, 0, 4, 8, point, 8);
  787.     PenColor (hdc, VL_RED);
  788.     if (type == VL_TWOD)
  789.         Polyline2D (hdc, VL_2D, point, 8);
  790.     else
  791.         Polyline3D (hdc, VL_2D, point, 8);
  792.     PenColor (hdc, VL_BLUE);
  793.     if (type == VL_TWOD)
  794.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  795.     else
  796.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  797.     PenColor (hdc, VL_GREEN);
  798.     if (type == VL_TWOD)
  799.         CatmullRomSpline2D (hdc, VL_2D, point, 8);
  800.     else
  801.         CatmullRomSpline3D (hdc, VL_2D, point, 8);
  802. }
  803.  
  804. void    heart (HDC hdc, int type, BOOL showpnt)
  805. {
  806.     COORD point[] = {0, 0, 0.4f, 0.8f, 2, 1.4f, 2.5f, -1, 1, -2, 0, -3,
  807.                     -1, -2, -2.5f, -1, -2, 1.4f,
  808.                     -0.4f, 0.8f, 0, 0};
  809.     real    knot[20] = {0, 0, 0, 1, 2, 3, 3, 3, 4, 5, 6, 6, 6};
  810.  
  811.     if (type == VL_TWOD) {
  812.         PenColor (hdc, VL_RED);
  813.         PushTransformation2D (NULL);
  814.         Scale2D (2, 2);
  815.         NURBSCurve2D (hdc, VL_2D, point, 11, knot);
  816.     }
  817.     else {
  818.         PenColor (hdc, VL_WHITE);
  819.         PushTransformation3D (NULL);
  820.         Scale3D (3, 3, 3);
  821.         NURBSCurve3D (hdc, VL_2D, point, 11, knot);
  822.     }
  823.     if (showpnt) {
  824.         if (type == VL_TWOD) {
  825.             PenColor (hdc, VL_GREEN);
  826.             ClosedPolyline2D (hdc, VL_2D, point, 10); 
  827.             PolyMark2D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  828.         }
  829.         else {
  830.             PenColor (hdc, VL_BLUE);
  831.             ClosedPolyline3D (hdc, VL_2D, point, 10); 
  832.             PolyMark3D (hdc, VL_2D, point, 10, 4, 4, VL_BOXMARK);
  833.         }
  834.     }
  835.     if (type == VL_TWOD)
  836.         PopTransformation2D (NULL);
  837.     else
  838.         PopTransformation3D (NULL);
  839. }
  840.  
  841. void    circle (HDC hdc, int type, BOOL showpnt)
  842. {
  843.     POINT2H p[20] = {
  844.         {0, 1, 1}, {0.707f, 0.707f, 0.707f}, {1, 0, 1},
  845.         {0.707f, -0.707f, 0.707f}, {0, -1, 1}, {-0.707f, -0.707f, 0.707f},
  846.         {-1, 0, 1}, {-0.707f, 0.707f, 0.707f}, {0, 1, 1}};
  847.     real    knot[20] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  848.  
  849.     if (type == VL_TWOD) {
  850.         PenColor (hdc, VL_RED);
  851.         PushTransformation2D (NULL);
  852.         Scale2D (3, 3);
  853.         QNURBSCurve2D (hdc, VL_2H, (LPCOORD) p, 9, knot);
  854.     }
  855.     else {
  856.         PenColor (hdc, VL_WHITE);
  857.         PushTransformation3D (NULL);
  858.         Scale3D (3, 3, 3);
  859.         QNURBSCurve3D (hdc, VL_2H, (LPCOORD) p, 9, knot);
  860.     }
  861.     if (showpnt) {
  862.         if (type == VL_TWOD) {
  863.             PenColor (hdc, VL_GREEN);
  864.             ClosedPolyline2D (hdc, VL_2H, (LPCOORD) p, 8);
  865.             PolyMark2D (hdc, VL_2H, (LPCOORD) p, 8, 4, 4, VL_BOXMARK);
  866.         }
  867.         else {
  868.             PenColor (hdc, VL_BLUE);
  869.             ClosedPolyline3D (hdc, VL_2H, (LPCOORD) p, 8);
  870.             PolyMark3D (hdc, VL_2H, (LPCOORD) p, 8, 4, 4, VL_BOXMARK);
  871.         }
  872.     }
  873.     if (type == VL_TWOD)
  874.         PopTransformation2D (NULL);
  875.     else
  876.         PopTransformation3D (NULL);
  877. }
  878.  
  879. VOIDED    DrawNURBSCurve (HDC hdc, int type)
  880. {
  881.     circle (hdc, type, TRUE);
  882.     heart (hdc, type, TRUE);
  883. }
  884.  
  885. VOIDED    DrawHermitCurve (HDC hdc, int type)
  886. {
  887.     COORD    point[20];
  888.  
  889.     point[0] = -6; point[1] = -1; point[2] = 6; point[3] = -1;
  890.     point[4] = -10; point[5] = 0; point[6] = 0; point[7] = -40;
  891.     PenColor (hdc, VL_WHITE);
  892.     if (type == VL_TWOD)
  893.         HermitCurve2D (hdc, VL_2D, point);
  894.     else
  895.         HermitCurve3D (hdc, VL_2D, point);
  896.     PenColor (hdc, VL_GREEN);    
  897.     if (type == VL_TWOD) {
  898.         Arrow2D (hdc, point[0], point[1], point[4], point[5],
  899.             4, 1, 0.5f, VL_OPENARROW);
  900.         Arrow2D (hdc, point[2], point[3], point[6], point[7],
  901.             4, 1, 0.5f, VL_OPENARROW);
  902.     }
  903.     else {
  904.         Arrow3D (hdc, point[0], point[1], 0, point[4], point[5], 0,
  905.             4, 1, 0.5f, VL_OPENARROW);
  906.         Arrow3D (hdc, point[2], point[3], 0, point[6], point[7], 0,
  907.             4, 1, 0.5f, VL_OPENARROW);
  908.     }
  909.     PenColor (hdc, VL_WHITE);
  910.     if (type == VL_TWOD) {
  911.         Mark2D (hdc, point[0], point[1], 4, 4, VL_DIAMONDMARK);
  912.         Mark2D (hdc, point[2], point[3], 4, 4, VL_DIAMONDMARK);
  913.     }
  914.     else {
  915.         Mark3D (hdc, point[0], point[1], 0, 4, 4, VL_DIAMONDMARK);
  916.         Mark3D (hdc, point[2], point[3], 0, 4, 4, VL_DIAMONDMARK);
  917.     }
  918. }
  919.  
  920. VOIDED    DrawNURBSCurveKnot (HDC hdc, int type)
  921. {
  922.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0};
  923.     real Knot1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  924.     real Knot2[] = {0, 0, 0, 1, 1, 1, 4, 5, 5, 5};
  925.     real Knot3[] = {0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 6};
  926.     real Knot4[] = {0, 0, 0, 1, 3, 5, 7, 9, 10, 15};
  927.  
  928.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 8);
  929.     PenColor (hdc, VL_RED);
  930.     if (type == VL_TWOD)
  931.         Polyline2D (hdc, VL_2D, point, 8);
  932.     else
  933.         Polyline3D (hdc, VL_2D, point, 8);
  934.         
  935.     PenColor (hdc, VL_BLUE);
  936.     if (type == VL_TWOD)
  937.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  938.     else
  939.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  940.     PenColor (hdc, VL_GREEN);
  941.     if (type == VL_TWOD)
  942.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot1);
  943.     else
  944.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot1);
  945.  
  946.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  947.     PenColor (hdc, VL_RED);
  948.     if (type == VL_TWOD)
  949.         Polyline2D (hdc, VL_2D, point, 8);
  950.     else
  951.         Polyline3D (hdc, VL_2D, point, 8);
  952.     PenColor (hdc, VL_BLUE);
  953.     if (type == VL_TWOD)
  954.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  955.     else
  956.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  957.     PenColor (hdc, VL_GREEN);
  958.     if (type == VL_TWOD)
  959.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot2);
  960.     else
  961.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot2);
  962.  
  963.     TransfVertex (VL_2D, -10, -6, 0, 1, 1, point, 8);
  964.     PenColor (hdc, VL_RED);
  965.     if (type == VL_TWOD)
  966.         Polyline2D (hdc, VL_2D, point, 8);
  967.     else
  968.         Polyline3D (hdc, VL_2D, point, 8);
  969.     PenColor (hdc, VL_BLUE);
  970.     if (type == VL_TWOD)
  971.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  972.     else
  973.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  974.     PenColor (hdc, VL_GREEN);
  975.     if (type == VL_TWOD)
  976.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot3);
  977.     else
  978.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot3);
  979.  
  980.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 8);
  981.     PenColor (hdc, VL_RED);
  982.     if (type == VL_TWOD)
  983.         Polyline2D (hdc, VL_2D, point, 8);
  984.     else
  985.         Polyline3D (hdc, VL_2D, point, 8);
  986.     PenColor (hdc, VL_BLUE);
  987.     if (type == VL_TWOD)
  988.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  989.     else
  990.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  991.     PenColor (hdc, VL_GREEN);
  992.     if (type == VL_TWOD)
  993.         NURBSCurve2D (hdc, VL_2D, point, 8, Knot4);
  994.     else
  995.         NURBSCurve3D (hdc, VL_2D, point, 8, Knot4);
  996. }
  997.  
  998. VOIDED    DrawQNURBSCurve (HDC hdc, int type)
  999. {
  1000.     COORD    point[] = {0, 1, 1, 0.707f, 0.707f, 0.707f, 1, 0, 1,
  1001.         0.707f, -0.707f, 0.707f, 0, -1, 1, -0.707f, -0.707f, 0.707f,
  1002.         -1, 0, 1, -0.707f, 0.707f, 0.707f, 0, 1, 1};
  1003.     real knot[] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4};
  1004.  
  1005.     PenColor (hdc, VL_RED);
  1006.     if (type == VL_TWOD) {
  1007.         PushTransformation2D (NULL);
  1008.         Translate2D (-5, -3);
  1009.         Scale2D (3, 3);
  1010.         ClosedPolyline2D (hdc, VL_2H, point, 8);
  1011.     }
  1012.     else {
  1013.         PushTransformation3D (NULL);
  1014.         Translate3D (-5, -3, 0);
  1015.         Scale3D (3, 3, 3);
  1016.         ClosedPolyline3D (hdc, VL_2H, point, 8);
  1017.     }
  1018.     PenColor (hdc, VL_BLUE);
  1019.     if (type == VL_TWOD)
  1020.         PolyMark2D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  1021.     else
  1022.         PolyMark3D (hdc, VL_2H, point, 8, 3, 3, VL_DIAMONDMARK);
  1023.     PenColor (hdc, VL_GREEN);
  1024.     if (type == VL_TWOD) {
  1025.         QNURBSCurve2D (hdc, VL_2H, point, 9, knot);
  1026.         PopTransformation2D (NULL);
  1027.     }
  1028.     else {
  1029.         QNURBSCurve3D (hdc, VL_2H, point, 9, knot);
  1030.         PopTransformation3D (NULL);
  1031.     }
  1032. }
  1033.  
  1034. VOIDED    DrawQuadraticCurve (HDC hdc, int type)
  1035. {
  1036.     COORD    point[] = {0, 0, 0, 4, 2, 4, 2, 0, 4, 0, 6, 4, 8, 4, 8, 0, 0, 0};
  1037.     real    knot[20] = {0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7};
  1038.     short    i;
  1039.  
  1040.     PenColor (hdc, VL_RED);
  1041.     TransfVertex (VL_2D, -9, 1, 0, 1, 1, point, 9);
  1042.     if (type == VL_TWOD)
  1043.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  1044.     else
  1045.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  1046.     PenColor (hdc, VL_BLUE);
  1047.     if (type == VL_TWOD)
  1048.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1049.     else
  1050.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1051.     PenColor (hdc, VL_GREEN);
  1052.     if (type == VL_TWOD) {
  1053.         for (i = 0; i < 7; i += 2)
  1054.             QBezierCurve2D (hdc, VL_2D, &point[i*2]);
  1055.     }
  1056.     else {
  1057.         for (i = 0; i < 7; i += 2)
  1058.             QBezierCurve3D (hdc, VL_2D, &point[i*2]);
  1059.     }
  1060.     TransfVertex (VL_2D, 10, 0, 0, 1, 1, point, 9);
  1061.     PenColor (hdc, VL_RED);
  1062.     if (type == VL_TWOD)
  1063.         ClosedPolyline2D (hdc, VL_2D, point, 8);
  1064.     else
  1065.         ClosedPolyline3D (hdc, VL_2D, point, 8);
  1066.     PenColor (hdc, VL_BLUE);
  1067.     if (type == VL_TWOD)
  1068.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1069.     else
  1070.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1071.     PenColor (hdc, VL_GREEN);
  1072.     if (type == VL_TWOD)
  1073.         QBSplineCurve2D (hdc, VL_2D, point, 9);
  1074.     else
  1075.         QBSplineCurve3D (hdc, VL_2D, point, 9);
  1076.  
  1077.     TransfVertex (VL_2D, 0, -6, 0, 1, 1, point, 9);
  1078.     PenColor (hdc, VL_RED);
  1079.     if (type == VL_TWOD)
  1080.         Polyline2D (hdc, VL_2D, point, 8);
  1081.     else
  1082.         Polyline3D (hdc, VL_2D, point, 8);
  1083.     PenColor (hdc, VL_BLUE);
  1084.     if (type == VL_TWOD)
  1085.         PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1086.     else
  1087.         PolyMark3D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1088.     PenColor (hdc, VL_GREEN);
  1089.     if (type == VL_TWOD)
  1090.         QNURBSCurve2D (hdc, VL_2D, point, 8, knot);
  1091.     else
  1092.         QNURBSCurve3D (hdc, VL_2D, point, 8, knot);
  1093.     DrawQNURBSCurve (hdc, type);
  1094. }
  1095.  
  1096. VOIDED    SelectPrimitives (HDC hdc, WORD cmd)
  1097. {
  1098.     switch (cmd) {
  1099.         case IDM_2DCURVE_BEZIER:
  1100.             SetViewerName (VL_CURRENT, "Bezier Curves in 2D");
  1101.             DrawBezierCurve (hdc, VL_TWOD);
  1102.             break;
  1103.         case IDM_3DCURVE_BEZIER:
  1104.             SetViewerName (VL_CURRENT, "Bezier Curves in 3D");
  1105.             DrawBezierCurve (hdc, VL_THREED);
  1106.             break;
  1107.         case IDM_2DCURVE_BSPLINE:
  1108.             SetViewerName (VL_CURRENT, "B-Spline Curves in 2D");
  1109.             DrawBSplineCurve (hdc, VL_TWOD);
  1110.             break;
  1111.         case IDM_3DCURVE_BSPLINE:
  1112.             SetViewerName (VL_CURRENT, "B-Spline Curves in 3D");
  1113.             DrawBSplineCurve (hdc, VL_THREED);
  1114.             break;
  1115.         case IDM_2DCURVE_HERMIT:
  1116.             SetViewerName (VL_CURRENT, "2D Hermit Curves");
  1117.             DrawHermitCurve (hdc, VL_TWOD);
  1118.             break;
  1119.         case IDM_3DCURVE_HERMIT:
  1120.             SetViewerName (VL_CURRENT, "3D Hermit Curves");
  1121.             DrawHermitCurve (hdc, VL_THREED);
  1122.             break;
  1123.         case IDM_2DCURVE_NURBSKNOTS:
  1124.             SetViewerName (VL_CURRENT, "2D NUBRS Curves w/ Different Knots");
  1125.             DrawNURBSCurveKnot (hdc, VL_TWOD);
  1126.             break;
  1127.         case IDM_3DCURVE_NURBSKNOTS:
  1128.             SetViewerName (VL_CURRENT, "3D NUBRS Curves w/ Different Knots");
  1129.             DrawNURBSCurveKnot (hdc, VL_THREED);
  1130.             break;
  1131.         case IDM_2DCURVE_CATMULLROM:
  1132.             SetViewerName (VL_CURRENT, "2D Catmull-Rom Curve");
  1133.             DrawCatmullRomCurve (hdc, VL_TWOD);
  1134.             break;
  1135.         case IDM_3DCURVE_CATMULLROM:
  1136.             SetViewerName (VL_CURRENT, "3D Catmull-Rom Curve");
  1137.             DrawCatmullRomCurve (hdc, VL_THREED);
  1138.             break;
  1139.         case IDM_2DCURVE_NURBS:
  1140.             SetViewerName (VL_CURRENT, "2D Cubic and Quadratic NUBRS");
  1141.             DrawNURBSCurve (hdc, VL_TWOD);
  1142.             break;
  1143.         case IDM_3DCURVE_NURBS:
  1144.             SetViewerName (VL_CURRENT, "3D Cubic and Quadratic NUBRS");
  1145.             DrawNURBSCurve (hdc, VL_THREED);
  1146.             break;
  1147.         case IDM_2DCURVE_QBEZIER:
  1148.             SetViewerName (VL_CURRENT, "2D Quadratic Bezier Curve");
  1149.             DrawQuadraticCurve (hdc, VL_TWOD);
  1150.             break;
  1151.         case IDM_3DCURVE_QBEZIER:
  1152.             SetViewerName (VL_CURRENT, "3D Quadratic Bezier Curve");
  1153.             DrawQuadraticCurve (hdc, VL_THREED);
  1154.             break;
  1155.         case IDM_3DSHAPE_ROSE:
  1156.             SetViewerName (VL_CURRENT, "Roses in 3D");
  1157.             DrawRose (hdc, VL_THREED);
  1158.             break;
  1159.         case IDM_3DSHAPE_BOX:
  1160.             SetViewerName (VL_CURRENT, "Rectangles in 3D");
  1161.             DrawBox (hdc, VL_THREED);
  1162.             break;
  1163.         case IDM_3DSHAPE_DISK:
  1164.             SetViewerName (VL_CURRENT, "Disks in 3D");
  1165.             DrawDisk (hdc, VL_THREED);
  1166.             break;
  1167.         case IDM_3DSHAPE_NGON:
  1168.             SetViewerName (VL_CURRENT, "Nside Polygons in 3D");
  1169.             DrawNgon (hdc, VL_THREED);
  1170.             break;
  1171.         case IDM_3DSHAPE_STAR:
  1172.             SetViewerName (VL_CURRENT, "Nside Stars in 3D");
  1173.             DrawStar (hdc, VL_THREED);
  1174.             break;
  1175.         case IDM_3DSHAPE_FLOWER:
  1176.             DrawFlower (hdc, VL_THREED);
  1177.             SetViewerName (VL_CURRENT, "Nside Flowers in 3D");
  1178.             break;
  1179.         case IDM_3DSHAPE_BOW:
  1180.             SetViewerName (VL_CURRENT, "Bows in 3D");
  1181.             DrawBow (hdc, VL_THREED);
  1182.             break;
  1183.         case IDM_3DSHAPE_WEDGE:
  1184.             SetViewerName (VL_CURRENT, "Wedges in 3D");
  1185.             DrawWedge (hdc, VL_THREED);
  1186.             break;
  1187.         case IDM_3DSHAPE_RING:
  1188.             SetViewerName (VL_CURRENT, "Rings in 3D");
  1189.             DrawRing (hdc, VL_THREED);
  1190.             break;
  1191.         case IDM_2DSHAPE_ROSE:
  1192.             SetViewerName (VL_CURRENT, "Roses in 2D");
  1193.             DrawRose (hdc, VL_TWOD);
  1194.             break;
  1195.         case IDM_2DSHAPE_BOX:
  1196.             SetViewerName (VL_CURRENT, "Rectangles in 2D");
  1197.             DrawBox (hdc, VL_TWOD);
  1198.             break;
  1199.         case IDM_2DSHAPE_DISK:
  1200.             SetViewerName (VL_CURRENT, "Disks in 2D");
  1201.             DrawDisk (hdc, VL_TWOD);
  1202.             break;
  1203.         case IDM_2DSHAPE_NGON:
  1204.             SetViewerName (VL_CURRENT, "Nside Polygons in 2D");
  1205.             DrawNgon (hdc, VL_TWOD);
  1206.             break;
  1207.         case IDM_2DSHAPE_STAR:
  1208.             SetViewerName (VL_CURRENT, "Nside Stars in 2D");
  1209.             DrawStar (hdc, VL_TWOD);
  1210.             break;
  1211.         case IDM_2DSHAPE_FLOWER:
  1212.             SetViewerName (VL_CURRENT, "Nside Flowers in 2D");
  1213.             DrawFlower (hdc, VL_TWOD);
  1214.             break;
  1215.         case IDM_2DSHAPE_BOW:
  1216.             SetViewerName (VL_CURRENT, "Bows in 2D");
  1217.             DrawBow (hdc, VL_TWOD);
  1218.             break;
  1219.         case IDM_2DSHAPE_WEDGE:
  1220.             SetViewerName (VL_CURRENT, "Wedges in 2D");
  1221.             DrawWedge (hdc, VL_TWOD);
  1222.             break;
  1223.         case IDM_2DSHAPE_RING:
  1224.             SetViewerName (VL_CURRENT, "Rings in 2D");
  1225.             DrawRing (hdc, VL_TWOD);
  1226.             break;
  1227.     }
  1228. }
  1229.  
  1230. VOIDED    Primitives2D (HDC hdc, int cmd)
  1231. {
  1232.     PenColor (hdc, VL_RED);
  1233.     DisplayViewerFrame (hdc, VL_CURRENT);
  1234.     SelectPrimitives (hdc, cmd);
  1235.     TextColor (hdc, VL_BLUE, VL_BLACK, TRANSPARENT);
  1236.     DisplayViewerName (hdc, VL_CURRENT, 0);
  1237. }
  1238.  
  1239. VOIDED    Primitives3D (HDC hdc, int cmd)
  1240. {
  1241.     PenColor (hdc, VL_RED);
  1242.     DisplayViewerFrame (hdc, VL_CURRENT);
  1243.     PushTransformation3D (NULL);
  1244.     Scale3D (3, 3, 3);
  1245.     MarkPosition3D (hdc, 0, 0, 0, 10, VL_ORIGIN);
  1246.  
  1247.     PushTransformation3D (NULL);
  1248.     Translate3D (10, 8, 0);
  1249.     SelectPrimitives (hdc, cmd);
  1250.     PopTransformation3D (NULL);
  1251.     PushTransformation3D (NULL);
  1252.     Rotate3D (90, 'x');
  1253.     Translate3D (10, 8, 0);
  1254.     SelectPrimitives (hdc, cmd);
  1255.     PopTransformation3D (NULL);
  1256.     PushTransformation3D (NULL);
  1257.     Rotate3D (-90, 'y');
  1258.     Translate3D (10, 8, 0);
  1259.     SelectPrimitives (hdc, cmd);
  1260.     PopTransformation3D (NULL);
  1261.     PopTransformation3D (NULL);
  1262.     TextColor (hdc, VL_BLUE, VL_BLACK, TRANSPARENT);
  1263.     DisplayViewerName (hdc, VL_CURRENT, 0);
  1264. }
  1265.  
  1266. VOIDED    Curves2D (HDC hdc, int cmd)
  1267. {
  1268.     PenColor (hdc, VL_BLUE);
  1269.     DisplayViewerFrame (hdc, VL_CURRENT);
  1270.     switch (cmd) {
  1271.         case IDM_2DCURVE_NURBS:
  1272.             SetViewerName (VL_CURRENT, "2D NURBS Curves");
  1273.             PushTransformation2D (NULL);
  1274.             Scale2D (2, 2);
  1275.             PopTransformation2D (NULL);
  1276.             break;
  1277.         case IDM_2DCURVE_QBSPLINE:
  1278.         {
  1279.             COORD    point[] = {0, 0, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 4, 1, 4, 0};
  1280.             SetViewerName (VL_CURRENT, "2D Quadratic Bezier Curve");
  1281.             Scale2D (2, 2);
  1282.             PenColor (hdc, VL_RED);
  1283.             Polyline2D (hdc, VL_2D, point, 8);
  1284.             PenColor (hdc, VL_BLUE);
  1285.             PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1286.             PenColor (hdc, VL_GREEN);
  1287.             QBSplineCurve2D (hdc, VL_2D, point, 8);
  1288.             break;
  1289.         }
  1290.         case IDM_2DCURVE_QNURBS:
  1291.         {
  1292.             COORD    point[] = {0, 0, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 4, 1, 4, 0};
  1293.             real knot[] = {0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 6};
  1294.             
  1295.             SetViewerName (VL_CURRENT, "2D Quadratic Bezier Curve");
  1296.             Scale2D (2, 2);
  1297.             PenColor (hdc, VL_RED);
  1298.             Polyline2D (hdc, VL_2D, point, 8);
  1299.             PenColor (hdc, VL_BLUE);
  1300.             PolyMark2D (hdc, VL_2D, point, 8, 3, 3, VL_DIAMONDMARK);
  1301.             PenColor (hdc, VL_GREEN);
  1302.             QNURBSCurve2D (hdc, VL_2D, point, 8, knot);
  1303.             break;
  1304.         }
  1305.         case IDM_2DCURVE_PARABOLA:
  1306.             SetViewerName (VL_CURRENT, "2D Parabola Curve");
  1307.             break;
  1308.         case IDM_2DCURVE_HYPERBOLA:
  1309.             PenColor (hdc, VL_YELLOW);
  1310. //            Hyperbola (hdc, 1, 2);
  1311.             SetViewerName (VL_CURRENT, "2D Hyperbola Curve");
  1312.             break;
  1313.         case IDM_2DCURVE_OSCILWAVE:
  1314.             PenColor (hdc, VL_YELLOW);
  1315. //            OscillatoryWave (hdc, 1, 2, 3, 4);
  1316.             SetViewerName (VL_CURRENT, "2D Oscillatory Wave");
  1317.             break;
  1318.         case IDM_2DCURVE_CATENARY:
  1319.             PenColor (hdc, VL_BLUE);
  1320. //            Catenary (hdc, 1, 2);
  1321.             SetViewerName (VL_CURRENT, "2D Catenary Curve");
  1322.             break;
  1323.         case IDM_2DCURVE_SPIRAL:
  1324.             PenColor (hdc, VL_YELLOW);
  1325.             Spiral2D (hdc, 0, 0, 30, 5, 1, 1);
  1326.             SetViewerName (VL_CURRENT, "2D Spiral Curve");
  1327.             break;
  1328.         case IDM_2DSHAPE_CYCLOID:
  1329.             PenColor (hdc, VL_RED);
  1330. //            Cycloid (hdc, 1);
  1331.             SetViewerName (VL_CURRENT, "2D Cycloid Curve");
  1332.             break;
  1333.         case IDM_2DSHAPE_EPICYCLOID:
  1334.             PenColor (hdc, VL_GREEN);
  1335. //            Epicycloid (hdc, 1, 2);
  1336.             SetViewerName (VL_CURRENT, "2D Epicycloid Curve");
  1337.             break;
  1338.         case IDM_2DSHAPE_CARDIOID:
  1339.             PenColor (hdc, VL_WHITE);
  1340. //            Cardioid (hdc);
  1341.             SetViewerName (VL_CURRENT, "2D Cardioid Curve");
  1342.             break;
  1343.         case IDM_2DSHAPE_HYPOCYCLOID:
  1344.             PenColor (hdc, VL_GRAY);
  1345. //            Hypocycloid (hdc, 1, 2);
  1346.             SetViewerName (VL_CURRENT, "2D Hypocycloid Curve");
  1347.             break;
  1348.         
  1349.     }
  1350.     TextColor (hdc, VL_BLUE, VL_BLUE, TRANSPARENT);
  1351.     DisplayViewerName (hdc, VL_CURRENT, 0);
  1352. }
  1353.  
  1354. BINARY    BiArrayBox (HDC hdc, int row, int col)
  1355. {
  1356.     short    mid;
  1357.  
  1358.     switch ((row + col) % 4 + 1) {
  1359.         case 1: mid = 1; break;
  1360.         case 2: mid = 2; break;
  1361.         case 3: mid = 3; break;
  1362.         case 4: mid = 4; break;
  1363.     }
  1364.     SelectMaterial (mid);
  1365.     return (Cube (hdc, 2, 3, 4));
  1366. }
  1367.  
  1368. BINARY    TriArrayBox (HDC hdc, int row, int col, int lev)
  1369. {
  1370.     SelectMaterial ((row + col + lev) % 4 + 1);
  1371.     return (Cube (hdc, 2, 3, 2));
  1372. }
  1373.  
  1374. VOIDED    ObjectArray (HDC hdc, int func)
  1375. {
  1376.     PenColor (hdc, VL_CYAN);
  1377.     TextColor (hdc, VL_CYAN, VL_BLACK, TRANSPARENT);
  1378.     DisplayViewerFrame (hdc, VL_CURRENT);
  1379.     DisplayViewerName (hdc, VL_CURRENT, 0);
  1380.     ShadingOption (VL_CURRENT, VL_SHADINGMETHOD, VL_PHONGSHADE);
  1381.     ClearDepthBuffer (0xffff);
  1382.     switch (func) {
  1383.         case IDM_ARRAY_RECTANGLE:
  1384.             RectangularArray (hdc, 4, 6, 8, 8, BiArrayBox);
  1385.             SetViewerName (VL_CURRENT, "4x6 Rectangular Object Array");
  1386.             break;
  1387.         case IDM_ARRAY_CUBIC:
  1388.             CubicArray (hdc, 4, 6, 5, 8, 8, 4, TriArrayBox);
  1389.             SetViewerName (VL_CURRENT, "4x6x5 Cubic Object Array");
  1390.             break;
  1391.         case IDM_ARRAY_POLAR:
  1392.             PolarArray (hdc, 4, 6, 10, 30, 5, BiArrayBox);
  1393.             SetViewerName (VL_CURRENT, "4x6 Polar Object Array");
  1394.             break;
  1395.         case IDM_ARRAY_CYLINDRIC:
  1396.             CylindricArray (hdc, 4, 6, 5, 10, 30, 5, 5, TriArrayBox);
  1397.             SetViewerName (VL_CURRENT, "4x6x5 Cylindric Object Array");
  1398.             break;
  1399.         case IDM_ARRAY_SPHERIC:
  1400.             SphericArray (hdc, 4, 6, 5, 10, 30, 30, 10, 30, TriArrayBox);
  1401.             SetViewerName (VL_CURRENT, "4x6x5 Spheric Object Array");
  1402.             break;
  1403.     }
  1404. }
  1405.  
  1406. BINARY    USFlag (HDC hdc)
  1407. {
  1408.     short   i, j;
  1409.     real    x1, y1, x2, y2;
  1410.     real    r, width, height;
  1411.  
  1412.     width = 1;
  1413.     height = (real) 13 / 24;
  1414.     x1 = 0;
  1415.     x2 = width;
  1416.     y1 = 0;
  1417.     y2 = height / 13;
  1418.     BrushColor (hdc, VL_RED);
  1419.     PenColor (hdc, VL_RED);
  1420.     for (i = 0; i < 7; i ++) {
  1421.         Rectangle2D (hdc, x1, y1, x2, y2);
  1422.         y1 += height * 2 / 13;
  1423.         y2 += height * 2 / 13;
  1424.     }
  1425.  
  1426.     BrushColor (hdc, VL_WHITE);
  1427.     PenColor (hdc, VL_WHITE);
  1428.     y1 = height / 13;
  1429.     y2 = height * 2 / 13 - 0.001f;
  1430.     for (i = 0; i < 6; i ++) {
  1431.         Rectangle2D (hdc, x1, y1, x2, y2);
  1432.         y1 += height * 2 / 13;
  1433.         y2 += height * 2 / 13;
  1434.     }
  1435.  
  1436.     BrushColor (hdc, VL_BLUE);
  1437.     PenColor (hdc, VL_BLUE);
  1438.     x2 = 10 * width / 24;
  1439.     y1 = 6 * height / 13;
  1440.     y2 = height;
  1441.     Rectangle2D (hdc, x1, y1, x2, y2);
  1442.  
  1443.     BrushColor (hdc, VL_WHITE);
  1444.     PenColor (hdc, VL_WHITE);
  1445.     x2 /= 6;
  1446.     x1 = x2 / 2;
  1447.     y2 = height * 7 / 13 / 5;
  1448.     r = 0.01f;
  1449.     for (i = 0; i < 6 ; i ++) {
  1450.         y1 = height - y2 / 2;
  1451.         for (j = 0; j < 5; j ++) {
  1452.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1453.             y1 -= y2;
  1454.         }
  1455.         x1 = x1 + x2;
  1456.     }
  1457.     x1 = x2;
  1458.     for (i = 0; i < 5; i ++) {
  1459.         y1 = height - y2;
  1460.         for (j = 0; j < 4; j ++) {
  1461.             Star2D (hdc, x1, y1, 0, r, r, 5);
  1462.             y1 -= y2;
  1463.         }
  1464.         x1 = x1 + x2;
  1465.     }
  1466.     return (TRUE);
  1467. }
  1468.  
  1469.  
  1470.