Changeset 929 for trunk


Ignore:
Timestamp:
Mar 7, 2008, 9:56:26 AM (17 years ago)
Author:
gah
Message:
 
Location:
trunk/vizservers/nanovis
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/Command.cpp

    r928 r929  
    230230
    231231static int
    232 GetVolumeLimits(Tcl_Interp *interp, float *minPtr, float *maxPtr)
    233 {
    234     int i;
     232GetVolumeLimits(Tcl_Interp *interp, AxisRange *range)
     233{
    235234
    236235    /* Find the first volume. */
    237     for (i = 0; i < NanoVis::n_volumes; i++) {
    238         if (NanoVis::volume[i] != NULL) {
     236    int start;
     237    for (start = 0; start < NanoVis::n_volumes; start++) {
     238        if (NanoVis::volume[start] != NULL) {
    239239            break;
    240240        }
    241241    }
    242     if (i == NanoVis::n_volumes) {
     242    if (start == NanoVis::n_volumes) {
    243243        Tcl_AppendResult(interp, "no volumes found", (char *)NULL);
    244244        return TCL_ERROR;
    245245    }
    246     Volume *volPtr;
    247     volPtr = NanoVis::volume[i];
    248     float min, max;
    249     min = volPtr->range_min();
    250     max = volPtr->range_max();
    251     for (i++; i < NanoVis::n_volumes; i++) {
    252         if (NanoVis::volume[i] == NULL) {
    253             continue;
    254         }
    255         volPtr = NanoVis::volume[i];
    256         if (min > volPtr->range_min()) {
    257             min = volPtr->range_min();
    258         }
    259         if (max < volPtr->range_max()) {
    260             max = volPtr->range_max();
    261         }
    262     }
    263     *minPtr = min;
    264     *maxPtr = max;
     246    int axis;
     247    for (axis = AxisRange::X; axis <= AxisRange::VALUES; axis++) {
     248        Volume *volPtr;
     249        int i;
     250
     251        i = start;
     252        volPtr = NanoVis::volume[i];
     253        range[axis] = *volPtr->GetRange(axis);
     254        for (i++; i < NanoVis::n_volumes; i++) {
     255            const AxisRange *rangePtr;
     256
     257            volPtr = NanoVis::volume[i];
     258            rangePtr = volPtr->GetRange(axis);
     259            if (range[axis].max < rangePtr->max) {
     260                range[axis].max = rangePtr->max;
     261            }
     262            if (range[axis].min > rangePtr->min) {
     263                range[axis].min = rangePtr->min;
     264            }
     265        }
     266    }
    265267    return TCL_OK;
    266268}
     
    553555        c = tolower((unsigned char)string[0]);
    554556        if (c == 'x') {
    555             *indexPtr = NanoVis::X;
     557            *indexPtr = AxisRange::X;
    556558            return TCL_OK;
    557559        } else if (c == 'y') {
    558             *indexPtr = NanoVis::Y;
     560            *indexPtr = AxisRange::Y;
    559561            return TCL_OK;
    560562        } else if (c == 'z') {
    561             *indexPtr = NanoVis::Z;
     563            *indexPtr = AxisRange::Z;
    562564            return TCL_OK;
    563565        }
     
    728730}
    729731
    730 static Rappture::CmdSpec cameraOps[] =
    731     {
    732         {"aim",     2, CameraAimOp,      5, 5, "x y z",},
    733         {"angle",   2, CameraAngleOp,    5, 5, "xAngle yAngle zAngle",},
    734         {"zoom",    1, CameraZoomOp,     3, 3, "factor",},
    735     };
     732static Rappture::CmdSpec cameraOps[] = {
     733    {"aim",     2, CameraAimOp,      5, 5, "x y z",},
     734    {"angle",   2, CameraAngleOp,    5, 5, "xAngle yAngle zAngle",},
     735    {"zoom",    1, CameraZoomOp,     3, 3, "factor",},
     736};
    736737static int nCameraOps = NumCmdSpecs(cameraOps);
    737738
     
    786787      }
    787788      Texture2D* plane = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    788       NanoVis::color_table_renderer->render(1024, 1024, plane, tf, vol->range_min(),
    789       vol->range_max());
     789      AxisRange *rangePtr;
     790      rangePtr = vol->GetRange(AxisRange::VALUES);
     791      NanoVis::color_table_renderer->render(1024, 1024, plane, tf, rangePtr->min,
     792                rangePtr->max);
    790793      delete plane;
    791794   
     
    861864}
    862865
    863 static Rappture::CmdSpec cutplaneOps[] =
    864     {
    865         {"position", 1, CutplanePositionOp, 4, 0, "bool axis ?indices?",},
    866         {"state",    1, CutplaneStateOp,    4, 0, "relval axis ?indices?",},
    867     };
     866static Rappture::CmdSpec cutplaneOps[] = {
     867    {"position", 1, CutplanePositionOp, 4, 0, "bool axis ?indices?",},
     868    {"state",    1, CutplaneStateOp,    4, 0, "relval axis ?indices?",},
     869};
    868870static int nCutplaneOps = NumCmdSpecs(cutplaneOps);
    869871
     
    935937        return TCL_ERROR;
    936938    }
    937     float vmin, vmax;
    938     if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) {
    939         return TCL_ERROR;
    940     }
    941     NanoVis::render_legend(tf, vmin, vmax, w, h, label);
     939    AxisRange range[4];
     940    if (GetVolumeLimits(interp, range) != TCL_OK) {
     941        return TCL_ERROR;
     942    }
     943    NanoVis::render_legend(tf,
     944                           range[AxisRange::VALUES].min,
     945                           range[AxisRange::VALUES].max,
     946                           w, h, label);
    942947    return TCL_OK;
    943948}
     
    11101115}
    11111116
    1112 #ifndef notdef
    11131117
    11141118static int
     
    11871191}
    11881192
    1189 static Rappture::CmdSpec volumeAnimationOps[] =
    1190     {
    1191         {"capture",   2, VolumeAnimationCaptureOp,  4, 5, "numframes ?filename?",},
    1192         {"clear",     2, VolumeAnimationClearOp,    3, 3, "",},
    1193         {"start",     3, VolumeAnimationStartOp,    3, 3, "",},
    1194         {"stop",      3, VolumeAnimationStopOp,     3, 3, "",},
    1195         {"volumes",   1, VolumeAnimationVolumesOp,  3, 0, "?indices?",},
    1196     };
     1193static Rappture::CmdSpec volumeAnimationOps[] = {
     1194    {"capture",   2, VolumeAnimationCaptureOp,  4, 5, "numframes ?filename?",},
     1195    {"clear",     2, VolumeAnimationClearOp,    3, 3, "",},
     1196    {"start",     3, VolumeAnimationStartOp,    3, 3, "",},
     1197    {"stop",      3, VolumeAnimationStopOp,     3, 3, "",},
     1198    {"volumes",   1, VolumeAnimationVolumesOp,  3, 0, "?indices?",},
     1199};
    11971200
    11981201static int nVolumeAnimationOps = NumCmdSpecs(volumeAnimationOps);
     
    13471350        Volume *volPtr;
    13481351        char info[1024];
    1349         float vmin, vmax;
     1352        AxisRange overall[4];
    13501353       
    1351         if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) {
     1354        if (GetVolumeLimits(interp, overall) != TCL_OK) {
    13521355            return TCL_ERROR;
    13531356        }
    13541357        volPtr = NanoVis::volume[n];
     1358        const AxisRange *rangePtr;
     1359        rangePtr = volPtr->GetRange(AxisRange::VALUES);
    13551360        sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n",
    1356                 n, volPtr->range_min(), volPtr->range_max(),vmin, vmax);
     1361                n, rangePtr->min, rangePtr->max,
     1362                overall[AxisRange::VALUES].min,
     1363                overall[AxisRange::VALUES].max);
    13571364        write(0, info, strlen(info));
    13581365    }
     
    13861393}
    13871394
    1388 static Rappture::CmdSpec volumeDataOps[] =
    1389     {
    1390         {"follows",   1, VolumeDataFollowsOp, 4, 4, "size",},
    1391         {"state",     1, VolumeDataStateOp,   4, 0, "bool ?indices?",},
    1392     };
     1395static Rappture::CmdSpec volumeDataOps[] = {
     1396    {"follows",   1, VolumeDataFollowsOp, 4, 4, "size",},
     1397    {"state",     1, VolumeDataStateOp,   4, 0, "bool ?indices?",},
     1398};
    13931399static int nVolumeDataOps = NumCmdSpecs(volumeDataOps);
    13941400
     
    14521458}
    14531459
    1454 static int
    1455 VolumeOutlineVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
    1456                        Tcl_Obj *CONST *objv)
    1457 {
    1458     bool visible;
    1459     if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {
    1460         return TCL_ERROR;
    1461     }           
    1462     if (!visible) {
    1463         for (int i = 0; i < NanoVis::n_volumes; ++i) {
    1464             if (NanoVis::volume[i]) {
    1465                 NanoVis::volume[i]->disable_outline();
    1466             }
    1467         }
    1468     } else {
    1469         for (int i = 0; i < NanoVis::n_volumes; ++i) {
    1470             if (NanoVis::volume[i]) {
    1471                 NanoVis::volume[i]->enable_outline();
    1472             }
    1473         }
    1474     }
    1475     return TCL_OK;
    1476 }
    1477 
    1478 static Rappture::CmdSpec volumeOutlineOps[] =
    1479     {
    1480         {"color",     1, VolumeOutlineColorOp,    6, 0, "r g b ?indices?",},
    1481         {"state",     1, VolumeOutlineStateOp,    4, 0, "bool ?indices?",},
    1482         {"visible",   1, VolumeOutlineVisibleOp,  4, 0, "bool ?indices?",},
    1483     };
     1460
     1461static Rappture::CmdSpec volumeOutlineOps[] = {
     1462    {"color",     1, VolumeOutlineColorOp,  6, 0, "r g b ?indices?",},
     1463    {"state",     1, VolumeOutlineStateOp,  4, 0, "bool ?indices?",},
     1464    {"visible",   1, VolumeOutlineStateOp,  4, 0, "bool ?indices?",},
     1465};
    14841466static int nVolumeOutlineOps = NumCmdSpecs(volumeOutlineOps);
    14851467
     
    16041586}
    16051587
    1606 static Rappture::CmdSpec volumeShadingOps[] =
    1607     {
    1608         {"diffuse",     1, VolumeShadingDiffuseOp,    4, 0, "value ?indices?",},
    1609         {"isosurface",  1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",},
    1610         {"opacity",     1, VolumeShadingOpacityOp,    4, 0, "value ?indices?",},
    1611         {"specular",    1, VolumeShadingSpecularOp,   4, 0, "value ?indices?",},
    1612         {"transfunc",   1, VolumeShadingTransFuncOp,  4, 0, "funcName ?indices?",},
    1613     };
     1588static Rappture::CmdSpec volumeShadingOps[] = {
     1589    {"diffuse",     1, VolumeShadingDiffuseOp,    4, 0, "value ?indices?",},
     1590    {"isosurface",  1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",},
     1591    {"opacity",     1, VolumeShadingOpacityOp,    4, 0, "value ?indices?",},
     1592    {"specular",    1, VolumeShadingSpecularOp,   4, 0, "value ?indices?",},
     1593    {"transfunc",   1, VolumeShadingTransFuncOp,  4, 0, "funcName ?indices?",},
     1594};
    16141595static int nVolumeShadingOps = NumCmdSpecs(volumeShadingOps);
    16151596
     
    16931674}
    16941675
    1695 static Rappture::CmdSpec volumeOps[] =
    1696     {
    1697         {"animation", 2, VolumeAnimationOp,   3, 3, "oper ?args?",},
    1698         {"axis",      2, VolumeAxisOp,        3, 3, "label axis value ?indices?",},
    1699         {"data",      1, VolumeDataOp,        3, 3, "oper ?args?",},
    1700         {"outline",   1, VolumeOutlineOp,     3, 0, "oper ?args?",},
    1701         {"shading",   2, VolumeShadingOp,     3, 0, "oper ?args?",},
    1702         {"state",     2, VolumeStateOp,       3, 0, "bool ?indices?",},
    1703         {"test2",     1, VolumeTestOp,        2, 2, "",},
    1704     };
     1676static Rappture::CmdSpec volumeOps[] = {
     1677    {"animation", 2, VolumeAnimationOp,   3, 3, "oper ?args?",},
     1678    {"axis",      2, VolumeAxisOp,        3, 3, "label axis value ?indices?",},
     1679    {"data",      1, VolumeDataOp,        3, 3, "oper ?args?",},
     1680    {"outline",   1, VolumeOutlineOp,     3, 0, "oper ?args?",},
     1681    {"shading",   2, VolumeShadingOp,     3, 0, "oper ?args?",},
     1682    {"state",     2, VolumeStateOp,       3, 0, "bool ?indices?",},
     1683    {"test2",     1, VolumeTestOp,        2, 2, "",},
     1684};
    17051685static int nVolumeOps = NumCmdSpecs(volumeOps);
    17061686
     
    17341714}
    17351715
    1736 #else
    1737 
    1738 static int
    1739 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
    1740 {
    1741     if (objc < 2) {
    1742         Tcl_AppendResult(interp, "wrong # args: should be \"",
    1743                          Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
    1744         return TCL_ERROR;
    1745     }
    1746 
    1747     char *string = Tcl_GetString(objv[1]);
    1748     char c = string[0];
    1749     if ((c == 'a') && (strcmp(string, "axis") == 0)) {
    1750         if (objc < 3) {
    1751             Tcl_AppendResult(interp, "wrong # args: should be \"",
    1752                              Tcl_GetString(objv[0]), " axis option ?arg arg...?\"",
    1753                              (char*)NULL);
    1754             return TCL_ERROR;
    1755         }
    1756         char *string = Tcl_GetString(objv[2]);
    1757         c = string[0];
    1758         if ((c == 'l') && (strcmp(string, "label") == 0)) {
    1759             if (objc < 5) {
    1760                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    1761                                  Tcl_GetString(objv[0]),
    1762                                  " axis label x|y|z string ?volume ...?\"", (char*)NULL);
    1763                 return TCL_ERROR;
    1764             }
    1765             int axis;
    1766             if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    1767                 return TCL_ERROR;
    1768             }
    1769             vector<Volume *> ivol;
    1770             if (GetVolumes(interp, objc - 5, objv + 5, &ivol) != TCL_OK) {
    1771                 return TCL_ERROR;
    1772             }
    1773             vector<Volume *>::iterator iter;
    1774             char *label;
    1775             label = Tcl_GetString(objv[4]);
    1776             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1777                 (*iter)->set_label(axis, label);
    1778             }
    1779         } else {
    1780             Tcl_AppendResult(interp, "bad option \"", string,
    1781                              "\": should be label", (char*)NULL);
    1782             return TCL_ERROR;
    1783         }
    1784     } else if ((c == 'd') && (strcmp(string, "data") == 0)) {
    1785         if (objc < 3) {
    1786             Tcl_AppendResult(interp, "wrong # args: should be \"",
    1787                              Tcl_GetString(objv[0]), " data option ?arg arg...?\"",
    1788                              (char*)NULL);
    1789             return TCL_ERROR;
    1790         }
    1791         char *string = Tcl_GetString(objv[2]);
    1792         c = string[0];
    1793         if ((c == 's') && (strcmp(string, "state") == 0)) {
    1794             if (objc < 4) {
    1795                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    1796                                  Tcl_GetString(objv[0])," data state on|off ?volume...?\"",
    1797                                  (char*)NULL);
    1798                 return TCL_ERROR;
    1799             }
    1800             bool state;
    1801             if (GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {
    1802                 return TCL_ERROR;
    1803             }
    1804             vector<Volume *> ivol;
    1805             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    1806                 return TCL_ERROR;
    1807             }
    1808             if (state) {
    1809                 vector<Volume *>::iterator iter;
    1810                 for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1811                     (*iter)->enable_data();
    1812                 }
    1813             } else {
    1814                 vector<Volume *>::iterator iter;
    1815                 for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1816                     (*iter)->disable_data();
    1817                 }
    1818             }
    1819         } else if (c == 'f' && strcmp(string, "follows") == 0) {
    1820             if (objc < 4) {
    1821                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    1822                                  Tcl_GetString(objv[0]), " data follows size", (char*)NULL);
    1823                 return TCL_ERROR;
    1824             }
    1825             printf("Data Loading\n");
    1826             fflush(stdout);
    1827 
    1828             int nbytes;
    1829             if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) {
    1830                 return TCL_ERROR;
    1831             }
    1832            
    1833             Rappture::Buffer buf;
    1834             if (GetDataStream(interp, buf, nbytes) != TCL_OK) {
    1835                 return TCL_ERROR;
    1836             }
    1837             int n = NanoVis::n_volumes;
    1838             char header[6];
    1839             memcpy(header, buf.bytes(), sizeof(char) * 5);
    1840             header[5] = '\0';
    1841 
    1842 #if _LOCAL_ZINC_TEST_
    1843             //FILE* fp = fopen("/home/nanohub/vrinside/nv/data/HOON/QDWL_100_100_50_strain_8000i.nd_zatom_12_1", "rb");
    1844             FILE* fp;
    1845 
    1846             fp = fopen("/home/nanohub/vrinside/nv/data/HOON/GaAs_AlGaAs_2QD_B4.nd_zc_1_wf", "rb");
    1847             if (fp == NULL) {
    1848                 printf("cannot open the file\n");
    1849                 fflush(stdout);
    1850                 return TCL_ERROR;
    1851             }
    1852             unsigned char* b = (unsigned char*)malloc(buf.size());
    1853             fread(b, buf.size(), 1, fp);
    1854             fclose(fp);
    1855 #endif  /*_LOCAL_ZINC_TEST_*/
    1856             printf("Checking header[%s]\n", header);
    1857             fflush(stdout);
    1858             if (strcmp(header, "<HDR>") == 0) {
    1859                 Volume* vol = NULL;
    1860 
    1861                 printf("ZincBlende stream is in\n");
    1862                 fflush(stdout);
    1863                 //std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary);
    1864                 //fdata.write(buf.bytes(),buf.size());
    1865                 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata);
    1866                
    1867 #if _LOCAL_ZINC_TEST_
    1868                 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory(b);
    1869 #else
    1870                 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes());
    1871 #endif  /*_LOCAL_ZINC_TEST_*/
    1872 
    1873                 printf("finish loading\n");
    1874                 fflush(stdout);
    1875                 if (vol) {
    1876                     while (NanoVis::n_volumes <= n) {
    1877                         NanoVis::volume.push_back((Volume*) NULL);
    1878                         NanoVis::n_volumes++;
    1879                     }
    1880 
    1881                     if (NanoVis::volume[n] != NULL) {
    1882                         delete NanoVis::volume[n];
    1883                         NanoVis::volume[n] = NULL;
    1884                     }
    1885 
    1886                     float dx0 = -0.5;
    1887                     float dy0 = -0.5*vol->height/vol->width;
    1888                     float dz0 = -0.5*vol->depth/vol->width;
    1889                     vol->move(Vector3(dx0, dy0, dz0));
    1890 
    1891                     NanoVis::volume[n] = vol;
    1892                 }
    1893 #if __TEST_CODE__
    1894             } else if (strcmp(header, "<FET>") == 0) {
    1895                 printf("FET loading...\n");
    1896                 fflush(stdout);
    1897                 std::stringstream fdata;
    1898                 fdata.write(buf.bytes(),buf.size());
    1899                 err = load_volume_stream3(n, fdata);
    1900 
    1901                 if (err) {
    1902                     Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);
    1903                     return TCL_ERROR;
    1904                 }
    1905 #endif  /*__TEST_CODE__*/
    1906             } else if (strcmp(header, "<ODX>") == 0) {
    1907                 Rappture::Outcome err;
    1908 
    1909                 printf("Loading DX using OpenDX library...\n");
    1910                 fflush(stdout);
    1911                 //err = load_volume_stream_odx(n, buf.bytes()+5, buf.size()-5);
    1912                 //err = load_volume_stream2(n, fdata);
    1913                 if (err) {
    1914                     Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);
    1915                     return TCL_ERROR;
    1916                 }
    1917             } else {
    1918                 Rappture::Outcome err;
    1919 
    1920                 printf("OpenDX loading...\n");
    1921                 fflush(stdout);
    1922                 std::stringstream fdata;
    1923                 fdata.write(buf.bytes(),buf.size());
    1924                
    1925 #if ISO_TEST
    1926                 err = load_volume_stream2(n, fdata);
    1927 #else
    1928                 err = load_volume_stream(n, fdata);
    1929 #endif
    1930                 if (err) {
    1931                     Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);
    1932                     return TCL_ERROR;
    1933                 }
    1934             }
    1935 
    1936             //
    1937             // BE CAREFUL:  Set the number of slices to something
    1938             //   slightly different for each volume.  If we have
    1939             //   identical volumes at exactly the same position
    1940             //   with exactly the same number of slices, the second
    1941             //   volume will overwrite the first, so the first won't
    1942             //   appear at all.
    1943             //
    1944             if (NanoVis::volume[n] != NULL) {
    1945                 NanoVis::volume[n]->set_n_slice(256-n);
    1946                 NanoVis::volume[n]->disable_cutplane(0);
    1947                 NanoVis::volume[n]->disable_cutplane(1);
    1948                 NanoVis::volume[n]->disable_cutplane(2);
    1949 
    1950                 NanoVis::vol_renderer->add_volume(NanoVis::volume[n],NanoVis::get_transfunc("default"));
    1951             }
    1952 
    1953             {
    1954                 Volume *volPtr;
    1955                 char info[1024];
    1956                 float vmin, vmax;
    1957 
    1958                 if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) {
    1959                     return TCL_ERROR;
    1960                 }
    1961                 volPtr = NanoVis::volume[n];
    1962                 sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n",
    1963                         n, volPtr->range_min(), volPtr->range_max(),vmin, vmax);
    1964                 write(0, info, strlen(info));
    1965             }
    1966         } else {
    1967             Tcl_AppendResult(interp, "bad data option \"", string,
    1968                              "\": should be follows or state", (char*)NULL);
    1969             return TCL_ERROR;
    1970         }
    1971     } else if (c == 'o' && strcmp(string, "outline") == 0) {
    1972         if (objc < 3) {
    1973             Tcl_AppendResult(interp, "wrong # args: should be \"",
    1974                              Tcl_GetString(objv[0]), " outline option ?arg arg...?\"",
    1975                              (char*)NULL);
    1976             return TCL_ERROR;
    1977         }
    1978         char *string = Tcl_GetString(objv[2]);
    1979         c = string[0];
    1980         if ((c == 's') && (strcmp(string, "state") == 0)) {
    1981             if (objc < 3) {
    1982                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    1983                                  Tcl_GetString(objv[0]),
    1984                                  " outline state on|off ?volume ...? \"", (char*)NULL);
    1985                 return TCL_ERROR;
    1986             }
    1987 
    1988             bool state;
    1989             if (GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {
    1990                 return TCL_ERROR;
    1991             }
    1992             vector<Volume *> ivol;
    1993             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    1994                 return TCL_ERROR;
    1995             }
    1996             if (state) {
    1997                 vector<Volume *>::iterator iter;
    1998                 for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    1999                     (*iter)->enable_outline();
    2000                 }
    2001             } else {
    2002                 vector<Volume *>::iterator iter;
    2003                 for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2004                     (*iter)->disable_outline();
    2005                 }
    2006             }
    2007         } else if ((c == 'v') && (strcmp(string, "visible") == 0)) {
    2008             bool visible;
    2009 
    2010             if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {
    2011                 return TCL_ERROR;
    2012             }           
    2013             if (!visible) {
    2014                 for (int i = 0; i < NanoVis::n_volumes; ++i) {
    2015                     if (NanoVis::volume[i]) {
    2016                         NanoVis::volume[i]->disable_outline();
    2017                     }
    2018                 }
    2019             } else {
    2020                 for (int i = 0; i < NanoVis::n_volumes; ++i) {
    2021                     if (NanoVis::volume[i]) {
    2022                         NanoVis::volume[i]->enable_outline();
    2023                     }
    2024                 }
    2025             }
    2026         } else if ((c == 'c') && (strcmp(string, "color") == 0)) {
    2027             if (objc < 6) {
    2028                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2029                                  Tcl_GetString(objv[0]),
    2030                                  " outline color R G B ?volume ...? \"", (char*)NULL);
    2031                 return TCL_ERROR;
    2032             }
    2033             float rgb[3];
    2034             if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) {
    2035                 return TCL_ERROR;
    2036             }
    2037             vector<Volume *> ivol;
    2038             if (GetVolumes(interp, objc - 6, objv + 6, &ivol) != TCL_OK) {
    2039                 return TCL_ERROR;
    2040             }
    2041             vector<Volume *>::iterator iter;
    2042             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2043                 (*iter)->set_outline_color(rgb);
    2044             }
    2045         }
    2046         else {
    2047             Tcl_AppendResult(interp, "bad outline option \"", string,
    2048                              "\": should be color, visible, or state", (char*)NULL);
    2049             return TCL_ERROR;
    2050         }
    2051     } else if ((c == 's') && (strcmp(string, "shading") == 0)) {
    2052         if (objc < 3) {
    2053             Tcl_AppendResult(interp, "wrong # args: should be \"",
    2054                              Tcl_GetString(objv[0]), " shading option ?arg arg...?\"",
    2055                              (char*)NULL);
    2056             return TCL_ERROR;
    2057         }
    2058         char *string = Tcl_GetString(objv[2]);
    2059         c = string[0];
    2060         if ((c == 't') && (strcmp(string, "transfunc") == 0)) {
    2061             if (objc < 4) {
    2062                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2063                                  Tcl_GetString(objv[0]),
    2064                                  " shading transfunc name ?volume ...?\"", (char*)NULL);
    2065                 return TCL_ERROR;
    2066             }
    2067             TransferFunction *tf;
    2068             char *name = Tcl_GetString(objv[3]);
    2069             tf = NanoVis::get_transfunc(name);
    2070             if (tf == NULL) {
    2071                 Tcl_AppendResult(interp, "transfer function \"", name,
    2072                                  "\" is not defined", (char*)NULL);
    2073                 return TCL_ERROR;
    2074             }
    2075             vector<Volume *> ivol;
    2076             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    2077                 return TCL_ERROR;
    2078             }
    2079             vector<Volume *>::iterator iter;
    2080             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2081                 NanoVis::vol_renderer->shade_volume(*iter, tf);
    2082                
    2083                 // TBD..
    2084                 // POINTSET
    2085                 /*
    2086                   if ((*iter)->pointsetIndex != -1) {
    2087                   g_pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256);
    2088                   }
    2089                 */
    2090             }
    2091         } else if ((c == 'd') && (strcmp(string, "diffuse") == 0)) {
    2092             if (objc < 4) {
    2093                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2094                                  Tcl_GetString(objv[0]),
    2095                                  " shading diffuse value ?volume ...?\"", (char*)NULL);
    2096                 return TCL_ERROR;
    2097             }
    2098 
    2099             float diffuse;
    2100             if (GetFloatFromObj(interp, objv[3], &diffuse) != TCL_OK) {
    2101                 return TCL_ERROR;
    2102             }
    2103             vector<Volume *> ivol;
    2104             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    2105                 return TCL_ERROR;
    2106             }
    2107             vector<Volume *>::iterator iter;
    2108             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2109                 (*iter)->set_diffuse(diffuse);
    2110             }
    2111         } else if ((c == 'o') && (strcmp(string, "opacity") == 0)) {
    2112             if (objc < 4) {
    2113                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2114                                  Tcl_GetString(objv[0]),
    2115                                  " shading opacity value ?volume ...?\"", (char*)NULL);
    2116                 return TCL_ERROR;
    2117             }
    2118             float opacity;
    2119             if (GetFloatFromObj(interp, objv[3], &opacity) != TCL_OK) {
    2120                 return TCL_ERROR;
    2121             }
    2122             vector<Volume *> ivol;
    2123             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    2124                 return TCL_ERROR;
    2125             }
    2126             vector<Volume *>::iterator iter;
    2127             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2128                 (*iter)->set_opacity_scale(opacity);
    2129             }
    2130         } else if ((c == 's') && (strcmp(string, "specular") == 0)) {
    2131             if (objc < 4) {
    2132                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2133                                  Tcl_GetString(objv[0]),
    2134                                  " shading specular value ?volume ...?\"", (char*)NULL);
    2135                 return TCL_ERROR;
    2136             }
    2137             float specular;
    2138             if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) {
    2139                 return TCL_ERROR;
    2140             }
    2141             vector<Volume *> ivol;
    2142             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    2143                 return TCL_ERROR;
    2144             }
    2145             vector<Volume *>::iterator iter;
    2146             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2147                 (*iter)->set_specular(specular);
    2148             }
    2149         } else if ((c == 'i') && (strcmp(string, "isosurface") == 0)) {
    2150             if (objc < 4) {
    2151                 Tcl_AppendResult(interp, "wrong # args: should be \"",
    2152                                  Tcl_GetString(objv[0]),
    2153                                  " shading isosurface on|off ?volume ...?\"", (char*)NULL);
    2154                 return TCL_ERROR;
    2155             }
    2156             bool iso_surface;
    2157             if (GetBooleanFromObj(interp, objv[3], &iso_surface) != TCL_OK) {
    2158                 return TCL_ERROR;
    2159             }
    2160             vector<Volume *> ivol;
    2161             if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    2162                 return TCL_ERROR;
    2163             }
    2164             vector<Volume *>::iterator iter;
    2165             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2166                 (*iter)->set_isosurface(iso_surface);
    2167             }
    2168         } else {
    2169             Tcl_AppendResult(interp, "bad shading option \"", string,
    2170                              "\": should be diffuse, opacity, specular, transfunc, or ",
    2171                              "isosurface", (char*)NULL);
    2172             return TCL_ERROR;
    2173         }
    2174     } else if ((c == 's') && (strcmp(string, "state") == 0)) {
    2175         if (objc < 3) {
    2176             Tcl_AppendResult(interp, "wrong # args: should be \"",
    2177                              Tcl_GetString(objv[0]), " state on|off ?volume...?\"",
    2178                              (char*)NULL);
    2179             return TCL_ERROR;
    2180         }
    2181         bool state;
    2182         if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
    2183             return TCL_ERROR;
    2184         }
    2185         vector<Volume *> ivol;
    2186         if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {
    2187             return TCL_ERROR;
    2188         }
    2189         if (state) {
    2190             vector<Volume *>::iterator iter;
    2191             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2192                 (*iter)->enable();
    2193             }
    2194         } else {
    2195             vector<Volume *>::iterator iter;
    2196             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2197                 (*iter)->disable();
    2198             }
    2199         }
    2200     } else if (strcmp(string, "animation") == 0) {
    2201         if (objc < 3) {
    2202             Tcl_AppendResult(interp, "wrong # args: should be \"",
    2203                              Tcl_GetString(objv[0]), " animation option ?args...?\"",
    2204                              (char*)NULL);
    2205             return TCL_ERROR;
    2206         }
    2207         char *string = Tcl_GetString(objv[2]);
    2208         char c = string[0];
    2209         if ((c == 'v') && (strcmp(string,"volumes") == 0)) {
    2210             vector<unsigned int> ivol;
    2211             if (GetVolumeIndices(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {
    2212                 return TCL_ERROR;
    2213             }
    2214             Trace("parsing volume index\n");
    2215             vector<unsigned int>::iterator iter;
    2216             for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    2217                 Trace("index: %d\n", *iter);
    2218                 NanoVis::vol_renderer->addAnimatedVolume(NanoVis::volume[*iter],
    2219                                                          *iter);
    2220             }
    2221         } else if ((c == 'c') && (strcmp(string,"capture") == 0)) {
    2222             int total;
    2223 
    2224             if (Tcl_GetIntFromObj(interp, objv[3], &total) != TCL_OK) {
    2225                 return TCL_ERROR;
    2226             }
    2227             VolumeInterpolator* interpolator;
    2228             interpolator = NanoVis::vol_renderer->getVolumeInterpolator();
    2229             interpolator->start();
    2230             if (interpolator->is_started()) {
    2231                 char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]);
    2232                 for (int frame_num = 0; frame_num < total; ++frame_num) {
    2233                     float fraction;
    2234 
    2235                     fraction = ((float)frame_num) / (total - 1);
    2236                     Trace("fraction : %f\n", fraction);
    2237                     //interpolator->update(((float)frame_num) / (total - 1));
    2238                     interpolator->update(fraction);
    2239 
    2240                     NanoVis::offscreen_buffer_capture();  //enable offscreen render
    2241 
    2242                     NanoVis::display();
    2243                     NanoVis::read_screen();
    2244 
    2245                     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    2246            
    2247                     NanoVis::bmp_write_to_file(frame_num, fileName);
    2248                 }
    2249             }
    2250         } else if ((c == 's') && (strcmp(string, "start") == 0)) {
    2251             NanoVis::vol_renderer->startVolumeAnimation();
    2252         } else if ((c == 's') && (strcmp(string, "stop") == 0)) {
    2253             NanoVis::vol_renderer->stopVolumeAnimation();
    2254         } else if ((c == 'c') && (strcmp(string, "clear") == 0)) {
    2255             NanoVis::vol_renderer->clearAnimatedVolumeInfo();
    2256         } else {
    2257             Tcl_AppendResult(interp, "bad animation option \"", string,
    2258                              "\": should be volumes, start, stop,  or clear", (char*)NULL);
    2259             return TCL_ERROR;
    2260         }
    2261     } else if ((c == 't') && (strcmp(string, "test2") == 0)) {
    2262         NanoVis::volume[1]->disable_data();
    2263         NanoVis::volume[1]->disable();
    2264     } else {
    2265         Tcl_AppendResult(interp, "bad option \"", string, "\": should be ",
    2266                          "data, outline, shading, or state", (char*)NULL);
    2267         return TCL_ERROR;
    2268     }
    2269     return TCL_OK;
    2270 }
    2271 #endif
    2272 
    22731716static int
    22741717FlowCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     
    22901733        }
    22911734        Volume *volPtr;
     1735        const AxisRange *rangePtr;
    22921736
    22931737        if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) {
    22941738            return TCL_ERROR;
    22951739        }
     1740        rangePtr = volPtr->GetRange(AxisRange::VALUES);
    22961741        if (NanoVis::particleRenderer != NULL) {
    22971742            NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f,
    2298                                                       volPtr->height / (float)volPtr->width,
    2299                                                       volPtr->depth  / (float)volPtr->width,
    2300                                                       volPtr->range_max());
     1743                volPtr->height / (float)volPtr->width,
     1744                volPtr->depth  / (float)volPtr->width,
     1745                rangePtr->max);
    23011746            NanoVis::initParticle();
    23021747        }
    23031748        if (NanoVis::licRenderer != NULL) {
    23041749            NanoVis::licRenderer->setVectorField(volPtr->id,
    2305                                                  1.0f / volPtr->aspect_ratio_width,
    2306                                                  1.0f / volPtr->aspect_ratio_height,
    2307                                                  1.0f / volPtr->aspect_ratio_depth,
    2308                                                  volPtr->range_max());
     1750                1.0f / volPtr->aspect_ratio_width,
     1751                1.0f / volPtr->aspect_ratio_height,
     1752                1.0f / volPtr->aspect_ratio_depth,
     1753                rangePtr->max);
    23091754            NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z);
    23101755        }
     
    25411986}
    25421987
    2543 static Rappture::CmdSpec heightMapDataOps[] =
    2544     {
    2545         {"follows",      1, HeightMapDataFollowsOp, 4, 4, "length",},
    2546         {"visible",      1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",},
    2547     };
     1988static Rappture::CmdSpec heightMapDataOps[] = {
     1989    {"follows",      1, HeightMapDataFollowsOp, 4, 4, "length",},
     1990    {"visible",      1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",},
     1991};
    25481992static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps);
    25491993
     
    26052049}
    26062050
    2607 static Rappture::CmdSpec heightMapLineContourOps[] =
    2608     {
    2609         {"color",   1, HeightMapLineContourColorOp,   4, 4, "length",},
    2610         {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",},
    2611     };
     2051static Rappture::CmdSpec heightMapLineContourOps[] = {
     2052    {"color",   1, HeightMapLineContourColorOp,   4, 4, "length",},
     2053    {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",},
     2054};
    26122055static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps);
    26132056
     
    26742117        return TCL_ERROR;
    26752118    }
    2676     NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(),
    2677                            w, h, "label");
     2119    const AxisRange *rangePtr;
     2120    rangePtr = hMap->GetRange(AxisRange::VALUES);
     2121    NanoVis::render_legend(tf, rangePtr->min, rangePtr->max, w, h, "label");
    26782122    return TCL_OK;
    26792123}
     
    27332177
    27342178
    2735     Vector3 min(minx, (float) heightMap->range_min(), miny);
    2736     Vector3 max(maxx, (float) heightMap->range_max(), maxy);
     2179    const AxisRange *rangePtr;
     2180    rangePtr = heightMap->GetRange(AxisRange::VALUES);
     2181    Vector3 min(minx, (float)rangePtr->min, miny);
     2182    Vector3 max(maxx, (float)rangePtr->max, maxy);
    27372183   
    27382184    NanoVis::grid->setMinMax(min, max);
     
    27682214}
    27692215
    2770 static Rappture::CmdSpec heightMapOps[] =
    2771     {
    2772         {"create",       2, HeightMapCreateOp,      9, 9,
    2773          "xmin ymin xmax ymax xnum ynum values",},
    2774         {"cull",         2, HeightMapCullOp,        3, 3, "mode",},
    2775         {"data",         1, HeightMapDataOp,        3, 0, "oper ?args?",},
    2776         {"legend",       2, HeightMapLegendOp,      5, 5, "index width height",},
    2777         {"linecontour",  2, HeightMapLineContourOp, 2, 0, "oper ?args?",},
    2778         {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
    2779         {"shade",        1, HeightMapShadeOp,       3, 3, "model",},
    2780         {"test",         2, HeightMapTestOp,        2, 2, "",},
    2781         {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?indices?",},
    2782     };
     2216static Rappture::CmdSpec heightMapOps[] = {
     2217    {"create",       2, HeightMapCreateOp,      9, 9,
     2218     "xmin ymin xmax ymax xnum ynum values",},
     2219    {"cull",         2, HeightMapCullOp,        3, 3, "mode",},
     2220    {"data",         1, HeightMapDataOp,        3, 0, "oper ?args?",},
     2221    {"legend",       2, HeightMapLegendOp,      5, 5, "index width height",},
     2222    {"linecontour",  2, HeightMapLineContourOp, 2, 0, "oper ?args?",},
     2223    {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
     2224    {"shade",        1, HeightMapShadeOp,       3, 3, "model",},
     2225    {"test",         2, HeightMapTestOp,        2, 2, "",},
     2226    {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?indices?",},
     2227};
    27832228static int nHeightMapOps = NumCmdSpecs(heightMapOps);
    27842229
     
    28962341}
    28972342
    2898 static Rappture::CmdSpec gridOps[] =
    2899     {
    2900         {"axiscolor",  5, GridAxisColorOp,  5, 6, "r g b ?a?",},
    2901         {"axisname",   5, GridAxisNameOp,   5, 5, "index width height",},
    2902         {"linecolor",  7, GridLineColorOp,  5, 6, "r g b ?a?",},
    2903         {"linecount",  7, GridLineCountOp,  5, 5, "xCount yCount zCount",},
    2904         {"minmax",     1, GridMinMaxOp,     8, 8, "xMin yMin zMin xMax yMax zMax",},
    2905         {"visible",    1, GridVisibleOp,    3, 3, "bool",},
    2906     };
     2343static Rappture::CmdSpec gridOps[] = {
     2344    {"axiscolor",  5, GridAxisColorOp,  5, 6, "r g b ?a?",},
     2345    {"axisname",   5, GridAxisNameOp,   5, 5, "index width height",},
     2346    {"linecolor",  7, GridLineColorOp,  5, 6, "r g b ?a?",},
     2347    {"linecount",  7, GridLineCountOp,  5, 5, "xCount yCount zCount",},
     2348    {"minmax",     1, GridMinMaxOp,     8, 8, "xMin yMin zMin xMax yMax zMax",},
     2349    {"visible",    1, GridVisibleOp,    3, 3, "bool",},
     2350};
    29072351static int nGridOps = NumCmdSpecs(gridOps);
    29082352
     
    30352479}
    30362480
    3037 static Rappture::CmdSpec planeOps[] =
    3038     {
    3039         {"enable",     1, PlaneEnableOp,    4, 4, "planeIdx mode",},
    3040         {"link",       1, PlaneLinkOp,      4, 4, "planeIdx transfuncIdx",},
    3041         {"new",        1, PlaneNewOp,       5, 5, "planeIdx width height",},
    3042     };
     2481static Rappture::CmdSpec planeOps[] = {
     2482    {"enable",     1, PlaneEnableOp,    4, 4, "planeIdx mode",},
     2483    {"link",       1, PlaneLinkOp,      4, 4, "planeIdx transfuncIdx",},
     2484    {"new",        1, PlaneNewOp,       5, 5, "planeIdx width height",},
     2485};
    30432486static int nPlaneOps = NumCmdSpecs(planeOps);
    30442487
  • trunk/vizservers/nanovis/Grid.cpp

    r922 r929  
    33#include "Grid.h"
    44
    5 Grid::Grid()
    6 : _axisColor(1.0f, 1.0f, 1.0f, 1.0f), _font(0), _axisGridLineCount(5.0f, 5.0f, 5.0f),
    7 _axisMin(0.0f, 0.0f, 0.0f), _axisMax(1.0f, 1.0f, 1.0f), _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f), _visible(false)
     5Grid::Grid() :
     6    _axisColor(1.0f, 1.0f, 1.0f, 1.0f),
     7    _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f),
     8    _axisMin(0.0f, 0.0f, 0.0f),
     9    _axisMax(1.0f, 1.0f, 1.0f),
     10    _axisGridLineCount(5.0f, 5.0f, 5.0f),
     11    _font(0),
     12    _visible(false)
    813{
    914    __axisScale = _axisMax - _axisMin;
     
    4247    glBegin(GL_LINES);
    4348
    44     float linecount = 2.0f;
    45     float linecountY = 4.0f;
    4649    // +y
    4750    for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) {
     
    7780
    7881    if (_font) {
    79         double x = 1.0f, y = 0.0f, z = 0.0f;
    8082        double mv[16], prjm[16];
    8183        int viewport[4];
  • trunk/vizservers/nanovis/Grid.h

    r862 r929  
    1111    Vector4 _axisColor;
    1212    Vector4 _gridLineColor;
     13    Vector3 _axisMin;
    1314    Vector3 _axisMax;
    14     Vector3 _axisMin;
    1515    Vector3 _axisGridLineCount;
    1616    R2Fonts* _font;
    17     bool _showGrid;
    1817    bool _visible;
    1918   
  • trunk/vizservers/nanovis/HeightMap.cpp

    r927 r929  
    2828    _visible(false),
    2929    _scale(1.0f, 1.0f, 1.0f),
    30     _centerPoint(0.0f, 0.0f, 0.0f),
    31     _vmin(0.0f),
    32     _vmax(0.0f)
     30    _centerPoint(0.0f, 0.0f, 0.0f)
    3331{
    3432    _shader = new NvShader();
     
    214212    reset();
    215213   
    216     _vmin = heights[0].y, _vmax = heights[0].y;
     214    float min, max;
     215    min = heights[0].y, max = heights[0].y;
     216
    217217    int count = xCount * yCount;
    218218    for (int i = 0; i < count; ++i) {
    219         if (_vmin > heights[i].y) {
    220             _vmin = heights[i].y;
     219        if (min > heights[i].y) {
     220            min = heights[i].y;
    221221        }
    222         if (_vmax < heights[i].y) {
    223             _vmax = heights[i].y;
     222        if (max < heights[i].y) {
     223            max = heights[i].y;
    224224        }
    225225    }
    226226
    227227    _scale.x = 1.0f;
    228     _scale.z = _vmax - _vmin;
     228    _scale.z = max - min;
    229229    _scale.y = 1.0f;
    230     set_limits(0, 0.0, 1.0);
    231     set_limits(1, 0.0, 1.0);
    232     set_limits(2, _vmin, _vmax);
    233 
    234     _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + _vmin, _scale.y * 0.5);
     230
     231    SetRange(AxisRange::VALUES, min, max);
     232    SetRange(AxisRange::X, 0.0, 1.0);
     233    SetRange(AxisRange::Y, 0.0, 1.0);
     234    SetRange(AxisRange::Z, min, max);
     235
     236    _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5);
    235237
    236238    Vector3* texcoord = new Vector3[count];
     
    278280    reset();
    279281
    280     _vmin = heights[0], _vmax = heights[0];
     282    float min, max;
     283    min = heights[0], max = heights[0];
    281284    int count = xCount * yCount;
    282285    for (int i = 0; i < count; ++i) {
    283         if (_vmin > heights[i]) {
    284             _vmin = heights[i];
    285         } else if (_vmax < heights[i]) {
    286             _vmax = heights[i];
     286        if (min > heights[i]) {
     287            min = heights[i];
     288        } else if (max < heights[i]) {
     289            max = heights[i];
    287290        }
    288291    }
    289292    _scale.x = endX - startX;
    290     _scale.y = _vmax - _vmin;
     293    _scale.y = max - min;
    291294    _scale.z = endY - startY;
    292     set_limits(0, startX, endX);
    293     set_limits(1, startY, endY);
    294     set_limits(2, _vmin, _vmax);
    295    
    296     _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + _vmin, _scale.z * 0.5 + startY);
     295
     296    SetRange(AxisRange::VALUES, min, max);
     297    SetRange(AxisRange::X, startX, endX);
     298    SetRange(AxisRange::Y, min, max);
     299    SetRange(AxisRange::Z, startY, endY);
     300
     301    _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + min,
     302        _scale.z * 0.5 + startY);
    297303   
    298304    Vector3* texcoord = new Vector3[count];
  • trunk/vizservers/nanovis/HeightMap.h

    r927 r929  
    99#include "Vector3.h"
    1010#include <RenderContext.h>
     11#include "AxisRange.h"
    1112
    1213namespace graphics {
     
    3738    Vector3 _centerPoint;
    3839
    39     double _limits[3][2];
    40     double _vmin, _vmax;
     40    AxisRange _ranges[4];
    4141public :
    4242    /**
     
    7777     *@brief Define a color map for color shading of heightmap
    7878     */
    79         void setColorMap(TransferFunction* colorMap);
     79    void setColorMap(TransferFunction* colorMap);
    8080
    8181    /**
    8282     *@brief Get the color map defined for shading of this heightmap
    8383     */
    84     TransferFunction *getColorMap(void);
    85 
     84    TransferFunction *getColorMap(void) {
     85        return _colorMap;
     86    }
    8687    /**
    8788     *@brief Set the visibility of the height map
    8889     */
    89         void setVisible(bool visible);
     90    void setVisible(bool visible) {
     91        _visible = visible;
     92    }
    9093
    9194    /**
    9295     *@brief Return the status of the visibility
    9396     */
    94         bool isVisible() const;
    95 
     97    bool isVisible() const {
     98        return _visible;
     99    }
    96100    /**
    97101     *@brief Set the visibility of the line contour
    98102     */
    99         void setLineContourVisible(bool visible);
     103    void setLineContourVisible(bool visible) {
     104        _contourVisible = visible;
     105    }
    100106
    101107    /**
    102108     *@brief Defind the color of the line contour
    103109     */
    104     void setLineContourColor(float *rgb);
     110    void setLineContourColor(float *rgb) {
     111        _contourColor.x = rgb[0];
     112        _contourColor.y = rgb[1];
     113        _contourColor.z = rgb[2];
     114    }
    105115
    106     double range_min(void);
    107     double range_max(void);
    108     void set_limits(int axis, double min, double max);
    109     void get_limits(int axis, double *minPtr, double *maxPtr);
     116    void SetRange(int axis, double min, double max) {
     117        _ranges[axis].min = min;
     118        _ranges[axis].max = max;
     119    }
     120    const AxisRange *GetRange(int axis) {
     121        return _ranges + axis;
     122    }
    110123};
    111124
    112 inline void HeightMap::setVisible(bool visible)
    113 {
    114         _visible = visible;
    115 }
    116 
    117 inline bool HeightMap::isVisible() const
    118 {
    119         return _visible;
    120 }
    121 
    122 inline void HeightMap::setLineContourVisible(bool visible)
    123 {
    124         _contourVisible = visible;
    125 }
    126 
    127 inline void HeightMap::setLineContourColor(float rgb[])
    128 {
    129     _contourColor.x = rgb[0];
    130     _contourColor.y = rgb[1];
    131     _contourColor.z = rgb[2];
    132 }
    133 
    134 inline TransferFunction *
    135 HeightMap::getColorMap()
    136 {
    137     return _colorMap;
    138 }
    139 
    140 inline void
    141 HeightMap::set_limits(int axis, double min, double max)
    142 {
    143     _limits[axis][0] = min;
    144     _limits[axis][1] = max;
    145 }
    146 
    147 inline void
    148 HeightMap::get_limits(int axis, double *minPtr, double *maxPtr)
    149 {
    150     *minPtr = _limits[axis][0];
    151     *maxPtr = _limits[axis][1];
    152 }
    153 
    154 inline double
    155 HeightMap::range_min()
    156 {
    157     return _vmin;
    158 }
    159 
    160 inline double
    161 HeightMap::range_max()
    162 {
    163     return _vmax;
    164 }
    165125#endif
  • trunk/vizservers/nanovis/R2/include/R2/graphics/R2Geometry.h

    r776 r929  
     1 
    12#ifndef _R2_GEOMETRY_H_
    23#define _R2_GEOMETRY_H_
     
    89class R2Geometry {
    910public :
    10         enum {
    11                 LINES = GL_LINES,
    12                 LINE_STRIP = GL_LINE_STRIP,
    13                 TRIANGLES = GL_TRIANGLES,
    14                 TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
    15                 QUADS = GL_QUADS,
    16         };
     11    enum {
     12        LINES = GL_LINES,
     13        LINE_STRIP = GL_LINE_STRIP,
     14        TRIANGLES = GL_TRIANGLES,
     15        TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
     16        QUADS = GL_QUADS,
     17    };
    1718
    1819private :
    19         R2VertexBuffer* _vertexBuffer;
    20         R2VertexBuffer* _colorBuffer;
    21         R2IndexBuffer* _indexBuffer;
    22         int _primitiveType;
     20    R2VertexBuffer* _vertexBuffer;
     21    R2VertexBuffer* _colorBuffer;
     22    R2IndexBuffer* _indexBuffer;
     23    int _primitiveType;
    2324
    2425public :
    25         R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2IndexBuffer* indexBuffer);
    26         R2Geometry(int primitive, R2VertexBuffer* pointBuffer, R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer);
    27         ~R2Geometry();
    28 
     26    R2Geometry(int primitive, R2VertexBuffer* vertexBuffer,
     27               R2IndexBuffer* indexBuffer);
     28    R2Geometry(int primitive, R2VertexBuffer* pointBuffer,
     29               R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer);
     30    ~R2Geometry();
     31   
    2932public :
    30         void render();
     33    void render();
    3134};
    3235
    33 #endif //
     36#endif /*_R2_GEOMETRY_H_*/
  • trunk/vizservers/nanovis/R2/src/R2Fonts.cpp

    r835 r929  
    1313R2Fonts::~R2Fonts()
    1414{
    15     for (R2int32 index = 0; index < _fonts.size(); ++index) {
     15    for (unsigned index = 0; index < _fonts.size(); ++index) {
    1616        glDeleteLists(_fonts[index]._displayLists, 256);
    1717        glDeleteTextures(1, &(_fonts[_fontIndex]. _fontTextureID));
     
    2222R2Fonts::setFont(const char* fontName)
    2323{
    24     for (R2int32 index = 0; index < _fonts.size(); ++index) {
     24    for (unsigned index = 0; index < _fonts.size(); ++index) {
    2525        if (_fonts[index]._fontName == fontName) {
    2626            _fontIndex = index;
     
    138138        unsigned int uiFileId = 0;
    139139        fsInput.read(reinterpret_cast<char*>(&uiFileId), sizeof(unsigned int));
    140         if (uiFileId == c_nFileMagicHeader) {
     140        if (uiFileId == (unsigned int)c_nFileMagicHeader) {
    141141            // read general font/texture dimensions
    142142            unsigned int uiTextureWidth, uiTextureHeight, uiFontHeight;
  • trunk/vizservers/nanovis/R2/src/R2Geometry.cpp

    r780 r929  
     1
    12#include <GL/glew.h>
    23#include <GL/gl.h>
    34#include <R2/graphics/R2Geometry.h>
    45
    5 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2IndexBuffer* indexBuffer)
    6 : _primitiveType(primitive), _vertexBuffer(vertexBuffer), _indexBuffer(indexBuffer), _colorBuffer(0)
     6R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer,
     7                       R2IndexBuffer* indexBuffer) :
     8    _vertexBuffer(vertexBuffer),
     9    _colorBuffer(0),
     10    _indexBuffer(indexBuffer),
     11    _primitiveType(primitive)
    712{
    813}
    914
    10 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer)
    11 : _primitiveType(primitive), _vertexBuffer(vertexBuffer), _indexBuffer(indexBuffer), _colorBuffer(colorBuffer)
     15R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer,
     16                       R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer) :
     17    _vertexBuffer(vertexBuffer),
     18    _colorBuffer(colorBuffer),
     19    _indexBuffer(indexBuffer),
     20    _primitiveType(primitive)
    1221{
    1322}
     
    1827}
    1928
    20 void R2Geometry::render()
     29void
     30R2Geometry::render()
    2131{
    22         //glDisableClientState(GL_NORMAL_ARRAY);
    23         //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    24         glEnableClientState(GL_VERTEX_ARRAY);
    25         glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID());
    26         glVertexPointer(3, GL_FLOAT, 0, 0);
    27        
    28         if (_colorBuffer)
    29         {
    30                 glEnableClientState(GL_COLOR_ARRAY);
    31                 glBindBuffer(GL_ARRAY_BUFFER, _colorBuffer->getGraphicObjectID());
    32                 glColorPointer(3, GL_FLOAT, 0, 0);
    33         }
    34     else
    35     {
    36                 glDisableClientState(GL_COLOR_ARRAY);
     32    //glDisableClientState(GL_NORMAL_ARRAY);
     33    //glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     34    glEnableClientState(GL_VERTEX_ARRAY);
     35    glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID());
     36    glVertexPointer(3, GL_FLOAT, 0, 0);
     37   
     38    if (_colorBuffer) {
     39        glEnableClientState(GL_COLOR_ARRAY);
     40        glBindBuffer(GL_ARRAY_BUFFER, _colorBuffer->getGraphicObjectID());
     41        glColorPointer(3, GL_FLOAT, 0, 0);
     42    } else {
     43        glDisableClientState(GL_COLOR_ARRAY);
    3744    }
    38         glBindBuffer(GL_ARRAY_BUFFER, 0);
    39 
    40         if (_indexBuffer)
    41         {
    42                 glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(),  GL_UNSIGNED_INT, _indexBuffer->getData());
    43         }
    44         else
    45         {
    46                 glBindBuffer(GL_ARRAY_BUFFER, 0);
    47                 glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount());
    48         }
    49 
    50         glDisableClientState(GL_VERTEX_ARRAY);
    51         if (_colorBuffer) glDisableClientState(GL_COLOR_ARRAY);
     45    glBindBuffer(GL_ARRAY_BUFFER, 0);
     46   
     47    if (_indexBuffer) {
     48        glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(), GL_UNSIGNED_INT,
     49                      _indexBuffer->getData());
     50    } else {
     51        glBindBuffer(GL_ARRAY_BUFFER, 0);
     52        glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount());
     53    }
     54   
     55    glDisableClientState(GL_VERTEX_ARRAY);
     56    if (_colorBuffer) {
     57        glDisableClientState(GL_COLOR_ARRAY);
     58    }
    5259}
  • trunk/vizservers/nanovis/Volume.cpp

    r900 r929  
    2727    size(s),
    2828    n_components(n),
    29     vmin(v0),
    30     vmax(v1),
    3129    nonzero_min(nz_min),
    3230    pointsetIndex(-1),
     
    6361    id = tex->id;
    6462   
     63    SetRange(AxisRange::VALUES, v0, v1);
     64
    6565    aspect_ratio_width = s*tex->aspect_ratio_width;
    6666    aspect_ratio_height = s*tex->aspect_ratio_height;
  • trunk/vizservers/nanovis/Volume.h

    r927 r929  
    2424#include "Texture3D.h"
    2525#include "Vector3.h"
     26#include "AxisRange.h"
    2627
    2728struct CutPlane{
     
    5758    int n_components;
    5859
    59     double _limits[3][2];       // min/max for each axis
    60 
    61     double vmin;                // minimum (unscaled) value in data
    62     double vmax;                // maximum (unscaled) value in data
     60    AxisRange _ranges[4];       // min/max for each axis
     61
    6362    double nonzero_min;
    6463   
     
    118117    int get_isosurface() const;
    119118
    120     double range_min() { return vmin; }
    121     double range_max() { return vmax; }
    122119    double range_nzero_min() { return nonzero_min; }
    123120   
     
    155152    void get_outline_color(float* rgb);
    156153   
    157     void set_limits(int axis, double min, double max);
    158     void get_limits(int axis, double *minPtr, double *maxPtr);
     154    void SetRange(int axis, double min, double max);
     155    const AxisRange *GetRange(int axis);
    159156    void set_label(int axis, const char* txt); // change the label displayed
    160157                                               // on an axis
     
    335332
    336333inline void
    337 Volume::set_limits(int axis, double min, double max)
    338 {
    339     _limits[axis][0] = min;
    340     _limits[axis][1] = max;
    341 }
    342 
    343 inline void
    344 Volume::get_limits(int axis, double *minPtr, double *maxPtr)
    345 {
    346     *minPtr = _limits[axis][0];
    347     *maxPtr = _limits[axis][1];
     334Volume::SetRange(int axis, double min, double max)
     335{
     336    _ranges[axis].min = min;
     337    _ranges[axis].max = max;
     338}
     339
     340inline const AxisRange *
     341Volume::GetRange(int axis)
     342{
     343    return _ranges + axis;
    348344}
    349345
  • trunk/vizservers/nanovis/VolumeInterpolator.cpp

    r927 r929  
    146146                             volume->n_components,
    147147                             volume->_data,
    148                              volume->vmin,
    149                              volume->vmax, volume->nonzero_min);
     148                             volume->_ranges[AxisRange::VALUES].min,
     149                             volume->_ranges[AxisRange::VALUES].max,
     150                             volume->nonzero_min);
    150151        _referenceOfVolume = volumeId;
    151152        _volume->set_n_slice(256-1);
  • trunk/vizservers/nanovis/dxReader.cpp

    r928 r929  
    237237        volPtr = NanoVis::load_volume(index, nx, ny, nz, 3, data, vmin, vmax,
    238238                nzero_min);
    239         volPtr->set_limits(NanoVis::X, x0, x0 + (nx * ddx));
    240         volPtr->set_limits(NanoVis::Y, y0, y0 + (ny * ddy));
    241         volPtr->set_limits(NanoVis::Z, z0, z0 + (nz * ddz));
     239        volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx));
     240        volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy));
     241        volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz));
    242242        delete [] data;
    243243    } else {
     
    488488            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    489489                                          vmin, vmax, nzero_min);
    490             volPtr->set_limits(NanoVis::X, x0, x0 + (nx * ddx));
    491             volPtr->set_limits(NanoVis::Y, y0, y0 + (ny * ddy));
    492             volPtr->set_limits(NanoVis::Z, z0, z0 + (nz * ddz));
     490            volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx));
     491            volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy));
     492            volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz));
    493493            delete [] data;
    494494
     
    621621            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    622622                field.valueMin(), field.valueMax(), nzero_min);
    623             volPtr->set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),
     623            volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    624624                               field.rangeMax(Rappture::xaxis));
    625             volPtr->set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),
     625            volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    626626                               field.rangeMax(Rappture::yaxis));
    627             volPtr->set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),
     627            volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    628628                               field.rangeMax(Rappture::zaxis));
    629629            delete [] data;
     
    917917            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    918918                field.valueMin(), field.valueMax(), nzero_min);
    919             volPtr->set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),
     919            volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    920920                               field.rangeMax(Rappture::xaxis));
    921             volPtr->set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),
     921            volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    922922                               field.rangeMax(Rappture::yaxis));
    923             volPtr->set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),
     923            volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    924924                               field.rangeMax(Rappture::zaxis));
    925925            // TBD..
     
    10631063            volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data,
    10641064                field.valueMin(), field.valueMax(), nzero_min);
    1065             volPtr->set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),
     1065            volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis),
    10661066                               field.rangeMax(Rappture::xaxis));
    1067             volPtr->set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),
     1067            volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis),
    10681068                               field.rangeMax(Rappture::yaxis));
    1069             volPtr->set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),
     1069            volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis),
    10701070                               field.rangeMax(Rappture::zaxis));
    10711071
  • trunk/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp

    r823 r929  
    1313}
    1414
    15 // I referred to cjbackhouse@hotmail.com                www.backhouse.tk
     15// I referred to cjbackhouse@hotmail.com                www.backhouse.tk
    1616Image* BMPImageLoaderImpl::load(const char* fileName)
    1717{
     
    3030    fread(&header, 54, 1, f);
    3131
    32     if (header[0] != 'B' ||  header[1] != 'M')
    33     {
    34         printf("File is not BMP format\n");
    35         return 0;
     32    if (header[0] != 'B' ||  header[1] != 'M') {
     33        printf("File is not BMP format\n");
     34        return 0;
    3635    }
    3736
    38         //it seems gimp sometimes makes its headers small, so we have to do this. hence all the fseeks
    39         int offset=*(unsigned int*)(header+10);
    40        
    41         const unsigned int width =*(int*) (header+18);
    42         const unsigned int height =*(int*) (header+22);
     37    //it seems gimp sometimes makes its headers small, so we have to do
     38    //this. hence all the fseeks
     39    int offset=*(unsigned int*)(header+10);
     40       
     41    const unsigned int width =*(int*) (header+18);
     42    const unsigned int height =*(int*) (header+22);
    4343
    44         int bits=int(header[28]);               //colourdepth
     44    int bits=int(header[28]);           //colourdepth
    4545
    4646    printf("image width = %d height = %d bits=%d\n", width, height, bits);
    4747    fflush(stdout);
    4848   
    49     image = new Image(width, height, _targetImageFormat, Image::IMG_UNSIGNED_BYTE, 0);
     49    image = new Image(width, height, _targetImageFormat,
     50                      Image::IMG_UNSIGNED_BYTE, 0);
    5051
    5152    printf("image created\n");
     
    5859    fflush(stdout);
    5960
    60         int x,y,c;
    61         unsigned char cols[256*4];                              //colourtable
    62         switch(bits)
    63         {
    64         case(24):
    65                 fseek(f,offset,SEEK_SET);
    66         if (_targetImageFormat == Image::IMG_RGB)
    67         {
    68                     fread(bytes,width*height*3,1,f);    //24bit is easy
    69                     for(x=0;x<width*height*3;x+=3)                      //except the format is BGR, grr
    70                     {
    71                             unsigned char temp = bytes[x];
    72                             bytes[x] = bytes[x+2];
    73                             bytes[x+2] = temp;
    74                     }
    75         }
    76         else if (_targetImageFormat == Image::IMG_RGBA)
    77         {
    78             char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3);
    79                     fread(buff,width*height*3,1,f);                     //24bit is easy
    80                     for(x=0, y = 0;x<width*height*3;x+=3, y+=4)         //except the format is BGR, grr
    81                     {
    82                             bytes[y] = buff[x+2];
    83                             bytes[y+2] = buff[x];
    84                 bytes[y+3] = 255;
    85                     }
    86             free(buff);
    87         }
    88                 break;
    89         case(8):
    90                 fread(cols,256 * 4,1,f);                                                        //read colortable
    91                 fseek(f,offset,SEEK_SET);
    92                 for(y=0;y<height;++y)                                           //(Notice 4bytes/col for some reason)
    93         {
    94                         for(x=0;x<width;++x)
    95                         {
    96                                 unsigned char byte;                     
    97                                 fread(&byte,1,1,f);                                                     //just read byte                                       
    98                                 for(int c=0; c< 3; ++c)
    99                 {
    100                     //bytes[(y*width+x)*3+c] = cols[byte*4+2-c];        //and look up in the table
    101                     bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c];       //and look up in the table
    102                 }
    103             }
    104         }
    105             break;
    106     /*
    107         case(4):
    108                 fread(cols,16*4,1,f);
    109                 fseek(f,offset,SEEK_SET);
    110                 for(y=0;y<256;++y)
    111                         for(x=0;x<256;x+=2)
    112                         {
    113                                 BYTE byte;
    114                                 fread(&byte,1,1,f);                                             //as above, but need to exract two
     61    unsigned int x,y;
     62    unsigned char cols[256*4];  //colourtable
     63    switch(bits) {
     64    case 24:
     65        fseek(f,offset,SEEK_SET);
     66        if (_targetImageFormat == Image::IMG_RGB) {
     67            fread(bytes,width*height*3,1,f); //24bit is easy
     68            for(x=0;x<width*height*3;x+=3)  { //except the format is BGR, grr
     69                unsigned char temp = bytes[x];
     70                bytes[x] = bytes[x+2];
     71                bytes[x+2] = temp;
     72            }
     73        } else if (_targetImageFormat == Image::IMG_RGBA) {
     74            char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3);
     75            fread(buff,width*height*3,1,f);                 //24bit is easy
     76            for(x=0, y = 0;x<width*height*3;x+=3, y+=4)     {       //except the format is BGR, grr
     77                bytes[y] = buff[x+2];
     78                bytes[y+2] = buff[x];
     79                bytes[y+3] = 255;
     80            }
     81            free(buff);
     82        }
     83        break;
     84    case 8:
     85        fread(cols,256 * 4,1,f); //read colortable
     86        fseek(f,offset,SEEK_SET); 
     87        for(y=0;y<height;++y) { //(Notice 4bytes/col for some reason)
     88            for(x=0;x<width;++x) {
     89                unsigned char byte;                 
     90                fread(&byte,1,1,f);                                                 //just read byte                                       
     91                for(int c=0; c< 3; ++c) {
     92                    //bytes[(y*width+x)*3+c] = cols[byte*4+2-c];        //and look up in the table
     93                    bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c];       //and look up in the table
     94                }
     95            }
     96        }
     97        break;
     98        /*
     99          case(4):
     100          fread(cols,16*4,1,f);
     101          fseek(f,offset,SEEK_SET);
     102          for(y=0;y<256;++y)
     103          for(x=0;x<256;x+=2)
     104          {
     105          BYTE byte;
     106          fread(&byte,1,1,f);                                               //as above, but need to exract two
     107         
     108          for(c=0;c<_targetImageFormat;++c)                                         //pixels from each byte
     109          bmp.pixel(x,y,c)=cols[byte/16*4+2-c];
    115110
    116                                 for(c=0;c<_targetImageFormat;++c)                                               //pixels from each byte
    117                                         bmp.pixel(x,y,c)=cols[byte/16*4+2-c];
    118 
    119                                 for(c=0;c<_targetImageFormat;++c)
    120                                         bmp.pixel(x+1,y,c)=cols[byte%16*4+2-c];
    121     */
     111          for(c=0;c<_targetImageFormat;++c)
     112          bmp.pixel(x+1,y,c)=cols[byte%16*4+2-c];
     113        */
    122114    }
    123 
     115   
    124116    printf("image initialized\n");
    125117    fflush(stdout);
  • trunk/vizservers/nanovis/imgLoaders/Image.cpp

    r823 r929  
    33#include <stdlib.h>
    44
    5 Image::Image(const unsigned int width, const unsigned int height, const ImageFormat format, const Image::DataType type, void* data )
    6 : _width(width), _height(height), _dataType(type), _format(format)
     5Image::Image(const unsigned int width, const unsigned int height,
     6             const ImageFormat format, const Image::DataType type, void* data ) :
     7    _width(width),
     8    _height(height),
     9    _format(format),
     10    _dataType(type)
    711{
    812    switch (type)
  • trunk/vizservers/nanovis/nanovis.h

    r927 r929  
    102102class NanoVis {
    103103public:
    104     enum Axis { X, Y, Z };
    105104    static VolumeRenderer* vol_renderer;
    106105    static PointSetRenderer* pointset_renderer;
Note: See TracChangeset for help on using the changeset viewer.