MCPcopy Create free account
hub / github.com/Kitware/VTK / EvaluateGradient

Method EvaluateGradient

Common/DataModel/vtkImplicitDataSet.cxx:99–149  ·  view source on GitHub ↗

Evaluate implicit function gradient.

Source from the content-addressed store, hash-verified

97
98// Evaluate implicit function gradient.
99void vtkImplicitDataSet::EvaluateGradient(double x[3], double n[3])
100{
101 vtkDataArray* scalars;
102 vtkCell* cell;
103 vtkIdType id;
104 int subId, i, numPts;
105 double pcoords[3];
106
107 // See if a dataset has been specified
108 if (!this->DataSet || !(scalars = this->DataSet->GetPointData()->GetScalars()))
109 {
110 vtkErrorMacro(
111 << "Can't evaluate gradient: either data set is missing or data set has no point data");
112 for (i = 0; i < 3; i++)
113 {
114 n[i] = this->OutGradient[i];
115 }
116 return;
117 }
118
119 if (this->DataSet->GetMaxCellSize() > this->Size)
120 {
121 delete[] this->Weights;
122 this->Weights = new double[this->DataSet->GetMaxCellSize()];
123 this->Size = this->DataSet->GetMaxCellSize();
124 }
125
126 // Find the cell that contains xyz and get it
127 cell =
128 this->DataSet->FindAndGetCell(x, nullptr, -1, VTK_DBL_EPSILON, subId, pcoords, this->Weights);
129
130 if (cell)
131 { // Interpolate the point data
132 numPts = cell->GetNumberOfPoints();
133
134 for (i = 0; i < numPts; i++) // Weights used to hold scalar values
135 {
136 id = cell->PointIds->GetId(i);
137 this->Weights[i] = scalars->GetComponent(id, 0);
138 }
139 cell->Derivatives(subId, pcoords, this->Weights, 1, n);
140 }
141
142 else
143 { // use outside value
144 for (i = 0; i < 3; i++)
145 {
146 n[i] = this->OutGradient[i];
147 }
148 }
149}
150
151void vtkImplicitDataSet::PrintSelf(ostream& os, vtkIndent indent)
152{

Callers

nothing calls this directly

Calls 8

GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
GetMaxCellSizeMethod · 0.45
FindAndGetCellMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetIdMethod · 0.45
GetComponentMethod · 0.45
DerivativesMethod · 0.45

Tested by

no test coverage detected