shader_map.h
Go to the documentation of this file.
00001 
00002 // Copyright 1986, 2015 NVIDIA ARC GmbH. All rights reserved.
00004 // Created:     27.02.08
00005 // Module:      api
00006 // Purpose:     mental ray C++ shader interface extensions
00008 
00017 
00018 
00019 #ifndef SHADER_MAP_H
00020 #define SHADER_MAP_H
00021 
00022 #include "mi_shader_if.h"
00023 
00024 namespace mi {
00025 namespace shader_v3 {
00026 
00032 class Map_status {
00033     public:
00035         enum Status_code {
00036             OK = 0,                     
00037 
00038             Insufficient_memory,        
00039             No_such_field,              
00040             Out_of_bounds,              
00041             No_declaration,             
00042             Declaration_mismatch,       
00043             Wrong_dimension,            
00044             Illegal_on_slave,           
00045             
00046             Failure = 15,               
00047 
00048             File_could_not_be_opened = 16,  
00049             File_not_a_map,                 
00050             File_version_unsupported,       
00051             
00052             Field_undefined = 32,       
00053             Field_name_too_long,        
00054             Field_name_empty,           
00055             Field_name_illegal,         
00056             Field_null_array,           
00057             Field_type_mismatch,        
00058             Field_illegal,              
00059 
00060             Iterator_invalid = 48,      
00061             Iterator_past_end,          
00062             Iterator_out_of_bounds,     
00063             
00064             Lookup_invalid = 64,        
00065             Lookup_past_end,            
00066             Lookup_out_of_bounds,       
00067             Lookup_dimension_mismatch,  
00068             Lookup_no_previous_search   
00069         };
00070 
00072         Map_status()
00073             : m_status(OK)
00074         {}
00075 
00078         Map_status(Status_code status)
00079             : m_status(status)
00080         {}
00081 
00084         Map_status(const Map_status& status)
00085             : m_status(status.m_status)
00086         {}
00087 
00091         Map_status& operator=(const Status_code& rhs)
00092         {m_status=rhs;return *this;}
00093 
00097         Map_status& operator=(const Map_status& rhs)
00098         {m_status=rhs.m_status;return *this;}
00099 
00103         bool operator==(const Status_code rhs) const
00104         {return m_status==rhs;}
00105 
00109         bool operator==(const Map_status& rhs) const
00110         {return m_status==rhs.m_status;}
00111 
00115         bool operator!=(const Status_code rhs) const
00116         {return m_status!=rhs;}
00117 
00121         bool operator!=(const Map_status& rhs) const
00122         {return m_status!=rhs.m_status;}
00123         
00126         bool is_ok() const
00127         {return m_status==OK;}
00128 
00131         Status_code status() const
00132         {return m_status;}
00133 
00134     private:
00136         Status_code m_status;
00137 };
00138 
00144 class Map_field_type {
00145     public:
00147         enum Type {
00148             Undefined = 0,          
00149 
00150             Scalar,                 
00151             Integer,                
00152             Vector,                 
00153             Color,                  
00154             Transform,              
00155 
00156             Scalar_array = 16,      
00157             Integer_array,          
00158             String                  
00159         };
00160 
00162         Map_field_type()
00163             : m_type(Undefined)
00164         {}
00165 
00168         Map_field_type(Type type)
00169             : m_type(type)
00170         {}
00171 
00174         Map_field_type(const Map_field_type& type)
00175             : m_type(type.m_type)
00176         {}
00177 
00181         Map_field_type& operator=(const Type& rhs)
00182         {m_type=rhs;return *this;}
00183 
00187         Map_field_type& operator=(const Map_field_type& rhs)
00188         {m_type=rhs.m_type;return *this;}
00189 
00193         bool operator==(const Type rhs) const
00194         {return m_type==rhs;}
00195 
00199         bool operator==(const Map_field_type& rhs) const
00200         {return m_type==rhs.m_type;}
00201 
00205         bool operator!=(const Type rhs) const
00206         {return m_type!=rhs;}
00207 
00211         bool operator!=(const Map_field_type& rhs) const
00212         {return m_type!=rhs.m_type;}
00213 
00216         Type type() const
00217         {return m_type;}
00218 
00219     private:
00221         Type m_type;
00222 };
00223 
00226 typedef miUint Map_field_id;
00227 
00229 class Map_declaration;
00230 class Map_element;
00231 class Map_lookup;
00232 
00248 class Map_base {
00249     public:
00251         enum File_format {
00252             Closed_binary = 0,      
00253             Open_binary,            
00254             Open_ASCII              
00255         };
00256 
00259         virtual miUint size() const = 0;
00260 
00263         virtual bool is_empty() const = 0;
00264 
00267         virtual bool has_declaration() const = 0;
00268 
00273         virtual Map_status get(
00274             const miUint    index,
00275             Map_element     &map_element) const = 0;
00276 
00281         virtual Map_status set(
00282             const miUint        index,
00283             const Map_element   &map_element) = 0;
00284 
00288         virtual Map_status append(
00289             const Map_element   &map_element) = 0;
00290 
00295         virtual Map_status read(
00296             const char  *file_name,
00297             const bool  notify = true) = 0;
00298 
00303         virtual Map_status append_to(
00304             const char  *file_name,
00305             const bool  notify = true) const = 0;
00306 
00311         virtual Map_status append_from(
00312             const char  *file_name,
00313             const bool  notify = true) = 0;
00314 
00320         virtual Map_status write(
00321             const char          *file_name,
00322             const bool          notify = true,
00323             const File_format   file_format = Closed_binary) const = 0;
00324 
00329         virtual Map_status consolidate(
00330             const float bvh_quality = 0.6f) = 0;
00331 
00336         virtual Map_status get(
00337             const Map_field_id  field_id,
00338             float               &value) const = 0;
00339 
00344         virtual Map_status get(
00345             const Map_field_id  field_id,
00346             int                 &value) const = 0;
00347 
00352         virtual Map_status get(
00353             const Map_field_id  field_id,
00354             miVector            &value) const = 0;
00355 
00360         virtual Map_status get(
00361             const Map_field_id  field_id,
00362             miColor             &value) const = 0;
00363 
00369         virtual Map_status get(
00370             const Map_field_id  field_id,
00371             miMatrix            *value) const = 0;
00372 
00377         virtual Map_status get(
00378             const Map_field_id  field_id,
00379             float               *value) const = 0;
00380 
00385         virtual Map_status get(
00386             const Map_field_id  field_id,
00387             int                 *value) const = 0;
00388 
00393         virtual Map_status get(
00394             const Map_field_id  field_id,
00395             char                *value) const = 0;
00396 
00401         virtual Map_status set(
00402             const Map_field_id  field_id,
00403             const float         value) = 0;
00404 
00409         virtual Map_status set(
00410             const Map_field_id  field_id,
00411             const int           value) = 0;
00412 
00417         virtual Map_status set(
00418             const Map_field_id  field_id,
00419             const miVector      &value) = 0;
00420 
00425         virtual Map_status set(
00426             const Map_field_id  field_id,
00427             const miColor       &value) = 0;
00428 
00434         virtual Map_status set(
00435             const Map_field_id  field_id,
00436             const miMatrix      *value) = 0;
00437 
00442         virtual Map_status set(
00443             const Map_field_id  field_id,
00444             const float         *value) = 0;
00445 
00450         virtual Map_status set(
00451             const Map_field_id  field_id,
00452             const int           *value) = 0;
00453 
00460         virtual Map_status set(
00461             const Map_field_id  field_id,
00462             const char          *value,
00463             const int           length = -1) = 0;
00464 };
00465 
00469 class Access_map_dbhandle {
00470 public:
00473     virtual const Map_base * operator->() = 0;
00474 
00476     virtual void release() const = 0;
00477 
00480     virtual miTag get_tag() const = 0;
00481 
00484     virtual miTag store() = 0;
00485 };
00486 
00490 typedef Access_map_dbhandle Map_dbhandle_access;
00491 
00496 class Access_map {
00497 public:
00500     Access_map(
00501         const miTag tag);
00502 
00506     Access_map(
00507         const char *filename,
00508         Map_status *status = 0);
00509 
00511     ~Access_map();
00512 
00515     const Map_base * operator->();
00516 
00519     const Map_base * operator->() const;
00520 
00523     miTag get_tag() const;
00524 
00527     miTag store();
00528 
00529 private:
00530     Access_map();
00531     Access_map(const Access_map &);
00532     const Access_map & operator=(const Access_map &);
00533 
00534     Access_map_dbhandle *m_map_h;
00535 };
00536 
00540 typedef Access_map Map_access;
00541 
00545 class Edit_map_dbhandle {
00546 public:
00549     virtual Map_base * operator->() = 0;
00550 
00552     virtual void release() const = 0;
00553 
00556     virtual miTag get_tag() const = 0;
00557 
00560     virtual miTag store() = 0;
00561 };
00562 
00566 typedef Edit_map_dbhandle Map_dbhandle_edit;
00567 
00573 class Edit_map {
00574 public:
00577     Edit_map(
00578         const Map_declaration &map_declaration);
00579 
00581     Edit_map();
00582 
00585     Edit_map(
00586         const miTag tag);
00587 
00591     Edit_map(
00592         const char *filename,
00593         Map_status *status = 0);
00594 
00596     ~Edit_map();
00597 
00600     Map_base * operator->();
00601 
00604     const Map_base * operator->() const;
00605 
00608     miTag get_tag() const;
00609 
00612     miTag store();
00613 
00614 private:
00615     Edit_map(const Edit_map &);
00616     const Edit_map & operator=(const Edit_map &);
00617 
00618     Edit_map_dbhandle *m_map_h;
00619 };
00620 
00624 typedef Edit_map Map_edit;
00625 
00647 class Map_declaration_base {
00648     public:
00650         virtual void release() const = 0;
00651 
00655         virtual miUint get_fields() const = 0;
00656 
00659         virtual miUint get_element_fields() const = 0;
00660 
00663         virtual miUint get_global_fields() const = 0;
00664 
00668         virtual bool is_empty() const = 0;
00669 
00672         virtual miUint get_dimension() const = 0;
00673 
00680         virtual bool is_equivalent(
00681             const Map_declaration   &other,
00682             Map_status              *status = 0) const = 0;
00683 
00690         virtual bool matches(
00691             const Map_declaration   &other,
00692             Map_status              *status = 0) const = 0;
00693 
00699         virtual bool has_field(
00700             const char  *name,
00701             Map_status  *status = 0) const = 0;
00702 
00708         virtual bool is_global(
00709             const char  *name,
00710             Map_status  *status = 0) const = 0;
00711 
00717         virtual bool is_global(
00718             const Map_field_id  field_id,
00719             Map_status          *status = 0) const = 0;
00720 
00725         virtual const char* get_field_name(
00726             const Map_field_id  field_id,
00727             Map_status          *status = 0) const = 0;
00728 
00733         virtual Map_field_id get_field_id(
00734             const char      *field_name,
00735             Map_status      *status = 0) const = 0;
00736 
00742         virtual Map_field_id get_element_field_id(
00743             const miUint    index,
00744             Map_status      *status = 0) const = 0;
00745 
00751         virtual Map_field_id get_global_field_id(
00752             const miUint    index,
00753             Map_status      *status = 0) const = 0;
00754 
00762         virtual Map_status get_field_info(
00763             const Map_field_id  field_id,
00764             Map_field_type      &field_type,
00765             miUint              &field_dimension,
00766             bool                &field_global) const = 0;
00767 
00775         virtual Map_status get_field_info(
00776             const char          *field_name,
00777             Map_field_type      &field_type,
00778             miUint              &field_dimension,
00779             bool                &field_global) const = 0;
00780 
00787         virtual Map_status add(
00788             const char              *name,
00789             const Map_field_type    type,
00790             const miUint            dim = 0) = 0;
00791 
00795         virtual Map_status add_scalar(
00796             const char      *name) = 0;
00797 
00801         virtual Map_status add_integer(
00802             const char      *name) = 0;
00803 
00807         virtual Map_status add_vector(
00808             const char      *name) = 0;
00809 
00813         virtual Map_status add_color(
00814             const char      *name) = 0;
00815 
00819         virtual Map_status add_transform(
00820             const char      *name) = 0;
00821 
00826         virtual Map_status add_scalar_array(
00827             const char      *name,
00828             const miUint    dim) = 0;
00829 
00834         virtual Map_status add_integer_array(
00835             const char      *name,
00836             const miUint    dim) = 0;
00837 
00844         virtual Map_status add_global(
00845             const char              *name,
00846             const Map_field_type    type,
00847             const miUint            dim = 0) = 0;
00848 
00852         virtual Map_status add_global_scalar(
00853             const char      *name) = 0;
00854 
00858         virtual Map_status add_global_integer(
00859             const char      *name) = 0;
00860 
00864         virtual Map_status add_global_vector(
00865             const char      *name) = 0;
00866 
00870         virtual Map_status add_global_color(
00871             const char      *name) = 0;
00872 
00876         virtual Map_status add_global_transform(
00877             const char      *name) = 0;
00878 
00883         virtual Map_status add_global_scalar_array(
00884             const char      *name,
00885             const miUint    dim) = 0;
00886 
00891         virtual Map_status add_global_integer_array(
00892             const char      *name,
00893             const miUint    dim) = 0;
00894 
00899         virtual Map_status add_global_string(
00900             const char      *name,
00901             const miUint    dim) = 0;
00902 };
00903 
00910 class Map_declaration {
00911 public:
00914     Map_declaration(
00915         const miUint dimension=3);
00916 
00920     Map_declaration(
00921         const Access_map &map,
00922         Map_status *status = 0);
00923 
00927     Map_declaration(
00928         const Edit_map &map,
00929         Map_status *status = 0);
00930 
00934     Map_declaration(
00935         const Map_element &map_element,
00936         Map_status *status = 0);
00937 
00941     Map_declaration(
00942         const Map_declaration &other,
00943         Map_status *status = 0);
00944 
00946     ~Map_declaration();
00947 
00950     Map_declaration & operator=(
00951         const Map_declaration &other);
00952 
00955     Map_declaration_base * operator->();
00956 
00959     const Map_declaration_base * operator->() const;
00960 
00961 private:
00962     Map_declaration_base *m_map_declaration;
00963 };
00964 
00988 class Map_element_base {
00989     public:
00991         virtual void release() const = 0;
00992 
00996         virtual Map_status set_declaration(
00997             const Map_declaration&  declaration) = 0;
00998 
01002         virtual Map_status get_position(
01003             float               *position) const = 0;
01004 
01008         virtual Map_status get_position(
01009             miVector            &position) const = 0;
01010 
01015         virtual Map_status get(
01016             const Map_field_id  field_id,
01017             float               &value) const = 0;
01018 
01023         virtual Map_status get(
01024             const Map_field_id  field_id,
01025             int                 &value) const = 0;
01026 
01031         virtual Map_status get(
01032             const Map_field_id  field_id,
01033             miVector            &value) const = 0;
01034 
01039         virtual Map_status get(
01040             const Map_field_id  field_id,
01041             miColor             &value) const = 0;
01042 
01048         virtual Map_status get(
01049             const Map_field_id  field_id,
01050             miMatrix            *value) const = 0;
01051 
01056         virtual Map_status get(
01057             const Map_field_id  field_id,
01058             float               *value) const = 0;
01059 
01064         virtual Map_status get(
01065             const Map_field_id  field_id,
01066             int                 *value) const = 0;
01067 
01071         virtual Map_status set_position(
01072             const float         *position) = 0;
01073 
01077         virtual Map_status set_position(
01078             const miVector      &position) = 0;
01079 
01084         virtual Map_status set(
01085             const Map_field_id  field_id,
01086             const float         value) = 0;
01087 
01092         virtual Map_status set(
01093             const Map_field_id  field_id,
01094             const int           value) = 0;
01095 
01100         virtual Map_status set(
01101             const Map_field_id  field_id,
01102             const miVector      &value) = 0;
01103 
01108         virtual Map_status set(
01109             const Map_field_id  field_id,
01110             const miColor       &value) = 0;
01111 
01117         virtual Map_status set(
01118             const Map_field_id  field_id,
01119             const miMatrix      *value) = 0;
01120 
01125         virtual Map_status set(
01126             const Map_field_id  field_id,
01127             const float         *value) = 0;
01128 
01133         virtual Map_status set(
01134             const Map_field_id  field_id,
01135             const int           *value) = 0;
01136 };
01137 
01142 class Map_element {
01143 public:
01146     Map_element();
01147 
01151     Map_element(
01152         const Map_declaration& declaration);
01153 
01156     Map_element(
01157         const Map_element &other);
01158 
01160     ~Map_element();
01161 
01164     Map_element & operator=(
01165         const Map_element &other);
01166 
01169     Map_element_base * operator->(); 
01170 
01173     const Map_element_base * operator->() const; 
01174 
01175 private:
01176     Map_element_base *m_map_element;
01177 };
01178 
01203 class Map_iterator_base {
01204     public:
01206         virtual void release() const = 0;
01207 
01210         virtual Map_status reset() const = 0;
01211 
01215         virtual Map_status set_to(
01216             const miUint    index) const = 0;
01217 
01220         virtual Map_status next() const = 0;
01221 
01224         virtual Map_status previous() const = 0;
01225 
01229         virtual Map_status skip(
01230             const miUint    amount) const = 0;
01231 
01235         virtual bool at_end(
01236             Map_status  *status = 0) const = 0;
01237 
01241         virtual miUint current(
01242             Map_status  *status = 0) const = 0;
01243 
01247         virtual Map_status get(
01248             Map_element         &element) const = 0;
01249 
01253         virtual Map_status get_position(
01254             float               *position) const = 0;
01255 
01259         virtual Map_status get_position(
01260             miVector            &position) const = 0;
01261 
01267         virtual Map_status get(
01268             const Map_field_id  field_id,
01269             float               &value) const = 0;
01270 
01276         virtual Map_status get(
01277             const Map_field_id  field_id,
01278             int                 &value) const = 0;
01279 
01285         virtual Map_status get(
01286             const Map_field_id  field_id,
01287             miVector            &value) const = 0;
01288 
01294         virtual Map_status get(
01295             const Map_field_id  field_id,
01296             miColor             &value) const = 0;
01297 
01304         virtual Map_status get(
01305             const Map_field_id  field_id,
01306             miMatrix            *value) const = 0;
01307 
01313         virtual Map_status get(
01314             const Map_field_id  field_id,
01315             float               *value) const = 0;
01316 
01322         virtual Map_status get(
01323             const Map_field_id  field_id,
01324             int                 *value) const = 0;
01325 
01329         virtual Map_status set(
01330             const Map_element   &element) = 0;
01331 
01335         virtual Map_status set_position(
01336             const float         *position) = 0;
01337 
01341         virtual Map_status set_position(
01342             const miVector      &position) = 0;
01343 
01349         virtual Map_status set(
01350             const Map_field_id  field_id,
01351             const float         value) = 0;
01352 
01358         virtual Map_status set(
01359             const Map_field_id  field_id,
01360             const int           value) = 0;
01361 
01367         virtual Map_status set(
01368             const Map_field_id  field_id,
01369             const miVector      &value) = 0;
01370 
01376         virtual Map_status set(
01377             const Map_field_id  field_id,
01378             const miColor       &value) = 0;
01379 
01386         virtual Map_status set(
01387             const Map_field_id  field_id,
01388             const miMatrix      *value) = 0;
01389 
01395         virtual Map_status set(
01396             const Map_field_id  field_id,
01397             const float         *value) = 0;
01398 
01404         virtual Map_status set(
01405             const Map_field_id  field_id,
01406             const int           *value) = 0;
01407 };
01408 
01410 class Edit_map_iterator;
01411 
01416 class Access_map_iterator {
01417 public:
01421     Access_map_iterator(
01422         const Access_map &map,
01423         Map_status *status = 0);
01424 
01428     Access_map_iterator(
01429         const Edit_map &map,
01430         Map_status *status = 0);
01431 
01435     Access_map_iterator(
01436         const Access_map_iterator &other,
01437         Map_status *status = 0);
01438 
01442     Access_map_iterator(
01443         const Edit_map_iterator &other,
01444         Map_status *status = 0);
01445 
01447     ~Access_map_iterator();
01448 
01451     Access_map_iterator & operator=(
01452         const Access_map_iterator &other);
01453 
01456     Access_map_iterator & operator=(
01457         const Edit_map_iterator &other);
01458 
01461     const Map_iterator_base * operator->(); 
01462 
01463 private:
01464     Map_iterator_base *m_map_iterator;
01465 };
01466 
01470 typedef Access_map_iterator Map_iterator_access;
01471 
01476 class Edit_map_iterator {
01477 public:
01481     Edit_map_iterator(
01482         const Edit_map &map,
01483         Map_status *status = 0);
01484 
01488     Edit_map_iterator(
01489         const Edit_map_iterator &other,
01490         Map_status *status = 0);
01491 
01493     ~Edit_map_iterator();
01494 
01497     Edit_map_iterator & operator=(
01498         const Edit_map_iterator &other);
01499 
01502     Map_iterator_base * operator->(); 
01503 
01506     const Map_iterator_base * operator->() const; 
01507 
01508 private:
01509     Map_iterator_base *m_map_iterator;
01510 };
01511 
01515 typedef Edit_map_iterator Map_iterator_edit;
01516 
01522 class Map_distance_base {
01523 public:
01526     virtual miUint get_dimension() const = 0;
01527 
01530     virtual const float *get_point() const = 0;
01531 
01536     virtual float operator() (
01537         const float *min,
01538         const float *max) const = 0;
01539 
01543     virtual float operator() (
01544         const Map_iterator_base *element) const = 0;
01545 };
01546 
01547 
01555 template<miUint DIM>
01556 class Map_distance : public mi::shader_v3::Map_distance_base {
01557 public:
01559     static const miUint DIMENSION = DIM;
01560 
01562     Map_distance()
01563     {}
01564 
01567     Map_distance(
01568         const float *point)
01569     {
01570         for (miUint i = 0; i < DIMENSION; ++i)
01571             m_point[i] = point[i];
01572     }
01573 
01576     miUint get_dimension() const { return DIMENSION; }
01577 
01580     const float *get_point() const { return m_point; }
01581 
01586     float operator() (
01587         const float *min,
01588         const float *max) const
01589     {
01590         float d = 0.0f;
01591         float da, db, max_da_db, tmp;
01592 
01593         for (miUint i = 0; i < DIMENSION; ++i) {
01594             da = min[i] - m_point[i];
01595             db = m_point[i] - max[i];
01596 
01597             max_da_db = da > db ? da : db;
01598             tmp = max_da_db > 0.0f ? max_da_db : 0.0f;
01599 
01600             d += tmp * tmp;
01601         }
01602 
01603         return d;
01604     }
01605 
01609     virtual float operator() (
01610         const Map_iterator_base *element) const = 0;
01611 
01612 protected:
01614     float m_point[DIM];
01615 };
01616 
01623 template<miUint DIM>
01624 class Map_quad_distance : public mi::shader_v3::Map_distance<DIM> {
01625 public:
01628     Map_quad_distance(
01629         const float *point)
01630         : Map_distance<DIM>::Map_distance(point)
01631     {}
01632 
01636     float operator() (
01637         const Map_iterator_base *element) const
01638     {
01639         float d = 0.0f;
01640         float diff;
01641         float position[DIM];
01642 
01643         element->get_position(position);
01644 
01645         for (miUint i = 0; i < DIM; ++i) {
01646             diff = this->m_point[i] - position[i];
01647             d += diff * diff;
01648         }
01649 
01650         return d;
01651     }
01652 };
01653 
01656 typedef Map_quad_distance<3> Map_quad_distance3;
01657 
01661 struct Map_lookup_entry {
01663     miUint  index;
01664 
01666     float   distance;
01667 };
01668 
01696 class Map_lookup_base {
01697     public:
01699         virtual void release() const = 0;
01700 
01703         virtual miUint size() const = 0;
01704 
01707         virtual bool is_empty() const = 0;
01708 
01711         virtual Map_status reset() = 0;
01712 
01715         virtual Map_status next() = 0;
01716 
01720         virtual bool at_end(
01721             Map_status  *status = 0) const = 0;
01722 
01725         virtual Map_status sort() = 0;
01726 
01729         virtual Map_status sort_descending() = 0;
01730 
01735         virtual Map_lookup_entry get(
01736             const miUint    n,
01737             Map_status      *status = 0) const = 0;
01738 
01742         virtual Map_lookup_entry get(
01743             Map_status  *status = 0) const = 0;
01744 
01748         virtual miUint get_index(
01749             Map_status  *status = 0) const = 0;
01750 
01754         virtual float get_distance(
01755             Map_status  *status = 0) const = 0;
01756 
01760         virtual Map_status get(
01761             Map_element &element) const = 0;
01762 
01766         virtual Map_status get_position(
01767             float       *position) const = 0;
01768 
01772         virtual Map_status get_position(
01773             miVector    &position) const = 0;
01774 
01780         virtual Map_status get(
01781             const Map_field_id  field_id,
01782             float               &value) const = 0;
01783 
01789         virtual Map_status get(
01790             const Map_field_id  field_id,
01791             int                 &value) const = 0;
01792 
01798         virtual Map_status get(
01799             const Map_field_id  field_id,
01800             miVector            &value) const = 0;
01801 
01807         virtual Map_status get(
01808             const Map_field_id  field_id,
01809             miColor             &value) const = 0;
01810 
01817         virtual Map_status get(
01818             const Map_field_id  field_id,
01819             miMatrix            *value) const = 0;
01820 
01826         virtual Map_status get(
01827             const Map_field_id  field_id,
01828             float               *value) const = 0;
01829 
01835         virtual Map_status get(
01836             const Map_field_id  field_id,
01837             int                 *value) const = 0;
01838 
01845         virtual Map_status search(
01846             const Map_distance_base &distance_functor,
01847             const miUint        max_elements = 1,
01848             const float         max_search_dist = miHUGE_SCALAR) = 0;
01849 
01858         virtual Map_status search(
01859             const miVector      &point,
01860             const miUint        max_elements = 1,
01861             const float         max_search_dist = miHUGE_SCALAR) = 0;
01862 
01873         virtual Map_status search(
01874             const miVector      &origin,
01875             const miVector      &direction,
01876             const float         extension = miHUGE_SCALAR,
01877             const miUint        max_elements = 1,
01878             const float         max_search_dist = miHUGE_SCALAR) = 0;
01879 
01883         virtual Map_status search_next() = 0;
01884 };
01885 
01890 class Map_lookup {
01891 public:
01895     Map_lookup(
01896         const Access_map &map,
01897         Map_status *status = 0);
01898 
01902     Map_lookup(
01903         const Map_lookup &other,
01904         Map_status *status = 0);
01905 
01907     ~Map_lookup();
01908 
01911     Map_lookup & operator=(
01912         const Map_lookup &other);
01913 
01916     Map_lookup_base * operator->(); 
01917 
01918 private:
01919     Map_lookup_base* m_map_lookup;
01920 };
01921 
01924 inline Access_map::Access_map(
01925     const miTag tag)
01926     : m_map_h(0)
01927 {
01928     m_map_h = Access_interface()->accessMap(tag);
01929 }
01930 
01931 inline Access_map::Access_map(
01932     const char *filename,
01933     Map_status *status)
01934     : m_map_h(0)
01935 {
01936     m_map_h = Access_interface()->accessMap(filename, status);
01937 }
01938 
01939 inline Access_map::~Access_map()
01940 {
01941     if(m_map_h != 0)
01942         m_map_h->release();
01943 }
01944 
01945 inline const Map_base * Access_map::operator->()
01946 {
01947     if(m_map_h != 0){
01948         return (*m_map_h).operator->();
01949     }
01950     return 0;
01951 }
01952 
01953 inline const Map_base * Access_map::operator->() const
01954 {
01955     if(m_map_h != 0){
01956         return (*m_map_h).operator->();
01957     }
01958     return 0;
01959 }
01960 
01961 inline miTag Access_map::get_tag() const
01962 {
01963     if(m_map_h != 0){
01964         return m_map_h->get_tag();
01965     }
01966     return 0;
01967 }
01968 
01969 inline miTag Access_map::store()
01970 {
01971     if(m_map_h != 0){
01972         return m_map_h->store();
01973     }
01974     return 0;
01975 }
01976 
01979 inline Edit_map::Edit_map(
01980     const Map_declaration &map_declaration)
01981     : m_map_h(0)
01982 {
01983     m_map_h = Access_interface()->createMap(map_declaration.operator->());
01984 }
01985 
01986 inline Edit_map::Edit_map()
01987     : m_map_h(0)
01988 {
01989     m_map_h = Access_interface()->createMap();
01990 }
01991 
01992 inline Edit_map::Edit_map(
01993     const miTag tag)
01994     : m_map_h(0)
01995 {
01996     m_map_h = Access_interface()->editMap(tag);
01997 }
01998 
01999 inline Edit_map::Edit_map(
02000     const char *filename,
02001     Map_status *status)
02002     : m_map_h(0)
02003 {
02004     m_map_h = Access_interface()->editMap(filename, status);
02005 }
02006 
02007 inline Edit_map::~Edit_map()
02008 {
02009     if(m_map_h != 0)
02010         m_map_h->release();
02011 }
02012 
02013 inline Map_base * Edit_map::operator->()
02014 {
02015     if(m_map_h != 0){
02016         return (*m_map_h).operator->();
02017     }
02018     return 0;
02019 }
02020 
02021 inline const Map_base * Edit_map::operator->() const
02022 {
02023     if(m_map_h != 0){
02024         return (*m_map_h).operator->();
02025     }
02026     return 0;
02027 }
02028 
02029 inline miTag Edit_map::get_tag() const
02030 {
02031     if(m_map_h != 0){
02032         return m_map_h->get_tag();
02033     }
02034     return 0;
02035 }
02036 
02037 inline miTag Edit_map::store()
02038 {
02039     if(m_map_h != 0){
02040         return m_map_h->store();
02041     }
02042     return 0;
02043 }
02044 
02047 inline Map_declaration::Map_declaration(
02048     miUint dimension)
02049     : m_map_declaration(0)
02050 {
02051     m_map_declaration = Access_interface()->createMapDeclaration(
02052         dimension);
02053 }
02054 
02055 inline Map_declaration::Map_declaration(
02056     const Access_map &map,
02057     Map_status *status)
02058     : m_map_declaration(0)
02059 {
02060     m_map_declaration = Access_interface()->copyMapDeclaration(
02061         map.operator->(), status);
02062 }
02063 
02064 inline Map_declaration::Map_declaration(
02065     const Edit_map &map,
02066     Map_status *status)
02067     : m_map_declaration(0)
02068 {
02069     m_map_declaration = Access_interface()->copyMapDeclaration(
02070         map.operator->(), status);
02071 }
02072 
02073 inline Map_declaration::Map_declaration(
02074     const Map_element &map_element,
02075     Map_status *status)
02076     : m_map_declaration(0)
02077 {
02078     m_map_declaration = Access_interface()->copyMapDeclaration(
02079         map_element.operator->(), status);
02080 }
02081 
02082 inline Map_declaration::Map_declaration(
02083     const Map_declaration &other,
02084     Map_status *status)
02085     : m_map_declaration(0)
02086 {
02087     m_map_declaration = Access_interface()->copyMapDeclaration(
02088         other.m_map_declaration, status);
02089 }
02090 
02091 inline Map_declaration & Map_declaration::operator=(
02092     const Map_declaration &other)
02093 {
02094     if (m_map_declaration != 0)
02095         m_map_declaration->release();
02096     m_map_declaration = Access_interface()->copyMapDeclaration(
02097         other.m_map_declaration, 0);
02098     return *this;
02099 }
02100 
02101 inline Map_declaration::~Map_declaration()
02102 {
02103     if (m_map_declaration != 0)
02104         m_map_declaration->release();
02105 }
02106 
02107 inline Map_declaration_base * Map_declaration::operator->()
02108 {
02109     return m_map_declaration;
02110 }
02111 
02112 inline const Map_declaration_base * Map_declaration::operator->() const
02113 {
02114     return m_map_declaration;
02115 }
02116 
02119 inline Map_element::Map_element()
02120     : m_map_element(0)
02121 {
02122     m_map_element = Access_interface()->createMapElement();
02123 }
02124 
02125 inline Map_element::Map_element(
02126     const Map_declaration &declaration)
02127     : m_map_element(0)
02128 {
02129     m_map_element = Access_interface()->createMapElement(
02130         declaration.operator->());
02131 }
02132 
02133 inline Map_element::Map_element(
02134     const Map_element &other)
02135     : m_map_element(0)
02136 {
02137     m_map_element = Access_interface()->copyMapElement(
02138         other.m_map_element);
02139 }
02140 
02141 inline Map_element & Map_element::operator=(
02142     const Map_element &other)
02143 {
02144     m_map_element->release();
02145     m_map_element = Access_interface()->copyMapElement(
02146         other.m_map_element);
02147     return *this;
02148 }
02149 
02150 inline Map_element::~Map_element()
02151 {
02152     m_map_element->release();
02153 }
02154 
02155 inline Map_element_base * Map_element::operator->()
02156 {
02157     return m_map_element;
02158 }
02159 
02160 inline const Map_element_base * Map_element::operator->() const
02161 {
02162     return m_map_element;
02163 }
02164 
02167 inline Access_map_iterator::Access_map_iterator(
02168     const Access_map &map,
02169     Map_status *status)
02170     : m_map_iterator(0)
02171 {
02172     m_map_iterator = Access_interface()->createMapIterator(
02173         map.operator->(), status);
02174 }
02175 
02176 inline Access_map_iterator::Access_map_iterator(
02177     const Edit_map &map,
02178     Map_status *status)
02179     : m_map_iterator(0)
02180 {
02181     m_map_iterator = Access_interface()->createMapIterator(
02182         map.operator->(), status);
02183 }
02184 
02185 inline Access_map_iterator::Access_map_iterator(
02186     const Access_map_iterator &other,
02187     Map_status *status)
02188     : m_map_iterator(0)
02189 {
02190     m_map_iterator = Access_interface()->copyMapIterator(
02191         other.m_map_iterator, status);
02192 }
02193 
02194 inline Access_map_iterator::Access_map_iterator(
02195     const Edit_map_iterator &other,
02196     Map_status *status)
02197     : m_map_iterator(0)
02198 {
02199     m_map_iterator = Access_interface()->copyMapIterator(
02200         other.operator->(), status);
02201 }
02202 
02203 inline Access_map_iterator & Access_map_iterator::operator =(
02204     const Access_map_iterator &other)
02205 {
02206     m_map_iterator->release();
02207     m_map_iterator = Access_interface()->copyMapIterator(
02208         other.m_map_iterator, 0);
02209     return *this;
02210 }
02211 
02212 inline Access_map_iterator & Access_map_iterator::operator =(
02213     const Edit_map_iterator &other)
02214 {
02215     if (m_map_iterator != 0)
02216         m_map_iterator->release();
02217     m_map_iterator = Access_interface()->copyMapIterator(
02218         other.operator->(), 0);
02219     return *this;
02220 }
02221 
02222 inline Access_map_iterator::~Access_map_iterator()
02223 {
02224     if (m_map_iterator != 0)
02225         m_map_iterator->release();
02226 }
02227 
02228 inline const Map_iterator_base * Access_map_iterator::operator->()
02229 {
02230     return m_map_iterator;
02231 }
02232 
02235 inline Edit_map_iterator::Edit_map_iterator(
02236     const Edit_map &map,
02237     Map_status *status)
02238     : m_map_iterator(0)
02239 {
02240     m_map_iterator = Access_interface()->createMapIterator(
02241         map.operator->(), status);
02242 }
02243 
02244 inline Edit_map_iterator::Edit_map_iterator(
02245     const Edit_map_iterator &other,
02246     Map_status *status)
02247     : m_map_iterator(0)
02248 {
02249     m_map_iterator = Access_interface()->copyMapIterator(
02250         other.m_map_iterator, status);
02251 }
02252 
02253 inline Edit_map_iterator & Edit_map_iterator::operator =(
02254     const Edit_map_iterator &other)
02255 {
02256     if (m_map_iterator != 0)
02257         m_map_iterator->release();
02258     m_map_iterator = Access_interface()->copyMapIterator(
02259         other.m_map_iterator, 0);
02260     return *this;
02261 }
02262 
02263 inline Edit_map_iterator::~Edit_map_iterator()
02264 {
02265     if (m_map_iterator != 0)
02266         m_map_iterator->release();
02267 }
02268 
02269 inline Map_iterator_base * Edit_map_iterator::operator->()
02270 {
02271     return m_map_iterator;
02272 }
02273 
02274 inline const Map_iterator_base * Edit_map_iterator::operator->() const
02275 {
02276     return m_map_iterator;
02277 }
02278 
02281 inline Map_lookup::Map_lookup(
02282     const Access_map &map,
02283     Map_status *status)
02284     : m_map_lookup(0)
02285 {
02286     m_map_lookup = Access_interface()->createMapLookup(
02287         map.operator->(), status);
02288 }
02289 
02290 inline Map_lookup::Map_lookup(
02291     const Map_lookup &other,
02292     Map_status *status)
02293     : m_map_lookup(0)
02294 {
02295     m_map_lookup = Access_interface()->copyMapLookup(
02296         other.m_map_lookup, status);
02297 }
02298 
02299 inline Map_lookup::~Map_lookup()
02300 {
02301     if (m_map_lookup != 0)
02302         m_map_lookup->release();
02303 }
02304 
02305 inline Map_lookup & Map_lookup::operator = (
02306     const Map_lookup &other)
02307 {
02308     if (m_map_lookup != 0)
02309         m_map_lookup->release();
02310     m_map_lookup = Access_interface()->copyMapLookup(
02311         other.m_map_lookup, 0);
02312     return *this;
02313 }
02314 
02315 inline Map_lookup_base * Map_lookup::operator->()
02316 {
02317     return m_map_lookup;
02318 }
02319 
02320 } // namespace shader_v3
02321 } // namespace mi
02322 
02323 #endif //SHADER_MAP_H

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.