| 1837 | // line segment, but can also include changes to the default color. |
| 1838 | |
| 1839 | void WriteWire(FILE *file) |
| 1840 | { |
| 1841 | word *pw = (word *)gi.bm; |
| 1842 | int x1, y1, z1, x2, y2, z2, n, nR, nG, nB; |
| 1843 | KV kv; |
| 1844 | |
| 1845 | if (file == NULL) |
| 1846 | return; |
| 1847 | fprintf(file, "DW#\n%d\n", gi.cWire); |
| 1848 | while (pw < gi.pwWireCur) { |
| 1849 | if (*pw != 32768) { |
| 1850 | |
| 1851 | // Output one line segment. |
| 1852 | x1 = (short)pw[0]; y1 = (short)pw[1]; z1 = (short)pw[2]; |
| 1853 | x2 = (short)pw[3]; y2 = (short)pw[4]; z2 = (short)pw[5]; |
| 1854 | fprintf(file, "%d %d %d %d %d %d\n", x1, y1, z1, x2, y2, z2); |
| 1855 | pw += 6; |
| 1856 | } else { |
| 1857 | |
| 1858 | // Output a color change. |
| 1859 | if (gs.fColor) { |
| 1860 | n = BLo(pw[1]); |
| 1861 | if (n < cColor2) { |
| 1862 | kv = rgbbmp[n]; |
| 1863 | if (kv != rgbbmpDef[n] || n >= kIndigo) |
| 1864 | fprintf(file, "Rgb %d %d %d\n", RgbR(kv), RgbG(kv), RgbB(kv)); |
| 1865 | else |
| 1866 | fprintf(file, "%s\n", szColor[n]); |
| 1867 | } else { |
| 1868 | // Invalid color index means RGB stored in current and next word. |
| 1869 | nR = BHi(pw[1]); nG = BLo(pw[2]); nB = BHi(pw[2]); |
| 1870 | if (nR == nG && nG == nB) |
| 1871 | fprintf(file, "GrayN %d\n", nR); |
| 1872 | else |
| 1873 | fprintf(file, "Rgb %d %d %d\n", nR, nG, nB); |
| 1874 | pw++; |
| 1875 | } |
| 1876 | } |
| 1877 | pw += 2; |
| 1878 | } |
| 1879 | } |
| 1880 | } |
| 1881 | |
| 1882 | |
| 1883 | // Add a single 16 bit number to the current wireframe file. |