------------------------------------------------------------------------------ Evaluate ImplicitVolume gradient.
| 95 | //------------------------------------------------------------------------------ |
| 96 | // Evaluate ImplicitVolume gradient. |
| 97 | void vtkImplicitVolume::EvaluateGradient(double x[3], double n[3]) |
| 98 | { |
| 99 | vtkDataArray* scalars; |
| 100 | int i, ijk[3]; |
| 101 | double pcoords[3], weights[8], *v; |
| 102 | vtkDoubleArray* gradient; |
| 103 | |
| 104 | // See if a volume is defined |
| 105 | if (!this->Volume || !(scalars = this->Volume->GetPointData()->GetScalars())) |
| 106 | { |
| 107 | vtkErrorMacro( |
| 108 | << "Can't evaluate gradient: either volume is missing or volume has no point data"); |
| 109 | for (i = 0; i < 3; i++) |
| 110 | { |
| 111 | n[i] = this->OutGradient[i]; |
| 112 | } |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | gradient = vtkDoubleArray::New(); |
| 117 | gradient->SetNumberOfComponents(3); |
| 118 | gradient->SetNumberOfTuples(8); |
| 119 | |
| 120 | // Find the cell that contains xyz and get it |
| 121 | if (this->Volume->ComputeStructuredCoordinates(x, ijk, pcoords)) |
| 122 | { |
| 123 | vtkVoxel::InterpolationFunctions(pcoords, weights); |
| 124 | this->Volume->GetVoxelGradient(ijk[0], ijk[1], ijk[2], scalars, gradient); |
| 125 | |
| 126 | n[0] = n[1] = n[2] = 0.0; |
| 127 | for (i = 0; i < 8; i++) |
| 128 | { |
| 129 | v = gradient->GetTuple(i); |
| 130 | n[0] += v[0] * weights[i]; |
| 131 | n[1] += v[1] * weights[i]; |
| 132 | n[2] += v[2] * weights[i]; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | else |
| 137 | { // use outside value |
| 138 | for (i = 0; i < 3; i++) |
| 139 | { |
| 140 | n[i] = this->OutGradient[i]; |
| 141 | } |
| 142 | } |
| 143 | gradient->Delete(); |
| 144 | } |
| 145 | |
| 146 | //------------------------------------------------------------------------------ |
| 147 | void vtkImplicitVolume::PrintSelf(ostream& os, vtkIndent indent) |
nothing calls this directly
no test coverage detected