NVIDIA Iray API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mdl_argument_editor.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2014 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
6 //*****************************************************************************
7 
8 #ifndef MI_NEURAYLIB_MDL_ARGUMENT_EDITOR_H
9 #define MI_NEURAYLIB_MDL_ARGUMENT_EDITOR_H
10 
11 #include <mi/base/handle.h>
12 #include <mi/neuraylib/assert.h>
13 #include <mi/neuraylib/iarray.h>
16 #include <mi/neuraylib/ifactory.h>
20 #include <mi/neuraylib/set_get.h>
21 
22 #include <string>
23 
24 namespace mi {
25 
30 class Mdl_argument_editor
50 {
51 public:
52 
54 
55 
63  neuraylib::ITransaction* transaction, const char* name, neuraylib::IFactory* factory);
64 
70  bool is_valid() const;
71 
77  Element_type get_type() const;
78 
80  const char* get_name() const;
81 
83  const char* get_definition() const;
84 
87 
92  const char* get_parameter_name( Uint32 index) const;
93 
98  const char* get_parameter_type( const char* parameter_name) const;
99 
105  bool is_parameter_type_uniform( const char* parameter_name) const;
106 
111  const char* get_argument_type( const char* argument_name) const;
112 
116  const char* get_return_type() const;
117 
121  bool is_return_type_varying() const;
122 
124 
126 
139  template <class T>
140  Sint32 get_value( const char* argument_name, T& value) const;
141 
155  template <class T>
156  Sint32 get_value( const char* argument_name, Size array_index, T& value) const;
157 
171  template <class T>
172  Sint32 set_value( const char* argument_name, const T& value);
173 
188  template <class T>
189  Sint32 set_value( const char* argument_name, Size array_index, const T& value);
190 
192 
194 
200  bool has_attachment( const char* argument_name) const;
201 
209  bool has_attachment( const char* argument_name, Size array_index) const;
210 
215  const char* get_attachment( const char* argument_name) const;
216 
222  const char* get_attachment( const char* argument_name, Size array_index) const;
223 
236  Sint32 set_attachment( const char* argument_name, const char* attachment_name);
237 
252  const char* argument_name, Size array_index, const char* attachment_name);
253 
265  Sint32 remove_attachment( const char* argument_name);
266 
279  Sint32 remove_attachment( const char* argument_name, Size array_index);
280 
282 
284 
294  Sint32 get_array_length( const char* argument_name, Size& size) const;
295 
305  Sint32 set_array_length( const char* argument_name, Size size);
306 
308 
309 private:
310  void promote_to_edit_if_needed();
311 
312  base::Handle<neuraylib::ITransaction> m_transaction;
313  base::Handle<neuraylib::IFactory> m_factory;
314  base::Handle<const IScene_element> m_access;
315  base::Handle<const IScene_element> m_old_access;
316  base::Handle<IScene_element> m_edit;
317  Element_type m_type;
318  MISTD::string m_name;
319 };
320  // end group mi_neuray_materials
322 
324  neuraylib::ITransaction* transaction, const char* name, neuraylib::IFactory* factory)
325 {
326  mi_neuray_assert( transaction);
327  mi_neuray_assert( name);
328 
329  m_transaction = make_handle_dup( transaction);
330  m_name = name;
331  m_factory = make_handle_dup( factory);
332  m_access = transaction->access<IScene_element>( name);
333  m_type = m_access.is_valid_interface()
334  ? m_access->get_element_type() : static_cast<Element_type>( 0);
335 }
336 
337 inline bool Mdl_argument_editor::is_valid() const
338 {
339  return m_access.is_valid_interface()
341  || m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL);
342 }
343 
345 {
346  return m_type;
347 }
348 
349 inline const char* Mdl_argument_editor::get_name() const
350 {
351  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
352 
354  m_access->get_interface<IMdl_material_instance>());
355  return mi->get_name();
356 
357  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
358 
360  m_access->get_interface<IMdl_function_call>());
361  return fc->get_name();
362 
363  } else
364  return 0;
365 }
366 
367 inline const char* Mdl_argument_editor::get_definition() const
368 {
369  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
370 
372  m_access->get_interface<IMdl_material_instance>());
373  return mi->get_material_definition();
374 
375  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
376 
378  m_access->get_interface<IMdl_function_call>());
379  return fc->get_function_definition();
380 
381  } else
382  return 0;
383 }
384 
386 {
387  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
388 
390  m_access->get_interface<IMdl_material_instance>());
391  return mi->get_parameter_count();
392 
393  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
394 
396  m_access->get_interface<IMdl_function_call>());
397  return fc->get_parameter_count();
398 
399  } else
400  return 0;
401 }
402 
403 inline const char* Mdl_argument_editor::get_parameter_name( Uint32 index) const
404 {
405  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
406 
408  m_access->get_interface<IMdl_material_instance>());
409  return mi->get_parameter_name( index);
410 
411  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
412 
414  m_access->get_interface<IMdl_function_call>());
415  return fc->get_parameter_name( index);
416 
417  } else
418  return 0;
419 }
420 
421 inline const char* Mdl_argument_editor::get_parameter_type( const char* parameter_name) const
422 {
423  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
424 
426  m_access->get_interface<IMdl_material_instance>());
427  return mi->get_parameter_type( parameter_name);
428 
429  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
430 
432  m_access->get_interface<IMdl_function_call>());
433  return fc->get_parameter_type( parameter_name);
434 
435  } else
436  return 0;
437 }
438 
439 inline const char* Mdl_argument_editor::get_argument_type( const char* argument_name) const
440 {
441  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
442 
444  m_access->get_interface<IMdl_material_instance>());
445  return mi->get_argument_type( argument_name);
446 
447  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
448 
450  m_access->get_interface<IMdl_function_call>());
451  return fc->get_argument_type( argument_name);
452 
453  } else
454  return 0;
455 }
456 
457 inline bool Mdl_argument_editor::is_parameter_type_uniform( const char* parameter_name) const
458 {
459  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
460 
462  m_access->get_interface<IMdl_material_instance>());
463  return mi->is_parameter_type_uniform( parameter_name);
464 
465  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
466 
468  m_access->get_interface<IMdl_function_call>());
469  return fc->is_parameter_type_uniform( parameter_name);
470 
471  } else
472  return false;
473 }
474 
475 inline const char* Mdl_argument_editor::get_return_type() const
476 {
477  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
478 
479  return 0;
480 
481  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
482 
484  m_access->get_interface<IMdl_function_call>());
485  return fc->get_return_type();
486 
487  } else
488  return 0;
489 }
490 
492 {
493  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
494 
495  return 0;
496 
497  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
498 
500  m_access->get_interface<IMdl_function_call>());
501  return fc->is_return_type_varying();
502 
503  } else
504  return false;
505 }
506 
507 template <class T>
508 Sint32 Mdl_argument_editor::get_value( const char* argument_name, T& value) const
509 {
510  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
511 
513  m_access->get_interface<IMdl_material_instance>());
514  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
515  if( !argument.is_valid_interface())
516  return -2;
517  base::Handle<const IData> data( argument->get_value());
518  Sint32 result = mi::get_value( data.get(), value);
519  return result == 0 ? 0 : -3;
520 
521  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
522 
524  m_access->get_interface<IMdl_function_call>());
525  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
526  if( !argument.is_valid_interface())
527  return -2;
528  base::Handle<const IData> data( argument->get_value());
529  Sint32 result = mi::get_value( data.get(), value);
530  return result == 0 ? 0 : -3;
531 
532  } else
533  return -1;
534 }
535 
536 template <class T>
537 Sint32 Mdl_argument_editor::get_value( const char* argument_name, Size array_index, T& value) const
538 {
539  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
540 
542  m_access->get_interface<IMdl_material_instance>());
543  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
544  if( !argument.is_valid_interface())
545  return -2;
546  base::Handle<const IArray> array( argument->get_value<IArray>());
547  if( !array.is_valid_interface())
548  return -2;
549  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
550  if( !element.is_valid_interface())
551  return -2;
552  base::Handle<const IData> data( element->get_value());
553  Sint32 result = mi::get_value( data.get(), value);
554  return result == 0 ? 0 : -3;
555 
556  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
557 
559  m_access->get_interface<IMdl_function_call>());
560  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
561  if( !argument.is_valid_interface())
562  return -2;
563  base::Handle<const IArray> array( argument->get_value<IArray>());
564  if( !array.is_valid_interface())
565  return -2;
566  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
567  if( !element.is_valid_interface())
568  return -2;
569  base::Handle<const IData> data( element->get_value());
570  Sint32 result = mi::get_value( data.get(), value);
571  return result == 0 ? 0 : -3;
572 
573  } else
574  return -1;
575 }
576 
577 template <class T>
578 Sint32 Mdl_argument_editor::set_value( const char* argument_name, const T& value)
579 {
580  promote_to_edit_if_needed();
581 
582  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
583 
584  base::Handle<IMdl_material_instance> mi( m_edit->get_interface<IMdl_material_instance>());
585  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
586  if( !argument.is_valid_interface())
587  return -2;
588  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
589  base::Handle<IData> data( clone->get_value());
590  if( mi::set_value( data.get(), value) != 0)
591  return -3;
592  return mi->set_argument( argument_name, clone.get());
593 
594  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
595 
596  base::Handle<IMdl_function_call> fc( m_edit->get_interface<IMdl_function_call>());
597  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
598  if( !argument.is_valid_interface())
599  return -2;
600  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
601  base::Handle<IData> data( clone->get_value());
602  if( mi::set_value( data.get(), value) != 0)
603  return -3;
604  return fc->set_argument( argument_name, clone.get());
605 
606  } else
607  return -1;
608 }
609 
610 template <class T>
611 Sint32 Mdl_argument_editor::set_value( const char* argument_name, Size array_index, const T& value)
612 {
613  promote_to_edit_if_needed();
614 
615  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
616 
617  base::Handle<IMdl_material_instance> mi( m_edit->get_interface<IMdl_material_instance>());
618  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
619  if( !argument.is_valid_interface())
620  return -2;
621  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
622  base::Handle<IArray> array( clone->get_value<IArray>());
623  if( !array.is_valid_interface())
624  return -2;
625  base::Handle<IAttachable> element( array->get_element<IAttachable>( array_index));
626  if( !element.is_valid_interface())
627  return -2;
628  base::Handle<IData> data( element->get_value());
629  if( mi::set_value( data.get(), value) != 0)
630  return -3;
631  return mi->set_argument( argument_name, clone.get());
632 
633  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
634 
635  base::Handle<IMdl_function_call> fc( m_edit->get_interface<IMdl_function_call>());
636  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
637  if( !argument.is_valid_interface())
638  return -2;
639  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
640  base::Handle<IArray> array( clone->get_value<IArray>());
641  if( !array.is_valid_interface())
642  return -2;
643  base::Handle<IAttachable> element( array->get_element<IAttachable>( array_index));
644  if( !element.is_valid_interface())
645  return -2;
646  base::Handle<IData> data( element->get_value());
647  if( mi::set_value( data.get(), value) != 0)
648  return -3;
649  return fc->set_argument( argument_name, clone.get());
650 
651  } else
652  return -1;
653 }
654 
655 inline bool Mdl_argument_editor::has_attachment( const char* argument_name) const
656 {
657  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
658 
660  m_access->get_interface<IMdl_material_instance>());
661  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
662  if( !argument.is_valid_interface())
663  return false;
664  return argument->get_reference_name() != 0;
665 
666  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
667 
669  m_access->get_interface<IMdl_function_call>());
670  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
671  if( !argument.is_valid_interface())
672  return false;
673  return argument->get_reference_name() != 0;
674 
675  } else
676  return false;
677 }
678 
679 inline bool Mdl_argument_editor::has_attachment( const char* argument_name, Size array_index) const
680 {
681  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
682 
684  m_access->get_interface<IMdl_material_instance>());
685  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
686  if( !argument.is_valid_interface())
687  return false;
688  base::Handle<const IArray> array( argument->get_value<IArray>());
689  if( !array.is_valid_interface())
690  return false;
691  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
692  if( !element.is_valid_interface())
693  return false;
694  return element->get_reference_name() != 0;
695 
696  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
697 
699  m_access->get_interface<IMdl_function_call>());
700  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
701  if( !argument.is_valid_interface())
702  return false;
703  base::Handle<const IArray> array( argument->get_value<IArray>());
704  if( !array.is_valid_interface())
705  return false;
706  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
707  if( !element.is_valid_interface())
708  return false;
709  return element->get_reference_name() != 0;
710 
711  } else
712  return false;
713 }
714 
715 inline const char* Mdl_argument_editor::get_attachment( const char* argument_name) const
716 {
717  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
718 
720  m_access->get_interface<IMdl_material_instance>());
721  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
722  if( !argument.is_valid_interface())
723  return 0;
724  return argument->get_reference_name();
725 
726  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
727 
729  m_access->get_interface<IMdl_function_call>());
730  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
731  if( !argument.is_valid_interface())
732  return 0;
733  return argument->get_reference_name();
734 
735  } else
736  return 0;
737 }
738 
740  const char* argument_name, Size array_index) const
741 {
742  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
743 
745  m_access->get_interface<IMdl_material_instance>());
746  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
747  if( !argument.is_valid_interface())
748  return 0;
749  base::Handle<const IArray> array( argument->get_value<IArray>());
750  if( !array.is_valid_interface())
751  return 0;
752  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
753  if( !element.is_valid_interface())
754  return 0;
755  return element->get_reference_name();
756 
757  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
758 
760  m_access->get_interface<IMdl_function_call>());
761  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
762  if( !argument.is_valid_interface())
763  return 0;
764  base::Handle<const IArray> array( argument->get_value<IArray>());
765  if( !array.is_valid_interface())
766  return 0;
767  base::Handle<const IAttachable> element( array->get_element<IAttachable>( array_index));
768  if( !element.is_valid_interface())
769  return 0;
770  return element->get_reference_name();
771 
772  } else
773  return 0;
774 }
775 
777  const char* argument_name, const char* attachment_name)
778 {
779  promote_to_edit_if_needed();
780 
781  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
782 
783  base::Handle<IMdl_material_instance> mi( m_edit->get_interface<IMdl_material_instance>());
784  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
785  if( !argument.is_valid_interface())
786  return -2;
787  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
788  if( clone->set_reference( attachment_name) != 0)
789  return -3;
790  return mi->set_argument( argument_name, clone.get());
791 
792  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
793 
794  base::Handle<IMdl_function_call> fc( m_edit->get_interface<IMdl_function_call>());
795  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
796  if( !argument.is_valid_interface())
797  return -2;
798  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
799  if( clone->set_reference( attachment_name) != 0)
800  return -3;
801  return fc->set_argument( argument_name, clone.get());
802 
803  } else
804  return -1;
805 }
806 
808  const char* argument_name, Size array_index, const char* attachment_name)
809 {
810  promote_to_edit_if_needed();
811 
812  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
813 
814  base::Handle<IMdl_material_instance> mi( m_edit->get_interface<IMdl_material_instance>());
815  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
816  if( !argument.is_valid_interface())
817  return -2;
818  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
819  base::Handle<IArray> array( clone->get_value<IArray>());
820  if( !array.is_valid_interface())
821  return -2;
822  base::Handle<IAttachable> element( array->get_element<IAttachable>( array_index));
823  if( !element.is_valid_interface())
824  return -2;
825  if( element->set_reference( attachment_name) != 0)
826  return -3;
827  return mi->set_argument( argument_name, clone.get());
828 
829  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
830 
831  base::Handle<IMdl_function_call> fc( m_edit->get_interface<IMdl_function_call>());
832  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
833  if( !argument.is_valid_interface())
834  return -2;
835  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
836  base::Handle<IArray> array( clone->get_value<IArray>());
837  if( !array.is_valid_interface())
838  return -2;
839  base::Handle<IAttachable> element( array->get_element<IAttachable>( array_index));
840  if( !element.is_valid_interface())
841  return -2;
842  if( element->set_reference( attachment_name) != 0)
843  return -3;
844  return fc->set_argument( argument_name, clone.get());
845 
846  } else
847  return -1;
848 }
849 
850 inline Sint32 Mdl_argument_editor::remove_attachment( const char* argument_name)
851 {
852  return set_attachment( argument_name, 0);
853 }
854 
855 inline Sint32 Mdl_argument_editor::remove_attachment( const char* argument_name, Size array_index)
856 {
857  return set_attachment( argument_name, array_index, 0);
858 }
859 
860 inline Sint32 Mdl_argument_editor::get_array_length( const char* argument_name, Size& size) const
861 {
862  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
863 
865  m_access->get_interface<IMdl_material_instance>());
866  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
867  if( !argument.is_valid_interface())
868  return -2;
869  base::Handle<const IArray> array( argument->get_value<IArray>());
870  if( !array.is_valid_interface())
871  return -4;
872  size = array->get_length();
873  return 0;
874 
875  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
876 
878  m_access->get_interface<IMdl_function_call>());
879  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
880  if( !argument.is_valid_interface())
881  return -2;
882  base::Handle<const IArray> array( argument->get_value<IArray>());
883  if( !array.is_valid_interface())
884  return -4;
885  size = array->get_length();
886  return 0;
887 
888  } else
889  return -1;
890 }
891 
892 inline Sint32 Mdl_argument_editor::set_array_length( const char* argument_name, Size size)
893 {
894  promote_to_edit_if_needed();
895 
896  if( m_type == ELEMENT_TYPE_MDL_MATERIAL_INSTANCE) {
897 
898  base::Handle<IMdl_material_instance> mi( m_edit->get_interface<IMdl_material_instance>());
899  base::Handle<const IAttachable> argument( mi->get_argument( argument_name));
900  if( !argument.is_valid_interface())
901  return -2;
902  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
903  base::Handle<IDynamic_array> dynamic_array( clone->get_value<IDynamic_array>());
904  if( !dynamic_array.is_valid_interface())
905  return -4;
906  dynamic_array->set_length( size);
907  mi->set_argument( argument_name, clone.get());
908  return 0;
909 
910  } else if( m_type == ELEMENT_TYPE_MDL_FUNCTION_CALL) {
911 
912  base::Handle<IMdl_function_call> fc( m_edit->get_interface<IMdl_function_call>());
913  base::Handle<const IAttachable> argument( fc->get_argument( argument_name));
914  if( !argument.is_valid_interface())
915  return -2;
916  base::Handle<IAttachable> clone( m_factory->clone<IAttachable>( argument.get()));
917  base::Handle<IDynamic_array> dynamic_array( clone->get_value<IDynamic_array>());
918  if( !dynamic_array.is_valid_interface())
919  return -4;
920  dynamic_array->set_length( size);
921  fc->set_argument( argument_name, clone.get());
922  return 0;
923 
924  } else
925  return -1;
926 }
927 
928 inline void Mdl_argument_editor::promote_to_edit_if_needed()
929 {
930  if( m_edit.is_valid_interface())
931  return;
932  m_edit = m_transaction->edit<IScene_element>( m_name.c_str());
933  mi_neuray_assert( m_edit.is_valid_interface());
934  m_old_access = m_access;
935  m_access = m_edit;
936 }
937 
938 } // namespace mi
939 
940 #endif // MI_NEURAYLIB_MDL_ARGUMENT_EDITOR_H