Ignore:
Timestamp:
Jun 9, 2008, 9:08:02 AM (16 years ago)
Author:
gah
Message:

various cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/PointSet.cpp

    r953 r1028  
    44#include <stdio.h>
    55
    6 PointSet::PointSet() :
    7     _sortLevel(4),
    8     _cluster(0),
    9     _max(1.0f),
    10     _min(0.0f),
    11     _visible(false)
    12 {
    13     /*empty*/
    14 }
    15 
    16 PointSet::~PointSet()
    17 {
    18     if (_cluster)
    19     {
    20         delete _cluster;
    21     }
    22 }
    23 
    24 void PointSet::initialize(Vector4* values, const unsigned int count, const Vector3& scale, const Vector3& origin, float min, float max)
     6void
     7PointSet::initialize(Vector4* values, const unsigned int count,
     8                     const Vector3& scale, const Vector3& origin,
     9                     float min, float max)
    2510{
    2611    PCA::PCASplit pcaSplit;
     
    3217
    3318    PCA::Point* points = (PCA::Point*) malloc(sizeof(PCA::Point) * count);
    34     for (unsigned int i = 0; i < count; ++i)
    35     {
     19    for (unsigned int i = 0; i < count; ++i) {
    3620        points[i].position.set(values[i].x, values[i].y, values[i].z);
    3721        points[i].color.set(1.0f, 1.0f, 1.0f, 0.2f);
     
    4024    }
    4125
    42     if (_cluster != 0)
    43     {
     26    if (_cluster != 0) {
    4427        delete _cluster;
    4528    }
     
    4932}
    5033
    51 void PointSet::updateColor(float* color,  int colorCount)
     34void
     35PointSet::updateColor(float* color,  int colorCount)
    5236{
    53         if (_cluster == 0) return;
    54 
     37    if (_cluster == 0) {
     38        return;
     39    }
    5540    int level = 4;
    5641
    57         PCA::Cluster* cluster = _cluster->startPointerCluster[level - 1];
    58         PCA::Cluster* c = &(cluster[0]);
    59         PCA::Cluster* end = &(cluster[_cluster->numOfClusters[level - 1] - 1]);
    60 
    61         Vector3 pos;
    62        
     42    PCA::Cluster* cluster = _cluster->startPointerCluster[level - 1];
     43    PCA::Cluster* c = &(cluster[0]);
     44    PCA::Cluster* end = &(cluster[_cluster->numOfClusters[level - 1] - 1]);
     45   
     46    Vector3 pos;
     47   
    6348    PCA::Point* points;
    6449    Vector4* colors = (Vector4*) color;
    65         int numOfPoints;
     50    int numOfPoints;
    6651    int index;
    6752    float d = _max - _min;
    68         for (; c <= end; c = (PCA::Cluster*) ((int) c + sizeof(PCA::Cluster)))
    69         {
     53    for (/*empty*/; c <= end; c = (PCA::Cluster*)((int)c+sizeof(PCA::Cluster))){
    7054        points = c->points;
    7155        numOfPoints = c->numOfPoints;
    72 
    73         for (int i = 0; i < numOfPoints; ++i)
    74         {
     56       
     57        for (int i = 0; i < numOfPoints; ++i) {
    7558            index = (points[i].value - _min) / d  * (colorCount - 1);
    76             if (index >= colorCount) index = colorCount - 1;
    77             //printf("TEST %f %d/%d -> %d (%f %f %f)\n", points[i].value, i, numOfPoints, index,
    78             //                                    colors[index].x, colors[index].y, colors[index].z);
    79             //fflush(stdout);
     59            if (index >= colorCount) {
     60                index = colorCount - 1;
     61            }
    8062            points[i].color = colors[index];
    8163        }
    82 
    83         }
     64    }
    8465}
    8566
Note: See TracChangeset for help on using the changeset viewer.