vtkSpherePuzzle.h 2.82 KB
Newer Older
Charles Law's avatar
Charles Law committed
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkSpherePuzzle.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Charles Law's avatar
Charles Law committed
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
Charles Law's avatar
Charles Law committed
13 14

=========================================================================*/
15 16 17 18 19 20
/**
 * @class   vtkSpherePuzzle
 * @brief   create a polygonal sphere centered at the origin
 *
 * vtkSpherePuzzle creates
*/
Charles Law's avatar
Charles Law committed
21

22 23
#ifndef vtkSpherePuzzle_h
#define vtkSpherePuzzle_h
Charles Law's avatar
Charles Law committed
24

25
#include "vtkFiltersModelingModule.h" // For export macro
26
#include "vtkPolyDataAlgorithm.h"
Charles Law's avatar
Charles Law committed
27 28 29

#define VTK_MAX_SPHERE_RESOLUTION 1024

30 31
class vtkTransform;

32
class VTKFILTERSMODELING_EXPORT vtkSpherePuzzle : public vtkPolyDataAlgorithm
Charles Law's avatar
Charles Law committed
33 34
{
public:
35
  vtkTypeMacro(vtkSpherePuzzle,vtkPolyDataAlgorithm);
36
  void PrintSelf(ostream& os, vtkIndent indent) override;
Charles Law's avatar
Charles Law committed
37 38 39

  static vtkSpherePuzzle *New();

40 41 42
  /**
   * Reset the state of this puzzle back to its original state.
   */
Charles Law's avatar
Charles Law committed
43 44
  void Reset();

45 46 47
  /**
   * Move the top/bottom half one segment either direction.
   */
Charles Law's avatar
Charles Law committed
48 49
  void MoveHorizontal(int section, int percentage, int rightFlag);

50 51 52
  /**
   * Rotate vertical half of sphere along one of the longitude lines.
   */
Charles Law's avatar
Charles Law committed
53
  void MoveVertical(int section, int percentage, int rightFlag);
54

55 56 57 58 59 60 61 62
  /**
   * SetPoint will be called as the mouse moves over the screen.
   * The output will change to indicate the pending move.
   * SetPoint returns zero if move is not activated by point.
   * Otherwise it encodes the move into a unique integer so that
   * the caller can determine if the move state has changed.
   * This will answer the question, "Should I render."
   */
63
  int SetPoint(double x, double y, double z);
Charles Law's avatar
Charles Law committed
64

65 66 67 68 69
  /**
   * Move actually implements the pending move. When percentage
   * is 100, the pending move becomes inactive, and SetPoint
   * will have to be called again to setup another move.
   */
70
  void MovePoint(int percentage);
Charles Law's avatar
Charles Law committed
71

72 73 74
  /**
   * For drawing state as arrows.
   */
Charles Law's avatar
Charles Law committed
75 76 77 78
  int *GetState() {return this->State;}

protected:
  vtkSpherePuzzle();
79
  ~vtkSpherePuzzle() override;
Charles Law's avatar
Charles Law committed
80

81
  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
Charles Law's avatar
Charles Law committed
82
  void MarkVertical(int section);
83 84
  void MarkHorizontal(int section);

Charles Law's avatar
Charles Law committed
85
  int State[32];
86

Charles Law's avatar
Charles Law committed
87 88 89 90 91 92 93 94 95 96 97 98
  // Stuff for storing a partial move.
  int PieceMask[32];
  vtkTransform *Transform;

  // Colors for faces.
  unsigned char Colors[96];

  // State for potential move.
  int Active;
  int VerticalFlag;
  int RightFlag;
  int Section;
99 100

private:
101 102
  vtkSpherePuzzle(const vtkSpherePuzzle&) = delete;
  void operator=(const vtkSpherePuzzle&) = delete;
Charles Law's avatar
Charles Law committed
103 104 105
};

#endif