ldpk
nuke_ld_3de4_base.h
1 #include <DDImage/Iop.h>
2 #include <DDImage/Box.h>
3 #include <DDImage/Filter.h>
4 #include <DDImage/Knobs.h>
5 #include <DDImage/Pixel.h>
6 #include <DDImage/Row.h>
7 #include <DDImage/Tile.h>
8 #include <DDImage/NukeWrapper.h>
9 #include <ldpk/ldpk_ldp_builtin.h>
10 
11 using namespace std;
12 
15 class nuke_ld_3de4_base:public DD::Image::Iop
16  {
17 private:
18  DD::Image::Filter _filter;
19 // Anzahl der modellabhaengigen Parameter, wird im Konstruktor ermittelt.
20  int _num_par;
21 // Der Wert des Richtungsknobs
22  int _knob_direction;
23 // Current output mode (extension by RSP, see .C-file)
24  int _knob_output_mode;
25 // Neu: Field-of-View
26  double _xa_fov_unit,_ya_fov_unit;
27  double _xb_fov_unit,_yb_fov_unit;
28  double _xd_fov_unit,_yd_fov_unit;
29  double _inv_xd_fov_unit,_inv_yd_fov_unit;
30 // Find out number of parameters per type and store here:
31  int _num_par_adjustable_double;
32  int _num_par_double;
33  int _num_par_int;
34  int _num_par_string;
35  int _num_par_file;
36  int _num_par_toggle;
37 // Wir verwenden hier absichtlich nicht std::vector, weil wir uns darauf verlassen
38 // muessen, dass die Werte nicht im Speicher verschoben werden. Es gibt einen Beispiel-Node,
39 // bei Nuke, der lustigerweise KnobParade heisst, da sehen wir, wie das geht.
40  double* _values_adjustable_double;
41  double* _values_double;
42  int* _values_int;
43  const char** _values_string;
44  const char** _values_file;
45  bool* _values_toggle;
46 // Default values for string- and file-knobs.
47  char** _defaults_string;
48  char** _defaults_file;
49 // The ld model instance. We derive from ldp_builtin instead of tde4_ld_plugin,
50 // since this class provides some extra functionality we need.
51 // typedef ldpk::ldp_builtin<ldpk::vec2d,ldpk::mat2d> ldm_type;
52  typedef tde4_ld_plugin ldm_type;
53  ldm_type* _ldm;
54 // Map x-coordinate from unit cordinates to fov coordinates.
55  double map_in_fov_x(double x_unit) const
56  { return (x_unit - _xa_fov_unit) * _inv_xd_fov_unit; }
57 // Map y-coordinate from unit cordinates to fov coordinates.
58  double map_in_fov_y(double y_unit) const
59  { return (y_unit - _ya_fov_unit) * _inv_yd_fov_unit; }
60 // Map x-coordinate from fov cordinates to unit coordinates.
61  double map_out_fov_x(double x_fov) const
62  { return x_fov * _xd_fov_unit + _xa_fov_unit; }
63 // Map y-coordinate from fov cordinates to unit coordinates.
64  double map_out_fov_y(double y_fov) const
65  { return y_fov * _yd_fov_unit + _ya_fov_unit; }
66 
67 // Model and parameter names in 3DE4 are human-readable, with characters
68 // like ",", "-" and space in it. This method eliminates maximum substrings containing
69 // other than [a-zA-Z0-9] and replaces them by a single underscore. The empty string is
70 // mapped to "_". A leading [0-9] is supplemented by a leading underscore.
71 // The result has the form of an identifier in C and Python.
72  std::string nukify_name(const std::string& name);
73 // Anscheinend von keiner Basisklasse gefordert.
74  enum direction_enum { distort = 0,undistort = 1 };
75  DD::Image::Box bounds(direction_enum,int x,int y,int r,int t);
76 // LDM-Parameter auf default
77  void set_default_values();
78 // Check for implementation errors
79  void check_indices(int i_par_adjustable_double,int i_par_double,int i_par_int,int i_par_string,int i_par_file,int i_par_toggle,int i_debug) const;
80 public:
81  nuke_ld_3de4_base(Node* node,ldm_type* ldm);
82  virtual ~nuke_ld_3de4_base();
83 
84  void knobs(DD::Image::Knob_Callback f);
85  void _validate(bool);
86  void _request(int x,int y,int r,int t,DD::Image::ChannelMask channels,int count);
87  void engine(int y,int x,int r,DD::Image::ChannelMask channels,DD::Image::Row& out);
88 
89  static const DD::Image::Iop::Description description;
90  };
Lens Distortion Plugin Base Class.
Definition: tde4_ld_plugin.h:21
The baseclass for Nuke plugins around LDPK-based lens distortion models. In order to implement a Nuke...
Definition: nuke_ld_3de4_base.h:15