Changeset 3630 for trunk/packages/vizservers/nanovis/Volume.cpp
- Timestamp:
- Apr 16, 2013, 12:52:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Volume.cpp
r3611 r3630 31 31 double Volume::valueMax = 1.0; 32 32 33 Volume::Volume(float x, float y, float z, 34 int w, int h, int d, 33 Volume::Volume(int w, int h, int d, 35 34 int n, float *data, 36 35 double v0, double v1, double nonZeroMin) : … … 50 49 _nonZeroMin(nonZeroMin), 51 50 _tex(NULL), 52 _location(x, y, z), 51 _position(0,0,0), 52 _scale(1,1,1), 53 53 _numSlices(512), 54 54 _enabled(true), … … 65 65 int fcount = _width * _height * _depth * _numComponents; 66 66 _data = new float[fcount]; 67 if (data != NULL) { 68 TRACE("data is copied"); 69 memcpy(_data, data, fcount * sizeof(float)); 70 _tex->initialize(_data); 71 } else { 72 TRACE("data is null"); 73 memset(_data, 0, sizeof(_width * _height * _depth * _numComponents * 74 sizeof(float))); 75 _tex->initialize(_data); 76 } 67 memcpy(_data, data, fcount * sizeof(float)); 68 _tex->initialize(_data); 77 69 78 70 _id = _tex->id(); … … 83 75 //The default location of cut plane is in the middle of the data. 84 76 _plane.clear(); 85 addCutplane( 1, 0.5f);86 addCutplane( 2, 0.5f);87 addCutplane( 3, 0.5f);77 addCutplane(CutPlane::X_AXIS, 0.5f); 78 addCutplane(CutPlane::Y_AXIS, 0.5f); 79 addCutplane(CutPlane::Z_AXIS, 0.5f); 88 80 89 81 TRACE("Leave"); … … 98 90 } 99 91 100 void Volume:: getWorldSpaceBounds(Vector3f& bboxMin, Vector3f& bboxMax) const92 void Volume::setData(float *data, double v0, double v1, double nonZeroMin) 101 93 { 102 Vector3f scale = getPhysicalScaling(); 94 int fcount = _width * _height * _depth * _numComponents; 95 memcpy(_data, data, fcount * sizeof(float)); 96 _tex->update(_data); 97 wAxis.setRange(v0, v1); 98 _nonZeroMin = nonZeroMin; 99 updatePending = true; 100 } 103 101 104 Matrix4x4d mat; 105 mat.makeTranslation(_location); 106 Matrix4x4d mat2; 107 mat2.makeScale(scale); 108 109 mat.multiply(mat2); 110 111 bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX); 112 bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); 113 114 Vector3f modelMin(0, 0, 0); 115 Vector3f modelMax(1, 1, 1); 116 117 Vector4f bvert[8]; 118 bvert[0] = Vector4f(modelMin.x, modelMin.y, modelMin.z, 1); 119 bvert[1] = Vector4f(modelMax.x, modelMin.y, modelMin.z, 1); 120 bvert[2] = Vector4f(modelMin.x, modelMax.y, modelMin.z, 1); 121 bvert[3] = Vector4f(modelMin.x, modelMin.y, modelMax.z, 1); 122 bvert[4] = Vector4f(modelMax.x, modelMax.y, modelMin.z, 1); 123 bvert[5] = Vector4f(modelMax.x, modelMin.y, modelMax.z, 1); 124 bvert[6] = Vector4f(modelMin.x, modelMax.y, modelMax.z, 1); 125 bvert[7] = Vector4f(modelMax.x, modelMax.y, modelMax.z, 1); 126 127 for (int i = 0; i < 8; i++) { 128 Vector4f worldVert = mat.transform(bvert[i]); 129 if (worldVert.x < bboxMin.x) bboxMin.x = worldVert.x; 130 if (worldVert.x > bboxMax.x) bboxMax.x = worldVert.x; 131 if (worldVert.y < bboxMin.y) bboxMin.y = worldVert.y; 132 if (worldVert.y > bboxMax.y) bboxMax.y = worldVert.y; 133 if (worldVert.z < bboxMin.z) bboxMin.z = worldVert.z; 134 if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z; 135 } 102 void Volume::getBounds(Vector3f& bboxMin, Vector3f& bboxMax) const 103 { 104 bboxMin.set(xAxis.min(), yAxis.min(), zAxis.min()); 105 bboxMax.set(xAxis.max(), yAxis.max(), zAxis.max()); 136 106 }
Note: See TracChangeset
for help on using the changeset viewer.