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

Method ClipEdge

Filters/Modeling/vtkBandedPolyDataContourFilter.cxx:167–254  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Interpolate the input scalars and create intermediate points between v1 and v2 at the contour values. The point ids are returned in the edgePts array, arranged from v1 to v2 if v1<v2 or vice-versa. The input array edgePts must be large enough to hold the point ids. Return the number of intersection points created in edg

Source from the content-addressed store, hash-verified

165// The input array edgePts must be large enough to hold the point ids.
166// Return the number of intersection points created in edgePts.
167int vtkBandedPolyDataContourFilter::ClipEdge(int v1, int v2, vtkPoints* newPts,
168 vtkDataArray* inScalars, vtkDoubleArray* outScalars, vtkPointData* inPD, vtkPointData* outPD,
169 vtkIdType edgePts[])
170{
171 double low = inScalars->GetComponent(v1, this->Component);
172 double high = inScalars->GetComponent(v2, this->Component);
173 auto b = this->Internal->ComputeClipValue(low);
174 auto e = this->Internal->ComputeClipValue(high);
175 assert(e != this->Internal->ClipValues.end());
176
177 if (b == e)
178 {
179 return 0;
180 }
181
182 // Insert from back to front if point ids are not ordered by increasing id
183 bool reverse = (v1 > v2);
184
185 // We iterate from lowest to highest end point
186 bool swap = (low > high);
187 if (swap)
188 {
189 std::swap(low, high);
190 std::swap(b, e);
191 reverse = !reverse;
192 }
193
194 // start with the first clip value larger than low
195 ++b;
196
197 // ComputeClipValue may have accepted a slightly too large value for the high
198 // clip value. If the difference between high and low is in the order of the
199 // internal clip tolerance this may lead to an interpolation factor that
200 // is significantly larger than 1. To prevent this only include the last
201 // clip value if it doesn't cause an overshoot of more than .01%
202 if ((*e - low) / (high - low) < 1.0001)
203 {
204 ++e;
205 }
206
207 if (b == e)
208 {
209 return 0;
210 }
211
212 // Interpolate between x1 and x2
213 double x1[3];
214 double x2[3];
215 if (!swap)
216 {
217 newPts->GetPoint(v1, x1);
218 newPts->GetPoint(v2, x2);
219 }
220 else
221 {
222 newPts->GetPoint(v2, x1);
223 newPts->GetPoint(v1, x2);
224 }

Callers 1

RequestDataMethod · 0.95

Calls 9

ComputeClipValueMethod · 0.80
assertFunction · 0.50
swapFunction · 0.50
distanceFunction · 0.50
GetComponentMethod · 0.45
endMethod · 0.45
GetPointMethod · 0.45
InsertNextPointMethod · 0.45
InterpolateEdgeMethod · 0.45

Tested by

no test coverage detected