Ignore:
Timestamp:
Mar 7, 2012 11:10:08 AM (12 years ago)
Author:
ldelgass
Message:

Move functions to sample a set of control points to TransferFunction? as static
methods and remove Util.cpp/h. Currently the functions are unused, but could
be useful as a replacement for using Rappture::Field1D.

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

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/Makefile.in

    r2819 r2820  
    161161                TransferFunction.o \
    162162                Unirect.o \
    163                 Util.o \
    164163                VelocityArrowsSlice.o \
    165164                Volume.o \
     
    349348TransferFunction.o: TransferFunction.cpp
    350349Unirect.o: Unirect.cpp Unirect.h Trace.h
    351 Util.o: Util.cpp Util.h
    352350VelocityArrowsSlice.o: VelocityArrowsSlice.cpp VelocityArrowsSlice.h
    353351Volume.o: Volume.cpp Volume.h $(AUXSRC)
  • trunk/packages/vizservers/nanovis/TransferFunction.cpp

    r2798 r2820  
    1414 * ======================================================================
    1515 */
    16 
    1716
    1817#include "TransferFunction.h"
     
    5554}
    5655
     56void
     57TransferFunction::sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret)
     58{
     59    int limit = count - 1;
     60    if (fraction <= key[0]) {
     61        *ret = keyValue[0];
     62    } else if (fraction >= key[limit]) {
     63        *ret = keyValue[limit];
     64    } else {
     65        int n;
     66        for (n = 0; n < limit; n++){
     67            if (fraction >= key[n] && fraction < key[n+1]) break;
     68        }
     69        if (n >= limit) {
     70            *ret = keyValue[limit];
     71        } else {
     72            float inter = (fraction - key[n]) / (key[n + 1] - key[n]);
     73            ret->set(inter * (keyValue[n + 1].x - keyValue[n].x) + keyValue[n].x,
     74                     inter * (keyValue[n + 1].y - keyValue[n].y) + keyValue[n].y,
     75                     inter * (keyValue[n + 1].z - keyValue[n].z) + keyValue[n].z);
     76        }
     77    }
     78}
     79
     80void
     81TransferFunction::sample(float fraction, float *key, int count, float *keyValue, float *ret)
     82{
     83    int limit = count - 1;
     84    if (fraction <= key[0]) {
     85        *ret = keyValue[0];
     86    } else if (fraction >= key[limit]) {
     87        *ret = keyValue[limit];
     88    } else {
     89        int n;
     90        for (n = 0; n < limit; n++){
     91            if (fraction >= key[n] && fraction < key[n+1]) break;
     92        }
     93        if (n >= limit) {
     94            *ret = keyValue[limit];
     95        } else {
     96            float inter = (fraction - key[n]) / (key[n + 1] - key[n]);
     97            *ret = inter * (keyValue[n + 1] - keyValue[n]) + keyValue[n];
     98        }
     99    }
     100}
  • trunk/packages/vizservers/nanovis/TransferFunction.h

    r2798 r2820  
    1414 * ======================================================================
    1515 */
     16#ifndef TRANSFER_FUNCTION_H
     17#define TRANSFER_FUNCTION_H
    1618
    17 #ifndef _TRANSFER_FUNCTION_H_
    18 #define _TRANSFER_FUNCTION_H_
    19 
     19#include <R2/R2Object.h>
    2020
    2121#include "Texture1D.h"
    22 #include <R2/R2Object.h>
     22#include "Vector3.h"
    2323
    24 
    25 class TransferFunction : public R2Object {
     24class TransferFunction : public R2Object
     25{
    2626    int _size;                  //the resolution of the color map, how many
    2727                                //(RGBA) quadraples
     
    3030    const char *_name;
    3131    GLuint _id;                 //OpenGL's texture identifier
     32
    3233protected :
    3334    ~TransferFunction();
     35
    3436public:
    3537    TransferFunction(int size, float *data);
     
    5759        _name = name;
    5860    }
     61
     62    static void sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret);
     63    static void sample(float fraction, float *key, int count, float *keyValue, float *ret);
    5964};
    6065
  • trunk/packages/vizservers/nanovis/nanovis.cpp

    r2819 r2820  
    4141#include "PointSetRenderer.h"
    4242#include "PointSet.h"
    43 #include "Util.h"
    4443#include <NvLIC.h>
    4544#include <Trace.h>
Note: See TracChangeset for help on using the changeset viewer.