<commit_before>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPiecewiseFunction.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkPiecewiseFunction.h"

#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"

#include <vtkstd/vector>
#include <vtkstd/set>
#include <vtkstd/algorithm>
#include <vtkstd/iterator>

vtkCxxRevisionMacro(vtkPiecewiseFunction, "1.52");
vtkStandardNewMacro(vtkPiecewiseFunction);

// The Node structure
class vtkPiecewiseFunctionNode
{
public:
  double X;
  double Y;
  double Sharpness;
  double Midpoint;
};

// A comparison method for sorting nodes in increasing order
class vtkPiecewiseFunctionCompareNodes
{
public:
  bool operator () ( const vtkPiecewiseFunctionNode *node1,
                     const vtkPiecewiseFunctionNode *node2 )
    {
      return node1->X < node2->X;
    }
};

// A find method for finding a particular node in the function
class vtkPiecewiseFunctionFindNodeEqual
{
public:
  double X;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return node->X == this->X;
    } 
};

// A find method for finding nodes inside a specified range
class vtkPiecewiseFunctionFindNodeInRange
{
public:
  double X1;
  double X2;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return ( node->X >= this->X1 &&
               node->X <= this->X2 );
    } 
};

// A find method for finding nodes outside a specified range
class vtkPiecewiseFunctionFindNodeOutOfRange
{
public:
  double X1;
  double X2;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return ( node->X < this->X1 &&
               node->X > this->X2 );
    } 
};

// The internal structure for containing the STL objects
class vtkPiecewiseFunctionInternals
{
public:
  vtkstd::vector<vtkPiecewiseFunctionNode*> Nodes;
  vtkPiecewiseFunctionCompareNodes        CompareNodes;
  vtkPiecewiseFunctionFindNodeEqual       FindNodeEqual;
  vtkPiecewiseFunctionFindNodeInRange     FindNodeInRange;
  vtkPiecewiseFunctionFindNodeOutOfRange  FindNodeOutOfRange;
};
<commit_msg>BUG: The "AdjustRange" method, which removes any nodes in the opacity transfer function outside the specified range was never working. The condition would always return false.<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPiecewiseFunction.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#include "vtkPiecewiseFunction.h"

#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"

#include <vtkstd/vector>
#include <vtkstd/set>
#include <vtkstd/algorithm>
#include <vtkstd/iterator>

vtkCxxRevisionMacro(vtkPiecewiseFunction, "1.53");
vtkStandardNewMacro(vtkPiecewiseFunction);

// The Node structure
class vtkPiecewiseFunctionNode
{
public:
  double X;
  double Y;
  double Sharpness;
  double Midpoint;
};

// A comparison method for sorting nodes in increasing order
class vtkPiecewiseFunctionCompareNodes
{
public:
  bool operator () ( const vtkPiecewiseFunctionNode *node1,
                     const vtkPiecewiseFunctionNode *node2 )
    {
      return node1->X < node2->X;
    }
};

// A find method for finding a particular node in the function
class vtkPiecewiseFunctionFindNodeEqual
{
public:
  double X;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return node->X == this->X;
    } 
};

// A find method for finding nodes inside a specified range
class vtkPiecewiseFunctionFindNodeInRange
{
public:
  double X1;
  double X2;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return ( node->X >= this->X1 &&
               node->X <= this->X2 );
    } 
};

// A find method for finding nodes outside a specified range
class vtkPiecewiseFunctionFindNodeOutOfRange
{
public:
  double X1;
  double X2;
  bool operator () ( const vtkPiecewiseFunctionNode *node )
    {
      return ( node->X < this->X1 ||
               node->X > this->X2 );
    } 
};

// The internal structure for containing the STL objects
class vtkPiecewiseFunctionInternals
{
public:
  vtkstd::vector<vtkPiecewiseFunctionNode*> Nodes;
  vtkPiecewiseFunctionCompareNodes        CompareNodes;
  vtkPiecewiseFunctionFindNodeEqual       FindNodeEqual;
  vtkPiecewiseFunctionFindNodeInRange     FindNodeInRange;
  vtkPiecewiseFunctionFindNodeOutOfRange  FindNodeOutOfRange;
};

{'fraction_non_alphanumeric': 0.13465195891974135, 'fraction_numerical': 0.005705591479650057, 'mean_word_length': 4.027724665391969, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4759267', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1519, 'n_words': 431}