vtkSphericalDirectionEncoder.h 2.65 KB
Newer Older
1 2
/*=========================================================================

3 4
  Program:   Visualization Toolkit
  Module:    vtkSphericalDirectionEncoder.h
5

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

10 11 12
     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.
13 14

=========================================================================*/
15 16 17 18 19 20 21 22 23
/**
 * @class   vtkSphericalDirectionEncoder
 * @brief   A direction encoder based on spherical coordinates
 *
 * vtkSphericalDirectionEncoder is a direction encoder which uses spherical
 * coordinates for mapping (nx, ny, nz) into an azimuth, elevation pair.
 *
 * @sa
 * vtkDirectionEncoder
24
 */
25

26 27
#ifndef vtkSphericalDirectionEncoder_h
#define vtkSphericalDirectionEncoder_h
28 29

#include "vtkDirectionEncoder.h"
30
#include "vtkRenderingVolumeModule.h" // For export macro
31

32
class VTKRENDERINGVOLUME_EXPORT vtkSphericalDirectionEncoder : public vtkDirectionEncoder
33 34
{
public:
35 36
  vtkTypeMacro(vtkSphericalDirectionEncoder, vtkDirectionEncoder);
  void PrintSelf(ostream& os, vtkIndent indent) override;
37

38 39 40 41 42
  /**
   * Construct the object. Initialize the index table which will be
   * used to map the normal into a patch on the recursively subdivided
   * sphere.
   */
43
  static vtkSphericalDirectionEncoder* New();
44

45 46 47
  /**
   * Given a normal vector n, return the encoded direction
   */
48
  int GetEncodedDirection(float n[3]) override;
49

50 51 52
  /**
   * / Given an encoded value, return a pointer to the normal vector
   */
53
  float* GetDecodedGradient(int value) VTK_SIZEHINT(3) override;
54

55 56 57
  /**
   * Return the number of encoded directions
   */
58
  int GetNumberOfEncodedDirections(void) override { return 65536; }
59

60 61 62 63 64 65
  /**
   * Get the decoded gradient table. There are
   * this->GetNumberOfEncodedDirections() entries in the table, each
   * containing a normal (direction) vector. This is a flat structure -
   * 3 times the number of directions floats in an array.
   */
66
  float* GetDecodedGradientTable(void) override { return &(this->DecodedGradientTable[0]); }
67

68 69
protected:
  vtkSphericalDirectionEncoder();
70
  ~vtkSphericalDirectionEncoder() override;
71

72
  static float DecodedGradientTable[65536 * 3];
73

74 75 76 77
  //@{
  /**
   * Initialize the table at startup
   */
78 79
  static void InitializeDecodedGradientTable();
  static int DecodedGradientTableInitialized;
80
  //@}
81

82
private:
83 84
  vtkSphericalDirectionEncoder(const vtkSphericalDirectionEncoder&) = delete;
  void operator=(const vtkSphericalDirectionEncoder&) = delete;
85
};
86 87

#endif