vtkBoostSplitTableField.h 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkBoostSplitTableField.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  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.

=========================================================================*/
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
/**
 * @class   vtkBoostSplitTableField
 * @brief   "Splits" one-or-more table fields by duplicating rows containing delimited data.
 *
 *
 * Assume the following table:
 *
 * Author                Year     Title
 * Brian; Jeff; Tim      2007     Foo
 * Tim                   2003     Bar
 *
 * If we produce a graph relating authors to the year in which they publish, the string
 * "Brian; Jeff; Tim" will be treated (incorrectly) as a single author associated with
 * the year 2007.  vtkBoostSplitTableField addresses this by splitting one-or-more fields into
 * "subvalues" using a configurable delimiter and placing each subvalue on its own row
 * (the other fields in the original row are copied).  Using the above example, splitting
 * the "Author" field with a ";" (semicolon) delimiter produces:
 *
 * Author                Year     Title
 * Brian                 2007     Foo
 * Jeff                  2007     Foo
 * Tim                   2007     Foo
 * Tim                   2003     Bar
 *
 * When this table is converted to a graph, each author (correctly) becomes a separate node.
 *
 * Usage:
 *
 * Use AddField() to specify the field(s) to be split.  If no fields have been specified,
 * vtkBoostSplitTableField will act as a passthrough.  By default, no fields are specified.
 *
 * The second argument to AddField() is a string containing zero-to-many single character
 * delimiters (multi-character delimiters are not supported).
 *
 * If the input table is missing a field specified by AddField(), it is an error.
 * If no fields are specified, no splitting is performed.
 * If the delimiter for a field is an empty string, no splitting is performed on that field.
*/
53

54 55
#ifndef vtkBoostSplitTableField_h
#define vtkBoostSplitTableField_h
56

57
#include "vtkInfovisBoostGraphAlgorithmsModule.h" // For export macro
58 59 60 61
#include "vtkTableAlgorithm.h"

class vtkStringArray;

62
class VTKINFOVISBOOSTGRAPHALGORITHMS_EXPORT vtkBoostSplitTableField : public vtkTableAlgorithm
63 64 65
{
public:
  static vtkBoostSplitTableField* New();
66
  vtkTypeMacro(vtkBoostSplitTableField, vtkTableAlgorithm);
67
  void PrintSelf(ostream& os, vtkIndent indent) override;
68 69 70 71 72 73 74 75 76

  void ClearFields();
  void AddField(const char* field, const char* delimiters);

protected:
  vtkBoostSplitTableField();
  ~vtkBoostSplitTableField();

  int RequestData(
77 78
    vtkInformation*,
    vtkInformationVector**,
79
    vtkInformationVector*) override;
80 81 82

  vtkStringArray* Fields;
  vtkStringArray* Delimiters;
83

84
private:
85

86
  class implementation;
87

88 89
  vtkBoostSplitTableField(const vtkBoostSplitTableField&) = delete;
  void operator=(const vtkBoostSplitTableField&) = delete;
90 91 92
};

#endif