Changeset 2807 for trunk/packages/vizservers
- Timestamp:
- Mar 6, 2012, 10:51:13 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/ParticleSystem.cpp
r2806 r2807 35 35 //#define TEST 36 36 // TEST 37 extern void* LoadFlowDx(const char* fname, int& width, int& height, int&depth, 38 float& min, float& max, float& nonzero_min, 39 float& axisScaleX, float& axisScaleY, float& axisScaleZ); 40 extern void* LoadFlowRaw(const char* fname, int width, int height, int depth, 41 float& min, float& max, float& nonzero_min, 42 float& axisScaleX, float& axisScaleY, float& axisScaleZ, 43 int skipByte, bool bigEndian); 44 extern void* LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, 45 float min, float max, 46 float& axisScaleX, float& axisScaleY, float& axisScaleZ, int skipByte); 47 extern void LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, 48 float* data); 37 extern void* 38 LoadFlowDx(const char* fname, int& width, int& height, int&depth, 39 float& min, float& max, float& nonzero_min, 40 float& axisScaleX, float& axisScaleY, float& axisScaleZ); 41 42 extern void* 43 LoadFlowRaw(const char* fname, int width, int height, int depth, 44 float& min, float& max, float& nonzero_min, 45 float& axisScaleX, float& axisScaleY, float& axisScaleZ, 46 int skipByte, bool bigEndian); 47 48 extern void* 49 LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, 50 float min, float max, 51 float& axisScaleX, float& axisScaleY, float& axisScaleZ, 52 int skipByte); 53 54 extern void 55 LoadProcessedFlowRaw(const char* fname, int width, int height, int depth, 56 float* data); 49 57 50 58 inline float randomRange(float rangeMin, float rangeMax) … … 69 77 } 70 78 71 void* ParticleSystem::dataLoadMain(void *data)79 void* ParticleSystem::dataLoadMain(void *data) 72 80 { 73 81 ParticleSystem* particleSystem = (ParticleSystem*) data; 74 82 CircularFifo<float*, 10>& queue = particleSystem->_queue; 75 83 76 84 // TBD.. 77 85 //float min = particleSystem->_time_series_vel_mag_min; … … 85 93 float flowHeight = particleSystem->_flowHeight; 86 94 float flowDepth = particleSystem->_flowDepth; 87 95 88 96 const char* fileNameFormat = particleSystem->_fileNameFormat.c_str(); 89 97 char buff[256]; … … 108 116 ++curIndex; 109 117 } 110 } 118 } 119 } 111 120 112 121 return 0; … … 130 139 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 131 140 132 133 141 float *img = new float[DIM*DIM]; 134 142 … … 139 147 for (int x = 0; x < DIM; x++) { 140 148 // Clamping the edges to zero allows Nvidia's blend optimizations to do their thing. 141 if (x ==0 || x==DIM-1 || y==0 || y==DIM-1) {149 if (x == 0 || x == DIM-1 || y == 0 || y == DIM-1) { 142 150 img[y*DIM+x] = 0; 143 151 } else { … … 176 184 bool timeVaryingData, 177 185 int flowFileStartIndex, int flowFileEndIndex) : 178 _width(width), _height(height) 186 _width(width), 187 _height(height) 179 188 { 180 189 //////////////////////////////// … … 243 252 int index = fileName.rfind('.'); 244 253 std::string ext = fileName.substr(index + 1, fileName.size() - (index + 1)); 245 float* data = 0; 246 254 float *data = 0; 247 255 248 256 if (this->isTimeVaryingField()) { … … 270 278 } else if (ext == "data") { 271 279 data = (float*) LoadFlowRaw(fileName.c_str(), _flowWidth, _flowHeight, _flowDepth, min, max, nonzero_min, axisScaleX, axisScaleY, axisScaleZ, 0, true); 280 #endif 272 281 } 273 #endif274 282 //_criticalPoints = find_critical_points((vrVector4f*) data, _flowWidth, _flowHeight, _flowDepth); 275 283 //algorithm_test((vrVector4f*) data, _flowWidth, _flowHeight, _flowDepth); … … 339 347 #ifdef notdef 340 348 // TBD.. 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 349 std::string path = vrFilePath::getInstance()->getPath("arrows_red_bg.bmp"); 350 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad(path.c_str()); 351 unsigned char* pixels = new unsigned char [pTextureImage->sizeX * pTextureImage->sizeY * sizeof(unsigned char) * 4]; 352 unsigned char* srcPixels = pTextureImage->data; 353 unsigned char* dstPixels = pixels; 354 for (int i = 0; i < pTextureImage->sizeX * pTextureImage->sizeY; ++i) { 355 *dstPixels = *srcPixels; ++srcPixels; 356 *(dstPixels + 1) = *srcPixels; ++srcPixels; 357 *(dstPixels + 2) = *srcPixels; ++srcPixels; 358 359 if ((*dstPixels > 127) && (*(dstPixels + 1) < 127) && (*(dstPixels + 2) < 127)) { 360 *(dstPixels + 3) = 0; 361 } else { 362 *(dstPixels + 3) = 255; 363 } 364 365 dstPixels += 4; 366 } 367 368 _arrows->setPixels(CF_RGBA, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pixels); 361 369 #endif 362 370 … … 460 468 { 461 469 CGerror lastError = cgGetError(); 462 if (lastError) {470 if (lastError) { 463 471 const char *listing = cgGetLastListing(_context); 464 472 ERROR("\n---------------------------------------------------\n"); … … 623 631 pinfo[i] = _particles[i]; 624 632 } 625 633 626 634 glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); 627 635 … … 977 985 glDisable(GL_BLEND); 978 986 glDisable(GL_DEPTH_TEST); 979 987 980 988 //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, psys_fbo[_destPosIndex]); 981 989 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 1055 1063 if (this->isTimeVaryingField()) { 1056 1064 static float oldTime = vrGetTimeStamp(); 1065 #ifdef WANT_TRACE 1057 1066 static int index = 0; 1067 #endif 1058 1068 float time = vrGetTimeStamp(); 1059 1069 if ((time - oldTime) > 2.0) { … … 1061 1071 float* data = 0; 1062 1072 if (_queue.top(data)) { 1073 #ifdef WANT_TRACE 1063 1074 float t = clock() /(float) CLOCKS_PER_SEC; 1064 1075 _vectorFields[0]->updatePixels(data); 1065 1076 float ti = clock() / (float) CLOCKS_PER_SEC; 1066 1077 TRACE("pixels %f\n",ti - t); 1078 #endif 1067 1079 _queue.pop(); 1068 1080 oldTime = time; … … 1277 1289 1278 1290 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1279 1291 1280 1292 // INIT NEW END 1281 1293 ///////////////////////////// … … 1347 1359 1348 1360 //if (i >= _maxUsedIndex) 1349 // 1350 // 1361 // while (!_usedIndices[_maxUsedIndex]) 1362 // _maxUsedIndex--; 1351 1363 } 1352 1364 } … … 1531 1543 { 1532 1544 if (count > 1) { 1533 mergeSort(count >> 1); 1545 mergeSort(count >> 1); 1534 1546 merge(count, 1); 1535 1547 } … … 1646 1658 //glColorPointer(4, GL_FLOAT, 0, 0); 1647 1659 1648 ::glDrawElements(GL_LINES, _particleCount * 2 * (_currentStreamlineIndex - 1), GL_UNSIGNED_INT, _indexBuffer); 1660 ::glDrawElements(GL_LINES, _particleCount * 2 * (_currentStreamlineIndex - 1), 1661 GL_UNSIGNED_INT, _indexBuffer); 1649 1662 glDisableClientState(GL_VERTEX_ARRAY); 1650 1663 glPopMatrix(); … … 1732 1745 cgGLDisableProfile(CG_PROFILE_FP40); 1733 1746 1734 1735 1747 glDepthMask(GL_TRUE); 1736 1748 … … 1773 1785 #endif 1774 1786 } else { 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1787 if (_drawBBoxEnabled) drawUnitBox(); 1788 1789 glColor3f(1, 1, 1); 1790 glEnableClientState(GL_VERTEX_ARRAY); 1791 //glEnableClientState(GL_COLOR_ARRAY); 1792 glPointSize(10); 1793 _vertices->SetPointer(0); 1794 //glBindBufferARB(GL_ARRAY_BUFFER, _colorBufferID); 1795 //glColorPointer(4, GL_FLOAT, 0, 0); 1796 //glBindBufferARB(GL_ARRAY_BUFFER, 0); 1797 glDrawArrays(GL_POINTS, 0, _particleMaxCount); 1798 1799 glPointSize(1); 1800 _vertices->SetPointer(0); 1801 //glBindBufferARB(GL_ARRAY_BUFFER, _colorBufferID); 1802 //glColorPointer(4, GL_FLOAT, 0, 0); 1803 //glBindBufferARB(GL_ARRAY_BUFFER, 0); 1804 glDrawArrays(GL_POINTS, 0, _particleMaxCount); 1805 1806 glDisableClientState(GL_VERTEX_ARRAY); 1795 1807 } 1796 1808 … … 1802 1814 glBegin(GL_POINTS); 1803 1815 for (iter = _criticalPoints->begin(); iter != _criticalPoints->end(); ++iter) { 1804 glVertex3f((*iter).x, (*iter).y, (*iter).z); 1816 glVertex3f((*iter).x, (*iter).y, (*iter).z); 1805 1817 } 1806 1818 glEnd();
Note: See TracChangeset
for help on using the changeset viewer.