Changeset 820


Ignore:
Timestamp:
Nov 26, 2007, 11:34:00 AM (17 years ago)
Author:
vrinside
Message:

NaN values in a data set is taken into account.

Location:
trunk/vizservers/nanovis
Files:
2 edited

Legend:

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

    r780 r820  
    88#include <memory.h>
    99#include <R2/R2FilePath.h>
     10#include "RpField1D.h"
     11#include <sys/time.h>
     12#include <sys/types.h>
     13#include <unistd.h>
     14#include <fcntl.h>
    1015
    1116HeightMap::HeightMap()
     
    104109}
    105110
    106 void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount)
     111void HeightMap::createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights)
    107112{
    108113        indexCount = (xCount - 1) * (zCount - 1) * 6;
     
    114119    int boundaryHeight = zCount - 1;
    115120    int* ptr = indexBuffer;
    116     for (i = 0; i < boundaryHeight; ++i)
     121    int index1, index2, index3, index4;
     122    bool index1Valid, index2Valid, index3Valid, index4Valid;
     123    index1Valid = index2Valid = index3Valid = index4Valid = true;
     124
     125    if (heights)
    117126    {
    118         for (j = 0; j < boundaryWidth; ++j)
     127        int ic = 0;
     128        for (i = 0; i < boundaryHeight; ++i)
    119129        {
    120             *ptr = i * xCount + j; ++ptr;
    121             *ptr = (i + 1) * xCount + j; ++ptr;
    122             *ptr = (i + 1) * xCount + j + 1; ++ptr;
    123 
    124                         *ptr = i * xCount + j; ++ptr;
    125                         *ptr = (i + 1) * xCount + j + 1; ++ptr;
    126             *ptr = i * xCount + j + 1; ++ptr;
     130            for (j = 0; j < boundaryWidth; ++j)
     131            {
     132                index1 = i * xCount +j;
     133                if (isnan(heights[index1])) index1Valid = false;
     134                index2 = (i + 1) * xCount + j;
     135                if (isnan(heights[index2])) index2Valid = false;
     136                index3 = (i + 1) * xCount + j + 1;
     137                if (isnan(heights[index3])) index3Valid = false;
     138                index4 = i * xCount + j + 1;
     139                if (isnan(heights[index4])) index4Valid = false;
     140
     141       
     142           
     143                if (index1Valid && index2Valid && index3Valid)
     144                {
     145                    *ptr = index1; ++ptr;
     146                    *ptr = index2; ++ptr;
     147                    *ptr = index3; ++ptr;
     148                    ++ic;
     149                }
     150                if (index1Valid && index3Valid && index4Valid)
     151                {
     152                    *ptr = index1; ++ptr;
     153                    *ptr = index3; ++ptr;
     154                    *ptr = index4; ++ptr;
     155                    ++ic;
     156                }
     157            }
    127158        }
    128159    }
     160    else
     161    {
     162        for (i = 0; i < boundaryHeight; ++i)
     163        {
     164            for (j = 0; j < boundaryWidth; ++j)
     165            {
     166                *ptr = i * xCount + j; ++ptr;
     167                *ptr = (i + 1) * xCount + j; ++ptr;
     168                *ptr = (i + 1) * xCount + j + 1; ++ptr;
     169
     170                        *ptr = i * xCount + j; ++ptr;
     171                            *ptr = (i + 1) * xCount + j + 1; ++ptr;
     172                *ptr = i * xCount + j + 1; ++ptr;
     173            }
     174        }
     175    }
     176
    129177}
    130178
     
    195243                }
    196244
    197                 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount);
     245                this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount, 0);
    198246        //}
    199247        //else
     
    258306                }
    259307
    260                 this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount);
     308                this->createIndexBuffer(xCount, yCount, _indexBuffer, _indexCount, heights);
    261309        //}
    262310        //else
  • trunk/vizservers/nanovis/HeightMap.h

    r780 r820  
    99#include "Vector3.h"
    1010
     11/**
     12 *@class HeightMap
     13 *@brief Create a surface from height map and line contour of the generated surface
     14 */
    1115class HeightMap {
    1216        unsigned int _vertexBufferObjectID;
     
    2832
    2933public :
     34    /**
     35     *@brief Constructor
     36     */
    3037        HeightMap();
     38    /**
     39     *@brief Destructor
     40     */
    3141        ~HeightMap();
    3242
    3343private :
    34         void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount);
     44        void createIndexBuffer(int xCount, int zCount, int*& indexBuffer, int& indexCount, float* heights);
    3545        Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
    3646        void reset();
    3747public :
    3848        void render();
     49    /**
     50     *@brief Create a height map with heigh values
     51     *@param startX a x position of the first height value
     52     *@param startY a y position of the first height value
     53     *@param endX a x position of the last height value
     54     *@param endY a y position of the last height value
     55     *@param xCount the number of columns of height values
     56     *@param yCount the number of rows of height values
     57     *@param height a pointer value adrressing xCount * yCount values of heights
     58     */
    3959        void setHeight(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);
     60
     61    /**
     62     *@brief Create a height map with a set of points
     63     *@param xCount the number of columns of height values
     64     *@param yCount the number of rows of height values
     65     */
    4066        void setHeight(int xCount, int yCount, Vector3* heights);
     67
     68    /**
     69     *@brief Define a color map for color shading of heighmap
     70     */
    4171        void setColorMap(TransferFunction* colorMap);
    4272
     73    /**
     74     *@brief Set the visibility of the height map
     75     */
    4376        void setVisible(bool visible);
     77
     78    /**
     79     *@brief Return the status of the visibility
     80     */
    4481        bool isVisible() const;
     82
     83    /**
     84     *@brief Set the visibility of the line contour
     85     */
    4586        void setLineContourVisible(bool visible);
     87
     88    /**
     89     *@brief Defind the color of the line contour
     90     */
    4691    void setLineContourColor(float r, float g, float b);
    4792};
Note: See TracChangeset for help on using the changeset viewer.