Changeset 932
- Timestamp:
- Mar 10, 2008 3:40:26 PM (16 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/AxisRange.h
r929 r932 3 3 4 4 class AxisRange { 5 double _min, _max; 5 6 public: 6 enum Axes { X, Y, Z, VALUES }; 7 double min, max; 7 AxisRange(void) { 8 SetRange(0.0, 1.0); 9 } 10 void SetRange(double min, double max) { 11 _min = min, _max = max; 12 } 13 double Min(void) { 14 return _min; 15 } 16 double Max(void) { 17 return _max; 18 } 8 19 }; 20 9 21 #endif /*_AXIS_RANGE_H*/ -
trunk/vizservers/nanovis/Command.cpp
r931 r932 228 228 } 229 229 230 231 static int232 GetVolumeLimits(Tcl_Interp *interp, AxisRange *range)233 {234 235 /* Find the first volume. */236 int start;237 for (start = 0; start < NanoVis::n_volumes; start++) {238 if (NanoVis::volume[start] != NULL) {239 break;240 }241 }242 if (start == NanoVis::n_volumes) {243 Tcl_AppendResult(interp, "no volumes found", (char *)NULL);244 return TCL_ERROR;245 }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 }267 return TCL_OK;268 }269 270 271 230 /* 272 231 * ----------------------------------------------------------------------- … … 334 293 } 335 294 } 336 HeightMap* h Map;337 h Map= new HeightMap();338 h Map->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights);339 h Map->setColorMap(NanoVis::get_transfunc("default"));340 h Map->setVisible(true);341 h Map->setLineContourVisible(true);295 HeightMap* hmPtr; 296 hmPtr = new HeightMap(); 297 hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights); 298 hmPtr->setColorMap(NanoVis::get_transfunc("default")); 299 hmPtr->setVisible(true); 300 hmPtr->setLineContourVisible(true); 342 301 delete [] heights; 343 return h Map;302 return hmPtr; 344 303 } 345 304 346 305 /* 347 306 * ---------------------------------------------------------------------- 348 * FUNCTION: GetHeightMap 349 * 350 * Used internally to decode a series of volume index values and 351 * store then in the specified vector. If there are no volume index 352 * arguments, this means "all volumes" to most commands, so all 353 * active volume indices are stored in the vector. 354 * 355 * Updates pushes index values into the vector. Returns TCL_OK or 356 * TCL_ERROR to indicate an error. 307 * 308 * GetHeightMapIndex -- 309 * 357 310 * ---------------------------------------------------------------------- 358 311 */ 359 312 static int 360 GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr) 361 { 362 int mapIndex; 363 if (Tcl_GetIntFromObj(interp, objPtr, &mapIndex) != TCL_OK) { 364 return TCL_ERROR; 365 } 366 if ((mapIndex < 0) || (mapIndex >= (int)NanoVis::heightMap.size()) || 367 (NanoVis::heightMap[mapIndex] == NULL)) { 368 Tcl_AppendResult(interp, "invalid heightmap index \"", 369 Tcl_GetString(objPtr), "\"", (char *)NULL); 370 return TCL_ERROR; 371 } 372 *hmPtrPtr = NanoVis::heightMap[mapIndex]; 313 GetHeightMapIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned int *indexPtr) 314 { 315 int index; 316 if (Tcl_GetIntFromObj(interp, objPtr, &index) != TCL_OK) { 317 return TCL_ERROR; 318 } 319 if (index < 0) { 320 Tcl_AppendResult(interp, "can't have negative index \"", 321 Tcl_GetString(objPtr), "\"", (char*)NULL); 322 return TCL_ERROR; 323 } 324 if (index >= (int)NanoVis::heightMap.size()) { 325 Tcl_AppendResult(interp, "index \"", Tcl_GetString(objPtr), 326 "\" is out of range", (char*)NULL); 327 return TCL_ERROR; 328 } 329 *indexPtr = (unsigned int)index; 330 return TCL_OK; 331 } 332 333 /* 334 * ---------------------------------------------------------------------- 335 * 336 * GetHeightMapFromObj -- 337 * 338 * ---------------------------------------------------------------------- 339 */ 340 static int 341 GetHeightMapFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr) 342 { 343 unsigned int index; 344 if (GetHeightMapIndex(interp, objPtr, &index) != TCL_OK) { 345 return TCL_ERROR; 346 } 347 HeightMap *hmPtr; 348 hmPtr = NanoVis::heightMap[index]; 349 if (hmPtr == NULL) { 350 Tcl_AppendResult(interp, "no heightmap defined for index \"", 351 Tcl_GetString(objPtr), "\"", (char*)NULL); 352 return TCL_ERROR; 353 } 354 *hmPtrPtr = hmPtr; 373 355 return TCL_OK; 374 356 } … … 477 459 } 478 460 479 static int480 GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,481 vector<unsigned int>* vectorPtr)482 {483 for (int n = 0; n < objc; n++) {484 int index;485 486 if (Tcl_GetIntFromObj(interp, objv[n], &index) != TCL_OK) {487 return TCL_ERROR;488 }489 if (index < 0) {490 Tcl_AppendResult(interp, "can't have negative index \"",491 Tcl_GetString(objv[n]), "\"", (char *)NULL);492 return TCL_ERROR;493 }494 vectorPtr->push_back((unsigned int)index);495 }496 return TCL_OK;497 }498 499 500 461 /* 501 462 * ---------------------------------------------------------------------- … … 528 489 return TCL_ERROR; 529 490 } 530 if (volPtr != NULL) { 531 vectorPtr->push_back(volPtr); 532 } 491 vectorPtr->push_back(volPtr); 492 } 493 } 494 return TCL_OK; 495 } 496 497 /* 498 * ---------------------------------------------------------------------- 499 * FUNCTION: GetHeightMaps() 500 * 501 * Used internally to decode a series of volume index values and 502 * store then in the specified vector. If there are no volume index 503 * arguments, this means "all volumes" to most commands, so all 504 * active volume indices are stored in the vector. 505 * 506 * Updates pushes index values into the vector. Returns TCL_OK or 507 * TCL_ERROR to indicate an error. 508 * ---------------------------------------------------------------------- 509 */ 510 static int 511 GetHeightMaps(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 512 vector<HeightMap *>* vectorPtr) 513 { 514 if (objc == 0) { 515 for (unsigned int n = 0; n < NanoVis::heightMap.size(); n++) { 516 if (NanoVis::heightMap[n] != NULL) { 517 vectorPtr->push_back(NanoVis::heightMap[n]); 518 } 519 } 520 } else { 521 for (int n = 0; n < objc; n++) { 522 HeightMap *hmPtr; 523 524 if (GetHeightMapFromObj(interp, objv[n], &hmPtr) != TCL_OK) { 525 return TCL_ERROR; 526 } 527 vectorPtr->push_back(hmPtr); 533 528 } 534 529 } … … 555 550 c = tolower((unsigned char)string[0]); 556 551 if (c == 'x') { 557 *indexPtr = AxisRange::X;552 *indexPtr = 0; 558 553 return TCL_OK; 559 554 } else if (c == 'y') { 560 *indexPtr = AxisRange::Y;555 *indexPtr = 1; 561 556 return TCL_OK; 562 557 } else if (c == 'z') { 563 *indexPtr = AxisRange::Z;558 *indexPtr = 2; 564 559 return TCL_OK; 565 560 } … … 787 782 } 788 783 Texture2D* plane = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 789 AxisRange *rangePtr; 790 rangePtr = vol->GetRange(AxisRange::VALUES); 791 NanoVis::color_table_renderer->render(1024, 1024, plane, tf, rangePtr->min, 792 rangePtr->max); 784 NanoVis::color_table_renderer->render(1024, 1024, plane, tf, vol->wAxis.Min(), 785 vol->wAxis.Max()); 793 786 delete plane; 794 787 … … 937 930 return TCL_ERROR; 938 931 } 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); 932 if (volPtr->update_pending) { 933 NanoVis::SetVolumeRanges(); 934 } 935 NanoVis::render_legend(tf, Volume::valueMin, Volume::valueMin, w, h, label); 947 936 return TCL_OK; 948 937 } … … 1350 1339 Volume *volPtr; 1351 1340 char info[1024]; 1352 AxisRange overall[4];1353 1341 1354 if ( GetVolumeLimits(interp, overall) != TCL_OK) {1355 return TCL_ERROR;1342 if (Volume::update_pending) { 1343 NanoVis::SetVolumeRanges(); 1356 1344 } 1357 1345 volPtr = NanoVis::volume[n]; 1358 const AxisRange *rangePtr;1359 rangePtr = volPtr->GetRange(AxisRange::VALUES);1360 1346 sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n", 1361 n, rangePtr->min, rangePtr->max, 1362 overall[AxisRange::VALUES].min, 1363 overall[AxisRange::VALUES].max); 1347 n, volPtr->wAxis.Min(), volPtr->wAxis.Max(), 1348 Volume::valueMin, Volume::valueMax); 1364 1349 write(0, info, strlen(info)); 1365 1350 } … … 1602 1587 1603 1588 proc = Rappture::GetOpFromObj(interp, nVolumeShadingOps, volumeShadingOps, 1604 1589 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1605 1590 if (proc == NULL) { 1606 1591 return TCL_ERROR; … … 1707 1692 1708 1693 proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps, 1709 1694 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1710 1695 if (proc == NULL) { 1711 1696 return TCL_ERROR; … … 1721 1706 if (objc < 2) { 1722 1707 Tcl_AppendResult(interp, "wrong # args: should be \"", 1723 1708 Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL); 1724 1709 return TCL_ERROR; 1725 1710 } … … 1729 1714 if (objc != 3) { 1730 1715 Tcl_AppendResult(interp, "wrong # args: should be \"", 1731 1716 Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL); 1732 1717 return TCL_ERROR; 1733 1718 } 1734 1719 Volume *volPtr; 1735 const AxisRange *rangePtr;1736 1737 1720 if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) { 1738 1721 return TCL_ERROR; 1739 1722 } 1740 rangePtr = volPtr->GetRange(AxisRange::VALUES);1741 1723 if (NanoVis::particleRenderer != NULL) { 1742 1724 NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f, 1743 1725 volPtr->height / (float)volPtr->width, 1744 1726 volPtr->depth / (float)volPtr->width, 1745 rangePtr->max);1727 volPtr->wAxis.Max()); 1746 1728 NanoVis::initParticle(); 1747 1729 } … … 1751 1733 1.0f / volPtr->aspect_ratio_height, 1752 1734 1.0f / volPtr->aspect_ratio_depth, 1753 rangePtr->max);1735 volPtr->wAxis.Max()); 1754 1736 NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z); 1755 1737 } … … 1768 1750 if (objc < 3) { 1769 1751 Tcl_AppendResult(interp, "wrong # args: should be \"", 1770 1771 1752 Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"", 1753 (char*)NULL); 1772 1754 return TCL_ERROR; 1773 1755 } … … 1931 1913 1932 1914 NanoVis::vol_renderer->add_volume(volPtr, 1933 1915 NanoVis::get_transfunc("default")); 1934 1916 } 1935 1917 } … … 1973 1955 return TCL_ERROR; 1974 1956 } 1975 vector<unsigned int> indices; 1976 if (GetIndices(interp, objc - 4, objv + 4, &indices) != TCL_OK) { 1977 return TCL_ERROR; 1978 } 1979 for (unsigned int i = 0; i < indices.size(); ++i) { 1980 if ((indices[i] < NanoVis::heightMap.size()) && 1981 (NanoVis::heightMap[indices[i]] != NULL)) { 1982 NanoVis::heightMap[indices[i]]->setVisible(visible); 1983 } 1957 vector<HeightMap *> imap; 1958 if (GetHeightMaps(interp, objc - 4, objv + 4, &imap) != TCL_OK) { 1959 return TCL_ERROR; 1960 } 1961 vector<HeightMap *>::iterator iter; 1962 for (iter = imap.begin(); iter != imap.end(); iter++) { 1963 (*iter)->setVisible(visible); 1984 1964 } 1985 1965 return TCL_OK; … … 2015 1995 return TCL_ERROR; 2016 1996 } 2017 vector<unsigned int> indices; 2018 if (GetIndices(interp, objc-6, objv + 6, &indices) != TCL_OK) { 2019 return TCL_ERROR; 2020 } 2021 for (unsigned int i = 0; i < indices.size(); ++i) { 2022 if ((indices[i] < NanoVis::heightMap.size()) && 2023 (NanoVis::heightMap[indices[i]] != NULL)) { 2024 NanoVis::heightMap[indices[i]]->setLineContourColor(rgb); 2025 } 1997 vector<HeightMap *> imap; 1998 if (GetHeightMaps(interp, objc - 6, objv + 6, &imap) != TCL_OK) { 1999 return TCL_ERROR; 2000 } 2001 vector<HeightMap *>::iterator iter; 2002 for (iter = imap.begin(); iter != imap.end(); iter++) { 2003 (*iter)->setLineContourColor(rgb); 2026 2004 } 2027 2005 return TCL_OK; … … 2036 2014 return TCL_ERROR; 2037 2015 } 2038 vector<unsigned int> indices; 2039 if (GetIndices(interp, objc-4, objv+4, &indices) != TCL_OK) { 2040 return TCL_ERROR; 2041 } 2042 for (unsigned int i = 0; i < indices.size(); ++i) { 2043 if ((indices[i] < NanoVis::heightMap.size()) && 2044 (NanoVis::heightMap[indices[i]] != NULL)) { 2045 NanoVis::heightMap[indices[i]]->setLineContourVisible(visible); 2046 } 2016 vector<HeightMap *> imap; 2017 if (GetHeightMaps(interp, objc - 4, objv + 4, &imap) != TCL_OK) { 2018 return TCL_ERROR; 2019 } 2020 vector<HeightMap *>::iterator iter; 2021 for (iter = imap.begin(); iter != imap.end(); iter++) { 2022 (*iter)->setLineContourVisible(visible); 2047 2023 } 2048 2024 return TCL_OK; … … 2062 2038 2063 2039 proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps, 2064 2040 heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0); 2065 2041 if (proc == NULL) { 2066 2042 return TCL_ERROR; … … 2085 2061 Tcl_Obj *CONST *objv) 2086 2062 { 2087 HeightMap *h Map;2063 HeightMap *hmPtr; 2088 2064 2089 2065 /* heightmap create xmin ymin xmax ymax xnum ynum values */ 2090 h Map= CreateHeightMap(cdata, interp, objc - 2, objv + 2);2091 if (h Map== NULL) {2092 return TCL_ERROR; 2093 } 2094 NanoVis::heightMap.push_back(h Map);2066 hmPtr = CreateHeightMap(cdata, interp, objc - 2, objv + 2); 2067 if (hmPtr == NULL) { 2068 return TCL_ERROR; 2069 } 2070 NanoVis::heightMap.push_back(hmPtr); 2095 2071 Tcl_SetIntObj(Tcl_GetObjResult(interp), NanoVis::heightMap.size() - 1);; 2096 2072 return TCL_OK; … … 2101 2077 Tcl_Obj *CONST *objv) 2102 2078 { 2103 HeightMap *h Map;2104 if (GetHeightMap (interp, objv[2], &hMap) != TCL_OK) {2079 HeightMap *hmPtr; 2080 if (GetHeightMapFromObj(interp, objv[2], &hmPtr) != TCL_OK) { 2105 2081 return TCL_ERROR; 2106 2082 } 2107 2083 TransferFunction *tf; 2108 tf = h Map->getColorMap();2084 tf = hmPtr->getColorMap(); 2109 2085 if (tf == NULL) { 2110 2086 Tcl_AppendResult(interp, "no transfer function defined for heightmap \"", … … 2117 2093 return TCL_ERROR; 2118 2094 } 2119 const AxisRange *rangePtr; 2120 rangePtr = hMap->GetRange(AxisRange::VALUES); 2121 NanoVis::render_legend(tf, rangePtr->min, rangePtr->max, w, h, "label"); 2095 if (HeightMap::update_pending) { 2096 NanoVis::SetHeightmapRanges(); 2097 } 2098 NanoVis::render_legend(tf, HeightMap::valueMin, HeightMap::valueMax, w, h, 2099 "label"); 2122 2100 return TCL_OK; 2123 2101 } … … 2136 2114 2137 2115 static int 2138 HeightMapShad eOp(ClientData cdata, Tcl_Interp *interp, int objc,2116 HeightMapShadingOp(ClientData cdata, Tcl_Interp *interp, int objc, 2139 2117 Tcl_Obj *CONST *objv) 2140 2118 { … … 2165 2143 } 2166 2144 2167 HeightMap* h eightMap= new HeightMap();2145 HeightMap* hmPtr = new HeightMap(); 2168 2146 float minx = 0.0f; 2169 2147 float maxx = 1.0f; 2170 2148 float miny = 0.5f; 2171 2149 float maxy = 3.5f; 2172 heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data); 2173 heightMap->setColorMap(NanoVis::get_transfunc("default")); 2174 heightMap->setVisible(true); 2175 heightMap->setLineContourVisible(true); 2176 NanoVis::heightMap.push_back(heightMap); 2177 2178 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); 2183 2184 NanoVis::grid->setMinMax(min, max); 2150 hmPtr->setHeight(minx, miny, maxx, maxy, 20, 200, data); 2151 hmPtr->setColorMap(NanoVis::get_transfunc("default")); 2152 hmPtr->setVisible(true); 2153 hmPtr->setLineContourVisible(true); 2185 2154 NanoVis::grid->setVisible(true); 2186 2155 NanoVis::heightMap.push_back(hmPtr); 2187 2156 return TCL_OK; 2188 2157 } … … 2201 2170 return TCL_ERROR; 2202 2171 } 2203 vector<unsigned int> indices; 2204 if (GetIndices(interp, objc - 3, objv + 3, &indices) != TCL_OK) { 2205 return TCL_ERROR; 2206 } 2207 for (unsigned int i = 0; i < indices.size(); ++i) { 2208 if ((indices[i] < NanoVis::heightMap.size()) && 2209 (NanoVis::heightMap[indices[i]] != NULL)) { 2210 NanoVis::heightMap[indices[i]]->setColorMap(tf); 2211 } 2172 vector<HeightMap *> imap; 2173 if (GetHeightMaps(interp, objc - 3, objv + 3, &imap) != TCL_OK) { 2174 return TCL_ERROR; 2175 } 2176 vector<HeightMap *>::iterator iter; 2177 for (iter = imap.begin(); iter != imap.end(); iter++) { 2178 (*iter)->setColorMap(tf); 2212 2179 } 2213 2180 return TCL_OK; … … 2222 2189 {"linecontour", 2, HeightMapLineContourOp, 2, 0, "oper ?args?",}, 2223 2190 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 2224 {"shad e", 1, HeightMapShadeOp,3, 3, "model",},2191 {"shading", 1, HeightMapShadingOp, 3, 3, "model",}, 2225 2192 {"test", 2, HeightMapTestOp, 2, 2, "",}, 2226 2193 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?indices?",}, … … 2270 2237 } 2271 2238 if (NanoVis::grid) { 2239 #ifdef notdef 2272 2240 NanoVis::grid->setAxisName(axisId, Tcl_GetString(objv[3])); 2241 #endif 2273 2242 } 2274 2243 return TCL_OK; … … 2290 2259 } 2291 2260 if (NanoVis::grid) { 2292 NanoVis::grid->setGridLineColor(r, g, b, a); 2293 } 2294 return TCL_OK; 2295 } 2296 2297 static int 2298 GridLineCountOp(ClientData cdata, Tcl_Interp *interp, int objc, 2299 Tcl_Obj *CONST *objv) 2300 { 2301 int x, y, z; 2302 2303 if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || 2304 (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) || 2305 (Tcl_GetIntFromObj(interp, objv[4], &z) != TCL_OK)) { 2306 return TCL_ERROR; 2307 } 2308 if (NanoVis::grid) { 2309 NanoVis::grid->setGridLineCount(x, y, z); 2310 } 2311 return TCL_OK; 2312 } 2313 2314 static int 2315 GridMinMaxOp(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 2316 { 2317 double x1, y1, z1, x2, y2, z2; 2318 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x1) != TCL_OK) || 2319 (Tcl_GetDoubleFromObj(interp, objv[3], &y1) != TCL_OK) || 2320 (Tcl_GetDoubleFromObj(interp, objv[4], &z1) != TCL_OK) || 2321 (Tcl_GetDoubleFromObj(interp, objv[5], &x2) != TCL_OK) || 2322 (Tcl_GetDoubleFromObj(interp, objv[6], &y2) != TCL_OK) || 2323 (Tcl_GetDoubleFromObj(interp, objv[7], &z2) != TCL_OK)) { 2324 return TCL_ERROR; 2325 } 2326 if (NanoVis::grid) { 2327 NanoVis::grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2)); 2261 NanoVis::grid->setLineColor(r, g, b, a); 2328 2262 } 2329 2263 return TCL_OK; … … 2345 2279 {"axisname", 5, GridAxisNameOp, 5, 5, "index width height",}, 2346 2280 {"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 2281 {"visible", 1, GridVisibleOp, 3, 3, "bool",}, 2350 2282 }; … … 2596 2528 return TCL_ERROR; 2597 2529 } 2598 HeightMap* h Map;2599 h Map= new HeightMap();2600 h Map->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, zValues);2601 h Map->setColorMap(NanoVis::get_transfunc("default"));2602 h Map->setVisible(true);2603 h Map->setLineContourVisible(true);2604 NanoVis::heightMap.push_back(h Map);2530 HeightMap* hmPtr; 2531 hmPtr = new HeightMap(); 2532 hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, zValues); 2533 hmPtr->setColorMap(NanoVis::get_transfunc("default")); 2534 hmPtr->setVisible(true); 2535 hmPtr->setLineContourVisible(true); 2536 NanoVis::heightMap.push_back(hmPtr); 2605 2537 delete [] zValues; 2606 2538 return TCL_OK; -
trunk/vizservers/nanovis/Grid.cpp
r929 r932 3 3 #include "Grid.h" 4 4 5 #define NUMDIGITS 6 6 5 7 Grid::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), 8 _axisColor(1.0f, 1.0f, 1.0f, 1.0f), 9 _majorColor(1.0f, 1.0f, 1.0f, 1.0f), 10 _minorColor(0.7f, 0.7f, 0.7f, 1.0f), 11 11 _font(0), 12 _visible(false) 12 _visible(false), 13 xAxis("X"), 14 yAxis("Y"), 15 zAxis("Z") 13 16 { 14 __axisScale = _axisMax - _axisMin; 15 _axisName[0] = "X"; 16 _axisName[1] = "Y"; 17 _axisName[2] = "Z"; 17 /*empty*/ 18 18 } 19 19 … … 22 22 glPushMatrix(); 23 23 glEnable(GL_DEPTH_TEST); 24 glEnable(GL_BLEND); 25 26 glScalef(1.0 / __axisScale.x, __axisScale.y / __axisScale.x, __axisScale.z / __axisScale.x); 24 #ifdef notdef 25 glEnable(GL_LINE_SMOOTH); 26 #endif 27 #ifdef notdef 28 glScalef(xAxis.Scale(), 29 yAxis.Range() / xAxis.Range(), 30 zAxis.Range() / xAxis.Range()); 31 #endif 32 glScalef(1.0, 1.0, 1.0); 27 33 28 34 glTranslatef(-0.5f, -0.5f, -0.5f); 29 glDisable(GL_TEXTURE_2D);30 35 glLineWidth(2.0f); 31 glColor4f(_axisColor. x, _axisColor.y, _axisColor.z, _axisColor.w);32 //glColor3f(_axisColor.x, _axisColor.y, _axisColor.z);36 glColor4f(_axisColor.red, _axisColor.green, _axisColor.blue, 37 _axisColor.alpha); 33 38 34 39 glBegin(GL_LINES); 35 40 { 36 glVertex3f(0.0f,0.0f,0.0f);37 glVertex3f(1.2f,0.0f,0.0f);38 glVertex3f(0.0f,0.0f,0.0f);39 glVertex3f(0.0f,1.2f,0.0f);40 41 glVertex3f(0.0f, 0.0f, 0.0f); 41 glVertex3f(0.0f, 0.0f, 1.2f); 42 glVertex3f(1.15f, 0.0f, 0.0f); 43 glVertex3f(0.0f, 0.0f, 0.0f); 44 glVertex3f(0.0f, 1.15f, 0.0f); 45 glVertex3f(0.0f, 0.0f, 0.0f); 46 glVertex3f(0.0f, 0.0f, 1.15f); 42 47 } 43 48 glEnd(); 44 49 50 glDisable(GL_TEXTURE_2D); 45 51 glLineWidth(1.0f); 46 glColor4f(_gridLineColor.x, _gridLineColor.y, _gridLineColor.z, _gridLineColor.w); 52 glEnable(GL_BLEND); 53 glColor4f(_majorColor.red, _majorColor.green, _majorColor.blue, 54 _majorColor.alpha); 55 47 56 glBegin(GL_LINES); 48 49 // +y 50 for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) { 51 glVertex3f(0.0f, i / _axisGridLineCount.y, 0.0f); 52 glVertex3f(1.1f, i / _axisGridLineCount.y, 0.0f); 53 } 54 55 for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) { 56 glVertex3f(i / _axisGridLineCount.x, 0.0f, 0.0f); 57 glVertex3f(i / _axisGridLineCount.x, 1.0f, 0.0f); 58 } 59 60 for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) { 61 glVertex3f(0.0f, 0.0f, i / _axisGridLineCount.z); 62 glVertex3f(0.0f, 1.0f, i / _axisGridLineCount.z); 63 } 64 65 for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) { 66 glVertex3f(0.0f, i / _axisGridLineCount.y, 0.0f); 67 glVertex3f(0.0f, i / _axisGridLineCount.y, 1.0f); 68 } 69 70 for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) { 71 glVertex3f(i / _axisGridLineCount.x,0.0f, 0.0f); 72 glVertex3f(i / _axisGridLineCount.x,0.0f, 1.1f); 73 } 74 75 for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) { 76 glVertex3f(0.0f, 0.0f, i / _axisGridLineCount.z); 77 glVertex3f(1.1f, 0.0f, i / _axisGridLineCount.z); 57 { 58 bool result; 59 TickIter iter; 60 61 for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) { 62 float x; 63 x = xAxis.Map(iter.GetValue()); 64 glVertex3f(x, 0.0f, 0.0f); 65 glVertex3f(x, 1.0f, 0.0f); 66 glVertex3f(x, 0.0f, 0.0f); 67 glVertex3f(x, 0.0f, 1.1f); 68 } 69 for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) { 70 float y; 71 y = yAxis.Map(iter.GetValue()); 72 glVertex3f(0.0f, y, 0.0f); 73 glVertex3f(1.1f, y, 0.0f); 74 glVertex3f(0.0f, y, 0.0f); 75 glVertex3f(0.0f, y, 1.0f); 76 } 77 for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) { 78 float z; 79 z = zAxis.Map(iter.GetValue()); 80 glVertex3f(0.0f, 0.0f, z); 81 glVertex3f(0.0f, 1.0f, z); 82 glVertex3f(0.0f, 0.0f, z); 83 glVertex3f(1.1f, 0.0f, z); 84 } 78 85 } 79 86 glEnd(); 80 87 81 if (_font) { 88 // Set minor line color 89 glColor4f(_minorColor.red, _minorColor.green, _minorColor.blue, 90 _minorColor.alpha); 91 92 glBegin(GL_LINES); 93 { 94 bool result; 95 TickIter iter; 96 97 for (result = xAxis.FirstMinor(iter); result; result = iter.Next()) { 98 float x; 99 x = xAxis.Map(iter.GetValue()); 100 glVertex3f(x, 0.0f, 0.0f); 101 glVertex3f(x, 1.0f, 0.0f); 102 glVertex3f(x, 0.0f, 0.0f); 103 glVertex3f(x, 0.0f, 1.0f); 104 } 105 for (result = yAxis.FirstMinor(iter); result; result = iter.Next()) { 106 float y; 107 y = yAxis.Map(iter.GetValue()); 108 glVertex3f(0.0f, y, 0.0f); 109 glVertex3f(1.0f, y, 0.0f); 110 glVertex3f(0.0f, y, 0.0f); 111 glVertex3f(0.0f, y, 1.0f); 112 } 113 for (result = zAxis.FirstMinor(iter); result; result = iter.Next()) { 114 float z; 115 z = zAxis.Map(iter.GetValue()); 116 glVertex3f(0.0f, 0.0f, z); 117 glVertex3f(0.0f, 1.0f, z); 118 glVertex3f(0.0f, 0.0f, z); 119 glVertex3f(1.0f, 0.0f, z); 120 } 121 } 122 glEnd(); 123 124 if (_font != NULL) { 82 125 double mv[16], prjm[16]; 83 126 int viewport[4]; 84 double winx, winy, winz; 127 double wx, wy, wz; 128 bool result; 129 TickIter iter; 130 85 131 glGetDoublev(GL_MODELVIEW_MATRIX, mv); 86 132 glGetDoublev(GL_PROJECTION_MATRIX, prjm); 87 133 glGetIntegerv(GL_VIEWPORT, viewport); 88 134 89 90 135 _font->begin(); 91 if (gluProject(1.2, 0.0, 0.0, mv, prjm, viewport, &winx, &winy, 92 &winz)) { 136 if (gluProject(1.2, 0.0, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) { 93 137 glLoadIdentity(); 94 glTranslatef((int) winx, viewport[3] - (int) winy, 0); 95 _font->draw((const char*) _axisName[0]); 96 } 97 98 if (gluProject(0.0, 1.2, 0.0, mv, prjm, viewport, &winx, &winy, 99 &winz)) { 138 glTranslatef((int) wx, viewport[3] - (int) wy, 0); 139 _font->draw(xAxis.GetName()); 140 } 141 142 if (gluProject(0.0, 1.2, 0.0, mv, prjm, viewport, &wx, &wy, &wz)) { 100 143 glLoadIdentity(); 101 glTranslatef((int) winx, viewport[3] - (int)winy, 0); 102 _font->draw((const char*) _axisName[1]); 103 } 104 105 if (gluProject(0.0, 0.0, 1.2, mv, prjm, viewport, &winx, &winy, 106 &winz)) { 144 glTranslatef((int) wx, viewport[3] - (int)wy, 0); 145 _font->draw(yAxis.GetName()); 146 } 147 148 if (gluProject(0.0, 0.0, 1.2, mv, prjm, viewport, &wx, &wy, &wz)) { 107 149 glLoadIdentity(); 108 glTranslatef((int) winx, (int) viewport[3] - (int)winy, 0.0f); 109 _font->draw((const char*) _axisName[2]); 110 } 111 112 glColor4f(1.0f, 1.0f, 0.0f, 0.5f); 113 char buff[20]; 114 // Y 115 for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) { 116 if (gluProject(1.2, i / _axisGridLineCount.y, 0.0f, mv, prjm, viewport, &winx, &winy, &winz)) { 150 glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f); 151 _font->draw(zAxis.GetName()); 152 } 153 154 glColor4f(1.0f, 1.0f, 0.0f, 1.0f); 155 156 for (result = xAxis.FirstMajor(iter); result; result = iter.Next()) { 157 float x; 158 x = xAxis.Map(iter.GetValue()); 159 if (gluProject(x, 0.0f, 1.11f, mv, prjm, viewport, &wx, &wy, &wz)) { 160 char buff[20]; 117 161 glLoadIdentity(); 118 glTranslatef((int) w inx, (int) viewport[3] - (int)winy, 0.0f);119 sprintf(buff, "% 0.2f", __axisScale.y / _axisGridLineCount.y * i + _axisMin.y);162 glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f); 163 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue()); 120 164 _font->draw(buff); 121 165 } 122 166 } 123 124 for (int i = 1; i <= (int) _axisGridLineCount.z; ++i) { 125 if (gluProject(1.2, 0.0, i / _axisGridLineCount.z , mv, prjm, viewport, &winx, &winy, &winz)) { 167 for (result = yAxis.FirstMajor(iter); result; result = iter.Next()) { 168 float y; 169 y = yAxis.Map(iter.GetValue()); 170 if (gluProject(1.11f, y, 0.0f, mv, prjm, viewport, &wx, &wy, &wz)) { 171 char buff[20]; 126 172 glLoadIdentity(); 127 glTranslatef((int) w inx, (int) viewport[3] - (int)winy, 0.0f);128 sprintf(buff, "% 0.2f", __axisScale.z / _axisGridLineCount.z * i + _axisMin.z);173 glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f); 174 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue()); 129 175 _font->draw(buff); 130 176 } 131 177 } 132 133 for (int i = 1; i <= (int) _axisGridLineCount.x; ++i) { 134 if (gluProject( i / _axisGridLineCount.x, 0.0f, 1.2, mv, prjm, viewport, &winx, &winy, &winz)) { 178 for (result = zAxis.FirstMajor(iter); result; result = iter.Next()) { 179 float z; 180 z = zAxis.Map(iter.GetValue()); 181 if (gluProject(1.11f, 0.0f, z, mv, prjm, viewport, &wx, &wy, &wz)) { 182 char buff[20]; 135 183 glLoadIdentity(); 136 glTranslatef((int) w inx, (int) viewport[3] - (int)winy, 0.0f);137 sprintf(buff, "% 0.2f", __axisScale.x / _axisGridLineCount.x * i + _axisMin.x);184 glTranslatef((int) wx, (int) viewport[3] - (int)wy, 0.0f); 185 sprintf(buff, "%.*g", NUMDIGITS, iter.GetValue()); 138 186 _font->draw(buff); 139 187 } 140 188 } 141 142 189 _font->end(); 143 190 }; 144 145 191 glPopMatrix(); 146 192 glDisable(GL_DEPTH_TEST); 147 193 glDisable(GL_BLEND); 194 #ifdef notdef 195 glDisable(GL_LINE_SMOOTH); 196 #endif 148 197 } 149 198 … … 156 205 _font = font; 157 206 } 207 -
trunk/vizservers/nanovis/Grid.h
r929 r932 3 3 4 4 #include <R2/R2Fonts.h> 5 #include "Vector3.h" 6 #include "Vector4.h" 5 #include "Axis.h" 6 #include "AxisRange.h" 7 8 class RGBA { 9 public: 10 float red, green, blue, alpha; 11 RGBA(float r, float g, float b, float a) : 12 red(r), green(g), blue(b), alpha(a) 13 { /*empty*/ } 14 void SetColor(float r, float g, float b, float a) { 15 red = r; 16 green = g; 17 blue = b; 18 alpha = a; 19 } 20 }; 7 21 8 22 class Grid { 9 Vector3 __axisScale; 10 11 Vector4 _axisColor; 12 Vector4 _gridLineColor; 13 Vector3 _axisMin; 14 Vector3 _axisMax; 15 Vector3 _axisGridLineCount; 23 RGBA _axisColor, _majorColor, _minorColor; 16 24 R2Fonts* _font; 17 25 bool _visible; 18 19 R2string _axisName[3];20 26 21 27 public : 28 Axis xAxis; 29 Axis yAxis; 30 Axis zAxis; 31 22 32 Grid(); 23 public : 24 bool isVisible() const; 33 bool isVisible() const { 34 return _visible; 35 } 25 36 void render(); 26 27 void setMin(const Vector3& min);28 void setMax(const Vector3& max);29 37 30 38 void setFont(R2Fonts* font); 31 39 void setVisible(bool visible); 32 33 void setGridLineCount(int x, int y, int z);34 40 void setAxisColor(float r, float g, float b, float a); 35 void setGridLineColor(float r, float g, float b, float a); 36 void setMinMax(const Vector3& min, const Vector3& max); 37 void setAxisName(int axisID, const char* name); 41 void setLineColor(float r, float g, float b, float a); 38 42 }; 39 40 inline bool Grid::isVisible() const41 {42 return _visible;43 }44 45 inline void Grid::setMin(const Vector3& min)46 {47 _axisMin = min;48 __axisScale = _axisMax - _axisMin;49 }50 51 inline void Grid::setMax(const Vector3& max)52 {53 _axisMax = max;54 __axisScale = _axisMax - _axisMin;55 }56 43 57 44 inline void Grid::setVisible(bool visible) … … 60 47 } 61 48 62 inline void Grid::set GridLineCount(int x, int y, int z)49 inline void Grid::setAxisColor(float r, float g, float b, float a) 63 50 { 64 _axisGridLineCount.x = x; 65 _axisGridLineCount.y = y; 66 _axisGridLineCount.z = z; 51 _axisColor.SetColor(r, g, b, a); 67 52 } 68 53 69 inline void Grid::set AxisColor(float r, float g, float b, float a)54 inline void Grid::setLineColor(float r, float g, float b, float a) 70 55 { 71 _axisColor.x = r; 72 _axisColor.y = g; 73 _axisColor.z = b; 74 _axisColor.w = a; 56 _majorColor.SetColor(r, g, b, a); 57 _minorColor = _majorColor; 75 58 } 76 59 77 inline void Grid::setGridLineColor(float r, float g, float b, float a)78 {79 _gridLineColor.x = r;80 _gridLineColor.y = g;81 _gridLineColor.z = b;82 _gridLineColor.w = a;83 }84 85 inline void Grid::setMinMax(const Vector3& min, const Vector3& max)86 {87 _axisMin = min;88 _axisMax = max;89 __axisScale.x = _axisMax.x - _axisMin.x;90 __axisScale.y = _axisMax.y - _axisMin.y;91 __axisScale.z = _axisMax.z - _axisMin.z;92 }93 94 inline void Grid::setAxisName(int axisID, const char* name)95 {96 if (axisID >= 0 && axisID < 3) {97 _axisName[axisID] = name;98 }99 }100 101 102 60 #endif -
trunk/vizservers/nanovis/HeightMap.cpp
r929 r932 16 16 #include <RenderContext.h> 17 17 18 bool HeightMap::update_pending = false; 19 double HeightMap::valueMin = 0.0; 20 double HeightMap::valueMax = 1.0; 21 18 22 HeightMap::HeightMap() : 19 23 _vertexBufferObjectID(0), … … 66 70 glPushMatrix(); 67 71 68 if (_scale.x != 0 ) {72 if (_scale.x != 0.0) { 69 73 glScalef(1 / _scale.x, 1 / _scale.x , 1 / _scale.x); 70 74 } … … 133 137 } 134 138 135 void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights) 139 void 140 HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, 141 int& indexCount, float* heights) 136 142 { 137 143 indexCount = (xCount - 1) * (zCount - 1) * 6; … … 188 194 } 189 195 190 void HeightMap::reset() 196 void 197 HeightMap::reset() 191 198 { 192 199 if (_vertexBufferObjectID) { … … 207 214 } 208 215 209 void HeightMap::setHeight(int xCount, int yCount, Vector3* heights) 216 void 217 HeightMap::setHeight(int xCount, int yCount, Vector3* heights) 210 218 { 211 219 _vertexCount = xCount * yCount; … … 229 237 _scale.y = 1.0f; 230 238 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 239 xAxis.SetRange(0.0, 1.0); 240 yAxis.SetRange(0.0, 1.0); 241 zAxis.SetRange(0.0, 1.0); 242 wAxis.SetRange(min, max); 243 update_pending = true; 244 236 245 _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5); 237 246 … … 294 303 _scale.z = endY - startY; 295 304 296 SetRange(AxisRange::VALUES, min, max); 297 SetRange(AxisRange::X, startX, endX); 298 SetRange(AxisRange::Y, min, max); 299 SetRange(AxisRange::Z, startY, endY); 305 wAxis.SetRange(min, max); 306 xAxis.SetRange(startX, endX); 307 yAxis.SetRange(min, max); 308 zAxis.SetRange(startY, endY); 309 update_pending = true; 300 310 301 311 _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + min, -
trunk/vizservers/nanovis/HeightMap.h
r929 r932 38 38 Vector3 _centerPoint; 39 39 40 AxisRange _ranges[4];41 40 public : 41 AxisRange xAxis, yAxis, zAxis, wAxis; 42 static bool update_pending; 43 static double valueMin, valueMax; 44 42 45 /** 43 46 *@brief Constructor … … 113 116 _contourColor.z = rgb[2]; 114 117 } 115 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 }123 118 }; 124 119 -
trunk/vizservers/nanovis/RpDX.cpp
r931 r932 16 16 #include "RpDX.h" 17 17 #include <math.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif // ifdex __cplusplus 18 #include <stdio.h> 19 #include <stdlib.h> 22 20 23 21 using namespace Rappture; 24 22 25 DX::DX(const char* filename) 26 :_dataMin(0),27 28 29 30 31 32 33 34 35 36 37 38 23 DX::DX(const char* filename) : 24 _dataMin(0), 25 _dataMax(0), 26 _nzero_min(0), 27 _numAxis(0), 28 _axisLen(NULL), 29 _data(NULL), 30 _n(0), 31 _rank(0), 32 _shape(0), 33 _positions(NULL), 34 _delta(NULL), 35 _max(NULL), 36 _origin(NULL) 39 37 { 40 38 Array dxarr; … … 44 42 Category category; 45 43 Type type; 46 44 47 45 if (filename == NULL) { 48 46 // error 49 47 } 50 48 51 49 // open the file with libdx 52 50 fprintf(stdout, "Calling DXImportDX(%s)\n", filename); … … 271 269 } 272 270 273 #ifdef __cplusplus 274 } 275 #endif // ifdef __cplusplus 271 272 -
trunk/vizservers/nanovis/Volume.cpp
r929 r932 18 18 #include "Trace.h" 19 19 20 bool Volume::update_pending = false; 21 double Volume::valueMin = 0.0; 22 double Volume::valueMax = 1.0; 20 23 21 24 Volume::Volume(float x, float y, float z, … … 45 48 int fcount = width * height * depth * n_components; 46 49 _data = new float[fcount]; 47 if (data) 48 { 50 if (data) { 49 51 Trace("data is copied\n"); 50 52 memcpy(_data, data, fcount * sizeof(float)); 51 53 tex->initialize(_data); 52 } 53 else 54 { 54 } else { 55 55 Trace("data is null\n"); 56 memset(_data, 0x00, sizeof(width *height* depth * n_components *sizeof(float))); 56 memset(_data, 0, sizeof(width * height * depth * n_components * 57 sizeof(float))); 57 58 tex->initialize(_data); 58 59 59 } 60 60 61 61 id = tex->id; 62 62 63 SetRange(AxisRange::VALUES,v0, v1);63 wAxis.SetRange(v0, v1); 64 64 65 65 aspect_ratio_width = s*tex->aspect_ratio_width; -
trunk/vizservers/nanovis/Volume.h
r929 r932 55 55 // render engine. 56 56 57 AxisRange xAxis, yAxis, zAxis, wAxis; 58 static bool update_pending; 59 static double valueMin, valueMax; 57 60 58 61 int n_components; 59 60 AxisRange _ranges[4]; // min/max for each axis61 62 62 63 double nonzero_min; … … 152 153 void get_outline_color(float* rgb); 153 154 154 void SetRange(int axis, double min, double max);155 const AxisRange *GetRange(int axis);156 155 void set_label(int axis, const char* txt); // change the label displayed 157 156 // on an axis … … 331 330 } 332 331 333 inline void334 Volume::SetRange(int axis, double min, double max)335 {336 _ranges[axis].min = min;337 _ranges[axis].max = max;338 }339 340 inline const AxisRange *341 Volume::GetRange(int axis)342 {343 return _ranges + axis;344 }345 346 332 inline int 347 333 Volume::get_isosurface() const -
trunk/vizservers/nanovis/VolumeInterpolator.cpp
r929 r932 146 146 volume->n_components, 147 147 volume->_data, 148 volume-> _ranges[AxisRange::VALUES].min,149 volume-> _ranges[AxisRange::VALUES].max,148 volume->wAxis.Min(), 149 volume->wAxis.Max(), 150 150 volume->nonzero_min); 151 151 _referenceOfVolume = volumeId; -
trunk/vizservers/nanovis/dxReader.cpp
r931 r932 194 194 volPtr = NanoVis::load_volume(index, nx, ny, nz, 3, data, vmin, vmax, 195 195 nzero_min); 196 volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx)); 197 volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy)); 198 volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz)); 196 197 volPtr->xAxis.SetRange(x0, x0 + (nx * ddx)); 198 volPtr->yAxis.SetRange(y0, y0 + (ny * ddy)); 199 volPtr->zAxis.SetRange(z0, z0 + (nz * ddz)); 200 volPtr->wAxis.SetRange(y0, y0 + (ny * ddy)); 201 volPtr->update_pending = true; 199 202 delete [] data; 200 203 } else { … … 443 446 Volume *volPtr; 444 447 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 445 vmin, vmax, nzero_min); 446 volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx)); 447 volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy)); 448 volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz)); 448 vmin, vmax, nzero_min); 449 fprintf(stderr, "x nx=%d ddx=%g min=%g max=%g\n", nx, ddx, 450 x0, x0 + (nx * ddx)); 451 fflush(stderr); 452 #ifdef notdef 453 volPtr->xAxis.SetRange(x0, x0 + (nx * ddx)); 454 volPtr->yAxis.SetRange(y0, y0 + (ny * ddy)); 455 volPtr->zAxis.SetRange(z0, z0 + (nz * ddz)); 456 #endif 457 volPtr->xAxis.SetRange(-20.0, 108.0); 458 volPtr->yAxis.SetRange(0.001, 102.2); 459 volPtr->zAxis.SetRange(-21, 19); 460 volPtr->update_pending = true; 449 461 delete [] data; 450 462 … … 576 588 Volume *volPtr; 577 589 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 578 field.valueMin(), field.valueMax(), nzero_min); 579 volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis), 580 field.rangeMax(Rappture::xaxis)); 581 volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis), 582 field.rangeMax(Rappture::yaxis)); 583 volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis), 584 field.rangeMax(Rappture::zaxis)); 590 field.valueMin(), field.valueMax(), nzero_min); 591 fprintf(stderr, "x min=%g max=%g\n", 592 field.rangeMin(Rappture::xaxis), 593 field.rangeMax(Rappture::xaxis)); 594 fflush(stderr); 595 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 596 field.rangeMax(Rappture::xaxis)); 597 volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis), 598 field.rangeMax(Rappture::yaxis)); 599 volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis), 600 field.rangeMax(Rappture::zaxis)); 601 volPtr->update_pending = true; 585 602 delete [] data; 586 603 } … … 733 750 int nindex = iz*nx*ny + iy*nx + ix; 734 751 field.define(nindex, dval[p]); 735 fprintf(stdout,"nindex = %i\tdval[%i] = %lg\n",nindex,p,dval[p]); 736 fflush(stdout); 752 fprintf(stderr,"nindex = %i\tdval[%i] = %lg\n", nindex, p, 753 dval[p]); 754 fflush(stderr); 737 755 nread++; 738 756 if (++iz >= nz) { … … 800 818 801 819 for (int i=0; i<nx*ny*nz; i++) { 802 fprintf(std out,"enddata[%i] = %lg\n",i,data[i]);803 fflush(std out);820 fprintf(stderr,"enddata[%i] = %lg\n",i,data[i]); 821 fflush(stderr); 804 822 } 805 823 // Compute the gradient of this data. BE CAREFUL: center … … 879 897 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 880 898 field.valueMin(), field.valueMax(), nzero_min); 881 volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis), 882 field.rangeMax(Rappture::xaxis)); 883 volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis), 884 field.rangeMax(Rappture::yaxis)); 885 volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis), 886 field.rangeMax(Rappture::zaxis)); 899 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 900 field.rangeMax(Rappture::xaxis)); 901 volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis), 902 field.rangeMax(Rappture::yaxis)); 903 volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis), 904 field.rangeMax(Rappture::zaxis)); 905 volPtr->update_pending = true; 887 906 // TBD.. 888 907 // POINTSET … … 1025 1044 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 1026 1045 field.valueMin(), field.valueMax(), nzero_min); 1027 volPtr-> SetRange(AxisRange::X,field.rangeMin(Rappture::xaxis),1028 1029 volPtr-> SetRange(AxisRange::Y,field.rangeMin(Rappture::yaxis),1030 1031 volPtr-> SetRange(AxisRange::Z,field.rangeMin(Rappture::zaxis),1032 1033 1046 volPtr->xAxis.SetRange(field.rangeMin(Rappture::xaxis), 1047 field.rangeMax(Rappture::xaxis)); 1048 volPtr->yAxis.SetRange(field.rangeMin(Rappture::yaxis), 1049 field.rangeMax(Rappture::yaxis)); 1050 volPtr->zAxis.SetRange(field.rangeMin(Rappture::zaxis), 1051 field.rangeMax(Rappture::zaxis)); 1052 volPtr->update_pending = true; 1034 1053 // TBD.. 1035 1054 // POINTSET -
trunk/vizservers/nanovis/dxReader2.cpp
r931 r932 1 1 2 #include "RpDX.h" 2 3 #include "dxReaderCommon.h" 3 4 -
trunk/vizservers/nanovis/dxReaderCommon.h
r931 r932 1 #include "RpDX.h" 1 #ifndef _DX_READER_COMMON_H 2 #define _DX_READER_COMMON_H 3 2 4 3 5 float* merge(float* scalar, float* gradient, int size); 4 6 void normalizeScalar(float* fdata, int count, float min, float max); 5 float* computeGradient(float* fdata, int width, int height, int depth, float min, float max); 7 float* computeGradient(float* fdata, int width, int height, int depth, 8 float min, float max); 9 10 #endif /*_DX_READER_COMMON_H*/ -
trunk/vizservers/nanovis/nanovis.cpp
r927 r932 100 100 bool NanoVis::particle_on = false; 101 101 bool NanoVis::vector_on = false; 102 bool NanoVis::config_pending = false; 102 103 103 104 // pointers to volumes, currently handle up to 10 volumes … … 625 626 NvShader::setErrorCallback(CgErrorCallback); 626 627 627 /*628 628 fonts = new R2Fonts(); 629 629 fonts->addFont("verdana", "verdana.fnt"); 630 630 fonts->setFont("verdana"); 631 */632 631 633 632 color_table_renderer = new NvColorTableRenderer(); … … 988 987 nanosleep(&ts, 0); 989 988 #endif 990 991 989 #ifdef XINETD 992 990 xinetd_listen(); … … 1012 1010 glColor3f(1.,1.,1.); //MUST HAVE THIS LINE!!! 1013 1011 glBegin(GL_QUADS); 1014 glTexCoord2f(0, 0); glVertex2f(0, 0); 1015 glTexCoord2f(1, 0); glVertex2f(win_width, 0); 1016 glTexCoord2f(1, 1); glVertex2f(win_width, win_height); 1017 glTexCoord2f(0, 1); glVertex2f(0, win_height); 1012 { 1013 glTexCoord2f(0, 0); glVertex2f(0, 0); 1014 glTexCoord2f(1, 0); glVertex2f(win_width, 0); 1015 glTexCoord2f(1, 1); glVertex2f(win_width, win_height); 1016 glTexCoord2f(0, 1); glVertex2f(0, win_height); 1017 } 1018 1018 glEnd(); 1019 1019 } … … 1035 1035 { 1036 1036 glDisable(GL_TEXTURE_2D); 1037 1038 1037 glColor4d(r, g, b, 1.0); 1039 1038 glLineWidth(line_width); 1040 1041 1039 glBegin(GL_LINE_LOOP); 1042 1043 1044 1045 1046 1047 1040 { 1041 glVertex3d(x0, y0, z0); 1042 glVertex3d(x1, y0, z0); 1043 glVertex3d(x1, y1, z0); 1044 glVertex3d(x0, y1, z0); 1045 } 1048 1046 glEnd(); 1049 1050 1047 glBegin(GL_LINE_LOOP); 1051 1052 1053 1054 1055 1056 1048 { 1049 glVertex3d(x0, y0, z1); 1050 glVertex3d(x1, y0, z1); 1051 glVertex3d(x1, y1, z1); 1052 glVertex3d(x0, y1, z1); 1053 } 1057 1054 glEnd(); 1058 1059 1060 1055 glBegin(GL_LINE_LOOP); 1061 1062 1063 1064 1065 1066 1056 { 1057 glVertex3d(x0, y0, z0); 1058 glVertex3d(x0, y0, z1); 1059 glVertex3d(x0, y1, z1); 1060 glVertex3d(x0, y1, z0); 1061 } 1067 1062 glEnd(); 1068 1069 1063 glBegin(GL_LINE_LOOP); 1070 1071 1072 1073 1074 1075 1064 { 1065 glVertex3d(x1, y0, z0); 1066 glVertex3d(x1, y0, z1); 1067 glVertex3d(x1, y1, z1); 1068 glVertex3d(x1, y1, z0); 1069 } 1076 1070 glEnd(); 1077 1078 1071 glEnable(GL_TEXTURE_2D); 1079 1072 } … … 1169 1162 glColor4f(0,0.8,0.8,0.6); 1170 1163 glBegin(GL_POINTS); 1171 for(int i=0; i<psys->psys_width * psys->psys_height; i++){ 1172 glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]); 1164 { 1165 for(int i=0; i < psys->psys_width * psys->psys_height; i++){ 1166 glVertex3f(vert[3*i], vert[3*i+1], vert[3*i+2]); 1167 } 1173 1168 } 1174 1169 glEnd(); … … 1210 1205 glUniform3fARB(oddevenMergeSort.getUniformLocation("Param1"), float(pstage+pstage), 1211 1206 float(ppass%pstage), float((pstage+pstage)-(ppass%pstage)-1)); 1212 glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"), float(psys_width), float(psys_height), float(ppass)); 1207 glUniform3fARB(oddevenMergeSort.getUniformLocation("Param2"), 1208 float(psys_width), float(psys_height), float(ppass)); 1213 1209 glUniform1iARB(oddevenMergeSort.getUniformLocation("Data"), 0); 1214 1210 staticdebugmsg("sort","stage "<<pstage<<" pass "<<ppass); … … 1226 1222 // Initiate the sorting step on the GPU a full-screen quad 1227 1223 glBegin(GL_QUADS); 1224 { 1228 1225 #ifdef notdef 1229 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); glVertex2f(-1.0f,-1.0f); 1230 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); glVertex2f(1.0f,-1.0f); 1231 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); glVertex2f(1.0f,1.0f); 1232 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); glVertex2f(-1.0f,1.0f); 1233 #endif 1234 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); glVertex2f(0.,0.); 1235 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); glVertex2f(float(psys_width), 0.); 1236 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); glVertex2f(float(psys_width), float(psys_height)); 1237 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); glVertex2f(0., float(psys_height)); 1226 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); 1227 glVertex2f(-1.0f,-1.0f); 1228 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); 1229 glVertex2f(1.0f,-1.0f); 1230 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); 1231 glVertex2f(1.0f,1.0f); 1232 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); 1233 glVertex2f(-1.0f,1.0f); 1234 #endif 1235 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,0.0f,0.0f,1.0f); 1236 glVertex2f(0.,0.); 1237 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),0.0f,1.0f,1.0f); 1238 glVertex2f(float(psys_width), 0.); 1239 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,float(psys_width),float(psys_height),1.0f,0.0f); 1240 glVertex2f(float(psys_width), float(psys_height)); 1241 glMultiTexCoord4fARB(GL_TEXTURE0_ARB,0.0f,float(psys_height),0.0f,0.0f); 1242 glVertex2f(0., float(psys_height)); 1243 } 1238 1244 glEnd(); 1239 1240 1245 1241 1246 // switch off sorting shader … … 1383 1388 struct timeval clock; 1384 1389 gettimeofday(&clock, NULL); 1385 double elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 - vol_renderer->_volumeInterpolator->getStartTime(); 1390 double elapsed_time; 1391 1392 elapsed_time = clock.tv_sec + clock.tv_usec/1000000.0 - 1393 vol_renderer->_volumeInterpolator->getStartTime(); 1386 1394 1387 1395 Trace("%lf %lf\n", elapsed_time, vol_renderer->_volumeInterpolator->getInterval()); … … 1389 1397 float f; 1390 1398 1391 f = fmod((float) elapsed_time, (float) 1399 f = fmod((float) elapsed_time, (float)vol_renderer->_volumeInterpolator->getInterval()); 1392 1400 if (f == 0.0) { 1393 1401 fraction = 0.0f; … … 1395 1403 fraction = f / vol_renderer->_volumeInterpolator->getInterval(); 1396 1404 } 1397 1398 1405 Trace("fraction : %f\n", fraction); 1399 1406 vol_renderer->_volumeInterpolator->update(fraction); … … 1401 1408 } 1402 1409 1410 void 1411 NanoVis::SetVolumeRanges() 1412 { 1413 double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; 1414 1415 xMin = yMin = zMin = wMin = DBL_MAX; 1416 xMax = yMax = zMax = wMax = -DBL_MAX; 1417 for (unsigned int i = 0; i < volume.size(); i++) { 1418 Volume *volPtr; 1419 1420 volPtr = volume[i]; 1421 if (volPtr == NULL) { 1422 continue; 1423 } 1424 if (!volPtr->enabled) { 1425 continue; 1426 } 1427 if (xMin > volPtr->xAxis.Min()) { 1428 xMin = volPtr->xAxis.Min(); 1429 } 1430 if (xMax < volPtr->xAxis.Max()) { 1431 xMax = volPtr->xAxis.Max(); 1432 } 1433 if (yMin > volPtr->yAxis.Min()) { 1434 yMin = volPtr->yAxis.Min(); 1435 } 1436 if (yMax < volPtr->yAxis.Max()) { 1437 yMax = volPtr->yAxis.Max(); 1438 } 1439 if (zMin > volPtr->zAxis.Min()) { 1440 zMin = volPtr->zAxis.Min(); 1441 } 1442 if (zMax < volPtr->zAxis.Max()) { 1443 zMax = volPtr->zAxis.Max(); 1444 } 1445 if (wMin > volPtr->wAxis.Min()) { 1446 wMin = volPtr->wAxis.Min(); 1447 } 1448 if (wMax < volPtr->wAxis.Max()) { 1449 wMax = volPtr->wAxis.Max(); 1450 } 1451 } 1452 if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) { 1453 grid->xAxis.SetScale(xMin, xMax); 1454 } 1455 if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) { 1456 grid->yAxis.SetScale(yMin, yMax); 1457 } 1458 if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) { 1459 grid->zAxis.SetScale(zMin, zMax); 1460 } 1461 if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) { 1462 Volume::valueMin = wMin; 1463 Volume::valueMax = wMax; 1464 } 1465 Volume::update_pending = false; 1466 } 1467 1468 void 1469 NanoVis::SetHeightmapRanges() 1470 { 1471 double xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; 1472 1473 xMin = yMin = zMin = wMin = DBL_MAX; 1474 xMax = yMax = zMax = wMax = -DBL_MAX; 1475 for (unsigned int i = 0; i < heightMap.size(); i++) { 1476 HeightMap *hmPtr; 1477 1478 hmPtr = heightMap[i]; 1479 if (hmPtr == NULL) { 1480 continue; 1481 } 1482 if (xMin > hmPtr->xAxis.Min()) { 1483 xMin = hmPtr->xAxis.Min(); 1484 } 1485 if (xMax < hmPtr->xAxis.Max()) { 1486 xMax = hmPtr->xAxis.Max(); 1487 } 1488 if (yMin > hmPtr->yAxis.Min()) { 1489 yMin = hmPtr->yAxis.Min(); 1490 } 1491 if (yMax < hmPtr->yAxis.Max()) { 1492 yMax = hmPtr->yAxis.Max(); 1493 } 1494 if (zMin > hmPtr->zAxis.Min()) { 1495 zMin = hmPtr->zAxis.Min(); 1496 } 1497 if (zMax < hmPtr->zAxis.Max()) { 1498 zMax = hmPtr->zAxis.Max(); 1499 } 1500 if (wMin > hmPtr->wAxis.Min()) { 1501 wMin = hmPtr->wAxis.Min(); 1502 } 1503 if (wMax < hmPtr->wAxis.Max()) { 1504 wMax = hmPtr->wAxis.Max(); 1505 } 1506 } 1507 if ((xMin < DBL_MAX) && (xMax > -DBL_MAX)) { 1508 grid->xAxis.SetScale(xMin, xMax); 1509 } 1510 if ((yMin < DBL_MAX) && (yMax > -DBL_MAX)) { 1511 grid->yAxis.SetScale(yMin, yMax); 1512 } 1513 if ((zMin < DBL_MAX) && (zMax > -DBL_MAX)) { 1514 grid->zAxis.SetScale(zMin, zMax); 1515 } 1516 if ((wMin < DBL_MAX) && (wMax > -DBL_MAX)) { 1517 HeightMap::valueMin = wMin; 1518 HeightMap::valueMax = wMax; 1519 } 1520 HeightMap::update_pending = false; 1521 } 1522 1403 1523 /*----------------------------------------------------*/ 1404 1524 void … … 1406 1526 { 1407 1527 //assert(glGetError()==0); 1408 1528 if (HeightMap::update_pending) { 1529 SetHeightmapRanges(); 1530 } 1531 if (Volume::update_pending) { 1532 SetVolumeRanges(); 1533 } 1409 1534 //start final rendering 1410 1535 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen -
trunk/vizservers/nanovis/nanovis.h
r929 r932 127 127 static float lic_slice_y; 128 128 static float lic_slice_z; 129 static int lic_axis; 129 static int lic_axis; /* 0:x, 1:y, 2:z */ 130 130 131 131 static bool axis_on; 132 133 static int win_width; 134 static int win_height; 132 static bool config_pending; // Indicates if the limits need to be recomputed. 133 static int win_width; //size of the render window 134 static int win_height; //size of the render window 135 135 136 136 … … 142 142 static TransferFunction* set_transfunc(const char *name, int nSlots, 143 143 float *data); 144 static void SetVolumeRanges(void); 145 static void SetHeightmapRanges(void); 144 146 static void init(const char* path); 145 147 static void initGL(void);
Note: See TracChangeset
for help on using the changeset viewer.