MDL SDK API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ivalue.h
Go to the documentation of this file.
1 /***************************************************************************************************
2  * Copyright 2022 NVIDIA Corporation. All rights reserved.
3  **************************************************************************************************/
6 
7 #ifndef MI_NEURAYLIB_IVALUE_H
8 #define MI_NEURAYLIB_IVALUE_H
9 
10 #include <mi/base/handle.h>
11 #include <mi/math/color.h>
12 #include <mi/math/matrix.h>
13 #include <mi/math/spectrum.h>
14 #include <mi/math/vector.h>
15 #include <mi/neuraylib/itype.h>
16 
17 namespace mi {
18 
19 namespace neuraylib {
20 
25 class IAnnotation;
26 class IAnnotation_block;
27 
31 class IValue : public
32  mi::base::Interface_declare<0xbf837f4a,0x9034,0x4f32,0xaf,0x5c,0x75,0xb3,0x67,0x64,0x53,0x23>
33 {
34 public:
36  enum Kind {
67  // Undocumented, for alignment only.
68  VK_FORCE_32_BIT = 0xffffffffU
69  };
70 
72  virtual Kind get_kind() const = 0;
73 
75  virtual const IType* get_type() const = 0;
76 
78  template <class T>
79  const T* get_type() const
80  {
81  const IType* ptr_type = get_type();
82  if( !ptr_type)
83  return 0;
84  const T* ptr_T = static_cast<const T*>( ptr_type->get_interface( typename T::IID()));
85  ptr_type->release();
86  return ptr_T;
87  }
88 };
89 
90 mi_static_assert( sizeof( IValue::Kind) == sizeof( Uint32));
91 
93 class IValue_atomic : public
94  mi::base::Interface_declare<0xf2413c80,0x8e71,0x4974,0xaa,0xf2,0x60,0xd5,0xe2,0x94,0x9d,0x3e,
95  neuraylib::IValue>
96 {
97 public:
99  const IType_atomic* get_type() const = 0;
100 };
101 
103 class IValue_bool : public
104  mi::base::Interface_declare<0xaf253a14,0x1f04,0x4b67,0xba,0x70,0x7b,0x01,0x05,0xfb,0xc8,0xf5,
105  neuraylib::IValue_atomic>
106 {
107 public:
109  static const Kind s_kind = VK_BOOL;
110 
112  const IType_bool* get_type() const = 0;
113 
115  virtual bool get_value() const = 0;
116 
118  virtual void set_value( bool value) = 0;
119 };
120 
122 class IValue_int : public
123  mi::base::Interface_declare<0x91e6f145,0x280d,0x4d68,0x95,0x57,0xe1,0xd0,0x9c,0xd2,0x5c,0x74,
124  neuraylib::IValue_atomic>
125 {
126 public:
128  static const Kind s_kind = VK_INT;
129 
131  const IType_int* get_type() const = 0;
132 
134  virtual Sint32 get_value() const = 0;
135 
137  virtual void set_value( Sint32 value) = 0;
138 };
139 
141 class IValue_enum : public
142  mi::base::Interface_declare<0xdc876204,0x8a97,0x40e9,0xb9,0xb6,0xca,0xdc,0xdd,0x60,0x1f,0xbf,
143  neuraylib::IValue_atomic>
144 {
145 public:
147  static const Kind s_kind = VK_ENUM;
148 
150  virtual const IType_enum* get_type() const = 0;
151 
153  virtual Sint32 get_value() const = 0;
154 
156  virtual Size get_index() const = 0;
157 
163  virtual Sint32 set_value( Sint32 value) = 0;
164 
168  virtual Sint32 set_index( Size index) = 0;
169 
171  virtual const char* get_name() const = 0;
172 
176  virtual Sint32 set_name( const char* name) = 0;
177 };
178 
180 class IValue_float : public
181  mi::base::Interface_declare<0x21f07151,0x74b5,0x4296,0x90,0x29,0xc7,0xde,0x49,0x38,0x2a,0xbc,
182  neuraylib::IValue_atomic>
183 {
184 public:
186  static const Kind s_kind = VK_FLOAT;
187 
189  const IType_float* get_type() const = 0;
190 
192  virtual Float32 get_value() const = 0;
193 
195  virtual void set_value( Float32 value) = 0;
196 };
197 
199 class IValue_double : public
200  mi::base::Interface_declare<0xbdc84417,0x3e83,0x4bab,0x90,0xb1,0x9f,0x57,0xed,0x7b,0x15,0x03,
201  neuraylib::IValue_atomic>
202 {
203 public:
205  static const Kind s_kind = VK_DOUBLE;
206 
208  const IType_double* get_type() const = 0;
209 
211  virtual Float64 get_value() const = 0;
212 
214  virtual void set_value( Float64 value) = 0;
215 };
216 
218 class IValue_string : public
219  mi::base::Interface_declare<0x64b28506,0x8675,0x4724,0xa1,0x0d,0xc6,0xf2,0x35,0x46,0x26,0x39,
220  neuraylib::IValue_atomic>
221 {
222 public:
224  static const Kind s_kind = VK_STRING;
225 
227  const IType_string* get_type() const = 0;
228 
230  virtual const char* get_value() const = 0;
231 
233  virtual void set_value( const char* value) = 0;
234 };
235 
239  mi::base::Interface_declare<0x1fe80d3d,0xe79e,0x4bdb,0xb6,0x30,0xe3,0x36,0x31,0xa4,0x1e,0x39,
240  neuraylib::IValue_string>
241 {
242 public:
245  virtual const char* get_original_value() const = 0;
246 };
247 
249 class IValue_compound : public
250  mi::base::Interface_declare<0xdabc8fe3,0x5c70,0x4ef0,0xa2,0xf7,0x34,0x30,0xb5,0x67,0xdc,0x75,
251  neuraylib::IValue>
252 {
253 public:
255  virtual const IType_compound* get_type() const = 0;
256 
258  virtual Size get_size() const = 0;
259 
261  virtual const IValue* get_value( Size index) const = 0;
262 
264  template <class T>
265  const T* get_value( Size index) const
266  {
267  const IValue* ptr_value = get_value( index);
268  if( !ptr_value)
269  return 0;
270  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
271  ptr_value->release();
272  return ptr_T;
273  }
274 
276  virtual IValue* get_value( Size index) = 0;
277 
279  template <class T>
280  T* get_value( Size index)
281  {
282  IValue* ptr_value = get_value( index);
283  if( !ptr_value)
284  return 0;
285  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
286  ptr_value->release();
287  return ptr_T;
288  }
289 
299  virtual Sint32 set_value( Size index, IValue* value) = 0;
300 };
301 
306 class IValue_vector : public
307  mi::base::Interface_declare<0xf5d09fc3,0xd783,0x4571,0x8d,0x59,0x41,0xb1,0xff,0xd3,0x91,0x49,
308  neuraylib::IValue_compound>
309 {
310 public:
312  static const Kind s_kind = VK_VECTOR;
313 
315  virtual const IType_vector* get_type() const = 0;
316 
318  virtual const IValue_atomic* get_value( Size index) const = 0;
319 
321  template <class T>
322  const T* get_value( Size index) const
323  {
324  const IValue_atomic* ptr_value = get_value( index);
325  if( !ptr_value)
326  return 0;
327  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
328  ptr_value->release();
329  return ptr_T;
330  }
331 
333  virtual IValue_atomic* get_value( Size index) = 0;
334 
336  template <class T>
337  T* get_value( Size index)
338  {
339  IValue_atomic* ptr_value = get_value( index);
340  if( !ptr_value)
341  return 0;
342  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
343  ptr_value->release();
344  return ptr_T;
345  }
346 };
347 
352 class IValue_matrix : public
353  mi::base::Interface_declare<0x9ee95da6,0x2cd6,0x4168,0x89,0xea,0x92,0x10,0x57,0xda,0xe6,0xdc,
354  neuraylib::IValue_compound>
355 {
356 public:
358  static const Kind s_kind = VK_MATRIX;
359 
361  virtual const IType_matrix* get_type() const = 0;
362 
364  virtual const IValue_vector* get_value( Size index) const = 0;
365 
367  virtual IValue_vector* get_value( Size index) = 0;
368 };
369 
371 class IValue_color : public
372  mi::base::Interface_declare<0x3bb9bf46,0x1cbb,0x4460,0xbe,0x27,0x10,0xf5,0x71,0x61,0x96,0xa2,
373  neuraylib::IValue_compound>
374 {
375 public:
377  static const Kind s_kind = VK_COLOR;
378 
380  virtual const IType_color* get_type() const = 0;
381 
383  virtual const IValue_float* get_value( Size index) const = 0;
384 
386  virtual IValue_float* get_value( Size index) = 0;
387 
394  virtual Sint32 set_value( Size index, IValue_float* value) = 0;
395 
397 };
398 
400 class IValue_array : public
401  mi::base::Interface_declare<0xa17c5f57,0xa647,0x41c4,0x86,0x2f,0x4c,0x0d,0xe1,0x30,0x08,0xfc,
402  neuraylib::IValue_compound>
403 {
404 public:
406  static const Kind s_kind = VK_ARRAY;
407 
409  virtual const IType_array* get_type() const = 0;
410 
417  virtual Sint32 set_size( Size size) = 0;
418 };
419 
421 class IValue_struct : public
422  mi::base::Interface_declare<0xcbe089ce,0x4aea,0x474d,0x94,0x5f,0x52,0x13,0xef,0x01,0xce,0x81,
423  neuraylib::IValue_compound>
424 {
425 public:
427  static const Kind s_kind = VK_STRUCT;
428 
430  virtual const IType_struct* get_type() const = 0;
431 
436  virtual const IValue* get_field( const char* name) const = 0;
437 
442  template <class T>
443  const T* get_field( const char* name) const
444  {
445  const IValue* ptr_value = get_field( name);
446  if( !ptr_value)
447  return 0;
448  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
449  ptr_value->release();
450  return ptr_T;
451  }
452 
457  virtual IValue* get_field( const char* name) = 0;
458 
463  template <class T>
464  T* get_field( const char* name)
465  {
466  IValue* ptr_value = get_field( name);
467  if( !ptr_value)
468  return 0;
469  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
470  ptr_value->release();
471  return ptr_T;
472  }
473 
483  virtual Sint32 set_field( const char* name, IValue* value) = 0;
484 };
485 
487 class IValue_resource : public
488  mi::base::Interface_declare<0x479bb10c,0xd444,0x426c,0x83,0xab,0x26,0xdf,0xf6,0x1d,0x6f,0xd7,
489  neuraylib::IValue>
490 {
491 public:
493  virtual const IType_resource* get_type() const = 0;
494 
498  virtual const char* get_value() const = 0;
499 
510  virtual Sint32 set_value( const char* value) = 0;
511 
516  virtual const char* get_file_path() const = 0;
517 };
518 
520 class IValue_texture : public
521  mi::base::Interface_declare<0xf2a03651,0x8883,0x4ba4,0xb9,0xa9,0xe6,0x87,0x34,0x3a,0xb3,0xb8,
522  neuraylib::IValue_resource>
523 {
524 public:
526  static const Kind s_kind = VK_TEXTURE;
527 
529  virtual const IType_texture* get_type() const = 0;
530 
535  virtual Float32 get_gamma() const = 0;
536 
538  virtual const char* get_selector() const = 0;
539 };
540 
542 class IValue_light_profile : public
543  mi::base::Interface_declare<0xd7c9ffbd,0xb5e4,0x4bf4,0x90,0xd0,0xe9,0x75,0x4d,0x6d,0x49,0x07,
544  neuraylib::IValue_resource>
545 {
546 public:
548  static const Kind s_kind = VK_LIGHT_PROFILE;
549 
551  virtual const IType_light_profile* get_type() const = 0;
552 };
553 
556  mi::base::Interface_declare<0x31a55244,0x415c,0x4b4d,0xa7,0x86,0x2f,0x21,0x9c,0xb8,0xb9,0xff,
557  neuraylib::IValue_resource>
558 {
559 public:
562 
564  virtual const IType_bsdf_measurement* get_type() const = 0;
565 };
566 
568 class IValue_invalid_df : public
569  mi::base::Interface_declare<0x1588b6fa,0xa143,0x4bac,0xa0,0x32,0x06,0xbd,0x9e,0x7f,0xb6,0xe5,
570  neuraylib::IValue>
571 {
572 public:
574  static const Kind s_kind = VK_INVALID_DF;
575 
577  const IType_reference* get_type() const = 0;
578 };
579 
583 class IValue_list : public
584  mi::base::Interface_declare<0x8027a5e5,0x4e25,0x410c,0xbb,0xce,0x84,0xb4,0x88,0x8b,0x03,0x46>
585 {
586 public:
588  virtual Size get_size() const = 0;
589 
591  virtual Size get_index( const char* name) const = 0;
592 
594  virtual const char* get_name( Size index) const = 0;
595 
597  virtual const IValue* get_value( Size index) const = 0;
598 
600  template <class T>
601  const T* get_value( Size index) const
602  {
603  const IValue* ptr_value = get_value( index);
604  if( !ptr_value)
605  return 0;
606  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
607  ptr_value->release();
608  return ptr_T;
609  }
610 
612  virtual const IValue* get_value( const char* name) const = 0;
613 
615  template <class T>
616  const T* get_value( const char* name) const
617  {
618  const IValue* ptr_value = get_value( name);
619  if( !ptr_value)
620  return 0;
621  const T* ptr_T = static_cast<const T*>( ptr_value->get_interface( typename T::IID()));
622  ptr_value->release();
623  return ptr_T;
624  }
625 
632  virtual Sint32 set_value( Size index, const IValue* value) = 0;
633 
640  virtual Sint32 set_value( const char* name, const IValue* value) = 0;
641 
648  virtual Sint32 add_value( const char* name, const IValue* value) = 0;
649 };
650 
654 class IValue_factory : public
655  mi::base::Interface_declare<0x82595c0d,0x3687,0x4b45,0xa3,0x38,0x42,0x20,0x02,0xea,0x3f,0x9b>
656 {
657 public:
658 
660  virtual IType_factory* get_type_factory() const = 0;
661 
663  virtual IValue_bool* create_bool( bool value = false) const = 0;
664 
666  virtual IValue_int* create_int( Sint32 value = 0) const = 0;
667 
669  virtual IValue_enum* create_enum( const IType_enum* type, Size index = 0) const = 0;
670 
672  virtual IValue_float* create_float( Float32 value = 0.0f) const = 0;
673 
675  virtual IValue_double* create_double( Float64 value = 0.0) const = 0;
676 
680  virtual IValue_string* create_string( const char* value = "") const = 0;
681 
683  virtual IValue_vector* create_vector( const IType_vector* type) const = 0;
684 
686  virtual IValue_matrix* create_matrix( const IType_matrix* type) const = 0;
687 
689  virtual IValue_color* create_color(
690  Float32 red = 0.0f,
691  Float32 green = 0.0f,
692  Float32 blue = 0.0f) const = 0;
693 
695  virtual IValue_array* create_array( const IType_array* type) const = 0;
696 
698  virtual IValue_struct* create_struct( const IType_struct* type) const = 0;
699 
701  virtual IValue_texture* create_texture( const IType_texture* type, const char* value) const = 0;
702 
704  virtual IValue_light_profile* create_light_profile( const char* value) const = 0;
705 
707  virtual IValue_bsdf_measurement* create_bsdf_measurement( const char* value) const = 0;
708 
710  virtual IValue_invalid_df* create_invalid_df( const IType_reference* type) const = 0;
711 
713  virtual IValue* create( const IType* type) const = 0;
714 
716  template <class T>
717  T* create( const IType* type) const
718  {
719  IValue* ptr_value = create( type);
720  if( !ptr_value)
721  return 0;
722  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
723  ptr_value->release();
724  return ptr_T;
725  }
726 
731  virtual IValue* create( const IAnnotation* annotation) const = 0;
732 
737  template <class T>
738  T* create( const IAnnotation* annotation) const
739  {
740  IValue* ptr_value = create( annotation);
741  if( !ptr_value)
742  return 0;
743  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
744  ptr_value->release();
745  return ptr_T;
746  }
747 
756  virtual IValue* create( const IType* type, const IAnnotation_block* annotation_block) const = 0;
757 
766  template <class T>
767  T* create( const IType* type, const IAnnotation_block* annotation_block) const
768  {
769  IValue* ptr_value = create( type, annotation_block);
770  if( !ptr_value)
771  return 0;
772  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
773  ptr_value->release();
774  return ptr_T;
775  }
776 
778  virtual IValue_list* create_value_list() const = 0;
779 
783  virtual IValue* clone( const IValue* value) const = 0;
784 
788  template <class T>
789  T* clone( const T* value) const
790  {
791  IValue* ptr_value = clone( static_cast<const IValue*>( value));
792  if( !ptr_value)
793  return 0;
794  T* ptr_T = static_cast<T*>( ptr_value->get_interface( typename T::IID()));
795  ptr_value->release();
796  return ptr_T;
797  }
798 
802  virtual IValue_list* clone( const IValue_list* value_list) const = 0;
803 
825  virtual Sint32 compare(
826  const IValue* lhs, const IValue* rhs, Float64 epsilon = 0.0) const = 0;
827 
842  virtual Sint32 compare(
843  const IValue_list* lhs, const IValue_list* rhs, Float64 epsilon = 0.0) const = 0;
844 
855  virtual const IString* dump( const IValue* value, const char* name, Size depth = 0) const = 0;
856 
866  virtual const IString* dump(
867  const IValue_list* list, const char* name, Size depth = 0) const = 0;
868 };
869 
885 template<class T>
887 {
890  if( value_int) {
891  value_int->set_value( v);
892  return 0;
893  }
894 
897  if( value_enum) {
898  if( value_enum->set_value( v) != 0)
899  return -2;
900  return 0;
901  }
902 
903  return -1;
904 }
905 
909 inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const bool& v)
910 {
913  if( value_bool) {
914  value_bool->set_value( v);
915  return 0;
916  }
917 
918  return -1;
919 }
920 
925 {
928  if( value_float) {
929  value_float->set_value( v);
930  return 0;
931  }
932 
935  if( value_double) {
936  value_double->set_value( v);
937  return 0;
938  }
939 
940  return -1;
941 }
942 
947 {
950  if( value_float) {
951  value_float->set_value( static_cast<mi::Float32>( v));
952  return 0;
953  }
954 
957  if( value_double) {
958  value_double->set_value( v);
959  return 0;
960  }
961 
962  return -1;
963 }
964 
969 inline mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* v)
970 {
973  if( value_enum) {
974  if( value_enum->set_name( v) != 0)
975  return -2;
976  return 0;
977  }
978 
981  if( value_string) {
982  value_string->set_value( v);
983  return 0;
984  }
985 
988  if( value_resource) {
989  if( value_resource->set_value( v) != 0)
990  return -2;
991  return 0;
992  }
993 
994  return -1;
995 }
996 
1001 template<class T, Size DIM>
1003 {
1006  if( value_vector) {
1007  if( value_vector->get_size() != DIM)
1008  return -1;
1009  for( Size i = 0; i < DIM; ++i) {
1010  mi::base::Handle<mi::neuraylib::IValue> component( value_vector->get_value( i));
1011  mi::Sint32 result = set_value( component.get(), v[i]);
1012  if( result != 0)
1013  return result;
1014  }
1015  return 0;
1016  }
1017 
1018  return -1;
1019 }
1020 
1030 template<class T, Size ROW, Size COL>
1032 {
1035  if( value_matrix) {
1036  if( value_matrix->get_size() != ROW)
1037  return -1;
1038  for( Size i = 0; i < ROW; ++i) {
1039  mi::base::Handle<mi::neuraylib::IValue_vector> column( value_matrix->get_value( i));
1040  if( column->get_size() != COL)
1041  return -1;
1042  for( Size j = 0; j < COL; ++j) {
1043  mi::base::Handle<mi::neuraylib::IValue> element( column->get_value( j));
1044  mi::Sint32 result = set_value( element.get(), v[i][j]);
1045  if( result != 0)
1046  return result;
1047  }
1048  }
1049  return 0;
1050  }
1051 
1052  return -1;
1053 }
1054 
1059 {
1062  if( value_color) {
1064  red ->set_value( v.r);
1066  green->set_value( v.g);
1068  blue ->set_value( v.b);
1069  return 0;
1070  }
1071 
1072  return -1;
1073 }
1074 
1080 {
1083  if( value_color) {
1085  red ->set_value( v[0]);
1087  green->set_value( v[1]);
1089  blue ->set_value( v[2]);
1090  return 0;
1091  }
1092 
1093  return -1;
1094 }
1095 
1106 template<class T>
1108 {
1111  if( value_compound) {
1112  mi::base::Handle<mi::neuraylib::IValue> component( value_compound->get_value( index));
1113  if( !component)
1114  return -3;
1115  return set_value( component.get(), v);
1116  }
1117 
1118  return -1;
1119 }
1120 
1131 template<class T>
1132 mi::Sint32 set_value( mi::neuraylib::IValue* value, const char* name, const T& v)
1133 {
1136  if( value_struct) {
1137  mi::base::Handle<mi::neuraylib::IValue> field( value_struct->get_field( name));
1138  if( !field)
1139  return -3;
1140  return set_value( field.get(), v);
1141  }
1142 
1143  return -1;
1144 }
1145 
1146 // Simplifies reading the value of #mi::neuraylib::IValue into the corresponding classes from the
1160 template<class T>
1162 {
1165  if( value_int) {
1166  v = value_int->get_value();
1167  return 0;
1168  }
1169 
1172  if( value_enum) {
1173  v = value_enum->get_value();
1174  return 0;
1175  }
1176 
1177  return -1;
1178 }
1179 
1183 inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, bool& v)
1184 {
1187  if( value_bool) {
1188  v = value_bool->get_value();
1189  return 0;
1190  }
1191 
1192  return -1;
1193 }
1194 
1199 {
1202  if( value_float) {
1203  v = value_float->get_value();
1204  return 0;
1205  }
1206 
1209  if( value_double) {
1210  v = static_cast<mi::Float32>( value_double->get_value());
1211  return 0;
1212  }
1213 
1214  return -1;
1215 }
1216 
1221 {
1224  if( value_float) {
1225  v = value_float->get_value();
1226  return 0;
1227  }
1228 
1231  if( value_double) {
1232  v = value_double->get_value();
1233  return 0;
1234  }
1235 
1236  return -1;
1237 }
1238 
1243 inline mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char*& v)
1244 {
1247  if( value_enum) {
1248  v = value_enum->get_name();
1249  return 0;
1250  }
1251 
1254  if( value_string) {
1255  v = value_string->get_value();
1256  return 0;
1257  }
1258 
1261  if( value_resource) {
1262  v = value_resource->get_value();
1263  return 0;
1264  }
1265 
1266  return -1;
1267 }
1268 
1273 template <class T, Size DIM>
1275 {
1278  if( value_vector) {
1279  if( value_vector->get_size() != DIM)
1280  return -1;
1281  for( Size i = 0; i < DIM; ++i) {
1282  mi::base::Handle<const mi::neuraylib::IValue> component( value_vector->get_value( i));
1283  mi::Sint32 result = get_value( component.get(), v[i]);
1284  if( result != 0)
1285  return result;
1286  }
1287  return 0;
1288  }
1289 
1290  return -1;
1291 }
1292 
1302 template <class T, Size ROW, Size COL>
1304 {
1307  if( value_matrix) {
1308  if( value_matrix->get_size() != ROW)
1309  return -1;
1310  for( Size i = 0; i < ROW; ++i) {
1312  value_matrix->get_value( i));
1313  if( column->get_size() != COL)
1314  return -1;
1315  for( Size j = 0; j < COL; ++j) {
1316  mi::base::Handle<const mi::neuraylib::IValue> element( column->get_value( j));
1317  mi::Sint32 result = get_value( element.get(), v[i][j]);
1318  if( result != 0)
1319  return result;
1320  }
1321  }
1322  return 0;
1323  }
1324 
1325  return -1;
1326 }
1327 
1332 {
1335  if( value_color) {
1337  v.r = red ->get_value();
1339  v.g = green->get_value();
1341  v.b = blue ->get_value();
1342  v.a = 1.0f;
1343  return 0;
1344  }
1345 
1346  return -1;
1347 }
1348 
1354 {
1357  if( value_color) {
1359  v[0] = red ->get_value();
1361  v[1] = green->get_value();
1363  v[2] = blue ->get_value();
1364  return 0;
1365  }
1366 
1367  return -1;
1368 }
1369 
1380 template<class T>
1382 {
1385  if( value_compound) {
1386  mi::base::Handle<const mi::neuraylib::IValue> component( value_compound->get_value( index));
1387  if( !component)
1388  return -3;
1389  return get_value( component.get(), v);
1390  }
1391 
1392  return -1;
1393 }
1394 
1405 template<class T>
1406 mi::Sint32 get_value( const mi::neuraylib::IValue* value, const char* name, T& v)
1407 {
1410  if( value_struct) {
1411  mi::base::Handle<const mi::neuraylib::IValue> field( value_struct->get_field( name));
1412  if( !field)
1413  return -3;
1414  return get_value( field.get(), v);
1415  }
1416 
1417  return -1;
1418 }
1419  // end group mi_neuray_mdl_types
1421 
1422 } // namespace neuraylib
1423 
1424 } // namespace mi
1425 
1426 #endif // MI_NEURAYLIB_IVALUE_H