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

Method AdjustRange

Common/DataModel/vtkPiecewiseFunction.cxx:608–663  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

606
607//------------------------------------------------------------------------------
608int vtkPiecewiseFunction::AdjustRange(double range[2])
609{
610 if (!range)
611 {
612 return 0;
613 }
614
615 double* function_range = this->GetRange();
616
617 // Make sure we have points at each end of the range
618
619 if (function_range[0] < range[0])
620 {
621 this->AddPoint(range[0], this->GetValue(range[0]));
622 }
623 else
624 {
625 this->AddPoint(range[0], this->GetValue(function_range[0]));
626 }
627
628 if (function_range[1] > range[1])
629 {
630 this->AddPoint(range[1], this->GetValue(range[1]));
631 }
632 else
633 {
634 this->AddPoint(range[1], this->GetValue(function_range[1]));
635 }
636
637 // Remove all points out-of-range
638 int done;
639
640 done = 0;
641 while (!done)
642 {
643 done = 1;
644
645 this->Internal->FindNodeOutOfRange.X1 = range[0];
646 this->Internal->FindNodeOutOfRange.X2 = range[1];
647
648 std::vector<vtkPiecewiseFunctionNode*>::iterator iter =
649 std::find_if(this->Internal->Nodes.begin(), this->Internal->Nodes.end(),
650 this->Internal->FindNodeOutOfRange);
651
652 if (iter != this->Internal->Nodes.end())
653 {
654 delete *iter;
655 this->Internal->Nodes.erase(iter);
656 this->Modified();
657 done = 0;
658 }
659 }
660
661 this->SortAndUpdateRange();
662 return 1;
663}
664
665//------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 8

AddPointMethod · 0.95
GetValueMethod · 0.95
SortAndUpdateRangeMethod · 0.95
GetRangeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected