Changeset 1028 for trunk/packages/vizservers/nanovis/PointSet.cpp
- Timestamp:
- Jun 9, 2008, 9:08:02 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/PointSet.cpp
r953 r1028 4 4 #include <stdio.h> 5 5 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) 6 void 7 PointSet::initialize(Vector4* values, const unsigned int count, 8 const Vector3& scale, const Vector3& origin, 9 float min, float max) 25 10 { 26 11 PCA::PCASplit pcaSplit; … … 32 17 33 18 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) { 36 20 points[i].position.set(values[i].x, values[i].y, values[i].z); 37 21 points[i].color.set(1.0f, 1.0f, 1.0f, 0.2f); … … 40 24 } 41 25 42 if (_cluster != 0) 43 { 26 if (_cluster != 0) { 44 27 delete _cluster; 45 28 } … … 49 32 } 50 33 51 void PointSet::updateColor(float* color, int colorCount) 34 void 35 PointSet::updateColor(float* color, int colorCount) 52 36 { 53 if (_cluster == 0) return; 54 37 if (_cluster == 0) { 38 return; 39 } 55 40 int level = 4; 56 41 57 58 59 60 61 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 63 48 PCA::Point* points; 64 49 Vector4* colors = (Vector4*) color; 65 50 int numOfPoints; 66 51 int index; 67 52 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))){ 70 54 points = c->points; 71 55 numOfPoints = c->numOfPoints; 72 73 for (int i = 0; i < numOfPoints; ++i) 74 { 56 57 for (int i = 0; i < numOfPoints; ++i) { 75 58 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 } 80 62 points[i].color = colors[index]; 81 63 } 82 83 } 64 } 84 65 } 85 66
Note: See TracChangeset
for help on using the changeset viewer.