Changeset 827 for trunk/vizservers/nanovis/PointSet.cpp
- Timestamp:
- Dec 13, 2007 7:24:01 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/PointSet.cpp
r825 r827 2 2 #include "PCASplit.h" 3 3 #include <stdlib.h> 4 #include <stdio.h> 4 5 5 6 PointSet::PointSet() 6 : _visible(false), _cluster(0), _sortLevel(4) 7 : _visible(false), _cluster(0), _sortLevel(4), _min(0.0f), _max(1.0f) 7 8 { 8 9 } … … 16 17 } 17 18 18 void PointSet::initialize(Vector4* values, const unsigned int count )19 void PointSet::initialize(Vector4* values, const unsigned int count, const Vector3& scale, const Vector3& origin, float min, float max) 19 20 { 20 21 PCA::PCASplit pcaSplit; 22 23 _scale = scale; 24 _origin = origin; 25 _min = min; 26 _max = max; 21 27 22 28 PCA::Point* points = (PCA::Point*) malloc(sizeof(PCA::Point) * count); … … 24 30 { 25 31 points[i].position.set(values[i].x, values[i].y, values[i].z); 26 27 // TBD28 32 points[i].color.set(1.0f, 1.0f, 1.0f, 0.2f); 29 30 33 points[i].value = values[i].w; 34 points[i].size = 0.001; 31 35 } 32 36 … … 35 39 delete _cluster; 36 40 } 37 38 41 42 pcaSplit.setMinDistance(scale.length() / 3.0f); 39 43 _cluster = pcaSplit.doIt(points, count); 40 44 } 41 45 42 void PointSet::updateColor( )46 void PointSet::updateColor(float* color, int colorCount) 43 47 { 44 48 if (_cluster == 0) return; 49 50 int level = 4; 51 52 PCA::Cluster* cluster = _cluster->startPointerCluster[level - 1]; 53 PCA::Cluster* c = &(cluster[0]); 54 PCA::Cluster* end = &(cluster[_cluster->numOfClusters[level - 1] - 1]); 55 56 Vector3 pos; 57 58 PCA::Point* points; 59 Vector4* colors = (Vector4*) color; 60 int numOfPoints; 61 int index; 62 float d = _max - _min; 63 for (; c <= end; c = (PCA::Cluster*) ((int) c + sizeof(PCA::Cluster))) 64 { 65 points = c->points; 66 numOfPoints = c->numOfPoints; 67 68 for (int i = 0; i < numOfPoints; ++i) 69 { 70 index = (points[i].value - _min) / d * (colorCount - 1); 71 if (index >= colorCount) index = colorCount - 1; 72 //printf("TEST %f %d/%d -> %d (%f %f %f)\n", points[i].value, i, numOfPoints, index, 73 // colors[index].x, colors[index].y, colors[index].z); 74 //fflush(stdout); 75 points[i].color = colors[index]; 76 } 77 78 } 45 79 } 46 80
Note: See TracChangeset
for help on using the changeset viewer.