MCPcopy Create free account
hub / github.com/ImageEngine/cortex / trimEndPoints

Function trimEndPoints

src/IECore/Ramp.cpp:254–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252// points well, so regardless of why they are there, this function will remove them.
253template<typename PointContainer>
254void trimEndPoints( PointContainer &points )
255{
256 if( points.empty() )
257 {
258 return;
259 }
260
261 // Count how many initial points have an X value matching the first point
262 typename PointContainer::const_iterator startDuplicates = ++points.begin();
263 while( startDuplicates != points.end() && startDuplicates->first == points.begin()->first )
264 {
265 startDuplicates++;
266 }
267 // We need to keep one of these points, the rest are duplicates and should be removed
268 startDuplicates--;
269
270 points.erase( points.begin(), startDuplicates );
271
272 // Count how many points have an X value matching the last point
273 typename PointContainer::const_reverse_iterator endDuplicates = ++points.rbegin();
274 while( endDuplicates != points.rend() && endDuplicates->first == points.rbegin()->first )
275 {
276 endDuplicates++;
277 }
278
279 // We need to keep one of these points, the rest are duplicates and should be removed
280 endDuplicates--;
281
282 points.erase( endDuplicates.base(), points.rbegin().base() );
283
284 // This originally indicated whether the end point duplication matched the expected multiplicity
285 // for a certain interpolation. We no longer make assumptions about how the input data handles end
286 // point multiplicity, and instead just remove any duplicates, so we no longer consider any inputs
287 // to be invalid.
288 return;
289}
290
291}
292

Callers 2

fromOSLMethod · 0.85
fromDeprecatedSplineMethod · 0.85

Calls 3

beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected