Ignore:
Timestamp:
Mar 7, 2012 12:21:30 PM (12 years ago)
Author:
ldelgass
Message:

Const correctness fixes, pass vector/matrix objects by reference, various
formatting and style cleanups, don't spam syslog and uncomment openlog() call.
Still needs to be compiled with -DWANT_TRACE to get tracing, but now trace
output will be output to file in /tmp.

Location:
trunk/packages/vizservers/nanovis
Files:
2 deleted
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Axis.h

    r2798 r2822  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef _AXIS_H
    3 #define _AXIS_H
     2#ifndef AXIS_H
     3#define AXIS_H
    44
    55#include "Chain.h"
     
    77class Axis;
    88
    9 class NaN {
     9class NaN
     10{
    1011private:
    11     double x_;
     12    double _x;
    1213public:
    13     NaN(void) {
     14    NaN()
     15    {
    1416        union DoubleValue {
    1517            unsigned int words[2];
    1618            double value;
    1719        } result;
    18        
     20
    1921#ifdef WORDS_BIGENDIAN
    2022        result.words[0] = 0x7ff80000;
     
    2426        result.words[1] = 0x7ff80000;
    2527#endif
    26         x_ = result.value;
    27     }
    28     operator const double() {
    29         return x_;
     28        _x = result.value;
     29    }
     30
     31    operator double() const
     32    {
     33        return _x;
    3034    }
    3135};
     
    143147    void Append (float x) {
    144148        chain_.Append(GetClientData(x));
    145     }   
     149    }
    146150    void SetValues(double initial, double step, unsigned int nSteps) {
    147151        initial_ = initial, step_ = step, nSteps_ = nSteps;
     
    346350};
    347351
    348 #endif /*_AXIS_H*/
     352#endif
  • trunk/packages/vizservers/nanovis/AxisRange.h

    r2798 r2822  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef _AXIS_RANGE_H
    3 #define _AXIS_RANGE_H
     2#ifndef AXIS_RANGE_H
     3#define AXIS_RANGE_H
    44
    55#include <string.h>
     
    5050};
    5151
    52 #endif /*_AXIS_RANGE_H*/
     52#endif
  • trunk/packages/vizservers/nanovis/BucketSort.h

    r2798 r2822  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #ifndef __BUCKETSORT_H_
    3 #define __BUCKETSORT_H_
     2#ifndef BUCKETSORT_H
     3#define BUCKETSORT_H
    44
    55#include <vector>
     
    1313class ClusterList {
    1414public :
    15         Cluster* data;
    16         ClusterList* next;
     15    Cluster* data;
     16    ClusterList* next;
    1717public :
    18         ClusterList(Cluster* d, ClusterList* n)
    19                 : data(d), next(n)
    20         {}
     18    ClusterList(Cluster *d, ClusterList *n) :
     19        data(d), next(n)
     20    {}
    2121
    22         ClusterList()
    23                 : data(0), next(0)
    24         {}
     22    ClusterList() :
     23        data(0), next(0)
     24    {}
    2525
    26         ~ClusterList()
    27         {
    28                 //if (next) delete next;
    29         }
     26    ~ClusterList()
     27    {
     28        //if (next) delete next;
     29    }
    3030};
    3131
    3232class BucketSort {
    33         ClusterList** _buffer;
    34         int _size;
    35         int _count;
     33    ClusterList **_buffer;
     34    int _size;
     35    int _count;
    3636
    37         int _memChuckSize;
    38         bool _memChunckUsedFlag;
    39         ClusterList* _memChunck;
    40        
    41         float _invMaxLength;
    42 private :
    43         //void _sort(Cluster* cluster, const Matrix4& cameraMat, int level);
    44         void _sort(Cluster* cluster, const Mat4x4& cameraMat, int level);
    45 public :
    46         BucketSort(int maxSize)
    47         {
    48                 _size = maxSize;
    49                 _buffer = new ClusterList*[maxSize];
    50                 memset(_buffer, 0, _size * sizeof(ClusterList*));
     37    int _memChuckSize;
     38    bool _memChunckUsedFlag;
     39    ClusterList *_memChunck;
    5140
    52                 _memChuckSize = 1000000;
    53                 _memChunck = new ClusterList[_memChuckSize];
     41    float _invMaxLength;
     42private:
     43    void _sort(Cluster *cluster, const Mat4x4& cameraMat, int level);
     44public:
     45    BucketSort(int maxSize)
     46    {
     47        _size = maxSize;
     48        _buffer = new ClusterList*[maxSize];
     49        memset(_buffer, 0, _size * sizeof(ClusterList*));
    5450
    55                 _invMaxLength = 1.0f / 4.0f;
    56         }
     51        _memChuckSize = 1000000;
     52        _memChunck = new ClusterList[_memChuckSize];
    5753
    58         ~BucketSort()
    59         {
    60                 delete [] _buffer;
    61                 delete [] _memChunck;
    62         }
     54        _invMaxLength = 1.0f / 4.0f;
     55    }
    6356
    64         int getSize() const { return _size; }
    65         int getSortedItemCount() const { return _count; }
    66         void init();
    67         //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, float maxLength);
    68         //void sort(ClusterAccel* cluster, const Matrix4& cameraMat, int level);
    69         void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level);
    70         void addBucket(Cluster* cluster, float ratio);
    71         ClusterList** getBucket() { return _buffer; }
     57    ~BucketSort()
     58    {
     59        delete [] _buffer;
     60        delete [] _memChunck;
     61    }
     62
     63    int getSize() const
     64    { return _size; }
     65
     66    int getSortedItemCount() const
     67    { return _count; }
     68
     69    void init();
     70
     71    void sort(ClusterAccel* cluster, const Mat4x4& cameraMat, int level);
     72
     73    void addBucket(Cluster* cluster, float ratio);
     74
     75    ClusterList **getBucket()
     76    { return _buffer; }
    7277};
    7378
  • trunk/packages/vizservers/nanovis/Command.cpp

    r2821 r2822  
    5656#include "nanovis.h"
    5757#include "CmdProc.h"
    58 #include "Nv.h"
    5958#include "PointSetRenderer.h"
    6059#include "PointSet.h"
  • trunk/packages/vizservers/nanovis/ConvexPolygon.cpp

    r2798 r2822  
    1414 * ======================================================================
    1515 */
     16#include <assert.h>
     17
     18#include <GL/gl.h>
     19
    1620#include "ConvexPolygon.h"
    1721#include "Trace.h"
    18 #include <GL/gl.h>
    19 #include <assert.h>
    20 
    21 ConvexPolygon::ConvexPolygon(){}
    22 
    23 ConvexPolygon::ConvexPolygon(VertexVector newvertices){
     22
     23ConvexPolygon::ConvexPolygon(VertexVector newvertices)
     24{
    2425    vertices.insert(vertices.begin(), newvertices.begin(), newvertices.end());
    2526}
     
    3435// http://astronomy.swin.edu.au/pbourke/geometry/planeline/
    3536bool
    36 findIntersection(Vector4 p1, Vector4 p2, Vector4 plane, Vector4 &ret){
     37findIntersection(const Vector4& pt1, const Vector4& pt2, const Vector4& plane, Vector4& ret)
     38{
    3739    float a = plane.x;
    3840    float b = plane.y;
     
    4042    float d = plane.w;
    4143
    42     p1.perspective_devide();
     44    Vector4 p1 = pt1;
     45    p1.perspective_divide();
    4346    float x1 = p1.x;
    4447    float y1 = p1.y;
    4548    float z1 = p1.z;
    4649
    47     p2.perspective_devide();
     50    Vector4 p2 = pt2;
     51    p2.perspective_divide();
    4852    float x2 = p2.x;
    4953    float y2 = p2.y;
     
    5761        ERROR("Unexpected code path: ConvexPolygon.cpp\n");
    5862        if (uNumer == 0){
    59             for (int i = 0; i < 4; i++)
    60                 ret < p1;
     63            ret = p1;
    6164            return true;
    6265        }
     
    7275}
    7376
    74 void
    75 ConvexPolygon::transform(Mat4x4 mat){
     77void
     78ConvexPolygon::transform(const Mat4x4& mat)
     79{
    7680    VertexVector tmp = vertices;
    7781    vertices.clear();
     
    8387}
    8488
    85 
    86 void
    87 ConvexPolygon::translate(Vector4 shift){
     89void
     90ConvexPolygon::translate(const Vector4& shift)
     91{
    8892    VertexVector tmp = vertices;
    8993    vertices.clear();
     
    9599}
    96100
    97 void
    98 ConvexPolygon::clip(Plane &clipPlane, bool copy_to_texcoord) {
     101void
     102ConvexPolygon::clip(Plane& clipPlane, bool copy_to_texcoord)
     103{
    99104    if (vertices.size() == 0) {
    100105        //ERROR("ConvexPolygon: polygon has no vertices\n"); 
     
    149154                    clippedVerts.end());
    150155
    151     if(copy_to_texcoord)
     156    if (copy_to_texcoord)
    152157        copy_vertices_to_texcoords();
    153158}
    154159
    155 void
    156 ConvexPolygon::copy_vertices_to_texcoords(){
    157     if(texcoords.size()>0)
     160void
     161ConvexPolygon::copy_vertices_to_texcoords()
     162{
     163    if (texcoords.size() > 0)
    158164        texcoords.clear();
    159165
    160     for (unsigned int i=0; i<vertices.size(); i++) {
     166    for (unsigned int i = 0; i < vertices.size(); i++) {
    161167        texcoords.push_back(vertices[i]);
    162168    }
    163169}
    164170
    165 void 
    166 ConvexPolygon::Emit(bool use_texture) 
     171void
     172ConvexPolygon::Emit(bool use_texture)
    167173{
    168174    if (vertices.size() >= 3) {
    169         for (unsigned int i = 0; i<vertices.size(); i++) {
     175        for (unsigned int i = 0; i < vertices.size(); i++) {
    170176            if(use_texture) {
    171177                glTexCoord4fv((float *)&(texcoords[i]));
     
    177183}
    178184
    179 
    180185void
    181 ConvexPolygon::Emit(bool use_texture, Vector3& shift, Vector3& scale)
     186ConvexPolygon::Emit(bool use_texture, const Vector3& shift, const Vector3& scale)
    182187{
    183188    if (vertices.size() >= 3) {
    184         for (unsigned int i = 0; i<vertices.size(); i++) {
    185             if(use_texture) {
     189        for (unsigned int i = 0; i < vertices.size(); i++) {
     190            if (use_texture) {
    186191                glTexCoord4fv((float *)&(vertices[i]));
    187192            }
  • trunk/packages/vizservers/nanovis/ConvexPolygon.h

    r2798 r2822  
    1717#define _CONVEX_POLYGON_H_
    1818
     19#include <assert.h>
     20#include <vector>
     21
    1922#include "Vector4.h"
    2023#include "Plane.h"
    21 #include <assert.h>
    22 #include <vector>
    2324
    2425typedef std::vector<Vector4> VertexVector;
    2526typedef std::vector<Vector4> TexVector;
    2627
    27 class ConvexPolygon {
     28class ConvexPolygon
     29{
    2830public:
    2931    VertexVector vertices;
    3032    TexVector texcoords;
    3133    int volume_id;      //which volume this polygon slice belongs to
    32    
    33     ConvexPolygon();
     34
     35    ConvexPolygon()
     36    {}
     37
    3438    ConvexPolygon(VertexVector vertices);
    35    
    36     void transform(Mat4x4 mat);
    37     void translate(Vector4 shift);
    38    
     39
     40    void transform(const Mat4x4& mat);
     41
     42    void translate(const Vector4& shift);
     43
    3944    // Clips the polygon, retaining the portion where ax + by + cz + d >= 0
    40     void clip(Plane &clipPlane, bool copy_to_texcoords);
     45    void clip(Plane& clipPlane, bool copy_to_texcoords);
     46
    4147    void Emit(bool use_texture);
    42     void Emit(bool use_texture, Vector3& shift, Vector3& scale);
     48
     49    void Emit(bool use_texture, const Vector3& shift, const Vector3& scale);
     50
    4351    void copy_vertices_to_texcoords();
    4452
    45     void set_id(int v_id) {
    46         volume_id = v_id;
    47     };
    48     void append_vertex(Vector4 vert) {
    49         vertices.push_back(vert);
     53    void set_id(int v_id)
     54    {
     55        volume_id = v_id;
    5056    }
    51     void insert_vertex(unsigned int index, Vector4 vert) {
    52         assert(index<vertices.size());
    53         vertices.insert(vertices.begin() + index, vert);
     57
     58    void append_vertex(const Vector4& vert)
     59    {
     60        vertices.push_back(vert);
    5461    }
    55     bool is_retained(Vector4 point, Vector4 plane) {
    56         return ((point * plane) >= 0); 
     62
     63    void insert_vertex(unsigned int index, const Vector4& vert)
     64    {
     65        assert(index<vertices.size());
     66        vertices.insert(vertices.begin() + index, vert);
     67    }
     68
     69    bool is_retained(const Vector4& point, const Vector4& plane)
     70    {
     71        return ((point * plane) >= 0); 
    5772    }
    5873};
  • trunk/packages/vizservers/nanovis/EventPlayer.cpp

    r2800 r2822  
    2525
    2626#include "clientlib.h"
    27 #include "../Event.h"
     27#include "Event.h"
    2828
    2929Event* event[300];
     
    4141void display()
    4242{
    43    //paste to screen
    44    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    45    glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);       
    46    glFlush();
    47    glutSwapBuffers();
    48    return;
     43    //paste to screen
     44    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     45    glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, screen_buffer);       
     46    glFlush();
     47    glutSwapBuffers();
     48    return;
    4949}
    5050*/
    5151
    52 
    5352void key(unsigned char key, int x, int y)
    5453{
    55     switch (key)
    56     {
    57         case 'q':
    58           exit(0);
    59           break;
    60         default:
    61           return;
    62     }
    63 }
    64 
     54    switch (key) {
     55    case 'q':
     56        exit(0);
     57        break;
     58    default:
     59        return;
     60    }
     61}
    6562
    6663/*
     
    6966void idle(void)
    7067{
    71   //send requests
    72 
    73   if (cur_event >= sizeof(event)/sizeof(event[0])) {
    74     float ave = interval_sum / (cur_event-1);
    75     float fps = 1/ave;
    76     TRACE("Average frame time = %.6f\n", ave);
    77     TRACE("Frames per second  = %f\n", fps);
    78     exit(0);
    79   }
    80 
    81   Event* cur = event[cur_event];
    82   std::stringstream msgstream;
    83   std::string msg;
    84 
    85   switch(cur->type){
     68    //send requests
     69
     70    if (cur_event >= (int)(sizeof(event)/sizeof(event[0]))) {
     71        float ave = interval_sum / (cur_event-1);
     72        float fps = 1/ave;
     73        TRACE("Average frame time = %.6f\n", ave);
     74        TRACE("Frames per second  = %f\n", fps);
     75        exit(0);
     76    }
     77
     78    Event *cur = event[cur_event];
     79    std::stringstream msgstream;
     80    std::string msg;
     81
     82    switch (cur->type){
    8683    case 0: //rotate
    87       msgstream << "camera " << cur->parameter[0] << " "
    88                     << cur->parameter[1] << " "
    89                     << cur->parameter[2] << " " << endl;
    90       break;
    91 
     84        msgstream << "camera " << cur->parameter[0] << " "
     85                  << cur->parameter[1] << " "
     86                  << cur->parameter[2] << " " << endl;
     87        break;
    9288    case 1: //move
    93       msgstream << "move " << cur->parameter[0] << " "
    94                     << cur->parameter[1] << " "
    95                     << cur->parameter[2] << " " << endl;
    96       break;
    97 
     89        msgstream << "move " << cur->parameter[0] << " "
     90                  << cur->parameter[1] << " "
     91                  << cur->parameter[2] << " " << endl;
     92        break;
    9893    case 2: //other
    99       msgstream << "refresh " << cur->parameter[0] << " "
    100                     << cur->parameter[1] << " "
    101                     << cur->parameter[2] << " " << endl;
    102       break;
    103 
     94        msgstream << "refresh " << cur->parameter[0] << " "
     95                  << cur->parameter[1] << " "
     96                  << cur->parameter[2] << " " << endl;
     97        break;
    10498    default:
    105       return;
    106   }
    107 
    108   msg = msgstream.str();
    109 
    110   //sleep a little
    111   struct timespec ts;
    112   ts.tv_sec = 0;
    113   ts.tv_nsec = cur->msec*1000000000;
    114   nanosleep(&ts, 0);
     99        return;
     100    }
     101
     102    msg = msgstream.str();
     103
     104    //sleep a little
     105    struct timespec ts;
     106    ts.tv_sec = 0;
     107    ts.tv_nsec = cur->msec*1000000000;
     108    nanosleep(&ts, 0);
    115109 
    116   //start timer
    117   struct timeval clock;
    118   gettimeofday(&clock, NULL);
    119   double start_time = clock.tv_sec + clock.tv_usec/1000000.0;
    120 
    121   //send msg
    122   //TRACE("Writing message %04d to server: '%s'\n", cur_event, msg.c_str());
    123   int status = write(socket_fd, msg.c_str(), strlen(msg.c_str()));
    124   if (status <= 0) {
    125      perror("socket write");
    126      return;
    127   }
     110    //start timer
     111    struct timeval clock;
     112    gettimeofday(&clock, NULL);
     113    double start_time = clock.tv_sec + clock.tv_usec/1000000.0;
     114
     115    //send msg
     116    //TRACE("Writing message %04d to server: '%s'\n", cur_event, msg.c_str());
     117    int status = write(socket_fd, msg.c_str(), strlen(msg.c_str()));
     118    if (status <= 0) {
     119        perror("socket write");
     120        return;
     121    }
    128122
    129123#if DO_RLE
    130   int sizes[2];
    131   status = read(socket_fd, &sizes, sizeof(sizes));
    132   TRACE("Reading %d,%d bytes\n", sizes[0], sizes[1]);
    133   int len = sizes[0] + sizes[1];
     124    int sizes[2];
     125    status = read(socket_fd, &sizes, sizeof(sizes));
     126    TRACE("Reading %d,%d bytes\n", sizes[0], sizes[1]);
     127    int len = sizes[0] + sizes[1];
    134128#else
    135   int len = width * height * 3;
     129    int len = width * height * 3;
    136130#endif
    137131
    138   //receive screen update
    139   int remain = len;
    140   char* ptr = screen_buffer;
    141   while(remain>0){
    142     status = read(socket_fd, ptr, remain);
    143     if(status <= 0) {
    144       perror("socket read");
    145       return;
    146     }
    147     else {
    148        remain -= status;
    149        ptr += status;
    150     }
    151   }
    152 
    153   //TRACE("Read message to server.\n");
    154 
    155   //end timer
    156   gettimeofday(&clock, NULL);
    157   double end_time = clock.tv_sec + clock.tv_usec/1000000.0;
    158 
    159   double time_interval = end_time - start_time;
    160 
    161   if (cur_event != 0) {
    162     interval_sum += time_interval;
    163   }
    164   cur_event++;
    165 
    166   TRACE("% 6d %.6f\n", len, time_interval);
    167 }
    168 
     132    //receive screen update
     133    int remain = len;
     134    char* ptr = screen_buffer;
     135    while (remain > 0) {
     136        status = read(socket_fd, ptr, remain);
     137        if (status <= 0) {
     138            perror("socket read");
     139            return;
     140        } else {
     141            remain -= status;
     142            ptr += status;
     143        }
     144    }
     145
     146    //TRACE("Read message to server.\n");
     147
     148    //end timer
     149    gettimeofday(&clock, NULL);
     150    double end_time = clock.tv_sec + clock.tv_usec/1000000.0;
     151
     152    double time_interval = end_time - start_time;
     153
     154    if (cur_event != 0) {
     155        interval_sum += time_interval;
     156    }
     157    cur_event++;
     158
     159    TRACE("% 6d %.6f\n", len, time_interval);
     160}
    169161
    170162int init_client(char* host, char* port, char* file){
    171163
    172   //load the event file
    173   FILE* fd = fopen(file, "r");
    174 
    175   //load events
    176   for(int i=0; i<sizeof(event)/sizeof(event[0]); i++){
    177     int type;
    178     float param[3];
    179     double interval;
    180     fscanf(fd, "%d %f %f %f %g\n", &type, param, param+1, param+2, &interval);
    181     event[i] = new Event(type, param, interval);
    182     TRACE("%d %f %f %f\n", type, param[0], param[1], param[2]);
    183   }
    184   fclose(fd);
    185 
    186   socket_fd = connect_renderer(host, atoi(port), 100);
    187   if (socket_fd == -1) {
    188       ERROR("Could not connect to a server.\n");
    189       return 1;
    190   }
    191 
    192   return 0;
     164    //load the event file
     165    FILE* fd = fopen(file, "r");
     166
     167    //load events
     168    for (int i = 0; i < (int)(sizeof(event)/sizeof(event[0])); i++) {
     169        int type;
     170        float param[3];
     171        double interval;
     172        fscanf(fd, "%d %f %f %f %lf\n", &type, param, param+1, param+2, &interval);
     173        event[i] = new Event(type, param, interval);
     174        TRACE("%d %f %f %f\n", type, param[0], param[1], param[2]);
     175    }
     176    fclose(fd);
     177
     178    socket_fd = connect_renderer(host, atoi(port), 100);
     179    if (socket_fd == -1) {
     180        ERROR("Could not connect to a server.\n");
     181        return 1;
     182    }
     183
     184    return 0;
    193185}
    194186
     
    205197{
    206198    //parameters: host and port and event file
    207     if(argc!=4) help(argv[0]);
     199    if (argc != 4)
     200        help(argv[0]);
    208201
    209202    assert(init_client(argv[1], argv[2], argv[3])==0);
    210203
    211 /*
    212     glutInit(&argc, argv);
    213     glutInitWindowSize(width,height);
    214     glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    215 
    216     glutCreateWindow("Client");
    217 
    218     glutDisplayFunc(display);
    219     glutKeyboardFunc(key);
    220     glutIdleFunc(idle);
    221 
    222     glClearColor(0.,0.,0.,0.);
    223     glutMainLoop();
    224 */
    225     while(1) idle();
     204    /*
     205      glutInit(&argc, argv);
     206      glutInitWindowSize(width,height);
     207      glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
     208
     209      glutCreateWindow("Client");
     210
     211      glutDisplayFunc(display);
     212      glutKeyboardFunc(key);
     213      glutIdleFunc(idle);
     214
     215      glClearColor(0.,0.,0.,0.);
     216      glutMainLoop();
     217    */
     218    while (1)
     219        idle();
    226220
    227221    return 0;
    228222}
    229 
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r2810 r2822  
    2525#include "nanovis.h"
    2626#include "CmdProc.h"
    27 #include "Nv.h"
    2827
    2928#include "NvLIC.h"
  • trunk/packages/vizservers/nanovis/Makefile.in

    r2820 r2822  
    101101CXX             = @CXX@
    102102CFLAGS          = @CFLAGS@
    103 EXTRA_CFLAGS    = -Wall
     103EXTRA_CFLAGS    = -Wall -Wextra
    104104DEFINES         =
    105105CXX_SWITCHES    = $(CFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES)
     
    121121                HeightMap.o \
    122122                Mat4x4.o \
    123                 Nv.o \
    124123                NvCamera.o \
    125124                NvColorTableRenderer.o \
     
    282281        $(MAKE) -C $(R2_DIR)/src clean
    283282        $(MAKE) -C $(IMG_DIR) clean
    284         $(RM) nanovis client $(OBJS)
     283        $(RM) nanovis client *.o
    285284
    286285distclean: clean
     
    300299Command.o: Command.cpp
    301300ContourLineFilter.o: ContourLineFilter.cpp ContourLineFilter.h
    302 ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h
     301ConvexPolygon.o: ConvexPolygon.cpp ConvexPolygon.h Vector4.h Mat4x4.h Plane.h
    303302DataLoader.o: DataLoader.cpp
    304303Event.o: Event.cpp Event.h
    305 FlowCmd.o: FlowCmd.cpp FlowCmd.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h Nv.h NvLIC.h Unirect.h
     304FlowCmd.o: FlowCmd.cpp FlowCmd.h Switch.h Trace.h TransferFunction.h nanovis.h CmdProc.h NvLIC.h Unirect.h
    306305GradientFilter.o: GradientFilter.cpp GradientFilter.h
    307306Grid.o: Grid.cpp Grid.h
    308307HeightMap.o: HeightMap.cpp HeightMap.h
    309308Mat4x4.o: Mat4x4.cpp Mat4x4.h
    310 Nv.o: Nv.cpp Nv.h NvShader.h NvParticleRenderer.h NvColorTableRenderer.h NvEventLog.h VolumeRenderer.h PointSetRenderer.h
    311309NvCamera.o: NvCamera.cpp NvCamera.h
    312310NvColorTableRenderer.o: NvColorTableRenderer.cpp NvColorTableRenderer.h
     
    330328PCASplit.o: PCASplit.cpp PCASplit.h
    331329PerfQuery.o: PerfQuery.cpp PerfQuery.h
    332 Plane.o: Plane.cpp Plane.h
     330Plane.o: Plane.cpp Plane.h Vector4.h Mat4x4.h
    333331PlaneRenderer.o: PlaneRenderer.cpp PlaneRenderer.h
    334332PointSet.o: PointSet.cpp PointSet.h
     
    353351VolumeRenderer.o: VolumeRenderer.cpp VolumeRenderer.h
    354352ZincBlendeVolume.o: ZincBlendeVolume.cpp ZincBlendeVolume.h $(AUXSRC)
    355 dxReader.o: dxReader.cpp dxReaderCommon.h Nv.h nanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h
     353dxReader.o: dxReader.cpp dxReaderCommon.h nanovis.h Unirect.h ZincBlendeVolume.h NvZincBlendeReconstructor.h
    356354dxReaderCommon.o: dxReaderCommon.cpp dxReaderCommon.h GradientFilter.h Vector3.h
    357355nanovis.o: nanovis.cpp nanovis.h $(AUXSRC)
  • trunk/packages/vizservers/nanovis/Mat4x4.cpp

    r2798 r2822  
    1414 * ======================================================================
    1515 */
     16#include <math.h>
     17
    1618#include "Mat4x4.h"
    17 #include <math.h>
    18 #include <stdio.h>
    19 #include <assert.h>
    2019
    21 Mat4x4::Mat4x4(float *vals) {
    22     int i;
    23     for (i=0;i<16;i++)
    24         m[i] = vals[i];
     20Mat4x4::Mat4x4(float *vals)
     21{
     22    for (int i = 0; i < 16; i++) {
     23        m[i] = vals[i];
     24    }
    2525}
    2626
    27 void
    28 Mat4x4::print(){
    29     TRACE("\n%f %f %f %f\n", m[0], m[1], m[2], m[3]);
     27void
     28Mat4x4::print() const
     29{
     30    TRACE("%f %f %f %f\n", m[0], m[1], m[2], m[3]);
    3031    TRACE("%f %f %f %f\n", m[4], m[5], m[6], m[7]);
    3132    TRACE("%f %f %f %f\n", m[8], m[9], m[10], m[11]);
    32     TRACE("%f %f %f %f\n\n", m[12], m[13], m[14], m[15]);
     33    TRACE("%f %f %f %f\n", m[12], m[13], m[14], m[15]);
    3334}
    3435
    35 Mat4x4
    36 Mat4x4::inverse(){
     36Mat4x4
     37Mat4x4::inverse() const
     38{
    3739    Mat4x4 p;
    38        
     40
    3941    float m00 = m[0], m01 = m[4], m02 = m[8], m03 = m[12];
    4042    float m10 = m[1], m11 = m[5], m12 = m[9], m13 = m[13];
     
    5153    float cof02 =  det33(m13, m10, m11, m23, m20, m21, m33, m30, m31);
    5254    float cof03 = -det33(m10, m11, m12, m20, m21, m22, m30, m31, m32);
    53    
     55
    5456    float cof10 = -det33(m21, m22, m23, m31, m32, m33, m01, m02, m03);
    5557    float cof11 =  det33(m22, m23, m20, m32, m33, m30, m02, m03, m00);
    5658    float cof12 = -det33(m23, m20, m21, m33, m30, m31, m03, m00, m01);
    5759    float cof13 =  det33(m20, m21, m22, m30, m31, m32, m00, m01, m02);
    58    
     60
    5961    float cof20 =  det33(m31, m32, m33, m01, m02, m03, m11, m12, m13);
    6062    float cof21 = -det33(m32, m33, m30, m02, m03, m00, m12, m13, m10);
    6163    float cof22 =  det33(m33, m30, m31, m03, m00, m01, m13, m10, m11);
    6264    float cof23 = -det33(m30, m31, m32, m00, m01, m02, m10, m11, m12);
    63    
     65
    6466    float cof30 = -det33(m01, m02, m03, m11, m12, m13, m21, m22, m23);
    6567    float cof31 =  det33(m02, m03, m00, m12, m13, m10, m22, m23, m20);
     
    103105    p.m[14] = cof32 * inv0;
    104106    p.m[15]= cof33 * inv0;     
    105        
     107
    106108    return p;
    107109}
    108110
    109 Vector4
    110 Mat4x4::multiply_row_vector(Vector4 v){
     111Vector4
     112Mat4x4::multiply_row_vector(const Vector4& v) const
     113{
    111114    Vector4 ret;
    112115    ret.x = (m[0]  * v.x) + (m[1]  * v.y) + (m[2]  * v.z) + (m[3]  * v.w);
     
    117120}
    118121
    119 Vector4
    120 Mat4x4::transform(Vector4 v){
     122Vector4
     123Mat4x4::transform(const Vector4& v) const
     124{
    121125    Vector4 ret;
    122126    ret.x = v.x*m[0]+v.y*m[4]+v.z*m[8]+v.w*m[12];
     
    128132
    129133Mat4x4
    130 Mat4x4::operator *(Mat4x4 mat){
     134Mat4x4::operator *(const Mat4x4& mat) const
     135{
    131136    Mat4x4 ret;
    132137   
     
    154159}
    155160
    156 Mat4x4
    157 Mat4x4::transpose(){
     161Mat4x4
     162Mat4x4::transpose() const
     163{
    158164    Mat4x4 ret;
    159     for(int i=0; i<4; i++){
    160         for(int j=0; j<4; j++){
    161             ret.m[j+4*i] = this->m[i+4*j];
    162         }
     165    for (int i = 0; i < 4; i++) {
     166        for (int j = 0; j < 4; j++) {
     167            ret.m[j+4*i] = this->m[i+4*j];
     168        }
    163169    }
    164170    return ret;
    165171}
    166 
    167 
  • trunk/packages/vizservers/nanovis/Mat4x4.h

    r2798 r2822  
    1919#include "Vector4.h"
    2020
    21 class Mat4x4 
     21class Mat4x4
    2222{
    23        
    2423public:
    2524    float m[16];        //row by row
    26     Mat4x4() {
    27         /*empty*/
    28     };
     25
     26    Mat4x4()
     27    {}
     28
    2929    Mat4x4(float *vals);
    3030
    31     void print(void);
    32     Mat4x4 inverse(void);
    33     Mat4x4 transpose(void);
    34     Vector4 multiply_row_vector(Vector4 v);
    35     Vector4 transform(Vector4 v);
    36     Mat4x4 operator*(Mat4x4 op);
     31    void print() const;
     32
     33    Mat4x4 inverse() const;
     34
     35    Mat4x4 transpose() const;
     36
     37    Vector4 multiply_row_vector(const Vector4& v) const;
     38
     39    Vector4 transform(const Vector4& v) const;
     40
     41    Mat4x4 operator*(const Mat4x4& op) const;
    3742};
    3843
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.cpp

    r2798 r2822  
    66#include "ZincBlendeVolume.h"
    77
    8 
    9 //#define _LOADER_DEBUG_
    10 
    11 NvZincBlendeReconstructor* NvZincBlendeReconstructor::_instance = NULL;
     8NvZincBlendeReconstructor *NvZincBlendeReconstructor::_instance = NULL;
    129
    1310NvZincBlendeReconstructor::NvZincBlendeReconstructor()
     
    1916}
    2017
    21 NvZincBlendeReconstructor* NvZincBlendeReconstructor::getInstance()
    22 {
    23     if (_instance == NULL)
    24     {
     18NvZincBlendeReconstructor *NvZincBlendeReconstructor::getInstance()
     19{
     20    if (_instance == NULL) {
    2521        return (_instance = new NvZincBlendeReconstructor());
    2622    }
     
    2925}
    3026
    31 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromFile(const char* fileName)
     27ZincBlendeVolume *NvZincBlendeReconstructor::loadFromFile(const char *fileName)
    3228{
    3329    Vector3 origin, delta;
     
    3632    stream.open(fileName, std::ios::binary);
    3733
    38     ZincBlendeVolume* volume = loadFromStream(stream);
     34    ZincBlendeVolume *volume = loadFromStream(stream);
    3935
    4036    stream.close();
     
    4339}
    4440
    45 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromStream(std::istream& stream)
    46 {
    47     ZincBlendeVolume* volume = 0;
     41ZincBlendeVolume *NvZincBlendeReconstructor::loadFromStream(std::istream& stream)
     42{
     43    ZincBlendeVolume *volume = NULL;
    4844    Vector3 origin, delta;
    4945    int width = 0, height = 0, depth = 0;
    50     void* data = NULL;
     46    void *data = NULL;
    5147    int version = 1;
    5248
     
    5450    do {
    5551        getLine(stream);
    56         if (buff[0] == '#')
    57         {
     52        if (buff[0] == '#') {
    5853            continue;
    59         }
    60         else if (strstr((const char*) buff, "object") != 0)
    61         {
    62 #ifdef _LOADER_DEBUG_
     54        } else if (strstr((const char*) buff, "object") != 0) {
    6355            TRACE("VERSION 1\n");
    64 #endif
    65            version = 1;
    66            break;
    67         }
    68         else if (strstr(buff, "record format") != 0)
    69         {
    70 #ifdef _LOADER_DEBUG_
     56            version = 1;
     57            break;
     58        } else if (strstr(buff, "record format") != 0) {
    7159            TRACE("VERSION 2\n");
    72 #endif
    73            version = 2;
    74            break;
    75         }
    76     } while(1);
    77 
     60            version = 2;
     61            break;
     62        }
     63    } while (1);
    7864
    7965    if (version == 1) {
    8066        float dummy;
    8167
    82         sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4],&width, &height, &depth);
     68        sscanf(buff, "%s%s%s%s%s%d%d%d", str[0], str[1], str[2], str[3], str[4], &width, &height, &depth);
    8369        getLine(stream);
    8470        sscanf(buff, "%s%f%f%f", str[0], &(origin.x), &(origin.y), &(origin.z));
     
    9177        do {
    9278            getLine(stream);
    93         } while(strcmp(buff, "<\\HDR>") != 0);
     79        } while (strcmp(buff, "<\\HDR>") != 0);
    9480
    9581        width = width / 4;
     
    9884        //data = new double[width * height * depth * 8 * 4];
    9985        data = malloc(width * height * depth * 8 * 4 * sizeof(double));
    100             // 8 atom per cell, 4 double (x, y, z, and probability) per atom
     86        // 8 atom per cell, 4 double (x, y, z, and probability) per atom
    10187        try {
    102             stream.read((char*) data, width * height * depth * 8 * 4 * sizeof(double));
    103         }
    104         catch (...)
    105         {
    106             TRACE("ERROR\n");
     88            stream.read((char *)data, width * height * depth * 8 * 4 * sizeof(double));
     89        } catch (...) {
     90            ERROR("Caught exception trying to read stream\n");
    10791        }
    10892
     
    11094
    11195        free(data);
    112     }
    113     else if (version == 2)
    114     {
    115         const char* pt;
     96    } else if (version == 2) {
     97        const char *pt;
    11698        int datacount;
    11799        double emptyvalue;
    118100        do {
    119101            getLine(stream);
    120             if ((pt = strstr(buff, "delta")) != 0)
    121             {   
     102            if ((pt = strstr(buff, "delta")) != 0) {
    122103                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    123104#ifdef _LOADER_DEBUG_
    124105                TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z);
    125106#endif
     107            } else if ((pt = strstr(buff, "datacount")) != 0) {
     108                sscanf(pt, "%s%d", str[0], &datacount);
     109#ifdef _LOADER_DEBUG_
     110                TRACE("datacount = %d\n", datacount);
     111#endif
     112            } else if ((pt = strstr(buff, "datatype")) != 0) {
     113                sscanf(pt, "%s%s", str[0], str[1]);
     114                if (strcmp(str[1], "double64")) {
     115                }
     116            } else if ((pt = strstr(buff, "count")) != 0) {
     117                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
     118#ifdef _LOADER_DEBUG_
     119                TRACE("width height depth %d %d %d\n", width, height, depth);
     120#endif
     121            } else if ((pt = strstr(buff, "emptymark")) != 0) {
     122                sscanf(pt, "%s%lf", str[0], &emptyvalue);
     123#ifdef _LOADER_DEBUG_
     124                TRACE("emptyvalue %lf\n", emptyvalue);
     125#endif
     126            } else if ((pt = strstr(buff, "emprymark")) != 0) {
     127                sscanf(pt, "%s%lf", str[0], &emptyvalue);
     128#ifdef _LOADER_DEBUG_
     129                TRACE("emptyvalue %lf\n", emptyvalue);
     130#endif
    126131            }
    127             else if ((pt = strstr(buff, "datacount")) != 0)
    128             {
    129                 sscanf(pt, "%s%d", str[0], &datacount);
    130 #ifdef _LOADER_DEBUG_
    131                 TRACE("datacount = %d\n", datacount);
    132 #endif
    133             }
    134             else if ((pt = strstr(buff, "datatype")) != 0)
    135             {
    136                 sscanf(pt, "%s%s", str[0], str[1]);
    137                 if (strcmp(str[1], "double64"))
    138                 {
    139                 }
    140             }
    141             else if ((pt = strstr(buff, "count")) != 0)
    142             {
    143                 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    144 #ifdef _LOADER_DEBUG_
    145                 TRACE("width height depth %d %d %d\n", width, height, depth);
    146 #endif
    147             }
    148             else if ((pt = strstr(buff, "emptymark")) != 0)
    149             {
    150                 sscanf(pt, "%s%lf", str[0], &emptyvalue);
    151 #ifdef _LOADER_DEBUG_
    152                 TRACE("empryvalue %lf\n", emptyvalue);
    153 #endif
    154             }
    155             else if ((pt = strstr(buff, "emprymark")) != 0)
    156             {
    157                 sscanf(pt, "%s%lf", str[0], &emptyvalue);
    158 #ifdef _LOADER_DEBUG_
    159                 TRACE("emptyvalue %lf\n", emptyvalue);
    160 #endif
    161             }
    162         } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
     132        } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
    163133
    164134        data = malloc(width * height * depth * 8 * 4 * sizeof(double));
    165135        memset(data, 0, width * height * depth * 8 * 4 * sizeof(double));
    166         stream.read((char*) data, width * height * depth * 8 * 4 * sizeof(double));
     136        stream.read((char *) data, width * height * depth * 8 * 4 * sizeof(double));
    167137
    168138        volume =  buildUp(origin, delta, width, height, depth, datacount, emptyvalue, data);
     
    186156        // ,i.e. four atoms are mapped into RGBA component of one texel
    187157        //return ((int) (indexZ - 1)+ (int) (indexX - 1) * width + (int) (indexY - 1) * width * height) * 4;
    188         return ((int) (indexX - 1)+ (int) (indexY - 1) * width + (int) (indexZ - 1) * width * height) * 4;
     158        return ((int)(indexX - 1) + (int)(indexY - 1) * width + (int)(indexZ - 1) * width * height) * 4;
    189159    }
    190160};
    191161
    192 
    193 template<class T>
    194 inline T _NvMax2(T a, T b) { return ((a >= b)? a : b); }
    195 
    196 template<class T>
    197 inline T _NvMin2(T a, T b) { return ((a >= b)? a : b); }
    198 
    199 template<class T>
    200 inline T _NvMax3(T a, T b, T c) { return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); }
    201 
    202 template<class T>
    203 inline T _NvMin3(T a, T b, T c) { return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); }
    204 
    205 template<class T>
    206 inline T _NvMax9(T* a, T curMax) { return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); }
    207 
    208 template<class T>
    209 inline T _NvMin9(T* a, T curMax) { return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); }
    210 
    211 template<class T>
    212 inline T _NvMax4(T* a) { return _NvMax2(_NvMax2(a[0], a[1]), _NvMax2(a[2], a[3])); }
    213 
    214 template<class T>
    215 inline T _NvMin4(T* a) { return _NvMin2(_NvMin2(a[0], a[1]), _NvMin2(a[2], a[3])); }
    216 
    217 
    218 ZincBlendeVolume*
     162template<class T>
     163inline T _NvMax2(T a, T b)
     164{ return ((a >= b)? a : b); }
     165
     166template<class T>
     167inline T _NvMin2(T a, T b)
     168{ return ((a >= b)? a : b); }
     169
     170template<class T>
     171inline T _NvMax3(T a, T b, T c)
     172{ return ((a >= b)? ((a >= c) ? a : c) : ((b >= c)? b : c)); }
     173
     174template<class T>
     175inline T _NvMin3(T a, T b, T c)
     176{ return ((a <= b)? ((a <= c) ? a : c) : ((b <= c)? b : c)); }
     177
     178template<class T>
     179inline T _NvMax9(T* a, T curMax)
     180{ return _NvMax3(_NvMax3(a[0], a[1], a[2]), _NvMax3(a[3], a[4], a[5]), _NvMax3(a[6], a[7], curMax)); }
     181
     182template<class T>
     183inline T _NvMin9(T* a, T curMax)
     184{ return _NvMin3(_NvMax3(a[0], a[1], a[2]), _NvMin3(a[3], a[4], a[5]), _NvMin3(a[6], a[7], curMax)); }
     185
     186template<class T>
     187inline T _NvMax4(T* a)
     188{ return _NvMax2(_NvMax2(a[0], a[1]), _NvMax2(a[2], a[3])); }
     189
     190template<class T>
     191inline T _NvMin4(T* a)
     192{ return _NvMin2(_NvMin2(a[0], a[1]), _NvMin2(a[2], a[3])); }
     193
     194ZincBlendeVolume *
    219195NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta,
    220         int width, int height, int depth, void* data)
    221 {
    222     ZincBlendeVolume* zincBlendeVolume = NULL;
     196                                   int width, int height, int depth, void* data)
     197{
     198    ZincBlendeVolume *zincBlendeVolume = NULL;
    223199
    224200    float *fourAnionVolume, *fourCationVolume;
     
    227203    fourCationVolume = new float[cellCount * sizeof(float) * 4];
    228204
    229     _NvAtomInfo* srcPtr = (_NvAtomInfo*) data;
     205    _NvAtomInfo *srcPtr = (_NvAtomInfo *)data;
    230206
    231207    float vmin, vmax, nzero_min;
    232     float* component4A, *component4B;
     208    float *component4A, *component4B;
    233209    int index;
    234210
     
    236212    vmin = vmax = srcPtr->atom;
    237213
    238     int i;
    239     for (i = 0; i < cellCount; ++i)
    240     {
     214    for (int i = 0; i < cellCount; ++i) {
    241215        index = srcPtr->getIndex(width, height);
    242216
     
    248222        component4B = fourCationVolume + index;
    249223
    250         component4A[0] = (float) srcPtr->atom; srcPtr++;
    251         component4A[1] = (float) srcPtr->atom; srcPtr++;
    252         component4A[2] = (float) srcPtr->atom; srcPtr++;
    253         component4A[3] = (float) srcPtr->atom; srcPtr++;
     224        component4A[0] = (float)srcPtr->atom; srcPtr++;
     225        component4A[1] = (float)srcPtr->atom; srcPtr++;
     226        component4A[2] = (float)srcPtr->atom; srcPtr++;
     227        component4A[3] = (float)srcPtr->atom; srcPtr++;
    254228     
    255         component4B[0] = (float) srcPtr->atom; srcPtr++;
    256         component4B[1] = (float) srcPtr->atom; srcPtr++;
    257         component4B[2] = (float) srcPtr->atom; srcPtr++;
    258         component4B[3] = (float) srcPtr->atom; srcPtr++;
     229        component4B[0] = (float)srcPtr->atom; srcPtr++;
     230        component4B[1] = (float)srcPtr->atom; srcPtr++;
     231        component4B[2] = (float)srcPtr->atom; srcPtr++;
     232        component4B[3] = (float)srcPtr->atom; srcPtr++;
    259233
    260234        vmax = _NvMax3(_NvMax4(component4A), _NvMax4(component4B), vmax);
    261235        vmin = _NvMin3(_NvMin4(component4A), _NvMin4(component4B), vmin);
    262236
    263         if (vmin != 0.0 && vmin < nzero_min)
    264         {
    265             nzero_min = vmin;   
     237        if (vmin != 0.0 && vmin < nzero_min) {
     238            nzero_min = vmin;
    266239        }
    267240    }
    268241
    269242    double dv = vmax - vmin;
    270     if (vmax != 0.0f)
    271     {
    272         for (i=0; i < cellCount; ++i)
    273         {
     243    if (vmax != 0.0f) {
     244        for (int i = 0; i < cellCount; ++i) {
    274245            fourAnionVolume[i] = (fourAnionVolume[i] - vmin)/ dv;
    275246            fourCationVolume[i] = (fourCationVolume[i] - vmin) / dv;
     
    290261}
    291262
    292 ZincBlendeVolume* NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, int datacount, double emptyvalue, void* data)
    293 {
    294     ZincBlendeVolume* zincBlendeVolume = NULL;
     263ZincBlendeVolume *
     264NvZincBlendeReconstructor::buildUp(const Vector3& origin, const Vector3& delta,
     265                                   int width, int height, int depth,
     266                                   int datacount, double emptyvalue, void* data)
     267{
     268    ZincBlendeVolume *zincBlendeVolume = NULL;
    295269    float *fourAnionVolume, *fourCationVolume;
    296270    int size = width * height * depth * 4;
     
    301275    memset(fourCationVolume, 0, size * sizeof(float));
    302276
    303     _NvAtomInfo* srcPtr = (_NvAtomInfo*) data;
    304 
    305     float* component4A, *component4B;
     277    _NvAtomInfo *srcPtr = (_NvAtomInfo *) data;
     278
     279    float *component4A, *component4B;
    306280    float vmin, vmax, nzero_min;
    307281    int index;
    308282    nzero_min = 1e23f;
    309283    vmin = vmax = srcPtr->atom;
    310     int i;
    311     for (i = 0; i < datacount; ++i)
    312     {
    313 
     284    for (int i = 0; i < datacount; ++i) {
    314285        index = srcPtr->getIndex(width, height);
    315286
     
    342313        vmin = _NvMin3(_NvMin4(component4A), _NvMin4(component4B), vmin);
    343314
    344         if (vmin != 0.0 && vmin < nzero_min)
    345         {
     315        if (vmin != 0.0 && vmin < nzero_min) {
    346316            nzero_min = vmin;   
    347317        }
    348 
    349318    }
    350319
    351320    double dv = vmax - vmin;
    352     if (vmax != 0.0f)
    353     {
    354         for (i=0; i < datacount; ++i)
    355         {
     321    if (vmax != 0.0f) {
     322        for (int i = 0; i < datacount; ++i) {
    356323            fourAnionVolume[i] = (fourAnionVolume[i] - vmin)/ dv;
    357324            fourCationVolume[i] = (fourCationVolume[i] - vmin) / dv;
     
    380347        if (ch == '\n') break;
    381348        buff[index++] = ch;
    382         if (ch == '>')
    383         {
     349        if (ch == '>') {
    384350            if (buff[1] == '\\')
    385351                break;
     
    394360}
    395361
    396 ZincBlendeVolume* NvZincBlendeReconstructor::loadFromMemory(void* dataBlock)
    397 {
    398     ZincBlendeVolume* volume = 0;
     362ZincBlendeVolume *
     363NvZincBlendeReconstructor::loadFromMemory(void *dataBlock)
     364{
     365    ZincBlendeVolume *volume = NULL;
    399366    Vector3 origin, delta;
    400367    int width = 0, height = 0, depth = 0;
    401     void* data = NULL;
     368    void *data = NULL;
    402369    int version = 1;
    403370
    404     unsigned char* stream = (unsigned char*)dataBlock;
     371    unsigned char *stream = (unsigned char *)dataBlock;
    405372    char str[5][20];
    406373    do {
    407374        getLine(stream);
    408         if (buff[0] == '#')
    409         {
     375        if (buff[0] == '#') {
    410376            continue;
    411         }
    412         else if (strstr((const char*) buff, "object") != 0)
    413         {
     377        } else if (strstr((const char *)buff, "object") != 0) {
    414378            TRACE("VERSION 1\n");
    415            version = 1;
    416            break;
    417         }
    418         else if (strstr(buff, "record format") != 0)
    419         {
     379            version = 1;
     380            break;
     381        } else if (strstr(buff, "record format") != 0) {
    420382            TRACE("VERSION 2\n");
    421            version = 2;
    422            break;
    423         }
    424     } while(1);
    425 
    426 
    427     if (version == 1)
    428     {
     383            version = 2;
     384            break;
     385        }
     386    } while (1);
     387
     388    if (version == 1) {
    429389        float dummy;
    430390
     
    440400        do {
    441401            getLine(stream);
    442         } while(strcmp(buff, "<\\HDR>") != 0);
     402        } while (strcmp(buff, "<\\HDR>") != 0);
    443403
    444404        width = width / 4;
     
    446406        depth = depth / 4;
    447407        data = malloc(width * height * depth * 8 * 4 * sizeof(double));
    448             // 8 atom per cell, 4 double (x, y, z, and probability) per atom
    449         try {
    450             memcpy(data, stream, width * height * depth * 8 * 4 * sizeof(double));
    451         }
    452         catch (...)
    453         {
    454             TRACE("ERROR\n");
    455         }
     408        // 8 atom per cell, 4 double (x, y, z, and probability) per atom
     409        memcpy(data, stream, width * height * depth * 8 * 4 * sizeof(double));
    456410
    457411        volume = buildUp(origin, delta, width, height, depth, data);
    458412
    459413        free(data);
    460     }
    461     else if (version == 2)
    462     {
    463         const char* pt;
     414    } else if (version == 2) {
     415        const char *pt;
    464416        int datacount = -1;
    465417        double emptyvalue;
    466418        do {
    467419            getLine(stream);
    468             if ((pt = strstr(buff, "delta")) != 0)
    469             {   
     420            if ((pt = strstr(buff, "delta")) != 0) {   
    470421                sscanf(pt, "%s%f%f%f", str[0], &(delta.x), &(delta.y), &(delta.z));
    471422#ifdef _LOADER_DEBUG_
    472423                TRACE("delta : %f %f %f\n", delta.x, delta.y, delta.z);
    473424#endif
    474             }
    475             else if ((pt = strstr(buff, "datacount")) != 0)
    476             {
     425            } else if ((pt = strstr(buff, "datacount")) != 0) {
    477426                sscanf(pt, "%s%d", str[0], &datacount);
    478427                TRACE("datacount = %d\n", datacount);
     428            } else if ((pt = strstr(buff, "datatype")) != 0) {
     429                sscanf(pt, "%s%s", str[0], str[1]);
     430                if (strcmp(str[1], "double64")) {
     431                }
     432            } else if ((pt = strstr(buff, "count")) != 0) {
     433                sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
     434#ifdef _LOADER_DEBUG_
     435                TRACE("width height depth %d %d %d\n", width, height, depth);
     436#endif
     437            } else if ((pt = strstr(buff, "emptymark")) != 0) {
     438                sscanf(pt, "%s%lf", str[0], &emptyvalue);
     439#ifdef _LOADER_DEBUG_
     440                TRACE("emptyvalue %lf\n", emptyvalue);
     441#endif
     442            } else if ((pt = strstr(buff, "emprymark")) != 0) {
     443                sscanf(pt, "%s%lf", str[0], &emptyvalue);
     444#ifdef _LOADER_DEBUG_
     445                TRACE("emptyvalue %lf\n", emptyvalue);
     446#endif
    479447            }
    480             else if ((pt = strstr(buff, "datatype")) != 0)
    481             {
    482                 sscanf(pt, "%s%s", str[0], str[1]);
    483                 if (strcmp(str[1], "double64"))
    484                 {
    485                 }
    486             }
    487             else if ((pt = strstr(buff, "count")) != 0)
    488             {
    489                 sscanf(pt, "%s%d%d%d", str[0], &width, &height, &depth);
    490 #ifdef _LOADER_DEBUG_
    491                 TRACE("width height depth %d %d %d\n", width, height, depth);
    492 #endif
    493             }
    494             else if ((pt = strstr(buff, "emptymark")) != 0)
    495             {
    496                 sscanf(pt, "%s%lf", str[0], &emptyvalue);
    497 #ifdef _LOADER_DEBUG_
    498                 TRACE("empryvalue %lf\n", emptyvalue);
    499 #endif
    500             }
    501             else if ((pt = strstr(buff, "emprymark")) != 0)
    502             {
    503                 sscanf(pt, "%s%lf", str[0], &emptyvalue);
    504 #ifdef _LOADER_DEBUG_
    505                 TRACE("emptyvalue %lf\n", emptyvalue);
    506 #endif
    507             }
    508         } while(strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
     448        } while (strcmp(buff, "<\\HDR>") != 0 && strcmp(buff, "</HDR>") != 0);
    509449
    510450        if (datacount == -1) datacount = width * height * depth;
     
    530470        if (ch == '\n') break;
    531471        buff[index++] = ch;
    532         if (ch == '>')
    533         {
     472        if (ch == '>') {
    534473            if (buff[1] == '\\')
    535474                break;
  • trunk/packages/vizservers/nanovis/NvZincBlendeReconstructor.h

    r2798 r2822  
    1414 * ======================================================================
    1515 */
    16 
    1716#ifndef __NV_ZINC_BLENDE_RECONSTRUCTOR_H__
    1817#define __NV_ZINC_BLENDE_RECONSTRUCTOR_H__
     
    2726class ZincBlendeVolume;
    2827
    29 class NvZincBlendeReconstructor {
     28class NvZincBlendeReconstructor
     29{
    3030    char buff[255];
    3131
     
    3434     */
    3535    static NvZincBlendeReconstructor* _instance;
    36 private :
     36private:
    3737    /**
    3838     * @brief Constructor
     
    4545    ~NvZincBlendeReconstructor();
    4646
    47 public :
     47public:
    4848    /**
    4949     * @brief Return a singleton instance
     
    5151    static NvZincBlendeReconstructor* getInstance();
    5252
    53 private :
     53private:
    5454    /**
    5555     * @brief Get a line from file. It is used for reading header because header is written in ascii.
     
    5858    void getLine(std::istream& stream);
    5959    void getLine(unsigned char*& stream);
    60    
    61 public :
     60
     61public:
    6262    /**
    6363     * @brief Load Zinc blende binary volume data and create ZincBlendeVolume with the file
    6464     * @param fileName Zinc blende file name, which data is generated by NEMO-3D
    6565     */
    66     ZincBlendeVolume* loadFromFile(const char* fileName);
     66    ZincBlendeVolume *loadFromFile(const char* fileName);
    6767
    6868    /**
     
    7070     * @param data Zinc blende binary volume data, which data is generated by NEMO-3D and transferred from nanoscale
    7171     */
    72     ZincBlendeVolume* loadFromStream(std::istream& stream);
    73     ZincBlendeVolume* loadFromMemory(void* dataBlock);
     72    ZincBlendeVolume *loadFromStream(std::istream& stream);
     73    ZincBlendeVolume *loadFromMemory(void *dataBlock);
    7474
    7575    /**
     
    8282     * @param data the memory block of output data of NEMO-3D
    8383     */
    84     ZincBlendeVolume* buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, void* data);
    85     ZincBlendeVolume* buildUp(const Vector3& origin, const Vector3& delta, int width, int height, int depth, int datacount, double emptyvalue, void* data);
     84    ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
     85                              int width, int height, int depth, void *data);
     86    ZincBlendeVolume *buildUp(const Vector3& origin, const Vector3& delta,
     87                              int width, int height, int depth,
     88                              int datacount, double emptyvalue, void *data);
    8689};
    8790
    8891#endif
    89 
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp

    r2798 r2822  
    33#include <string.h>
    44#include "global.h"
    5 #include "Nv.h"
    65#include "NvZincBlendeVolumeShader.h"
    76
  • trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h

    r2798 r2822  
    33#define __NV_ZINCBLENDE_SHADER_H__
    44
    5 #include "Nv.h"
    65#include "ZincBlendeVolume.h"
    76#include "NvVolumeShader.h"
  • trunk/packages/vizservers/nanovis/PCASplit.cpp

    r2798 r2822  
    141141    }
    142142    if (count != i) {
    143         TRACE("ERROR\n");
     143        ERROR("Problem walking clusterList: count: %d, i: %d\n", count, i);
    144144    }
    145145    return clusterBlock;
  • trunk/packages/vizservers/nanovis/ParticleSystemFactory.cpp

    r2818 r2822  
    150150            if (index == -1) {
    151151                index = path.rfind('\\');
    152                 if (index == -1)
     152                if (index == -1) {
    153153                    TRACE("file not found\n");
     154                }
    154155            }
    155156
  • trunk/packages/vizservers/nanovis/PerfQuery.h

    r2798 r2822  
    1616 * ======================================================================
    1717 */
    18 
    1918#ifndef _PERFQUERY_H_
    2019#define _PERFQUERY_H_
    2120
    2221#include <stdio.h>
    23 #include "Trace.h"
     22
    2423#include <GL/glew.h>
    2524
     25#include "Trace.h"
    2626#include "define.h"
    2727
     
    3232    glGetQueryivARB(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
    3333                    &bitsSupported);
    34     if(bitsSupported == 0) {
    35         INFO("occlusion query not supported!\n");
     34    if (bitsSupported == 0) {
     35        TRACE("occlusion query not supported!\n");
    3636        return false;
    3737    } else {
    38         INFO("Occlusion query with %d bits supported\n", bitsSupported);
     38        TRACE("Occlusion query with %d bits supported\n", bitsSupported);
    3939        return true;
    4040    }
     
    4343class PerfQuery
    4444{
    45 
    4645public:
    4746    GLuint id;
     
    5150    ~PerfQuery();
    5251   
    53     void enable(void);  //start counting how many pixels are rendered
    54     void disable(void); //stop counting
     52    void enable();      //start counting how many pixels are rendered
     53    void disable();     //stop counting
    5554
    56     void reset(void) {
     55    void reset()
     56    {
    5757        pixel = 0;
    5858    }
    59     int get_pixel_count(void) {
     59
     60    int get_pixel_count()
     61    {
    6062        return pixel;           //return current pixel count
    6163    }
    6264};
    6365
    64 
    65 
    6666#endif
    6767
  • trunk/packages/vizservers/nanovis/Plane.cpp

    r2798 r2822  
    1515 */
    1616#include <assert.h>
     17
    1718#include "Plane.h"
    1819
    19 Plane::Plane(float _a, float _b, float _c, float _d) {
    20     this->a = _a;
    21     this->b = _b;
    22     this->c = _c;
    23     this->d = _d;
    24 
     20Plane::Plane(float _a, float _b, float _c, float _d) :
     21    a(_a),
     22    b(_b),
     23    c(_c),
     24    d(_d)
     25{
    2526    assert(a != 0 || b != 0 || c != 0);
    2627}
    2728
    28 Plane::Plane(float coeffs[4]) {
     29Plane::Plane(float coeffs[4])
     30{
    2931    a = coeffs[0];
    3032    b = coeffs[1];
     
    3537}
    3638
    37 
    38 void
    39 Plane::transform(Mat4x4 mat) {
     39void
     40Plane::transform(const Mat4x4& mat)
     41{
    4042    Vector4 coeffs(a, b, c, d);
    4143
     
    4850}
    4951
    50 void
    51 Plane::get_point(Vector3 &point){
    52     if (a != 0) {
    53         point.x = -d/a;
    54         point.y = 0;
    55         point.z = 0;
     52void
     53Plane::get_point(Vector3& point)
     54{
     55    if (a != 0) {
     56        point.x = -d/a;
     57        point.y = 0;
     58        point.z = 0;
    5659    } else if (b != 0) {
    57         point.y = -d/b;
    58         point.x = 0;
    59         point.z = 0;
     60        point.y = -d/b;
     61        point.x = 0;
     62        point.z = 0;
    6063    } else if (c != 0) {
    61         point.z = -d /c;
    62         point.y = 0;
    63         point.x = 0;
    64     } else{
    65         assert(false);
     64        point.z = -d /c;
     65        point.y = 0;
     66        point.x = 0;
     67    } else {
     68        assert(false);
    6669    }
    6770}
  • trunk/packages/vizservers/nanovis/Plane.h

    r2798 r2822  
    2020#include "Mat4x4.h"
    2121
    22 class Plane {
     22class Plane
     23{
    2324    float a, b, c, d;
    2425public:
    25        
     26
    2627    Plane(float a, float b, float c, float d);
     28
    2729    Plane(float coeffs[4]);
    28     Plane(void) {
    29         /*empty*/
    30     };
    31    
    32     void get_point(Vector3 &point);
     30
     31    Plane()
     32    {}
     33
     34    void get_point(Vector3& point);
     35
    3336    //bool clips(float point[3]) const { return !retains(point); }
    3437
    35     void transform(Mat4x4 mat);
    36     void transform(float *m) {
    37         Mat4x4 mat(m);
    38         transform(mat);
     38    void transform(const Mat4x4& mat);
     39
     40    void transform(float *m)
     41    {
     42        Mat4x4 mat(m);
     43        transform(mat);
    3944    }
    40     bool retains(Vector3 point) {
     45
     46    bool retains(const Vector3& point) const
     47    {
    4148        return ((a*point.x + b*point.y + c*point.z + d) >= 0);
    4249    }
    43     Vector4 get_coeffs(void) {
    44         return Vector4(a, b, c, d);
     50
     51    Vector4 get_coeffs() const
     52    {
     53        return Vector4(a, b, c, d);
    4554    }
    46     void set_coeffs(float a_val, float b_val, float c_val, float d_val) {
    47         a = a_val, b = b_val, c = c_val, d = d_val;
     55
     56    void set_coeffs(float a_val, float b_val, float c_val, float d_val)
     57    {
     58        a = a_val, b = b_val, c = c_val, d = d_val;
    4859    }
    49     void get_normal(Vector3 &normal) {
    50         normal.x = a;
    51         normal.y = b;
    52         normal.z = c;
     60
     61    void get_normal(Vector3& normal) const
     62    {
     63        normal.x = a;
     64        normal.y = b;
     65        normal.z = c;
    5366    }
    5467};
  • trunk/packages/vizservers/nanovis/PlaneRenderer.cpp

    r2800 r2822  
    1919#include "Trace.h"
    2020
    21 PlaneRenderer::PlaneRenderer(CGcontext _context, int _width, int _height):
     21PlaneRenderer::PlaneRenderer(CGcontext _context, int _width, int _height) :
    2222    active_plane(-1),
    2323    n_planes(0),
  • trunk/packages/vizservers/nanovis/PlaneRenderer.h

    r2800 r2822  
    1919#include <GL/glew.h>
    2020#include <Cg/cgGL.h>
    21 #include <GL/glut.h>
     21
    2222#include <math.h>
    2323#include <stdio.h>
     
    2626#include <vector>
    2727
    28 #include "define.h"
    2928#include "global.h"
    3029#include "TransferFunction.h"
  • trunk/packages/vizservers/nanovis/PointSetRenderer.cpp

    r2798 r2822  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include "Nv.h"
    3 #include <GL/gl.h>
    4 #include "PointSetRenderer.h"
    5 #include <PCASplit.h>
     2#include <GL/glew.h>
     3
    64#include <Image.h>
    75#include <ImageLoaderFactory.h>
    86#include <ImageLoader.h>
    9 #include <stdio.h>
    107#include <R2/R2FilePath.h>
     8
     9#include "PointSetRenderer.h"
     10#include "PCASplit.h"
    1111
    1212#define USE_TEXTURE
  • trunk/packages/vizservers/nanovis/PointShader.h

    r2798 r2822  
    33#define __POINTSHADER_H__
    44
    5 #include "Nv.h"
    65#include "NvShader.h"
    76#include "Texture3D.h"
  • trunk/packages/vizservers/nanovis/ScreenSnapper.cpp

    r2798 r2822  
    3636    n_channels_per_pixel = channel_per_pixel;
    3737
    38     if(type == GL_FLOAT)
     38    if (type == GL_FLOAT)
    3939        data = new float[w*h*channel_per_pixel];
    40     else if(type == GL_UNSIGNED_BYTE)
     40    else if (type == GL_UNSIGNED_BYTE)
    4141        data = new unsigned char[w*h*channel_per_pixel];
    4242 
    43     assert(data!=0);
     43    assert(data != 0);
    4444    reset(0);   //reset data
    4545}
     
    4747ScreenSnapper::~ScreenSnapper()
    4848{
    49     if(data_type == GL_FLOAT)
     49    if (data_type == GL_FLOAT)
    5050        delete[] (float*)data;
    5151    else if(data_type == GL_UNSIGNED_BYTE)
     
    6161        elemSize = sizeof(float);
    6262        break;
    63 
    6463    case GL_UNSIGNED_BYTE:
    6564        elemSize = sizeof(unsigned char);
    6665        break;
    67 
    6866    default:
    6967        assert(0);
     
    7876ScreenSnapper::capture()
    7977{
    80     if(data_type == GL_FLOAT){
    81         if(n_channels_per_pixel==3)
     78    if (data_type == GL_FLOAT) {
     79        if (n_channels_per_pixel == 3)
    8280            glReadPixels(0, 0, width, height, GL_RGB, GL_FLOAT, data);
    83         else if(n_channels_per_pixel==4)
     81        else if (n_channels_per_pixel == 4)
    8482            glReadPixels(0, 0, width, height, GL_RGBA, GL_FLOAT, data);
    85     }
    86     else if(data_type == GL_UNSIGNED_BYTE){
    87         if(n_channels_per_pixel==3)
     83    } else if (data_type == GL_UNSIGNED_BYTE) {
     84        if (n_channels_per_pixel == 3)
    8885            glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
    89         else if(n_channels_per_pixel==4)
     86        else if (n_channels_per_pixel == 4)
    9087            glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
    9188    }
    92     assert(glGetError()==0);
     89    assert(glGetError() == 0);
    9390}
    9491
    95 void 
     92void
    9693ScreenSnapper::print()
    9794{
    98     for(int i=0; i<width*height; i++){
    99         if(data_type == GL_FLOAT){
    100             if(n_channels_per_pixel==3)
     95    for (int i = 0; i < width*height; i++) {
     96        if (data_type == GL_FLOAT) {
     97            if (n_channels_per_pixel == 3) {
    10198                TRACE("(%f %f %f) ", ((float*)data)[3*i],
    102                        ((float*)data)[3*i+1], ((float*)data)[3*i+2]);
    103             else if(n_channels_per_pixel==4)
     99                      ((float*)data)[3*i+1], ((float*)data)[3*i+2]);
     100            } else if (n_channels_per_pixel==4) {
    104101                TRACE("(%f %f %f %f) ", ((float*)data)[4*i],
    105102                      ((float*)data)[4*i+1],
    106103                      ((float*)data)[4*i+2],
    107                        ((float*)data)[4*i+3]);
    108         }
    109         else if(data_type == GL_UNSIGNED_BYTE){
    110             if(n_channels_per_pixel==3)
     104                      ((float*)data)[4*i+3]);
     105            }
     106        } else if (data_type == GL_UNSIGNED_BYTE) {
     107            if (n_channels_per_pixel==3) {
    111108                TRACE("(%d %d %d) ",
    112                         ((unsigned char*)data)[3*i],
    113                         ((unsigned char*)data)[3*i+1],
    114                        ((unsigned char*)data)[3*i+2]);
    115             else if(n_channels_per_pixel==4)
     109                      ((unsigned char*)data)[3*i],
     110                      ((unsigned char*)data)[3*i+1],
     111                      ((unsigned char*)data)[3*i+2]);
     112            } else if (n_channels_per_pixel == 4) {
    116113                TRACE("(%d %d %d %d) ",
    117                         ((unsigned char*)data)[4*i],
    118                         ((unsigned char*)data)[4*i+1],
    119                         ((unsigned char*)data)[4*i+2],
    120                        ((unsigned char*)data)[4*i+3]);
     114                      ((unsigned char*)data)[4*i],
     115                      ((unsigned char*)data)[4*i+1],
     116                      ((unsigned char*)data)[4*i+2],
     117                      ((unsigned char*)data)[4*i+3]);
     118            }
    121119        }
    122120    }
  • trunk/packages/vizservers/nanovis/Sphere.cpp

    r2798 r2822  
    1616
    1717#include "Sphere.h"
    18 #include <stdio.h>
    1918
    2019Sphere::Sphere(float x, float y, float z,
     
    2221               float _radius,
    2322               int _stack,
    24                int _slice):
     23               int _slice) :
    2524    Renderable(Vector3(x, y, z)),
    2625    radius(_radius),
     
    3231}
    3332
    34 Sphere::~Sphere() {
    35     /*empty*/
     33Sphere::~Sphere()
     34{
    3635}
    3736
     
    3938Sphere::render()
    4039{
    41     /*empty*/
    4240}
    4341
  • trunk/packages/vizservers/nanovis/Sphere.h

    r2798 r2822  
    1818#define _SPHERE_H_
    1919
     20#include <GL/glew.h>
     21#include <GL/glu.h>
     22
    2023#include "Trace.h"
    21 #include <GL/glut.h>
    2224
    2325#include "Color.h"
    2426#include "Renderable.h"
    2527
    26 class Sphere : public Renderable{
    27 
     28class Sphere : public Renderable
     29{
    2830public:
    2931    float radius;
     
    3234    int slice;
    3335
    34     ~Sphere();
    3536    Sphere(float x, float y, float z, float r, float g, float b, float _radius,
    3637           int _stack, int _slice);
     38
     39    virtual ~Sphere();
     40
    3741    void set_vertical_res(int _stack);
    3842    void set_horizontal_res(int _slice);
  • trunk/packages/vizservers/nanovis/Trace.cpp

    r2798 r2822  
    66
    77#include <GL/glew.h>
    8 #include <GL/glut.h>
     8
    99#include <syslog.h>
    1010
     
    3636        s++;
    3737    }
    38     length = snprintf(message, MSG_LEN, "nanovis (%d) %s: %s:%d ",
    39                       getpid(), syslogLevels[priority], s, lineNum);
     38    length = snprintf(message, MSG_LEN, "%s: %s:%d ",
     39                      syslogLevels[priority], s, lineNum);
    4040    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
    4141    message[MSG_LEN] = '\0';
  • trunk/packages/vizservers/nanovis/Trace.h

    r2798 r2822  
    44
    55#include <GL/glew.h>
    6 #include <GL/glut.h>
    76#include <syslog.h>
    87
  • trunk/packages/vizservers/nanovis/Unirect.h

    r2798 r2822  
    22#ifndef _UNIRECT_H
    33#define _UNIRECT_H
     4
     5#include <float.h>
     6
    47#include <rappture.h>
     8
    59#include "Trace.h"
    610
  • trunk/packages/vizservers/nanovis/Vector3.h

    r2798 r2822  
    1717#define _VECTOR3_H_
    1818
    19 /*
    20  * FIXME: The files that explicitly use the "rot*", "length", "distance", or
    21  * "normalize" methods, should include the following headers.  Don't do it
    22  * here.
    23  */
    2419#include <math.h>
    2520#include "Mat4x4.h"
    2621
    27 class Vector3{
    28 private:
    29     float radians(float degree) const {
    30         return (M_PI * degree) / 180.0;
    31     }
     22class Vector3
     23{
    3224public:
    3325    float x, y, z;
    34     Vector3(void) {
    35         /*empty*/
     26
     27    Vector3()
     28    {}
     29
     30    Vector3(float x_val, float y_val, float z_val)
     31    {
     32        set(x_val, y_val, z_val);
    3633    }
    37     Vector3(float x_val, float y_val, float z_val) {
    38         set(x_val, y_val, z_val);
     34
     35    void set(float x_val, float y_val, float z_val)
     36    {
     37        x = x_val, y = y_val, z = z_val;
    3938    }
    40     Vector3 operator +(float scalar) {
    41         return Vector3(x + scalar, y + scalar, z + scalar);
     39
     40    void print() const
     41    {
     42        TRACE("(x:%f, y:%f, z:%f)\n", x, y, z);
    4243    }
    43     Vector3 operator -(float scalar) {
    44         return Vector3(x - scalar, y - scalar, z - scalar);
     44
     45    Vector3 operator +(float scalar) const
     46    {
     47        return Vector3(x + scalar, y + scalar, z + scalar);
    4548    }
    46     Vector3 operator *(float scalar) {
    47         return Vector3(x * scalar, y * scalar, z * scalar);
     49
     50    Vector3 operator -(float scalar) const
     51    {
     52        return Vector3(x - scalar, y - scalar, z - scalar);
    4853    }
    49     Vector3 operator /(float scalar) {
    50         return Vector3(x / scalar, y / scalar, z / scalar);
     54
     55    Vector3 operator *(float scalar) const
     56    {
     57        return Vector3(x * scalar, y * scalar, z * scalar);
    5158    }
    52     Vector3 operator +(Vector3 &op2) {
    53         return Vector3(x + op2.x, y + op2.y, z + op2.z);
     59
     60    Vector3 operator /(float scalar) const
     61    {
     62        return Vector3(x / scalar, y / scalar, z / scalar);
    5463    }
    55     Vector3 operator -(Vector3 &op2) {
    56         return Vector3(x - op2.x, y - op2.y, z - op2.z);
     64
     65    Vector3 operator +(const Vector3& op2) const
     66    {
     67        return Vector3(x + op2.x, y + op2.y, z + op2.z);
    5768    }
    58     float operator *(const Vector3 &op2){
    59         return x*op2.x + y*op2.y + z*op2.z;
     69
     70    Vector3 operator -(const Vector3& op2) const
     71    {
     72        return Vector3(x - op2.x, y - op2.y, z - op2.z);
    6073    }
    61     float dot(const Vector3& vec) const {
    62         return x*vec.x + y*vec.y + z*vec.z;
     74
     75    float dot(const Vector3& op2) const
     76    {
     77        return x*op2.x + y*op2.y + z*op2.z;
    6378    }
    64     bool equal(Vector3 &op2) {
    65         return (x==op2.x) && (y==op2.y) && (z==op2.z);
     79
     80    float operator *(const Vector3& op2) const
     81    {
     82        return dot(op2);
    6683    }
    67     Vector3 cross(Vector3 op2) {
    68         return Vector3(y*op2.z - z*op2.y, z*op2.x - x*op2.z, x*op2.y - y*op2.x);
     84
     85    Vector3 cross(const Vector3& op2) const
     86    {
     87        return Vector3(y*op2.z - z*op2.y, z*op2.x - x*op2.z, x*op2.y - y*op2.x);
    6988    }
    70     void operator<(Vector3 &op2) {
    71         set(op2.x, op2.y, op2.z);
     89
     90    Vector3 operator ^(const Vector3& op2) const
     91    {
     92        return cross(op2);
    7293    }
    73     Vector3 operator ^(Vector3 &op2) {
    74         return cross(op2);
     94
     95    Vector3 normalize() const
     96    {
     97        float len = length();
     98        return Vector3(x / len, y / len, z / len);
    7599    }
    76     Vector3 normalize(void) {
    77         float len = length();
    78         return Vector3(x / len, y / len, z / len);
     100
     101    Vector3 rot_x(float degree) const
     102    {
     103        float rad = radians(degree);
     104        return Vector3(x,
     105                       y*cos(rad) - z*sin(rad),
     106                       y*sin(rad) + z*cos(rad));
    79107    }
    80     Vector3 rot_x(float degree) {
    81         float rad = radians(degree);
    82         return Vector3(x,
    83                        y*cos(rad) - z*sin(rad),
    84                        y*sin(rad) + z*cos(rad));
     108
     109    Vector3 rot_y(float degree) const
     110    {
     111        float rad = radians(degree);
     112        return Vector3(x*cos(rad) + z*sin(rad),
     113                       y,
     114                       -x*sin(rad) + z*cos(rad));
    85115    }
    86     Vector3 rot_y(float degree) {
    87         float rad = radians(degree);
    88         return Vector3(x*cos(rad) + z*sin(rad),
    89                        y,
    90                        -x*sin(rad) + z*cos(rad));
     116
     117    Vector3 rot_z(float degree) const
     118    {
     119        float rad = radians(degree);
     120        return Vector3(x*cos(rad) - y*sin(rad),
     121                       x*sin(rad) + y*cos(rad),
     122                       z);
    91123    }
    92     Vector3 rot_z(float degree) {
    93         float rad = radians(degree);
    94         return Vector3(x*cos(rad) - y*sin(rad),
    95                        x*sin(rad) + y*cos(rad),
    96                        z);
     124
     125    float distance(const Vector3& v) const
     126    {
     127        return sqrtf(distanceSquare(v));
    97128    }
    98     void set(float x_val, float y_val, float z_val) {
    99         x = x_val, y = y_val, z = z_val;
     129
     130    float distanceSquare(const Vector3& v) const
     131    {
     132        return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z);
    100133    }
    101     void print(void){
    102         TRACE("(x:%f, y:%f, z:%f)\n", x, y, z);
     134
     135    float distanceSquare(float vx, float vy, float vz) const
     136    {
     137        return (x-vx)*(x-vx) + (y-vy)*(y-vy) + (z-vz)*(z-vz);
    103138    }
    104     float distance(Vector3 &v) const {
    105         return sqrtf(distanceSquare(v));
    106     }
    107     float distanceSquare(Vector3 &v) const {
    108         return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) + (z-v.z)*(z-v.z);
    109     }
    110     float distanceSquare(float vx, float vy, float vz) const {
    111         return (x-vx)*(x-vx) + (y-vy)*(y-vy) + (z-vz)*(z-vz);
    112     }
    113     void transform(const Vector3& v, const Mat4x4& mat) {
     139
     140    void transform(const Vector3& v, const Mat4x4& mat)
     141    {
    114142        const float* m = mat.m;
    115143        x = m[0] * v.x + m[4] * v.y + m[8]  * v.z + m[12];
     
    117145        z = m[2] * v.x + m[6] * v.y + m[10] * v.z + m[14];
    118146    }
    119     float length(void) const {
    120         return sqrt(x*x + y*y + z*z);
     147
     148    float length() const
     149    {
     150        return sqrt(x*x + y*y + z*z);
    121151    }
    122152
    123     Vector3 scale(const Vector3& scale)
     153    Vector3 scale(const Vector3& scale) const
    124154    {
    125155        Vector3 v;
     
    130160    }
    131161
    132     friend Vector3 operator+(const Vector3& value1, const Vector3& value2);
    133 
    134 
     162private:
     163    float radians(float degree) const
     164    {
     165        return (M_PI * degree) / 180.0;
     166    }
    135167};
    136168
    137 inline Vector3 operator+(const Vector3& value1, const Vector3& value2)
    138 {
    139         return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z);
    140 }
    141 
    142169#endif
  • trunk/packages/vizservers/nanovis/Vector4.h

    r2798 r2822  
    1717#define _VECTOR4_H_
    1818
    19 #include <stdio.h>
    20 #include <Trace.h>
     19#include "Trace.h"
    2120
    2221class Vector4 
     
    2524    float x, y, z, w;
    2625
    27     Vector4(void) {
    28         /*empty*/
    29     }
    30     Vector4(float x_val, float y_val, float z_val, float w_val) {
    31         set(x_val, y_val, z_val, w_val);
    32     }
    33     void perspective_devide(void) {
    34         /* Divide vector by w */
    35         x /= w, y /= w, z /= w, w = 1.;
     26    Vector4()
     27    {}
     28
     29    Vector4(float x_val, float y_val, float z_val, float w_val)
     30    {
     31        set(x_val, y_val, z_val, w_val);
    3632    }
    3733
    38     void print(void) {
    39         TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w);
     34    void set(float x_val, float y_val, float z_val, float w_val)
     35    {
     36        x = x_val, y = y_val, z = z_val, w = w_val;
    4037    }
    4138
    42     Vector4 operator +(Vector4 &op2){
    43         return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w);
     39    void perspective_divide()
     40    {
     41        /* Divide vector by w */
     42        x /= w, y /= w, z /= w, w = 1.;
    4443    }
    4544
    46     Vector4 operator -(Vector4 &op2){
    47         return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w);
     45    void print() const
     46    {
     47        TRACE("Vector4: (%.3f, %.3f, %.3f, %.3f)\n", x, y, z, w);
    4848    }
    4949
    50     float operator *(Vector4 &op2) {
    51         return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w);
     50    Vector4 operator +(const Vector4& op2) const
     51    {
     52        return Vector4(x + op2.x, y + op2.y, z + op2.z, w + op2.w);
    5253    }
    5354
    54     Vector4 operator *(float op2){
    55         return Vector4(x * op2, y * op2, z * op2, w * op2);
     55    Vector4 operator -(const Vector4& op2) const
     56    {
     57        return Vector4(x - op2.x, y - op2.y, z - op2.z, w - op2.w);
    5658    }
    5759
    58     Vector4 operator /(float op2) {
    59         return Vector4(x / op2, y / op2, z / op2, w / op2);
     60    float operator *(const Vector4& op2) const
     61    {
     62        return (x * op2.x) + (y * op2.y) + (z * op2.z) + (w * op2.w);
    6063    }
    6164
    62     void operator <(Vector4 &op2) {
    63         set(op2.x, op2.y, op2.z, op2.w);
     65    Vector4 operator *(float op2) const
     66    {
     67        return Vector4(x * op2, y * op2, z * op2, w * op2);
    6468    }
    65     void set(float x_val, float y_val, float z_val, float w_val) {
    66         x = x_val, y = y_val, z = z_val, w = w_val;
     69
     70    Vector4 operator /(float op2) const
     71    {
     72        return Vector4(x / op2, y / op2, z / op2, w / op2);
    6773    }
    6874};
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp

    r2818 r2822  
    2222#ifdef USE_NANOVIS_LIB
    2323#include "global.h"
    24 #include "Nv.h"
    2524#include "R2/R2FilePath.h"
    2625#endif
  • trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h

    r2818 r2822  
    150150        _enabled = enabled;
    151151    }
    152     bool enabled(void) const
     152    bool enabled() const
    153153    {
    154154        return _enabled;
  • trunk/packages/vizservers/nanovis/VolumeRenderer.cpp

    r2804 r2822  
    1414 * ======================================================================
    1515 */
    16 
     16#include <stdlib.h>
    1717#include <assert.h>
    1818#include <time.h>
    1919#include <sys/time.h>
    2020
     21#include <GL/glew.h>
     22#include <GL/glut.h>
     23
     24#include <tcl.h>
     25
     26#include <vector>
     27
    2128#include <R2/R2string.h>
    2229#include <R2/R2FilePath.h>
    2330
    2431#include "nanovis.h"
    25 
    2632#include "VolumeRenderer.h"
    27 #include "VolumeInterpolator.h"
     33#include "ConvexPolygon.h"
     34
    2835#include "NvStdVertexShader.h"
    2936#include "Trace.h"
     
    4047    const char *path = R2FilePath::getInstance()->getPath("Font.bmp");
    4148    if (path == NULL) {
    42         ERROR("can't find Font.bmp\n");
    43         assert(path != NULL);
     49        ERROR("can't find Font.bmp\n");
     50        assert(path != NULL);
    4451    }
    4552    init_font(path);
     
    5764
    5865//initialize the volume shaders
    59 void VolumeRenderer::init_shaders(){
    60  
    61   //standard vertex program
    62   _stdVertexShader = new NvStdVertexShader();
    63 
    64   //volume rendering shader: one cubic volume
    65   _regularVolumeShader = new NvRegularVolumeShader();
    66 
    67   //volume rendering shader: one zincblende orbital volume.
    68   //This shader renders one orbital of the simulation.
    69   //A sim has S, P, D, SS orbitals. thus a full rendering requires 4 zincblende orbital volumes.
    70   //A zincblende orbital volume is decomposed into 2 "interlocking" cubic 4-component volumes and passed to the shader.
    71   //We render each orbital with a independent transfer functions then blend the result.
    72   //
    73   //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on
    74   //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.
    75   _zincBlendeShader = new NvZincBlendeVolumeShader();
     66void VolumeRenderer::init_shaders()
     67{
     68    //standard vertex program
     69    _stdVertexShader = new NvStdVertexShader();
     70
     71    //volume rendering shader: one cubic volume
     72    _regularVolumeShader = new NvRegularVolumeShader();
     73
     74    //volume rendering shader: one zincblende orbital volume.
     75    //This shader renders one orbital of the simulation.
     76    //A sim has S, P, D, SS orbitals. thus a full rendering requires 4 zincblende orbital volumes.
     77    //A zincblende orbital volume is decomposed into 2 "interlocking" cubic 4-component volumes and passed to the shader.
     78    //We render each orbital with a independent transfer functions then blend the result.
     79    //
     80    //The engine is already capable of rendering multiple volumes and combine them. Thus, we just invoke this shader on
     81    //S, P, D and SS orbitals with different transfor functions. The result is a multi-orbital rendering.
     82    _zincBlendeShader = new NvZincBlendeVolumeShader();
    7683}
    7784
     
    8087    int volume_id;
    8188    int slice_id;
     89
    8290    SortElement(float _z, int _v, int _s) :
    83         z(_z), volume_id(_v), slice_id(_s)
     91        z(_z), volume_id(_v), slice_id(_s)
    8492    {}
    8593};
    8694
    87 int slice_sort(const void* a, const void* b){
    88     if((*((SortElement*)a)).z > (*((SortElement*)b)).z)
     95int slice_sort(const void* a, const void* b)
     96{
     97    if ((*((SortElement*)a)).z > (*((SortElement*)b)).z)
    8998        return 1;
    9099    else
     
    549558    }
    550559}
    551 
    552560void VolumeRenderer::deactivate_volume_shader()
    553561{
     
    557565}
    558566
    559 void VolumeRenderer::get_near_far_z(Mat4x4 mv, double &zNear, double &zFar)
    560 {
    561   double x0 = 0;
    562   double y0 = 0;
    563   double z0 = 0;
    564   double x1 = 1;
    565   double y1 = 1;
    566   double z1 = 1;
    567 
    568   double zMin, zMax;
    569   zMin =  10000;
    570   zMax = -10000;
    571 
    572   double vertex[8][4];
    573 
    574   vertex[0][0]=x0; vertex[0][1]=y0; vertex[0][2]=z0; vertex[0][3]=1.0;
    575   vertex[1][0]=x1; vertex[1][1]=y0; vertex[1][2]=z0; vertex[1][3]=1.0;
    576   vertex[2][0]=x0; vertex[2][1]=y1; vertex[2][2]=z0; vertex[2][3]=1.0;
    577   vertex[3][0]=x0; vertex[3][1]=y0; vertex[3][2]=z1; vertex[3][3]=1.0;
    578   vertex[4][0]=x1; vertex[4][1]=y1; vertex[4][2]=z0; vertex[4][3]=1.0;
    579   vertex[5][0]=x1; vertex[5][1]=y0; vertex[5][2]=z1; vertex[5][3]=1.0;
    580   vertex[6][0]=x0; vertex[6][1]=y1; vertex[6][2]=z1; vertex[6][3]=1.0;
    581   vertex[7][0]=x1; vertex[7][1]=y1; vertex[7][2]=z1; vertex[7][3]=1.0;
    582 
    583   for (int i = 0; i < 8; i++) {
    584     Vector4 tmp = mv.transform(Vector4(vertex[i][0], vertex[i][1], vertex[i][2], vertex[i][3]));
    585     tmp.perspective_devide();
    586     vertex[i][2] = tmp.z;
    587     if (vertex[i][2]<zMin) zMin = vertex[i][2];
    588     if (vertex[i][2]>zMax) zMax = vertex[i][2];
    589   }
    590 
    591   zNear = zMax;
    592   zFar = zMin;
    593 }
    594 
    595 void VolumeRenderer::set_slice_mode(bool val) { slice_mode = val; }
    596 void VolumeRenderer::set_volume_mode(bool val) { volume_mode = val; }
    597 void VolumeRenderer::switch_slice_mode() { slice_mode = (!slice_mode); }
    598 void VolumeRenderer::switch_volume_mode() { volume_mode = (!volume_mode); }
     567void VolumeRenderer::get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar)
     568{
     569    double x0 = 0;
     570    double y0 = 0;
     571    double z0 = 0;
     572    double x1 = 1;
     573    double y1 = 1;
     574    double z1 = 1;
     575
     576    double zMin, zMax;
     577    zMin =  10000;
     578    zMax = -10000;
     579
     580    double vertex[8][4];
     581
     582    vertex[0][0]=x0; vertex[0][1]=y0; vertex[0][2]=z0; vertex[0][3]=1.0;
     583    vertex[1][0]=x1; vertex[1][1]=y0; vertex[1][2]=z0; vertex[1][3]=1.0;
     584    vertex[2][0]=x0; vertex[2][1]=y1; vertex[2][2]=z0; vertex[2][3]=1.0;
     585    vertex[3][0]=x0; vertex[3][1]=y0; vertex[3][2]=z1; vertex[3][3]=1.0;
     586    vertex[4][0]=x1; vertex[4][1]=y1; vertex[4][2]=z0; vertex[4][3]=1.0;
     587    vertex[5][0]=x1; vertex[5][1]=y0; vertex[5][2]=z1; vertex[5][3]=1.0;
     588    vertex[6][0]=x0; vertex[6][1]=y1; vertex[6][2]=z1; vertex[6][3]=1.0;
     589    vertex[7][0]=x1; vertex[7][1]=y1; vertex[7][2]=z1; vertex[7][3]=1.0;
     590
     591    for (int i = 0; i < 8; i++) {
     592        Vector4 tmp = mv.transform(Vector4(vertex[i][0], vertex[i][1], vertex[i][2], vertex[i][3]));
     593        tmp.perspective_divide();
     594        vertex[i][2] = tmp.z;
     595        if (vertex[i][2] < zMin) zMin = vertex[i][2];
     596        if (vertex[i][2] > zMax) zMax = vertex[i][2];
     597    }
     598
     599    zNear = zMax;
     600    zFar = zMin;
     601}
    599602
    600603bool
     
    759762    glPushMatrix();
    760763
    761     glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height, 
     764    glTranslatef(.5*vol->aspect_ratio_width, vol->aspect_ratio_height,
    762765                 -0.1*vol->aspect_ratio_depth);
    763766    glRotatef(180, 0, 0, 1);
     
    765768
    766769    glScalef(0.0008, 0.0008, 0.0008);
    767     for(int i=0; i<length; i++){
     770    for (int i = 0; i < length; i++) {
    768771        glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[0].c_str()[i]);
    769772        glTranslatef(0.04, 0., 0.);
     
    777780    glRotatef(90, 0, 1, 0);
    778781    glRotatef(90, 0, 0, 1);
    779    
     782
    780783    glScalef(0.0008, 0.0008, 0.0008);
    781     for(int i=0; i<length; i++){
     784    for (int i = 0; i < length; i++) {
    782785        glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[1].c_str()[i]);
    783786        glTranslatef(0.04, 0., 0.);
     
    792795
    793796    glScalef(0.0008, 0.0008, 0.0008);
    794     for(int i=0; i<length; i++){
     797    for (int i = 0; i < length; i++) {
    795798        glutStrokeCharacter(GLUT_STROKE_ROMAN, vol->label[2].c_str()[i]);
    796799        glTranslatef(0.04, 0., 0.);
     
    811814        cy = (float) (loop / 16) / 16.0f;
    812815        glNewList(font_base + loop, GL_COMPILE);
    813         glBegin(GL_QUADS);
    814         glTexCoord2f(cx, 1 - cy - 0.0625f);
    815         glVertex3f(0, 0, 0);
    816         glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f);
    817         glVertex3f(0.04, 0, 0);
    818         glTexCoord2f(cx + 0.0625f, 1 - cy);
    819         glVertex3f(0.04, 0.04, 0);
    820         glTexCoord2f(cx, 1 - cy);
    821         glVertex3f(0, 0.04, 0);
    822         glEnd();
    823         glTranslated(0.04, 0, 0);
     816        glBegin(GL_QUADS);
     817        glTexCoord2f(cx, 1 - cy - 0.0625f);
     818        glVertex3f(0, 0, 0);
     819        glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f);
     820        glVertex3f(0.04, 0, 0);
     821        glTexCoord2f(cx + 0.0625f, 1 - cy);
     822        glVertex3f(0.04, 0.04, 0);
     823        glTexCoord2f(cx, 1 - cy);
     824        glVertex3f(0, 0.04, 0);
     825        glEnd();
     826        glTranslated(0.04, 0, 0);
    824827        glEndList();
    825828    }
     
    830833{
    831834    if (set > 1) {
    832         set=1;
     835        set = 1;
    833836    }
    834837    glBindTexture(GL_TEXTURE_2D, font_texture);
  • trunk/packages/vizservers/nanovis/VolumeRenderer.h

    r2798 r2822  
    2020#include <GL/glew.h>
    2121#include <Cg/cgGL.h>
    22 #include <GL/glut.h>
    23 #include <math.h>
    24 #include <stdio.h>
    25 #include <assert.h>
    26 #include <float.h>
    27 #include <vector>
    2822
    29 #include "define.h"
    30 #include "global.h"
    31 #include "ConvexPolygon.h"
    32 #include "TransferFunction.h"
    3323#include "Mat4x4.h"
    3424#include "Volume.h"
    35 #include "ZincBlendeVolume.h"
    36 #include "PerfQuery.h"
     25#include "VolumeInterpolator.h"
    3726#include "NvRegularVolumeShader.h"
    3827#include "NvZincBlendeVolumeShader.h"
    3928#include "NvStdVertexShader.h"
    40 #include "VolumeInterpolator.h"
    4129
    42 class VolumeRenderer {
     30class VolumeRenderer
     31{
    4332    friend class NanoVis;
     33
    4434private:
    4535    VolumeInterpolator* _volumeInterpolator;
     
    6858     */
    6959    NvZincBlendeVolumeShader* _zincBlendeShader;
    70  
     60
    7161    /**
    7262     * standard vertex shader
    7363     */
    7464    NvStdVertexShader* _stdVertexShader;
    75  
     65
    7666    //standard vertex shader parameters
    7767    CGprogram m_vert_std_vprog;
     
    8272
    8373    void init_shaders();
     74
    8475    void activate_volume_shader(Volume* vol, bool slice_mode);
     76
    8577    void deactivate_volume_shader();
     78
    8679    //draw bounding box
    8780    void draw_bounding_box(float x0, float y0, float z0,
     
    8982                           float r, float g, float b, float line_width);
    9083
    91     void get_near_far_z(Mat4x4 mv, double &zNear, double &zFar);
     84    void get_near_far_z(const Mat4x4& mv, double& zNear, double& zFar);
     85
    9286    bool init_font(const char* filename);
     87
    9388    void glPrint(char* string, int set); //there are two sets of font in the
    9489                                         //texture. 0, 1
     90
    9591    void draw_label(Volume* vol); //draw label using bitmap texture
    9692                                // the texture.
     93
    9794    void build_font();          // Register the location of each alphabet in
    9895
    9996public:
    10097    VolumeRenderer();
     98
    10199    ~VolumeRenderer();
    102100
    103101    void render_all();                  //render all enabled volumes;
     102
    104103    void specular(float val);
     104
    105105    void diffuse(float val);
    106     void set_slice_mode(bool val);      //control independently.
    107     void set_volume_mode(bool val);
    108     void switch_slice_mode();           //switch_cutplane_mode
    109     void switch_volume_mode();
    110106
    111     void clearAnimatedVolumeInfo(void) {
    112         _volumeInterpolator->clearAll();
     107    void set_slice_mode(bool val)       //control independently.
     108    {
     109        slice_mode = val;
    113110    }
    114     void addAnimatedVolume(Volume* volume) {
    115         _volumeInterpolator->addVolume(volume);
     111
     112    void set_volume_mode(bool val)
     113    {
     114        volume_mode = val;
    116115    }
    117     void startVolumeAnimation(void) {
    118         _volumeInterpolator->start();
     116
     117    void switch_slice_mode()            //switch_cutplane_mode
     118    {
     119        slice_mode = (!slice_mode);
    119120    }
    120     void stopVolumeAnimation(void) {
     121
     122    void switch_volume_mode()
     123    {
     124        volume_mode = (!volume_mode);
     125    }
     126
     127    void clearAnimatedVolumeInfo()
     128    {
     129        _volumeInterpolator->clearAll();
     130    }
     131
     132    void addAnimatedVolume(Volume* volume)
     133    {
     134        _volumeInterpolator->addVolume(volume);
     135    }
     136
     137    void startVolumeAnimation()
     138    {
     139        _volumeInterpolator->start();
     140    }
     141
     142    void stopVolumeAnimation()
     143    {
    121144        _volumeInterpolator->stop();
    122145    }
    123     VolumeInterpolator* getVolumeInterpolator(void) {
     146
     147    VolumeInterpolator* getVolumeInterpolator()
     148    {
    124149        return _volumeInterpolator;
    125150    }
  • trunk/packages/vizservers/nanovis/define.h

    r2806 r2822  
    2424    GLenum status;                                              \
    2525    status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);   \
    26     TRACE("%x\n", status);                                      \
    2726    switch(status) {                                            \
    2827    case GL_FRAMEBUFFER_COMPLETE_EXT:                           \
  • trunk/packages/vizservers/nanovis/dxReader.cpp

    r2798 r2822  
    3030#include <sys/types.h>
    3131#include <unistd.h>
    32 
    33 #include "Nv.h"
    3432
    3533#include "nanovis.h"
  • trunk/packages/vizservers/nanovis/dxReader2.cpp

    r2798 r2822  
    1111
    1212// nanovis headers
    13 #include "Nv.h"
    1413#include "nanovis.h"
    1514
  • trunk/packages/vizservers/nanovis/global.h

    r2806 r2822  
    1616#include <GL/glew.h>
    1717#include <Cg/cgGL.h>
     18
    1819#include <Trace.h>
    19 #include <stdio.h>
    2020
    2121inline void
     
    3434system_info()
    3535{
    36     INFO("-----------------------------------------------------------\n");
    37     INFO("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
     36    TRACE("-----------------------------------------------------------\n");
     37    TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
    3838           glGetString(GL_VERSION));
    39     INFO("Graphics hardware: %s\n", glGetString(GL_RENDERER));
    40     INFO("-----------------------------------------------------------\n");
     39    TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER));
     40    TRACE("-----------------------------------------------------------\n");
    4141}
    4242
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2820 r2822  
    3838#include <unistd.h>
    3939
    40 #include "Nv.h"
    4140#include "PointSetRenderer.h"
    4241#include "PointSet.h"
     
    347346    TRACE("in DoExit\n");
    348347    removeAllData();
    349     NvExit();
     348
     349#ifdef EVENTLOG
     350    NvExitEventLog();
     351#endif
     352
     353#ifdef XINETD
     354    NvExitService();
     355#endif
     356
    350357#if KEEPSTATS
    351358    WriteStats("nanovis", code);
     
    384391    int result;
    385392
    386     TRACE("in ExecuteCommand(%s)\n", Tcl_DStringValue(dsPtr));
     393    TRACE("command: '%s'", Tcl_DStringValue(dsPtr));
    387394
    388395    gettimeofday(&tv, NULL);
     
    703710{
    704711    // print system information
    705     TRACE("-----------------------------------------------------------\n");
    706     TRACE("OpenGL driver: %s %s\n", glGetString(GL_VENDOR),
    707            glGetString(GL_VERSION));
    708     TRACE("Graphics hardware: %s\n", glGetString(GL_RENDERER));
    709     TRACE("-----------------------------------------------------------\n");
     712    system_info();
     713
    710714    if (path == NULL) {
    711715        ERROR("No path defined for shaders or resources\n");
     
    20942098            ch = (char)c;
    20952099            Tcl_DStringAppend(&cmdbuffer, &ch, 1);
    2096             TRACE("in xinetd_listen: checking buffer=%s\n",
    2097                   Tcl_DStringValue(&cmdbuffer));
    20982100            if (ch == '\n') {
    20992101                isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer));
     
    21912193    fflush(stdout);
    21922194
    2193     /* openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID,  LOG_USER); */
     2195    openlog("nanovis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
    21942196    gettimeofday(&tv, NULL);
    21952197    stats.start = tv;
  • trunk/packages/vizservers/nanovis/nanovis.h

    r2818 r2822  
    4545#include "define.h"
    4646#include "global.h"
     47
    4748#include "NvCamera.h"
    4849#include "ConvexPolygon.h"
     
    6465#include "HeightMap.h"
    6566#include "Grid.h"
     67#include "VolumeRenderer.h"
    6668#include "VelocityArrowsSlice.h"
    6769
     
    8183struct Vector2 {
    8284    float x, y;
    83     float mag(void) {
     85    float mag()
     86    {
    8487        return sqrt(x*x+y*y);
    8588    }
    8689};
    8790
    88 struct RegGrid2{
     91struct RegGrid2 {
    8992    int width, height;
    9093    Vector2* field;
    9194   
    92     RegGrid2(int w, int h){
     95    RegGrid2(int w, int h)
     96    {
    9397        width = w;
    9498        height = h;
     
    96100    }
    97101
    98     void put(Vector2& v, int x ,int y) {
     102    void put(Vector2& v, int x ,int y)
     103    {
    99104        field[x+y*width] = v;
    100105    }
    101106   
    102     Vector2& get(int x, int y) {
     107    Vector2& get(int x, int y)
     108    {
    103109        return field[x+y*width];
    104110    }
     
    109115class FlowIterator;
    110116
    111 class NanoVis {
     117class NanoVis
     118{
    112119    //frame buffer for final rendering
    113120    static GLuint final_fbo, final_color_tex, final_depth_rb;
    114 public:
     121
    115122public:
    116123    static VolumeRenderer* vol_renderer;
     
    158165    static Tcl_DString cmdbuffer;
    159166
    160 public :
    161167    static TransferFunction* get_transfunc(const char *name);
    162168    static TransferFunction* DefineTransferFunction(const char *name,
     
    203209    static FILE *stdin, *logfile, *recfile;
    204210
    205     static void read_screen(void) {
     211    static void read_screen()
     212    {
    206213        glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
    207                 screen_buffer);
    208     }
    209     static void offscreen_buffer_capture(void) {
     214                     screen_buffer);
     215    }
     216    static void offscreen_buffer_capture()
     217    {
    210218        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);
    211219    }
  • trunk/packages/vizservers/nanovis/socket/Socket.cpp

    r2798 r2822  
    1414 * ======================================================================
    1515 */
    16 #include "Socket.h"
    17 #include "string.h"
    1816#include <string.h>
    1917#include <errno.h>
    2018#include <fcntl.h>
     19
     20#include "Socket.h"
    2121
    2222ssize_t writen(int fd, void *vptr, size_t n) ;
Note: See TracChangeset for help on using the changeset viewer.