Changeset 3354 for branches


Ignore:
Timestamp:
Feb 25, 2013 1:13:15 PM (11 years ago)
Author:
ldelgass
Message:

Remove incomplete, unused "2D" top view of heightmap/contour from nanovis

Location:
branches/nanovis2/packages/vizservers/nanovis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/nanovis2/packages/vizservers/nanovis/Command.cpp

    r3334 r3354  
    18931893}
    18941894
    1895 
    1896 static int
    1897 HeightMapTopView(ClientData data, Tcl_Interp *interp, int objc,
    1898                 Tcl_Obj *const *objv)
    1899 {
    1900 
    1901     // the variables below should be reassigned
    1902     int image_width = 512;
    1903     int image_height = 512;
    1904     HeightMap* heightmap = 0;
    1905 
    1906     // HELP ME
    1907     // GEORGE
    1908 
    1909     NanoVis::render2dContour(heightmap, image_width, image_height);
    1910     NanoVis::eventuallyRedraw();
    1911     return TCL_OK;
    1912 }
    1913 
    1914 static int
    1915 HeightMapTestOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1916                 Tcl_Obj *const *objv)
    1917 {
    1918     srand((unsigned)time(NULL));
    1919 
    1920     int size = 20 * 20;
    1921     double sigma = 5.0;
    1922     double mean = exp(0.0) / (sigma * sqrt(2.0));
    1923     float* data = (float*) malloc(sizeof(float) * size);
    1924 
    1925     float x, y;
    1926     for (int i = 0; i < size; ++i) {
    1927         x = - 10 + i%20;
    1928         y = - 10 + (i/20);
    1929         data[i] = exp(- (x * y)/(2 * sigma * sigma)) /
    1930             (sigma * sqrt(2.0)) / mean * 2 + 1000;
    1931         //data[i] = ((float)rand()) / RAND_MAX * 1.0;
    1932     }
    1933 
    1934     HeightMap* hmPtr = new HeightMap();
    1935     float minx = 0.0f;
    1936     float maxx = 1.0f;
    1937     float miny = 0.5f;
    1938     float maxy = 3.5f;
    1939     hmPtr->setHeight(minx, miny, maxx, maxy, 20, 20, data);
    1940     hmPtr->transferFunction(NanoVis::getTransfunc("default"));
    1941     hmPtr->setVisible(true);
    1942     hmPtr->setLineContourVisible(true);
    1943     NanoVis::grid->setVisible(true);
    1944     Tcl_HashEntry *hPtr;
    1945     int isNew;
    1946     hPtr = Tcl_CreateHashEntry(&NanoVis::heightmapTable, "test", &isNew);
    1947     if (!isNew) {
    1948         Tcl_AppendResult(interp, "heightmap \"test\" already exists.",
    1949                          (char *)NULL);
    1950         return TCL_ERROR;
    1951     }
    1952     Tcl_SetHashValue(hPtr, hmPtr);
    1953     int image_width = 512;
    1954     int image_height = 512;
    1955 
    1956     NanoVis::render2dContour(hmPtr, image_width, image_height);
    1957 
    1958     return TCL_OK;
    1959 }
    1960 
    19611895static int
    19621896HeightMapTransFuncOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    20141948    {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
    20151949    {"shading",      1, HeightMapShadingOp,     3, 3, "model",},
    2016     {"test",         2, HeightMapTestOp,        2, 2, "",},
    20171950    {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?heightmap...?",},
    2018 
    2019     // HELP ME
    2020     // GOERGE
    2021     {"topview",      2, HeightMapTopView,     2, 2, "",},
    20221951};
    20231952static int nHeightMapOps = NumCmdSpecs(heightMapOps);
  • branches/nanovis2/packages/vizservers/nanovis/HeightMap.cpp

    r2956 r3354  
    1212double HeightMap::valueMax = 1.0;
    1313
    14 #define TOPCONTOUR      0
    15 //#define TOPCONTOUR    1
    1614HeightMap::HeightMap() :
    1715    _vertexBufferObjectID(0),
     
    1917    _vertexCount(0),
    2018    _contour(0),
    21     _topContour(0),
    2219    _tfPtr(0),
    2320    _opacity(0.5f),
     
    2623    _contourColor(1.0f, 0.0f, 0.0f),
    2724    _contourVisible(false),
    28     _topContourVisible(true),
    2925    _visible(false),
    3026    _scale(1.0f, 1.0f, 1.0f),
     
    140136        }
    141137
    142 #if TOPCONTOUR
    143         if (_topContourVisible) {
    144             glDisable(GL_BLEND);
    145             glDisable(GL_TEXTURE_2D);
    146             glColor4f(_contourColor.x, _contourColor.y, _contourColor.z,
    147                       _opacity /*1.0f*/);
    148             //glDepthRange (0.0, 0.999);
    149             _topContour->render();
    150         }
    151 #endif
    152138        glDepthRange (0.0, 1.0);
    153139    }
     
    303289    _contour = lineFilter.create(0.0f, 1.0f, 10, heights, xCount, yCount);
    304290
    305 #if TOPCONTOUR
    306     ContourLineFilter topLineFilter;
    307     topLineFilter.setHeightTop(true);
    308     _topContour = topLineFilter.create(0.0f, 1.0f, 10, heights, xCount, yCount);
    309 #endif
    310 
    311291    //if (heightMap)
    312292    //{
     
    396376    //lineFilter.transferFunction(_tfPtr);
    397377    _contour = lineFilter.create(0.0f, 1.0f, 10, map, xNum, yNum);
    398    
    399 #if TOPCONTOUR
    400     ContourLineFilter topLineFilter;
    401     topLineFilter.setHeightTop(true);
    402     _topContour = topLineFilter.create(0.0f, 1.0f, 10, map, xNum, yNum);
    403 #endif
     378
    404379    this->createIndexBuffer(xNum, yNum, heights);
    405380    delete [] map;
     
    495470    _contour = lineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum);
    496471   
    497 #if TOPCONTOUR
    498     ContourLineFilter topLineFilter;
    499     topLineFilter.setHeightTop(true);
    500     _topContour = topLineFilter.create(0.0f, 1.0f, 10, vertices, _xNum, _yNum);
    501 #endif
    502472    this->createIndexBuffer(_xNum, _yNum, normHeights);
    503473    delete [] normHeights;
    504474    delete [] vertices;
    505475}
    506 
    507 void
    508 HeightMap::renderTopview(graphics::RenderContext* renderContext,
    509                          int render_width, int render_height)
    510 {
    511     glClear(GL_COLOR_BUFFER_BIT);
    512     glPushAttrib(GL_VIEWPORT_BIT);
    513     glViewport(0, 0, render_width, render_height);
    514     glMatrixMode(GL_PROJECTION);
    515     glPushMatrix();
    516     glLoadIdentity();
    517     //gluOrtho2D(0, render_width, 0, render_height);
    518     glOrtho(-.5, .5, -.5, .5, -50, 50);
    519     glMatrixMode(GL_MODELVIEW);
    520     glPushMatrix();
    521     glLoadIdentity();
    522 
    523     glTranslatef(0.0, 0.0, -10.0);
    524 
    525     // put camera rotation and translation
    526     //glScalef(1 / _scale.x, 1 / _scale.y , 1 / _scale.z);
    527 
    528     if (renderContext->getCullMode() == graphics::RenderContext::NO_CULL) {
    529         glDisable(GL_CULL_FACE);
    530     } else {
    531         glEnable(GL_CULL_FACE);
    532         glCullFace((GLuint) renderContext->getCullMode());
    533     }
    534 
    535     glPolygonMode(GL_FRONT_AND_BACK, (GLuint) renderContext->getPolygonMode());
    536     glShadeModel((GLuint) renderContext->getShadingModel());
    537 
    538     glPushMatrix();
    539 
    540     //glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);
    541 
    542     //glScalef(0.01, 0.01, 0.01f);
    543     glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
    544     glTranslatef(-_centerPoint.x, -_centerPoint.y, -_centerPoint.z);
    545     if (_contour != NULL) {
    546         glDepthRange (0.001, 1.0);
    547     }
    548        
    549     glEnable(GL_DEPTH_TEST);
    550 
    551     glEnable(GL_BLEND);
    552     glEnable(GL_TEXTURE_2D);
    553     if (_vertexBufferObjectID)
    554     {
    555         TRACE("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n");
    556         glColor3f(1.0f, 1.0f, 1.0f);
    557         glShadeModel(GL_SMOOTH);
    558         glEnable(GL_BLEND);
    559         glEnableClientState(GL_VERTEX_ARRAY);
    560         glDisableClientState(GL_COLOR_ARRAY);
    561         glDisableClientState(GL_INDEX_ARRAY);
    562         glDisableClientState(GL_NORMAL_ARRAY);
    563        
    564         if (_tfPtr != NULL) {
    565             _shader->bind();
    566 
    567             _shader->setFPTextureParameter("tf", _tfPtr->id());
    568 
    569             glEnable(GL_TEXTURE_1D);
    570             _tfPtr->getTexture()->activate();
    571 
    572             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    573         } else {
    574             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    575         }
    576 
    577         glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferObjectID);
    578         glVertexPointer(3, GL_FLOAT, 12, 0);
    579 
    580         glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    581         glTexCoordPointer(3, GL_FLOAT, 12, 0);
    582 
    583 #define _TRIANGLES_
    584 #ifdef _TRIANGLES_
    585         glDrawElements(GL_TRIANGLES, _indexCount, GL_UNSIGNED_INT,
    586                        _indexBuffer);
    587 #else
    588         glDrawElements(GL_QUADS, _indexCount, GL_UNSIGNED_INT,
    589                        _indexBuffer);
    590 #endif
    591 
    592         glBindBuffer(GL_ARRAY_BUFFER, 0);
    593 
    594         glDisableClientState(GL_VERTEX_ARRAY);
    595         if (_tfPtr != NULL) {
    596             _tfPtr->getTexture()->deactivate();
    597             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    598 
    599             _shader->disableFPTextureParameter("tf");
    600             _shader->unbind();
    601         }
    602     }
    603 
    604     glShadeModel(GL_FLAT);
    605     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    606 
    607     if (_contour != NULL) {
    608         if (_contourVisible) {
    609             glDisable(GL_BLEND);
    610             glDisable(GL_TEXTURE_2D);
    611             glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);
    612             glDepthRange (0.0, 0.999);
    613             _contour->render();
    614             glDepthRange (0.0, 1.0);
    615         }
    616 
    617 #if TOPCONTOUR
    618         if (_topContourVisible) {
    619             glDisable(GL_BLEND);
    620             glDisable(GL_TEXTURE_2D);
    621             glColor4f(_contourColor.x, _contourColor.y, _contourColor.z, 1.0f);
    622             //glDepthRange (0.0, 0.999);
    623             _topContour->render();
    624             //glDepthRange (0.0, 1.0);
    625         }
    626 #endif
    627     }
    628    
    629     glPopMatrix();
    630     glPopMatrix();
    631 
    632     glMatrixMode(GL_PROJECTION);
    633     glPushMatrix();
    634     glMatrixMode(GL_MODELVIEW);
    635 
    636     glPopAttrib();
    637 }
  • branches/nanovis2/packages/vizservers/nanovis/HeightMap.h

    r2956 r3354  
    2828
    2929    void render(graphics::RenderContext *renderContext);
    30 
    31     void renderTopview(graphics::RenderContext *renderContext,
    32                        int render_width, int render_height);
    3330
    3431    /**
     
    9491    }
    9592
    96     void setTopLineContourVisible(bool visible)
    97     {
    98         _topContourVisible = visible;
    99     }
    100 
    10193    void opacity(float opacity)
    10294    {
     
    134126    int _vertexCount;
    135127    R2Geometry *_contour;
    136     R2Geometry *_topContour;
    137128    TransferFunction *_tfPtr;
    138129    float _opacity;
     
    143134
    144135    bool _contourVisible;
    145     bool _topContourVisible;
    146136    bool _visible;
    147137
  • branches/nanovis2/packages/vizservers/nanovis/nanovis.cpp

    r3341 r3354  
    21342134}
    21352135
    2136 int
    2137 NanoVis::render2dContour(HeightMap* heightmap, int width, int height)
    2138 {
    2139     int old_width = winWidth;
    2140     int old_height = winHeight;
    2141 
    2142     resizeOffscreenBuffer(width, height);
    2143 
    2144     /*
    2145       planeRenderer->setScreenSize(width, height);
    2146 
    2147       // generate data for the legend
    2148       float data[512];
    2149       for (int i=0; i < 256; i++) {
    2150           data[i] = data[i+256] = (float)(i/255.0);
    2151       }
    2152       plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data);
    2153       int index = planeRenderer->addPlane(plane[0], tf);
    2154       planeRenderer->setActivePlane(index);
    2155 
    2156       bindOffscreenBuffer();
    2157       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    2158 
    2159       //planeRenderer->render();
    2160       // INSOO : is going to implement here for the topview of the heightmap
    2161       heightmap->render(renderContext);
    2162 
    2163       // INSOO
    2164       glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);
    2165       //glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, screen_buffer); // INSOO's
    2166       */
    2167 
    2168 
    2169     // HELP ME
    2170     // GEORGE
    2171     // I am not sure what I should do
    2172     //char prefix[200];
    2173     //sprintf(prefix, "nv>height_top_view %s %g %g", volArg, min, max);
    2174     //ppmWrite(prefix);
    2175     //write(1, "\n", 1);
    2176     //planeRenderer->removePlane(index);
    2177 
    2178     // CURRENT
    2179     bindOffscreenBuffer();
    2180     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen
    2181     //glEnable(GL_TEXTURE_2D);
    2182     //glEnable(GL_DEPTH_TEST);
    2183     //heightmap->renderTopview(renderContext, width, height);
    2184     //NanoVis::display();
    2185     if (HeightMap::updatePending) {
    2186         setHeightmapRanges();
    2187     }
    2188 
    2189     //cam->initialize();
    2190 
    2191     heightmap->renderTopview(renderContext, width, height);
    2192 
    2193     readScreen();
    2194 
    2195     // INSOO TEST CODE
    2196     bmpWriteToFile(1, "/tmp");
    2197 
    2198     resizeOffscreenBuffer(old_width, old_height);
    2199 
    2200     return TCL_OK;
    2201 }
    2202 
    22032136void
    22042137NanoVis::removeVolume(Volume *volPtr)
  • branches/nanovis2/packages/vizservers/nanovis/nanovis.h

    r3334 r3354  
    107107                                                    size_t n, float *data);
    108108
    109     static int render2dContour(HeightMap *heightmap, int width, int height);
    110 
    111109    static int renderLegend(TransferFunction *tf, double min, double max,
    112110                            int width, int height, const char *volArg);
Note: See TracChangeset for help on using the changeset viewer.