Changeset 5488 for nanovis/branches/1.2/VtkDataSetReader.cpp
- Timestamp:
- May 11, 2015 2:50:11 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.2/VtkDataSetReader.cpp
r5474 r5488 11 11 #include <vtkDataSet.h> 12 12 #include <vtkImageData.h> 13 #include <vtkPointData.h> 14 #include <vtkDataArray.h> 13 15 #include <vtkDataSetReader.h> 14 16 #include <vtkCharArray.h> … … 102 104 memset(data, 0, npts * 4); 103 105 106 bool isVectorData = (resampledDataSet->GetPointData()->GetVectors() != NULL); 107 104 108 int ix = 0; 105 109 int iy = 0; 106 110 int iz = 0; 111 vtkDataArray *mask = resampledDataSet->GetPointData()->GetArray("vtkValidPointMask"); 107 112 for (int p = 0; p < npts; p++) { 108 113 int nindex = p * 4; 109 double val = resampledDataSet->GetScalarComponentAsDouble(ix, iy, iz, 0); 110 data[nindex] = (float)val; 111 if (val < vmin) { 112 vmin = val; 113 } else if (val > vmax) { 114 vmax = val; 114 double val; 115 int loc[3]; 116 loc[0] = ix; loc[1] = iy; loc[2] = iz; 117 vtkIdType idx = resampledDataSet->ComputePointId(loc); 118 bool valid = (mask == NULL) ? true : (mask->GetComponent(idx, 0) != 0.0); 119 if (isVectorData) { 120 double vec[3]; 121 resampledDataSet->GetPointData()->GetVectors()->GetTuple(idx, vec); 122 val = sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); 123 data[nindex] = (float)val; 124 data[nindex+1] = (float)vec[0]; 125 data[nindex+2] = (float)vec[1]; 126 data[nindex+3] = (float)vec[2]; 127 } else { 128 //val = resampledDataSet->GetScalarComponentAsDouble(ix, iy, iz, 0); 129 val = resampledDataSet->GetPointData()->GetScalars()->GetComponent(idx, 0); 130 data[nindex] = valid ? (float)val : -FLT_MAX; 115 131 } 116 if (val != 0.0 && val < nzero_min) { 117 nzero_min = val; 132 if (valid) { 133 if (val < vmin) { 134 vmin = val; 135 } else if (val > vmax) { 136 vmax = val; 137 } 138 if (val != 0.0 && val < nzero_min) { 139 nzero_min = val; 140 } 118 141 } 119 142 … … 127 150 } 128 151 129 // scale all values [0-1], -1 => out of bounds 130 normalizeScalar(data, npts, 4, vmin, vmax); 131 computeSimpleGradient(data, nx, ny, nz, 132 dx, dy, dz); 152 if (isVectorData) { 153 // Normalize magnitude [0,1] and vector components [0,1] 154 normalizeVector(data, npts, vmin, vmax); 155 } else { 156 // scale all values [0-1], -1 => out of bounds 157 normalizeScalar(data, npts, 4, vmin, vmax); 158 computeSimpleGradient(data, nx, ny, nz, 159 dx, dy, dz); 160 } 133 161 162 TRACE("isVectorData: %s", isVectorData ? "yes" : "no"); 134 163 TRACE("nx = %i ny = %i nz = %i", nx, ny, nz); 135 164 TRACE("x0 = %lg y0 = %lg z0 = %lg", x0, y0, z0);
Note: See TracChangeset
for help on using the changeset viewer.