00001 00002 // Copyright 1986-2009 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin, 00003 // Germany. All rights reserved. 00005 // Created: 27.02.08 00006 // Module: api 00007 // Purpose: mental ray C++ shader interface extensions 00009 00018 00019 00020 #ifndef SHADER_MAP_H 00021 #define SHADER_MAP_H 00022 00023 #include "mi_shader_if.h" 00024 00025 namespace mi { 00026 namespace shader_v3 { 00027 00033 class Map_status { 00034 public: 00036 enum Status_code { 00037 OK = 0, 00038 00039 Insufficient_memory, 00040 No_such_field, 00041 Out_of_bounds, 00042 No_declaration, 00043 Declaration_mismatch, 00044 Wrong_dimension, 00045 00046 File_could_not_be_opened = 16, 00047 File_not_a_map, 00048 File_version_unsupported, 00049 00050 Field_undefined = 32, 00051 Field_name_too_long, 00052 Field_name_empty, 00053 Field_name_illegal, 00054 Field_null_array, 00055 Field_type_mismatch, 00056 Field_illegal, 00057 00058 Iterator_invalid = 48, 00059 Iterator_past_end, 00060 Iterator_out_of_bounds, 00061 00062 Lookup_invalid = 64, 00063 Lookup_past_end, 00064 Lookup_out_of_bounds, 00065 Lookup_dimension_mismatch 00066 }; 00067 00069 Map_status() 00070 : m_status(OK) 00071 {} 00072 00075 Map_status(Status_code status) 00076 : m_status(status) 00077 {} 00078 00081 Map_status(const Map_status& status) 00082 : m_status(status.m_status) 00083 {} 00084 00088 Map_status& operator=(const Status_code& rhs) 00089 {m_status=rhs;return *this;} 00090 00094 Map_status& operator=(const Map_status& rhs) 00095 {m_status=rhs.m_status;return *this;} 00096 00100 bool operator==(const Status_code rhs) const 00101 {return m_status==rhs;} 00102 00106 bool operator==(const Map_status& rhs) const 00107 {return m_status==rhs.m_status;} 00108 00112 bool operator!=(const Status_code rhs) const 00113 {return m_status!=rhs;} 00114 00118 bool operator!=(const Map_status& rhs) const 00119 {return m_status!=rhs.m_status;} 00120 00123 bool is_ok() const 00124 {return m_status==OK;} 00125 00128 Status_code status() const 00129 {return m_status;} 00130 00131 private: 00133 Status_code m_status; 00134 }; 00135 00141 class Map_field_type { 00142 public: 00144 enum Type { 00145 Undefined = 0, 00146 00147 Scalar, 00148 Integer, 00149 Vector, 00150 Color, 00151 Transform, 00152 00153 Scalar_array = 16, 00154 Integer_array, 00155 String 00156 }; 00157 00159 Map_field_type() 00160 : m_type(Undefined) 00161 {} 00162 00165 Map_field_type(Type type) 00166 : m_type(type) 00167 {} 00168 00171 Map_field_type(const Map_field_type& type) 00172 : m_type(type.m_type) 00173 {} 00174 00178 Map_field_type& operator=(const Type& rhs) 00179 {m_type=rhs;return *this;} 00180 00184 Map_field_type& operator=(const Map_field_type& rhs) 00185 {m_type=rhs.m_type;return *this;} 00186 00190 bool operator==(const Type rhs) const 00191 {return m_type==rhs;} 00192 00196 bool operator==(const Map_field_type& rhs) const 00197 {return m_type==rhs.m_type;} 00198 00202 bool operator!=(const Type rhs) const 00203 {return m_type!=rhs;} 00204 00208 bool operator!=(const Map_field_type& rhs) const 00209 {return m_type!=rhs.m_type;} 00210 00213 Type type() const 00214 {return m_type;} 00215 00216 private: 00218 Type m_type; 00219 }; 00220 00223 typedef miUint Map_field_id; 00224 00226 class Map_declaration; 00227 class Map_element; 00228 class Map_lookup; 00229 00245 class Map_base { 00246 public: 00249 virtual miUint size() const = 0; 00250 00253 virtual bool is_empty() const = 0; 00254 00257 virtual bool has_declaration() const = 0; 00258 00263 virtual Map_status get( 00264 const miUint index, 00265 Map_element &map_element) const = 0; 00266 00271 virtual Map_status set( 00272 const miUint index, 00273 const Map_element &map_element) = 0; 00274 00278 virtual Map_status append( 00279 const Map_element &map_element) = 0; 00280 00285 virtual Map_status read( 00286 const char *file_name, 00287 const bool notify = true) = 0; 00288 00293 virtual Map_status append_to( 00294 const char *file_name, 00295 const bool notify = true) const = 0; 00296 00301 virtual Map_status append_from( 00302 const char *file_name, 00303 const bool notify = true) = 0; 00304 00309 virtual Map_status write( 00310 const char *file_name, 00311 const bool notify = true) const = 0; 00312 00317 virtual Map_status consolidate( 00318 const float bvh_quality = 0.6f) = 0; 00319 00324 virtual Map_status get( 00325 const Map_field_id field_id, 00326 float &value) const = 0; 00327 00332 virtual Map_status get( 00333 const Map_field_id field_id, 00334 int &value) const = 0; 00335 00340 virtual Map_status get( 00341 const Map_field_id field_id, 00342 miVector &value) const = 0; 00343 00348 virtual Map_status get( 00349 const Map_field_id field_id, 00350 miColor &value) const = 0; 00351 00357 virtual Map_status get( 00358 const Map_field_id field_id, 00359 miMatrix *value) const = 0; 00360 00365 virtual Map_status get( 00366 const Map_field_id field_id, 00367 float *value) const = 0; 00368 00373 virtual Map_status get( 00374 const Map_field_id field_id, 00375 int *value) const = 0; 00376 00381 virtual Map_status get( 00382 const Map_field_id field_id, 00383 char *value) const = 0; 00384 00389 virtual Map_status set( 00390 const Map_field_id field_id, 00391 const float value) = 0; 00392 00397 virtual Map_status set( 00398 const Map_field_id field_id, 00399 const int value) = 0; 00400 00405 virtual Map_status set( 00406 const Map_field_id field_id, 00407 const miVector &value) = 0; 00408 00413 virtual Map_status set( 00414 const Map_field_id field_id, 00415 const miColor &value) = 0; 00416 00422 virtual Map_status set( 00423 const Map_field_id field_id, 00424 const miMatrix *value) = 0; 00425 00430 virtual Map_status set( 00431 const Map_field_id field_id, 00432 const float *value) = 0; 00433 00438 virtual Map_status set( 00439 const Map_field_id field_id, 00440 const int *value) = 0; 00441 00448 virtual Map_status set( 00449 const Map_field_id field_id, 00450 const char *value, 00451 const int length = -1) = 0; 00452 }; 00453 00457 class Access_map_dbhandle { 00458 public: 00461 virtual const Map_base * operator->() = 0; 00462 00464 virtual void release() const = 0; 00465 00468 virtual miTag get_tag() const = 0; 00469 00472 virtual miTag store() = 0; 00473 }; 00474 00478 typedef Access_map_dbhandle Map_dbhandle_access; 00479 00484 class Access_map { 00485 public: 00488 Access_map( 00489 const miTag tag); 00490 00494 Access_map( 00495 const char *filename, 00496 Map_status *status = 0); 00497 00499 ~Access_map(); 00500 00503 const Map_base * operator->(); 00504 00507 const Map_base * operator->() const; 00508 00511 miTag get_tag() const; 00512 00515 miTag store(); 00516 00517 private: 00518 Access_map(); 00519 Access_map(const Access_map &); 00520 const Access_map & operator=(const Access_map &); 00521 00522 Access_map_dbhandle *m_map_h; 00523 }; 00524 00528 typedef Access_map Map_access; 00529 00533 class Edit_map_dbhandle { 00534 public: 00537 virtual Map_base * operator->() = 0; 00538 00540 virtual void release() const = 0; 00541 00544 virtual miTag get_tag() const = 0; 00545 00548 virtual miTag store() = 0; 00549 }; 00550 00554 typedef Edit_map_dbhandle Map_dbhandle_edit; 00555 00561 class Edit_map { 00562 public: 00565 Edit_map( 00566 const Map_declaration &map_declaration); 00567 00569 Edit_map(); 00570 00573 Edit_map( 00574 const miTag tag); 00575 00579 Edit_map( 00580 const char *filename, 00581 Map_status *status = 0); 00582 00584 ~Edit_map(); 00585 00588 Map_base * operator->(); 00589 00592 const Map_base * operator->() const; 00593 00596 miTag get_tag() const; 00597 00600 miTag store(); 00601 00602 private: 00603 Edit_map(const Edit_map &); 00604 const Edit_map & operator=(const Edit_map &); 00605 00606 Edit_map_dbhandle *m_map_h; 00607 }; 00608 00612 typedef Edit_map Map_edit; 00613 00635 class Map_declaration_base { 00636 public: 00638 virtual void release() const = 0; 00639 00643 virtual miUint get_fields() const = 0; 00644 00647 virtual miUint get_element_fields() const = 0; 00648 00651 virtual miUint get_global_fields() const = 0; 00652 00656 virtual bool is_empty() const = 0; 00657 00660 virtual miUint get_dimension() const = 0; 00661 00668 virtual bool is_equivalent( 00669 const Map_declaration &other, 00670 Map_status *status = 0) const = 0; 00671 00678 virtual bool matches( 00679 const Map_declaration &other, 00680 Map_status *status = 0) const = 0; 00681 00687 virtual bool has_field( 00688 const char *name, 00689 Map_status *status = 0) const = 0; 00690 00696 virtual bool is_global( 00697 const char *name, 00698 Map_status *status = 0) const = 0; 00699 00705 virtual bool is_global( 00706 const Map_field_id field_id, 00707 Map_status *status = 0) const = 0; 00708 00713 virtual const char* get_field_name( 00714 const Map_field_id field_id, 00715 Map_status *status = 0) const = 0; 00716 00721 virtual Map_field_id get_field_id( 00722 const char *field_name, 00723 Map_status *status = 0) const = 0; 00724 00730 virtual Map_field_id get_element_field_id( 00731 const miUint index, 00732 Map_status *status = 0) const = 0; 00733 00739 virtual Map_field_id get_global_field_id( 00740 const miUint index, 00741 Map_status *status = 0) const = 0; 00742 00750 virtual Map_status get_field_info( 00751 const Map_field_id field_id, 00752 Map_field_type &field_type, 00753 miUint &field_dimension, 00754 bool &field_global) const = 0; 00755 00763 virtual Map_status get_field_info( 00764 const char *field_name, 00765 Map_field_type &field_type, 00766 miUint &field_dimension, 00767 bool &field_global) const = 0; 00768 00775 virtual Map_status add( 00776 const char *name, 00777 const Map_field_type type, 00778 const miUint dim = 0) = 0; 00779 00783 virtual Map_status add_scalar( 00784 const char *name) = 0; 00785 00789 virtual Map_status add_integer( 00790 const char *name) = 0; 00791 00795 virtual Map_status add_vector( 00796 const char *name) = 0; 00797 00801 virtual Map_status add_color( 00802 const char *name) = 0; 00803 00807 virtual Map_status add_transform( 00808 const char *name) = 0; 00809 00814 virtual Map_status add_scalar_array( 00815 const char *name, 00816 const miUint dim) = 0; 00817 00822 virtual Map_status add_integer_array( 00823 const char *name, 00824 const miUint dim) = 0; 00825 00832 virtual Map_status add_global( 00833 const char *name, 00834 const Map_field_type type, 00835 const miUint dim = 0) = 0; 00836 00840 virtual Map_status add_global_scalar( 00841 const char *name) = 0; 00842 00846 virtual Map_status add_global_integer( 00847 const char *name) = 0; 00848 00852 virtual Map_status add_global_vector( 00853 const char *name) = 0; 00854 00858 virtual Map_status add_global_color( 00859 const char *name) = 0; 00860 00864 virtual Map_status add_global_transform( 00865 const char *name) = 0; 00866 00871 virtual Map_status add_global_scalar_array( 00872 const char *name, 00873 const miUint dim) = 0; 00874 00879 virtual Map_status add_global_integer_array( 00880 const char *name, 00881 const miUint dim) = 0; 00882 00887 virtual Map_status add_global_string( 00888 const char *name, 00889 const miUint dim) = 0; 00890 }; 00891 00898 class Map_declaration { 00899 public: 00902 Map_declaration( 00903 const miUint dimension=3); 00904 00908 Map_declaration( 00909 const Access_map &map, 00910 Map_status *status = 0); 00911 00915 Map_declaration( 00916 const Edit_map &map, 00917 Map_status *status = 0); 00918 00922 Map_declaration( 00923 const Map_element &map_element, 00924 Map_status *status = 0); 00925 00929 Map_declaration( 00930 const Map_declaration &other, 00931 Map_status *status = 0); 00932 00934 ~Map_declaration(); 00935 00938 Map_declaration & operator=( 00939 const Map_declaration &other); 00940 00943 Map_declaration_base * operator->(); 00944 00947 const Map_declaration_base * operator->() const; 00948 00949 private: 00950 Map_declaration_base *m_map_declaration; 00951 }; 00952 00976 class Map_element_base { 00977 public: 00979 virtual void release() const = 0; 00980 00984 virtual Map_status set_declaration( 00985 const Map_declaration& declaration) = 0; 00986 00990 virtual Map_status get_position( 00991 float *position) const = 0; 00992 00996 virtual Map_status get_position( 00997 miVector &position) const = 0; 00998 01003 virtual Map_status get( 01004 const Map_field_id field_id, 01005 float &value) const = 0; 01006 01011 virtual Map_status get( 01012 const Map_field_id field_id, 01013 int &value) const = 0; 01014 01019 virtual Map_status get( 01020 const Map_field_id field_id, 01021 miVector &value) const = 0; 01022 01027 virtual Map_status get( 01028 const Map_field_id field_id, 01029 miColor &value) const = 0; 01030 01036 virtual Map_status get( 01037 const Map_field_id field_id, 01038 miMatrix *value) const = 0; 01039 01044 virtual Map_status get( 01045 const Map_field_id field_id, 01046 float *value) const = 0; 01047 01052 virtual Map_status get( 01053 const Map_field_id field_id, 01054 int *value) const = 0; 01055 01059 virtual Map_status set_position( 01060 const float *position) = 0; 01061 01065 virtual Map_status set_position( 01066 const miVector &position) = 0; 01067 01072 virtual Map_status set( 01073 const Map_field_id field_id, 01074 const float value) = 0; 01075 01080 virtual Map_status set( 01081 const Map_field_id field_id, 01082 const int value) = 0; 01083 01088 virtual Map_status set( 01089 const Map_field_id field_id, 01090 const miVector &value) = 0; 01091 01096 virtual Map_status set( 01097 const Map_field_id field_id, 01098 const miColor &value) = 0; 01099 01105 virtual Map_status set( 01106 const Map_field_id field_id, 01107 const miMatrix *value) = 0; 01108 01113 virtual Map_status set( 01114 const Map_field_id field_id, 01115 const float *value) = 0; 01116 01121 virtual Map_status set( 01122 const Map_field_id field_id, 01123 const int *value) = 0; 01124 }; 01125 01130 class Map_element { 01131 public: 01134 Map_element(); 01135 01139 Map_element( 01140 const Map_declaration& declaration); 01141 01144 Map_element( 01145 const Map_element &other); 01146 01148 ~Map_element(); 01149 01152 Map_element & operator=( 01153 const Map_element &other); 01154 01157 Map_element_base * operator->(); 01158 01161 const Map_element_base * operator->() const; 01162 01163 private: 01164 Map_element_base *m_map_element; 01165 }; 01166 01191 class Map_iterator_base { 01192 public: 01194 virtual void release() const = 0; 01195 01198 virtual Map_status reset() const = 0; 01199 01203 virtual Map_status set_to( 01204 const miUint index) const = 0; 01205 01208 virtual Map_status next() const = 0; 01209 01212 virtual Map_status previous() const = 0; 01213 01217 virtual Map_status skip( 01218 const miUint amount) const = 0; 01219 01223 virtual bool at_end( 01224 Map_status *status = 0) const = 0; 01225 01229 virtual miUint current( 01230 Map_status *status = 0) const = 0; 01231 01235 virtual Map_status get( 01236 Map_element &element) const = 0; 01237 01241 virtual Map_status get_position( 01242 float *position) const = 0; 01243 01247 virtual Map_status get_position( 01248 miVector &position) const = 0; 01249 01255 virtual Map_status get( 01256 const Map_field_id field_id, 01257 float &value) const = 0; 01258 01264 virtual Map_status get( 01265 const Map_field_id field_id, 01266 int &value) const = 0; 01267 01273 virtual Map_status get( 01274 const Map_field_id field_id, 01275 miVector &value) const = 0; 01276 01282 virtual Map_status get( 01283 const Map_field_id field_id, 01284 miColor &value) const = 0; 01285 01292 virtual Map_status get( 01293 const Map_field_id field_id, 01294 miMatrix *value) const = 0; 01295 01301 virtual Map_status get( 01302 const Map_field_id field_id, 01303 float *value) const = 0; 01304 01310 virtual Map_status get( 01311 const Map_field_id field_id, 01312 int *value) const = 0; 01313 01317 virtual Map_status set( 01318 const Map_element &element) = 0; 01319 01323 virtual Map_status set_position( 01324 const float *position) = 0; 01325 01329 virtual Map_status set_position( 01330 const miVector &position) = 0; 01331 01337 virtual Map_status set( 01338 const Map_field_id field_id, 01339 const float value) = 0; 01340 01346 virtual Map_status set( 01347 const Map_field_id field_id, 01348 const int value) = 0; 01349 01355 virtual Map_status set( 01356 const Map_field_id field_id, 01357 const miVector &value) = 0; 01358 01364 virtual Map_status set( 01365 const Map_field_id field_id, 01366 const miColor &value) = 0; 01367 01374 virtual Map_status set( 01375 const Map_field_id field_id, 01376 const miMatrix *value) = 0; 01377 01383 virtual Map_status set( 01384 const Map_field_id field_id, 01385 const float *value) = 0; 01386 01392 virtual Map_status set( 01393 const Map_field_id field_id, 01394 const int *value) = 0; 01395 }; 01396 01398 class Edit_map_iterator; 01399 01404 class Access_map_iterator { 01405 public: 01409 Access_map_iterator( 01410 const Access_map &map, 01411 Map_status *status = 0); 01412 01416 Access_map_iterator( 01417 const Edit_map &map, 01418 Map_status *status = 0); 01419 01423 Access_map_iterator( 01424 const Access_map_iterator &other, 01425 Map_status *status = 0); 01426 01430 Access_map_iterator( 01431 const Edit_map_iterator &other, 01432 Map_status *status = 0); 01433 01435 ~Access_map_iterator(); 01436 01439 Access_map_iterator & operator=( 01440 const Access_map_iterator &other); 01441 01444 Access_map_iterator & operator=( 01445 const Edit_map_iterator &other); 01446 01449 const Map_iterator_base * operator->(); 01450 01451 private: 01452 Map_iterator_base *m_map_iterator; 01453 }; 01454 01458 typedef Access_map_iterator Map_iterator_access; 01459 01464 class Edit_map_iterator { 01465 public: 01469 Edit_map_iterator( 01470 const Edit_map &map, 01471 Map_status *status = 0); 01472 01476 Edit_map_iterator( 01477 const Edit_map_iterator &other, 01478 Map_status *status = 0); 01479 01481 ~Edit_map_iterator(); 01482 01485 Edit_map_iterator & operator=( 01486 const Edit_map_iterator &other); 01487 01490 Map_iterator_base * operator->(); 01491 01494 const Map_iterator_base * operator->() const; 01495 01496 private: 01497 Map_iterator_base *m_map_iterator; 01498 }; 01499 01503 typedef Edit_map_iterator Map_iterator_edit; 01504 01510 class Map_distance_base { 01511 public: 01514 virtual miUint get_dimension() const = 0; 01515 01518 virtual const float *get_point() const = 0; 01519 01524 virtual float operator() ( 01525 const float *min, 01526 const float *max) const = 0; 01527 01531 virtual float operator() ( 01532 const Map_iterator_base *element) const = 0; 01533 }; 01534 01535 01543 template<miUint DIM> 01544 class Map_distance : public mi::shader_v3::Map_distance_base { 01545 public: 01547 static const miUint DIMENSION = DIM; 01548 01550 Map_distance() 01551 {} 01552 01555 Map_distance( 01556 const float *point) 01557 { 01558 for (miUint i = 0; i < DIMENSION; ++i) 01559 m_point[i] = point[i]; 01560 } 01561 01564 miUint get_dimension() const { return DIMENSION; } 01565 01568 const float *get_point() const { return m_point; } 01569 01574 float operator() ( 01575 const float *min, 01576 const float *max) const 01577 { 01578 float d = 0.0f; 01579 float da, db, max_da_db, tmp; 01580 01581 for (miUint i = 0; i < DIMENSION; ++i) { 01582 da = min[i] - m_point[i]; 01583 db = m_point[i] - max[i]; 01584 01585 max_da_db = da > db ? da : db; 01586 tmp = max_da_db > 0.0f ? max_da_db : 0.0f; 01587 01588 d += tmp * tmp; 01589 } 01590 01591 return d; 01592 } 01593 01597 virtual float operator() ( 01598 const Map_iterator_base *element) const = 0; 01599 01600 protected: 01602 float m_point[DIM]; 01603 }; 01604 01611 template<miUint DIM> 01612 class Map_quad_distance : public mi::shader_v3::Map_distance<DIM> { 01613 public: 01616 Map_quad_distance( 01617 const float *point) 01618 : Map_distance<DIM>::Map_distance(point) 01619 {} 01620 01624 float operator() ( 01625 const Map_iterator_base *element) const 01626 { 01627 float d = 0.0f; 01628 float diff; 01629 float position[DIM]; 01630 01631 element->get_position(position); 01632 01633 for (miUint i = 0; i < DIM; ++i) { 01634 diff = this->m_point[i] - position[i]; 01635 d += diff * diff; 01636 } 01637 01638 return d; 01639 } 01640 }; 01641 01644 typedef Map_quad_distance<3> Map_quad_distance3; 01645 01649 struct Map_lookup_entry { 01651 miUint index; 01652 01654 float distance; 01655 }; 01656 01684 class Map_lookup_base { 01685 public: 01687 virtual void release() const = 0; 01688 01691 virtual miUint size() const = 0; 01692 01695 virtual bool is_empty() const = 0; 01696 01699 virtual Map_status reset() = 0; 01700 01703 virtual Map_status next() = 0; 01704 01708 virtual bool at_end( 01709 Map_status *status = 0) const = 0; 01710 01713 virtual Map_status sort() = 0; 01714 01717 virtual Map_status sort_descending() = 0; 01718 01723 virtual Map_lookup_entry get( 01724 const miUint n, 01725 Map_status *status = 0) const = 0; 01726 01730 virtual Map_lookup_entry get( 01731 Map_status *status = 0) const = 0; 01732 01736 virtual miUint get_index( 01737 Map_status *status = 0) const = 0; 01738 01742 virtual float get_distance( 01743 Map_status *status = 0) const = 0; 01744 01748 virtual Map_status get( 01749 Map_element &element) const = 0; 01750 01754 virtual Map_status get_position( 01755 float *position) const = 0; 01756 01760 virtual Map_status get_position( 01761 miVector &position) const = 0; 01762 01768 virtual Map_status get( 01769 const Map_field_id field_id, 01770 float &value) const = 0; 01771 01777 virtual Map_status get( 01778 const Map_field_id field_id, 01779 int &value) const = 0; 01780 01786 virtual Map_status get( 01787 const Map_field_id field_id, 01788 miVector &value) const = 0; 01789 01795 virtual Map_status get( 01796 const Map_field_id field_id, 01797 miColor &value) const = 0; 01798 01805 virtual Map_status get( 01806 const Map_field_id field_id, 01807 miMatrix *value) const = 0; 01808 01814 virtual Map_status get( 01815 const Map_field_id field_id, 01816 float *value) const = 0; 01817 01823 virtual Map_status get( 01824 const Map_field_id field_id, 01825 int *value) const = 0; 01826 01833 virtual Map_status search( 01834 const Map_distance_base &distance_functor, 01835 const miUint max_elements = 1, 01836 const float max_search_dist = miHUGE_SCALAR) = 0; 01837 01846 virtual Map_status search( 01847 const miVector &point, 01848 const miUint max_elements = 1, 01849 const float max_search_dist = miHUGE_SCALAR) = 0; 01850 }; 01851 01856 class Map_lookup { 01857 public: 01861 Map_lookup( 01862 const Access_map &map, 01863 Map_status *status = 0); 01864 01868 Map_lookup( 01869 const Map_lookup &other, 01870 Map_status *status = 0); 01871 01873 ~Map_lookup(); 01874 01877 Map_lookup & operator=( 01878 const Map_lookup &other); 01879 01882 Map_lookup_base * operator->(); 01883 01884 private: 01885 Map_lookup_base* m_map_lookup; 01886 }; 01887 01890 inline Access_map::Access_map( 01891 const miTag tag) 01892 : m_map_h(0) 01893 { 01894 m_map_h = Access_interface()->accessMap(tag); 01895 } 01896 01897 inline Access_map::Access_map( 01898 const char *filename, 01899 Map_status *status) 01900 : m_map_h(0) 01901 { 01902 m_map_h = Access_interface()->accessMap(filename, status); 01903 } 01904 01905 inline Access_map::~Access_map() 01906 { 01907 if(m_map_h != 0) 01908 m_map_h->release(); 01909 } 01910 01911 inline const Map_base * Access_map::operator->() 01912 { 01913 if(m_map_h != 0){ 01914 return (*m_map_h).operator->(); 01915 } 01916 return 0; 01917 } 01918 01919 inline const Map_base * Access_map::operator->() const 01920 { 01921 if(m_map_h != 0){ 01922 return (*m_map_h).operator->(); 01923 } 01924 return 0; 01925 } 01926 01927 inline miTag Access_map::get_tag() const 01928 { 01929 if(m_map_h != 0){ 01930 return m_map_h->get_tag(); 01931 } 01932 return 0; 01933 } 01934 01935 inline miTag Access_map::store() 01936 { 01937 if(m_map_h != 0){ 01938 return m_map_h->store(); 01939 } 01940 return 0; 01941 } 01942 01945 inline Edit_map::Edit_map( 01946 const Map_declaration &map_declaration) 01947 : m_map_h(0) 01948 { 01949 m_map_h = Access_interface()->createMap(map_declaration.operator->()); 01950 } 01951 01952 inline Edit_map::Edit_map() 01953 : m_map_h(0) 01954 { 01955 m_map_h = Access_interface()->createMap(); 01956 } 01957 01958 inline Edit_map::Edit_map( 01959 const miTag tag) 01960 : m_map_h(0) 01961 { 01962 m_map_h = Access_interface()->editMap(tag); 01963 } 01964 01965 inline Edit_map::Edit_map( 01966 const char *filename, 01967 Map_status *status) 01968 : m_map_h(0) 01969 { 01970 m_map_h = Access_interface()->editMap(filename, status); 01971 } 01972 01973 inline Edit_map::~Edit_map() 01974 { 01975 if(m_map_h != 0) 01976 m_map_h->release(); 01977 } 01978 01979 inline Map_base * Edit_map::operator->() 01980 { 01981 if(m_map_h != 0){ 01982 return (*m_map_h).operator->(); 01983 } 01984 return 0; 01985 } 01986 01987 inline const Map_base * Edit_map::operator->() const 01988 { 01989 if(m_map_h != 0){ 01990 return (*m_map_h).operator->(); 01991 } 01992 return 0; 01993 } 01994 01995 inline miTag Edit_map::get_tag() const 01996 { 01997 if(m_map_h != 0){ 01998 return m_map_h->get_tag(); 01999 } 02000 return 0; 02001 } 02002 02003 inline miTag Edit_map::store() 02004 { 02005 if(m_map_h != 0){ 02006 return m_map_h->store(); 02007 } 02008 return 0; 02009 } 02010 02013 inline Map_declaration::Map_declaration( 02014 miUint dimension) 02015 : m_map_declaration(0) 02016 { 02017 m_map_declaration = Access_interface()->createMapDeclaration( 02018 dimension); 02019 } 02020 02021 inline Map_declaration::Map_declaration( 02022 const Access_map &map, 02023 Map_status *status) 02024 : m_map_declaration(0) 02025 { 02026 m_map_declaration = Access_interface()->copyMapDeclaration( 02027 map.operator->(), status); 02028 } 02029 02030 inline Map_declaration::Map_declaration( 02031 const Edit_map &map, 02032 Map_status *status) 02033 : m_map_declaration(0) 02034 { 02035 m_map_declaration = Access_interface()->copyMapDeclaration( 02036 map.operator->(), status); 02037 } 02038 02039 inline Map_declaration::Map_declaration( 02040 const Map_element &map_element, 02041 Map_status *status) 02042 : m_map_declaration(0) 02043 { 02044 m_map_declaration = Access_interface()->copyMapDeclaration( 02045 map_element.operator->(), status); 02046 } 02047 02048 inline Map_declaration::Map_declaration( 02049 const Map_declaration &other, 02050 Map_status *status) 02051 : m_map_declaration(0) 02052 { 02053 m_map_declaration = Access_interface()->copyMapDeclaration( 02054 other.m_map_declaration, status); 02055 } 02056 02057 inline Map_declaration & Map_declaration::operator=( 02058 const Map_declaration &other) 02059 { 02060 if (m_map_declaration != 0) 02061 m_map_declaration->release(); 02062 m_map_declaration = Access_interface()->copyMapDeclaration( 02063 other.m_map_declaration, 0); 02064 return *this; 02065 } 02066 02067 inline Map_declaration::~Map_declaration() 02068 { 02069 if (m_map_declaration != 0) 02070 m_map_declaration->release(); 02071 } 02072 02073 inline Map_declaration_base * Map_declaration::operator->() 02074 { 02075 return m_map_declaration; 02076 } 02077 02078 inline const Map_declaration_base * Map_declaration::operator->() const 02079 { 02080 return m_map_declaration; 02081 } 02082 02085 inline Map_element::Map_element() 02086 : m_map_element(0) 02087 { 02088 m_map_element = Access_interface()->createMapElement(); 02089 } 02090 02091 inline Map_element::Map_element( 02092 const Map_declaration &declaration) 02093 : m_map_element(0) 02094 { 02095 m_map_element = Access_interface()->createMapElement( 02096 declaration.operator->()); 02097 } 02098 02099 inline Map_element::Map_element( 02100 const Map_element &other) 02101 : m_map_element(0) 02102 { 02103 m_map_element = Access_interface()->copyMapElement( 02104 other.m_map_element); 02105 } 02106 02107 inline Map_element & Map_element::operator=( 02108 const Map_element &other) 02109 { 02110 m_map_element->release(); 02111 m_map_element = Access_interface()->copyMapElement( 02112 other.m_map_element); 02113 return *this; 02114 } 02115 02116 inline Map_element::~Map_element() 02117 { 02118 m_map_element->release(); 02119 } 02120 02121 inline Map_element_base * Map_element::operator->() 02122 { 02123 return m_map_element; 02124 } 02125 02126 inline const Map_element_base * Map_element::operator->() const 02127 { 02128 return m_map_element; 02129 } 02130 02133 inline Access_map_iterator::Access_map_iterator( 02134 const Access_map &map, 02135 Map_status *status) 02136 : m_map_iterator(0) 02137 { 02138 m_map_iterator = Access_interface()->createMapIterator( 02139 map.operator->(), status); 02140 } 02141 02142 inline Access_map_iterator::Access_map_iterator( 02143 const Edit_map &map, 02144 Map_status *status) 02145 : m_map_iterator(0) 02146 { 02147 m_map_iterator = Access_interface()->createMapIterator( 02148 map.operator->(), status); 02149 } 02150 02151 inline Access_map_iterator::Access_map_iterator( 02152 const Access_map_iterator &other, 02153 Map_status *status) 02154 : m_map_iterator(0) 02155 { 02156 m_map_iterator = Access_interface()->copyMapIterator( 02157 other.m_map_iterator, status); 02158 } 02159 02160 inline Access_map_iterator::Access_map_iterator( 02161 const Edit_map_iterator &other, 02162 Map_status *status) 02163 : m_map_iterator(0) 02164 { 02165 m_map_iterator = Access_interface()->copyMapIterator( 02166 other.operator->(), status); 02167 } 02168 02169 inline Access_map_iterator & Access_map_iterator::operator =( 02170 const Access_map_iterator &other) 02171 { 02172 m_map_iterator->release(); 02173 m_map_iterator = Access_interface()->copyMapIterator( 02174 other.m_map_iterator, 0); 02175 return *this; 02176 } 02177 02178 inline Access_map_iterator & Access_map_iterator::operator =( 02179 const Edit_map_iterator &other) 02180 { 02181 if (m_map_iterator != 0) 02182 m_map_iterator->release(); 02183 m_map_iterator = Access_interface()->copyMapIterator( 02184 other.operator->(), 0); 02185 return *this; 02186 } 02187 02188 inline Access_map_iterator::~Access_map_iterator() 02189 { 02190 if (m_map_iterator != 0) 02191 m_map_iterator->release(); 02192 } 02193 02194 inline const Map_iterator_base * Access_map_iterator::operator->() 02195 { 02196 return m_map_iterator; 02197 } 02198 02201 inline Edit_map_iterator::Edit_map_iterator( 02202 const Edit_map &map, 02203 Map_status *status) 02204 : m_map_iterator(0) 02205 { 02206 m_map_iterator = Access_interface()->createMapIterator( 02207 map.operator->(), status); 02208 } 02209 02210 inline Edit_map_iterator::Edit_map_iterator( 02211 const Edit_map_iterator &other, 02212 Map_status *status) 02213 : m_map_iterator(0) 02214 { 02215 m_map_iterator = Access_interface()->copyMapIterator( 02216 other.m_map_iterator, status); 02217 } 02218 02219 inline Edit_map_iterator & Edit_map_iterator::operator =( 02220 const Edit_map_iterator &other) 02221 { 02222 if (m_map_iterator != 0) 02223 m_map_iterator->release(); 02224 m_map_iterator = Access_interface()->copyMapIterator( 02225 other.m_map_iterator, 0); 02226 return *this; 02227 } 02228 02229 inline Edit_map_iterator::~Edit_map_iterator() 02230 { 02231 if (m_map_iterator != 0) 02232 m_map_iterator->release(); 02233 } 02234 02235 inline Map_iterator_base * Edit_map_iterator::operator->() 02236 { 02237 return m_map_iterator; 02238 } 02239 02240 inline const Map_iterator_base * Edit_map_iterator::operator->() const 02241 { 02242 return m_map_iterator; 02243 } 02244 02247 inline Map_lookup::Map_lookup( 02248 const Access_map &map, 02249 Map_status *status) 02250 : m_map_lookup(0) 02251 { 02252 m_map_lookup = Access_interface()->createMapLookup( 02253 map.operator->(), status); 02254 } 02255 02256 inline Map_lookup::Map_lookup( 02257 const Map_lookup &other, 02258 Map_status *status) 02259 : m_map_lookup(0) 02260 { 02261 m_map_lookup = Access_interface()->copyMapLookup( 02262 other.m_map_lookup, status); 02263 } 02264 02265 inline Map_lookup::~Map_lookup() 02266 { 02267 if (m_map_lookup != 0) 02268 m_map_lookup->release(); 02269 } 02270 02271 inline Map_lookup & Map_lookup::operator = ( 02272 const Map_lookup &other) 02273 { 02274 if (m_map_lookup != 0) 02275 m_map_lookup->release(); 02276 m_map_lookup = Access_interface()->copyMapLookup( 02277 other.m_map_lookup, 0); 02278 return *this; 02279 } 02280 02281 inline Map_lookup_base * Map_lookup::operator->() 02282 { 02283 return m_map_lookup; 02284 } 02285 02286 } // namespace shader_v3 02287 } // namespace mi 02288 02289 #endif //SHADER_MAP_H
Copyright © 1986-2010 by
mental images GmbH