shader_map.h

Go to the documentation of this file.
00001 
00002 // Copyright 1986-2011 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             Illegal_on_slave,           
00046             
00047             Failure = 15,               
00048 
00049             File_could_not_be_opened = 16,  
00050             File_not_a_map,                 
00051             File_version_unsupported,       
00052             
00053             Field_undefined = 32,       
00054             Field_name_too_long,        
00055             Field_name_empty,           
00056             Field_name_illegal,         
00057             Field_null_array,           
00058             Field_type_mismatch,        
00059             Field_illegal,              
00060 
00061             Iterator_invalid = 48,      
00062             Iterator_past_end,          
00063             Iterator_out_of_bounds,     
00064             
00065             Lookup_invalid = 64,        
00066             Lookup_past_end,            
00067             Lookup_out_of_bounds,       
00068             Lookup_dimension_mismatch   
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:
00252         virtual miUint size() const = 0;
00253 
00256         virtual bool is_empty() const = 0;
00257 
00260         virtual bool has_declaration() const = 0;
00261 
00266         virtual Map_status get(
00267             const miUint    index,
00268             Map_element     &map_element) const = 0;
00269 
00274         virtual Map_status set(
00275             const miUint        index,
00276             const Map_element   &map_element) = 0;
00277 
00281         virtual Map_status append(
00282             const Map_element   &map_element) = 0;
00283 
00288         virtual Map_status read(
00289             const char  *file_name,
00290             const bool  notify = true) = 0;
00291 
00296         virtual Map_status append_to(
00297             const char  *file_name,
00298             const bool  notify = true) const = 0;
00299 
00304         virtual Map_status append_from(
00305             const char  *file_name,
00306             const bool  notify = true) = 0;
00307 
00312         virtual Map_status write(
00313             const char  *file_name,
00314             const bool  notify = true) const = 0;
00315 
00320         virtual Map_status consolidate(
00321             const float bvh_quality = 0.6f) = 0;
00322 
00327         virtual Map_status get(
00328             const Map_field_id  field_id,
00329             float               &value) const = 0;
00330 
00335         virtual Map_status get(
00336             const Map_field_id  field_id,
00337             int                 &value) const = 0;
00338 
00343         virtual Map_status get(
00344             const Map_field_id  field_id,
00345             miVector            &value) const = 0;
00346 
00351         virtual Map_status get(
00352             const Map_field_id  field_id,
00353             miColor             &value) const = 0;
00354 
00360         virtual Map_status get(
00361             const Map_field_id  field_id,
00362             miMatrix            *value) const = 0;
00363 
00368         virtual Map_status get(
00369             const Map_field_id  field_id,
00370             float               *value) const = 0;
00371 
00376         virtual Map_status get(
00377             const Map_field_id  field_id,
00378             int                 *value) const = 0;
00379 
00384         virtual Map_status get(
00385             const Map_field_id  field_id,
00386             char                *value) const = 0;
00387 
00392         virtual Map_status set(
00393             const Map_field_id  field_id,
00394             const float         value) = 0;
00395 
00400         virtual Map_status set(
00401             const Map_field_id  field_id,
00402             const int           value) = 0;
00403 
00408         virtual Map_status set(
00409             const Map_field_id  field_id,
00410             const miVector      &value) = 0;
00411 
00416         virtual Map_status set(
00417             const Map_field_id  field_id,
00418             const miColor       &value) = 0;
00419 
00425         virtual Map_status set(
00426             const Map_field_id  field_id,
00427             const miMatrix      *value) = 0;
00428 
00433         virtual Map_status set(
00434             const Map_field_id  field_id,
00435             const float         *value) = 0;
00436 
00441         virtual Map_status set(
00442             const Map_field_id  field_id,
00443             const int           *value) = 0;
00444 
00451         virtual Map_status set(
00452             const Map_field_id  field_id,
00453             const char          *value,
00454             const int           length = -1) = 0;
00455 };
00456 
00460 class Access_map_dbhandle {
00461 public:
00464     virtual const Map_base * operator->() = 0;
00465 
00467     virtual void release() const = 0;
00468 
00471     virtual miTag get_tag() const = 0;
00472 
00475     virtual miTag store() = 0;
00476 };
00477 
00481 typedef Access_map_dbhandle Map_dbhandle_access;
00482 
00487 class Access_map {
00488 public:
00491     Access_map(
00492         const miTag tag);
00493 
00497     Access_map(
00498         const char *filename,
00499         Map_status *status = 0);
00500 
00502     ~Access_map();
00503 
00506     const Map_base * operator->();
00507 
00510     const Map_base * operator->() const;
00511 
00514     miTag get_tag() const;
00515 
00518     miTag store();
00519 
00520 private:
00521     Access_map();
00522     Access_map(const Access_map &);
00523     const Access_map & operator=(const Access_map &);
00524 
00525     Access_map_dbhandle *m_map_h;
00526 };
00527 
00531 typedef Access_map Map_access;
00532 
00536 class Edit_map_dbhandle {
00537 public:
00540     virtual Map_base * operator->() = 0;
00541 
00543     virtual void release() const = 0;
00544 
00547     virtual miTag get_tag() const = 0;
00548 
00551     virtual miTag store() = 0;
00552 };
00553 
00557 typedef Edit_map_dbhandle Map_dbhandle_edit;
00558 
00564 class Edit_map {
00565 public:
00568     Edit_map(
00569         const Map_declaration &map_declaration);
00570 
00572     Edit_map();
00573 
00576     Edit_map(
00577         const miTag tag);
00578 
00582     Edit_map(
00583         const char *filename,
00584         Map_status *status = 0);
00585 
00587     ~Edit_map();
00588 
00591     Map_base * operator->();
00592 
00595     const Map_base * operator->() const;
00596 
00599     miTag get_tag() const;
00600 
00603     miTag store();
00604 
00605 private:
00606     Edit_map(const Edit_map &);
00607     const Edit_map & operator=(const Edit_map &);
00608 
00609     Edit_map_dbhandle *m_map_h;
00610 };
00611 
00615 typedef Edit_map Map_edit;
00616 
00638 class Map_declaration_base {
00639     public:
00641         virtual void release() const = 0;
00642 
00646         virtual miUint get_fields() const = 0;
00647 
00650         virtual miUint get_element_fields() const = 0;
00651 
00654         virtual miUint get_global_fields() const = 0;
00655 
00659         virtual bool is_empty() const = 0;
00660 
00663         virtual miUint get_dimension() const = 0;
00664 
00671         virtual bool is_equivalent(
00672             const Map_declaration   &other,
00673             Map_status              *status = 0) const = 0;
00674 
00681         virtual bool matches(
00682             const Map_declaration   &other,
00683             Map_status              *status = 0) const = 0;
00684 
00690         virtual bool has_field(
00691             const char  *name,
00692             Map_status  *status = 0) const = 0;
00693 
00699         virtual bool is_global(
00700             const char  *name,
00701             Map_status  *status = 0) const = 0;
00702 
00708         virtual bool is_global(
00709             const Map_field_id  field_id,
00710             Map_status          *status = 0) const = 0;
00711 
00716         virtual const char* get_field_name(
00717             const Map_field_id  field_id,
00718             Map_status          *status = 0) const = 0;
00719 
00724         virtual Map_field_id get_field_id(
00725             const char      *field_name,
00726             Map_status      *status = 0) const = 0;
00727 
00733         virtual Map_field_id get_element_field_id(
00734             const miUint    index,
00735             Map_status      *status = 0) const = 0;
00736 
00742         virtual Map_field_id get_global_field_id(
00743             const miUint    index,
00744             Map_status      *status = 0) const = 0;
00745 
00753         virtual Map_status get_field_info(
00754             const Map_field_id  field_id,
00755             Map_field_type      &field_type,
00756             miUint              &field_dimension,
00757             bool                &field_global) const = 0;
00758 
00766         virtual Map_status get_field_info(
00767             const char          *field_name,
00768             Map_field_type      &field_type,
00769             miUint              &field_dimension,
00770             bool                &field_global) const = 0;
00771 
00778         virtual Map_status add(
00779             const char              *name,
00780             const Map_field_type    type,
00781             const miUint            dim = 0) = 0;
00782 
00786         virtual Map_status add_scalar(
00787             const char      *name) = 0;
00788 
00792         virtual Map_status add_integer(
00793             const char      *name) = 0;
00794 
00798         virtual Map_status add_vector(
00799             const char      *name) = 0;
00800 
00804         virtual Map_status add_color(
00805             const char      *name) = 0;
00806 
00810         virtual Map_status add_transform(
00811             const char      *name) = 0;
00812 
00817         virtual Map_status add_scalar_array(
00818             const char      *name,
00819             const miUint    dim) = 0;
00820 
00825         virtual Map_status add_integer_array(
00826             const char      *name,
00827             const miUint    dim) = 0;
00828 
00835         virtual Map_status add_global(
00836             const char              *name,
00837             const Map_field_type    type,
00838             const miUint            dim = 0) = 0;
00839 
00843         virtual Map_status add_global_scalar(
00844             const char      *name) = 0;
00845 
00849         virtual Map_status add_global_integer(
00850             const char      *name) = 0;
00851 
00855         virtual Map_status add_global_vector(
00856             const char      *name) = 0;
00857 
00861         virtual Map_status add_global_color(
00862             const char      *name) = 0;
00863 
00867         virtual Map_status add_global_transform(
00868             const char      *name) = 0;
00869 
00874         virtual Map_status add_global_scalar_array(
00875             const char      *name,
00876             const miUint    dim) = 0;
00877 
00882         virtual Map_status add_global_integer_array(
00883             const char      *name,
00884             const miUint    dim) = 0;
00885 
00890         virtual Map_status add_global_string(
00891             const char      *name,
00892             const miUint    dim) = 0;
00893 };
00894 
00901 class Map_declaration {
00902 public:
00905     Map_declaration(
00906         const miUint dimension=3);
00907 
00911     Map_declaration(
00912         const Access_map &map,
00913         Map_status *status = 0);
00914 
00918     Map_declaration(
00919         const Edit_map &map,
00920         Map_status *status = 0);
00921 
00925     Map_declaration(
00926         const Map_element &map_element,
00927         Map_status *status = 0);
00928 
00932     Map_declaration(
00933         const Map_declaration &other,
00934         Map_status *status = 0);
00935 
00937     ~Map_declaration();
00938 
00941     Map_declaration & operator=(
00942         const Map_declaration &other);
00943 
00946     Map_declaration_base * operator->();
00947 
00950     const Map_declaration_base * operator->() const;
00951 
00952 private:
00953     Map_declaration_base *m_map_declaration;
00954 };
00955 
00979 class Map_element_base {
00980     public:
00982         virtual void release() const = 0;
00983 
00987         virtual Map_status set_declaration(
00988             const Map_declaration&  declaration) = 0;
00989 
00993         virtual Map_status get_position(
00994             float               *position) const = 0;
00995 
00999         virtual Map_status get_position(
01000             miVector            &position) const = 0;
01001 
01006         virtual Map_status get(
01007             const Map_field_id  field_id,
01008             float               &value) const = 0;
01009 
01014         virtual Map_status get(
01015             const Map_field_id  field_id,
01016             int                 &value) const = 0;
01017 
01022         virtual Map_status get(
01023             const Map_field_id  field_id,
01024             miVector            &value) const = 0;
01025 
01030         virtual Map_status get(
01031             const Map_field_id  field_id,
01032             miColor             &value) const = 0;
01033 
01039         virtual Map_status get(
01040             const Map_field_id  field_id,
01041             miMatrix            *value) const = 0;
01042 
01047         virtual Map_status get(
01048             const Map_field_id  field_id,
01049             float               *value) const = 0;
01050 
01055         virtual Map_status get(
01056             const Map_field_id  field_id,
01057             int                 *value) const = 0;
01058 
01062         virtual Map_status set_position(
01063             const float         *position) = 0;
01064 
01068         virtual Map_status set_position(
01069             const miVector      &position) = 0;
01070 
01075         virtual Map_status set(
01076             const Map_field_id  field_id,
01077             const float         value) = 0;
01078 
01083         virtual Map_status set(
01084             const Map_field_id  field_id,
01085             const int           value) = 0;
01086 
01091         virtual Map_status set(
01092             const Map_field_id  field_id,
01093             const miVector      &value) = 0;
01094 
01099         virtual Map_status set(
01100             const Map_field_id  field_id,
01101             const miColor       &value) = 0;
01102 
01108         virtual Map_status set(
01109             const Map_field_id  field_id,
01110             const miMatrix      *value) = 0;
01111 
01116         virtual Map_status set(
01117             const Map_field_id  field_id,
01118             const float         *value) = 0;
01119 
01124         virtual Map_status set(
01125             const Map_field_id  field_id,
01126             const int           *value) = 0;
01127 };
01128 
01133 class Map_element {
01134 public:
01137     Map_element();
01138 
01142     Map_element(
01143         const Map_declaration& declaration);
01144 
01147     Map_element(
01148         const Map_element &other);
01149 
01151     ~Map_element();
01152 
01155     Map_element & operator=(
01156         const Map_element &other);
01157 
01160     Map_element_base * operator->(); 
01161 
01164     const Map_element_base * operator->() const; 
01165 
01166 private:
01167     Map_element_base *m_map_element;
01168 };
01169 
01194 class Map_iterator_base {
01195     public:
01197         virtual void release() const = 0;
01198 
01201         virtual Map_status reset() const = 0;
01202 
01206         virtual Map_status set_to(
01207             const miUint    index) const = 0;
01208 
01211         virtual Map_status next() const = 0;
01212 
01215         virtual Map_status previous() const = 0;
01216 
01220         virtual Map_status skip(
01221             const miUint    amount) const = 0;
01222 
01226         virtual bool at_end(
01227             Map_status  *status = 0) const = 0;
01228 
01232         virtual miUint current(
01233             Map_status  *status = 0) const = 0;
01234 
01238         virtual Map_status get(
01239             Map_element         &element) const = 0;
01240 
01244         virtual Map_status get_position(
01245             float               *position) const = 0;
01246 
01250         virtual Map_status get_position(
01251             miVector            &position) const = 0;
01252 
01258         virtual Map_status get(
01259             const Map_field_id  field_id,
01260             float               &value) const = 0;
01261 
01267         virtual Map_status get(
01268             const Map_field_id  field_id,
01269             int                 &value) const = 0;
01270 
01276         virtual Map_status get(
01277             const Map_field_id  field_id,
01278             miVector            &value) const = 0;
01279 
01285         virtual Map_status get(
01286             const Map_field_id  field_id,
01287             miColor             &value) const = 0;
01288 
01295         virtual Map_status get(
01296             const Map_field_id  field_id,
01297             miMatrix            *value) const = 0;
01298 
01304         virtual Map_status get(
01305             const Map_field_id  field_id,
01306             float               *value) const = 0;
01307 
01313         virtual Map_status get(
01314             const Map_field_id  field_id,
01315             int                 *value) const = 0;
01316 
01320         virtual Map_status set(
01321             const Map_element   &element) = 0;
01322 
01326         virtual Map_status set_position(
01327             const float         *position) = 0;
01328 
01332         virtual Map_status set_position(
01333             const miVector      &position) = 0;
01334 
01340         virtual Map_status set(
01341             const Map_field_id  field_id,
01342             const float         value) = 0;
01343 
01349         virtual Map_status set(
01350             const Map_field_id  field_id,
01351             const int           value) = 0;
01352 
01358         virtual Map_status set(
01359             const Map_field_id  field_id,
01360             const miVector      &value) = 0;
01361 
01367         virtual Map_status set(
01368             const Map_field_id  field_id,
01369             const miColor       &value) = 0;
01370 
01377         virtual Map_status set(
01378             const Map_field_id  field_id,
01379             const miMatrix      *value) = 0;
01380 
01386         virtual Map_status set(
01387             const Map_field_id  field_id,
01388             const float         *value) = 0;
01389 
01395         virtual Map_status set(
01396             const Map_field_id  field_id,
01397             const int           *value) = 0;
01398 };
01399 
01401 class Edit_map_iterator;
01402 
01407 class Access_map_iterator {
01408 public:
01412     Access_map_iterator(
01413         const Access_map &map,
01414         Map_status *status = 0);
01415 
01419     Access_map_iterator(
01420         const Edit_map &map,
01421         Map_status *status = 0);
01422 
01426     Access_map_iterator(
01427         const Access_map_iterator &other,
01428         Map_status *status = 0);
01429 
01433     Access_map_iterator(
01434         const Edit_map_iterator &other,
01435         Map_status *status = 0);
01436 
01438     ~Access_map_iterator();
01439 
01442     Access_map_iterator & operator=(
01443         const Access_map_iterator &other);
01444 
01447     Access_map_iterator & operator=(
01448         const Edit_map_iterator &other);
01449 
01452     const Map_iterator_base * operator->(); 
01453 
01454 private:
01455     Map_iterator_base *m_map_iterator;
01456 };
01457 
01461 typedef Access_map_iterator Map_iterator_access;
01462 
01467 class Edit_map_iterator {
01468 public:
01472     Edit_map_iterator(
01473         const Edit_map &map,
01474         Map_status *status = 0);
01475 
01479     Edit_map_iterator(
01480         const Edit_map_iterator &other,
01481         Map_status *status = 0);
01482 
01484     ~Edit_map_iterator();
01485 
01488     Edit_map_iterator & operator=(
01489         const Edit_map_iterator &other);
01490 
01493     Map_iterator_base * operator->(); 
01494 
01497     const Map_iterator_base * operator->() const; 
01498 
01499 private:
01500     Map_iterator_base *m_map_iterator;
01501 };
01502 
01506 typedef Edit_map_iterator Map_iterator_edit;
01507 
01513 class Map_distance_base {
01514 public:
01517     virtual miUint get_dimension() const = 0;
01518 
01521     virtual const float *get_point() const = 0;
01522 
01527     virtual float operator() (
01528         const float *min,
01529         const float *max) const = 0;
01530 
01534     virtual float operator() (
01535         const Map_iterator_base *element) const = 0;
01536 };
01537 
01538 
01546 template<miUint DIM>
01547 class Map_distance : public mi::shader_v3::Map_distance_base {
01548 public:
01550     static const miUint DIMENSION = DIM;
01551 
01553     Map_distance()
01554     {}
01555 
01558     Map_distance(
01559         const float *point)
01560     {
01561         for (miUint i = 0; i < DIMENSION; ++i)
01562             m_point[i] = point[i];
01563     }
01564 
01567     miUint get_dimension() const { return DIMENSION; }
01568 
01571     const float *get_point() const { return m_point; }
01572 
01577     float operator() (
01578         const float *min,
01579         const float *max) const
01580     {
01581         float d = 0.0f;
01582         float da, db, max_da_db, tmp;
01583 
01584         for (miUint i = 0; i < DIMENSION; ++i) {
01585             da = min[i] - m_point[i];
01586             db = m_point[i] - max[i];
01587 
01588             max_da_db = da > db ? da : db;
01589             tmp = max_da_db > 0.0f ? max_da_db : 0.0f;
01590 
01591             d += tmp * tmp;
01592         }
01593 
01594         return d;
01595     }
01596 
01600     virtual float operator() (
01601         const Map_iterator_base *element) const = 0;
01602 
01603 protected:
01605     float m_point[DIM];
01606 };
01607 
01614 template<miUint DIM>
01615 class Map_quad_distance : public mi::shader_v3::Map_distance<DIM> {
01616 public:
01619     Map_quad_distance(
01620         const float *point)
01621         : Map_distance<DIM>::Map_distance(point)
01622     {}
01623 
01627     float operator() (
01628         const Map_iterator_base *element) const
01629     {
01630         float d = 0.0f;
01631         float diff;
01632         float position[DIM];
01633 
01634         element->get_position(position);
01635 
01636         for (miUint i = 0; i < DIM; ++i) {
01637             diff = this->m_point[i] - position[i];
01638             d += diff * diff;
01639         }
01640 
01641         return d;
01642     }
01643 };
01644 
01647 typedef Map_quad_distance<3> Map_quad_distance3;
01648 
01652 struct Map_lookup_entry {
01654     miUint  index;
01655 
01657     float   distance;
01658 };
01659 
01687 class Map_lookup_base {
01688     public:
01690         virtual void release() const = 0;
01691 
01694         virtual miUint size() const = 0;
01695 
01698         virtual bool is_empty() const = 0;
01699 
01702         virtual Map_status reset() = 0;
01703 
01706         virtual Map_status next() = 0;
01707 
01711         virtual bool at_end(
01712             Map_status  *status = 0) const = 0;
01713 
01716         virtual Map_status sort() = 0;
01717 
01720         virtual Map_status sort_descending() = 0;
01721 
01726         virtual Map_lookup_entry get(
01727             const miUint    n,
01728             Map_status      *status = 0) const = 0;
01729 
01733         virtual Map_lookup_entry get(
01734             Map_status  *status = 0) const = 0;
01735 
01739         virtual miUint get_index(
01740             Map_status  *status = 0) const = 0;
01741 
01745         virtual float get_distance(
01746             Map_status  *status = 0) const = 0;
01747 
01751         virtual Map_status get(
01752             Map_element &element) const = 0;
01753 
01757         virtual Map_status get_position(
01758             float       *position) const = 0;
01759 
01763         virtual Map_status get_position(
01764             miVector    &position) const = 0;
01765 
01771         virtual Map_status get(
01772             const Map_field_id  field_id,
01773             float               &value) const = 0;
01774 
01780         virtual Map_status get(
01781             const Map_field_id  field_id,
01782             int                 &value) const = 0;
01783 
01789         virtual Map_status get(
01790             const Map_field_id  field_id,
01791             miVector            &value) const = 0;
01792 
01798         virtual Map_status get(
01799             const Map_field_id  field_id,
01800             miColor             &value) const = 0;
01801 
01808         virtual Map_status get(
01809             const Map_field_id  field_id,
01810             miMatrix            *value) const = 0;
01811 
01817         virtual Map_status get(
01818             const Map_field_id  field_id,
01819             float               *value) const = 0;
01820 
01826         virtual Map_status get(
01827             const Map_field_id  field_id,
01828             int                 *value) const = 0;
01829 
01836         virtual Map_status search(
01837             const Map_distance_base &distance_functor,
01838             const miUint        max_elements = 1,
01839             const float         max_search_dist = miHUGE_SCALAR) = 0;
01840 
01849         virtual Map_status search(
01850             const miVector      &point,
01851             const miUint        max_elements = 1,
01852             const float         max_search_dist = miHUGE_SCALAR) = 0;
01853 };
01854 
01859 class Map_lookup {
01860 public:
01864     Map_lookup(
01865         const Access_map &map,
01866         Map_status *status = 0);
01867 
01871     Map_lookup(
01872         const Map_lookup &other,
01873         Map_status *status = 0);
01874 
01876     ~Map_lookup();
01877 
01880     Map_lookup & operator=(
01881         const Map_lookup &other);
01882 
01885     Map_lookup_base * operator->(); 
01886 
01887 private:
01888     Map_lookup_base* m_map_lookup;
01889 };
01890 
01893 inline Access_map::Access_map(
01894     const miTag tag)
01895     : m_map_h(0)
01896 {
01897     m_map_h = Access_interface()->accessMap(tag);
01898 }
01899 
01900 inline Access_map::Access_map(
01901     const char *filename,
01902     Map_status *status)
01903     : m_map_h(0)
01904 {
01905     m_map_h = Access_interface()->accessMap(filename, status);
01906 }
01907 
01908 inline Access_map::~Access_map()
01909 {
01910     if(m_map_h != 0)
01911         m_map_h->release();
01912 }
01913 
01914 inline const Map_base * Access_map::operator->()
01915 {
01916     if(m_map_h != 0){
01917         return (*m_map_h).operator->();
01918     }
01919     return 0;
01920 }
01921 
01922 inline const Map_base * Access_map::operator->() const
01923 {
01924     if(m_map_h != 0){
01925         return (*m_map_h).operator->();
01926     }
01927     return 0;
01928 }
01929 
01930 inline miTag Access_map::get_tag() const
01931 {
01932     if(m_map_h != 0){
01933         return m_map_h->get_tag();
01934     }
01935     return 0;
01936 }
01937 
01938 inline miTag Access_map::store()
01939 {
01940     if(m_map_h != 0){
01941         return m_map_h->store();
01942     }
01943     return 0;
01944 }
01945 
01948 inline Edit_map::Edit_map(
01949     const Map_declaration &map_declaration)
01950     : m_map_h(0)
01951 {
01952     m_map_h = Access_interface()->createMap(map_declaration.operator->());
01953 }
01954 
01955 inline Edit_map::Edit_map()
01956     : m_map_h(0)
01957 {
01958     m_map_h = Access_interface()->createMap();
01959 }
01960 
01961 inline Edit_map::Edit_map(
01962     const miTag tag)
01963     : m_map_h(0)
01964 {
01965     m_map_h = Access_interface()->editMap(tag);
01966 }
01967 
01968 inline Edit_map::Edit_map(
01969     const char *filename,
01970     Map_status *status)
01971     : m_map_h(0)
01972 {
01973     m_map_h = Access_interface()->editMap(filename, status);
01974 }
01975 
01976 inline Edit_map::~Edit_map()
01977 {
01978     if(m_map_h != 0)
01979         m_map_h->release();
01980 }
01981 
01982 inline Map_base * Edit_map::operator->()
01983 {
01984     if(m_map_h != 0){
01985         return (*m_map_h).operator->();
01986     }
01987     return 0;
01988 }
01989 
01990 inline const Map_base * Edit_map::operator->() const
01991 {
01992     if(m_map_h != 0){
01993         return (*m_map_h).operator->();
01994     }
01995     return 0;
01996 }
01997 
01998 inline miTag Edit_map::get_tag() const
01999 {
02000     if(m_map_h != 0){
02001         return m_map_h->get_tag();
02002     }
02003     return 0;
02004 }
02005 
02006 inline miTag Edit_map::store()
02007 {
02008     if(m_map_h != 0){
02009         return m_map_h->store();
02010     }
02011     return 0;
02012 }
02013 
02016 inline Map_declaration::Map_declaration(
02017     miUint dimension)
02018     : m_map_declaration(0)
02019 {
02020     m_map_declaration = Access_interface()->createMapDeclaration(
02021         dimension);
02022 }
02023 
02024 inline Map_declaration::Map_declaration(
02025     const Access_map &map,
02026     Map_status *status)
02027     : m_map_declaration(0)
02028 {
02029     m_map_declaration = Access_interface()->copyMapDeclaration(
02030         map.operator->(), status);
02031 }
02032 
02033 inline Map_declaration::Map_declaration(
02034     const Edit_map &map,
02035     Map_status *status)
02036     : m_map_declaration(0)
02037 {
02038     m_map_declaration = Access_interface()->copyMapDeclaration(
02039         map.operator->(), status);
02040 }
02041 
02042 inline Map_declaration::Map_declaration(
02043     const Map_element &map_element,
02044     Map_status *status)
02045     : m_map_declaration(0)
02046 {
02047     m_map_declaration = Access_interface()->copyMapDeclaration(
02048         map_element.operator->(), status);
02049 }
02050 
02051 inline Map_declaration::Map_declaration(
02052     const Map_declaration &other,
02053     Map_status *status)
02054     : m_map_declaration(0)
02055 {
02056     m_map_declaration = Access_interface()->copyMapDeclaration(
02057         other.m_map_declaration, status);
02058 }
02059 
02060 inline Map_declaration & Map_declaration::operator=(
02061     const Map_declaration &other)
02062 {
02063     if (m_map_declaration != 0)
02064         m_map_declaration->release();
02065     m_map_declaration = Access_interface()->copyMapDeclaration(
02066         other.m_map_declaration, 0);
02067     return *this;
02068 }
02069 
02070 inline Map_declaration::~Map_declaration()
02071 {
02072     if (m_map_declaration != 0)
02073         m_map_declaration->release();
02074 }
02075 
02076 inline Map_declaration_base * Map_declaration::operator->()
02077 {
02078     return m_map_declaration;
02079 }
02080 
02081 inline const Map_declaration_base * Map_declaration::operator->() const
02082 {
02083     return m_map_declaration;
02084 }
02085 
02088 inline Map_element::Map_element()
02089     : m_map_element(0)
02090 {
02091     m_map_element = Access_interface()->createMapElement();
02092 }
02093 
02094 inline Map_element::Map_element(
02095     const Map_declaration &declaration)
02096     : m_map_element(0)
02097 {
02098     m_map_element = Access_interface()->createMapElement(
02099         declaration.operator->());
02100 }
02101 
02102 inline Map_element::Map_element(
02103     const Map_element &other)
02104     : m_map_element(0)
02105 {
02106     m_map_element = Access_interface()->copyMapElement(
02107         other.m_map_element);
02108 }
02109 
02110 inline Map_element & Map_element::operator=(
02111     const Map_element &other)
02112 {
02113     m_map_element->release();
02114     m_map_element = Access_interface()->copyMapElement(
02115         other.m_map_element);
02116     return *this;
02117 }
02118 
02119 inline Map_element::~Map_element()
02120 {
02121     m_map_element->release();
02122 }
02123 
02124 inline Map_element_base * Map_element::operator->()
02125 {
02126     return m_map_element;
02127 }
02128 
02129 inline const Map_element_base * Map_element::operator->() const
02130 {
02131     return m_map_element;
02132 }
02133 
02136 inline Access_map_iterator::Access_map_iterator(
02137     const Access_map &map,
02138     Map_status *status)
02139     : m_map_iterator(0)
02140 {
02141     m_map_iterator = Access_interface()->createMapIterator(
02142         map.operator->(), status);
02143 }
02144 
02145 inline Access_map_iterator::Access_map_iterator(
02146     const Edit_map &map,
02147     Map_status *status)
02148     : m_map_iterator(0)
02149 {
02150     m_map_iterator = Access_interface()->createMapIterator(
02151         map.operator->(), status);
02152 }
02153 
02154 inline Access_map_iterator::Access_map_iterator(
02155     const Access_map_iterator &other,
02156     Map_status *status)
02157     : m_map_iterator(0)
02158 {
02159     m_map_iterator = Access_interface()->copyMapIterator(
02160         other.m_map_iterator, status);
02161 }
02162 
02163 inline Access_map_iterator::Access_map_iterator(
02164     const Edit_map_iterator &other,
02165     Map_status *status)
02166     : m_map_iterator(0)
02167 {
02168     m_map_iterator = Access_interface()->copyMapIterator(
02169         other.operator->(), status);
02170 }
02171 
02172 inline Access_map_iterator & Access_map_iterator::operator =(
02173     const Access_map_iterator &other)
02174 {
02175     m_map_iterator->release();
02176     m_map_iterator = Access_interface()->copyMapIterator(
02177         other.m_map_iterator, 0);
02178     return *this;
02179 }
02180 
02181 inline Access_map_iterator & Access_map_iterator::operator =(
02182     const Edit_map_iterator &other)
02183 {
02184     if (m_map_iterator != 0)
02185         m_map_iterator->release();
02186     m_map_iterator = Access_interface()->copyMapIterator(
02187         other.operator->(), 0);
02188     return *this;
02189 }
02190 
02191 inline Access_map_iterator::~Access_map_iterator()
02192 {
02193     if (m_map_iterator != 0)
02194         m_map_iterator->release();
02195 }
02196 
02197 inline const Map_iterator_base * Access_map_iterator::operator->()
02198 {
02199     return m_map_iterator;
02200 }
02201 
02204 inline Edit_map_iterator::Edit_map_iterator(
02205     const Edit_map &map,
02206     Map_status *status)
02207     : m_map_iterator(0)
02208 {
02209     m_map_iterator = Access_interface()->createMapIterator(
02210         map.operator->(), status);
02211 }
02212 
02213 inline Edit_map_iterator::Edit_map_iterator(
02214     const Edit_map_iterator &other,
02215     Map_status *status)
02216     : m_map_iterator(0)
02217 {
02218     m_map_iterator = Access_interface()->copyMapIterator(
02219         other.m_map_iterator, status);
02220 }
02221 
02222 inline Edit_map_iterator & Edit_map_iterator::operator =(
02223     const Edit_map_iterator &other)
02224 {
02225     if (m_map_iterator != 0)
02226         m_map_iterator->release();
02227     m_map_iterator = Access_interface()->copyMapIterator(
02228         other.m_map_iterator, 0);
02229     return *this;
02230 }
02231 
02232 inline Edit_map_iterator::~Edit_map_iterator()
02233 {
02234     if (m_map_iterator != 0)
02235         m_map_iterator->release();
02236 }
02237 
02238 inline Map_iterator_base * Edit_map_iterator::operator->()
02239 {
02240     return m_map_iterator;
02241 }
02242 
02243 inline const Map_iterator_base * Edit_map_iterator::operator->() const
02244 {
02245     return m_map_iterator;
02246 }
02247 
02250 inline Map_lookup::Map_lookup(
02251     const Access_map &map,
02252     Map_status *status)
02253     : m_map_lookup(0)
02254 {
02255     m_map_lookup = Access_interface()->createMapLookup(
02256         map.operator->(), status);
02257 }
02258 
02259 inline Map_lookup::Map_lookup(
02260     const Map_lookup &other,
02261     Map_status *status)
02262     : m_map_lookup(0)
02263 {
02264     m_map_lookup = Access_interface()->copyMapLookup(
02265         other.m_map_lookup, status);
02266 }
02267 
02268 inline Map_lookup::~Map_lookup()
02269 {
02270     if (m_map_lookup != 0)
02271         m_map_lookup->release();
02272 }
02273 
02274 inline Map_lookup & Map_lookup::operator = (
02275     const Map_lookup &other)
02276 {
02277     if (m_map_lookup != 0)
02278         m_map_lookup->release();
02279     m_map_lookup = Access_interface()->copyMapLookup(
02280         other.m_map_lookup, 0);
02281     return *this;
02282 }
02283 
02284 inline Map_lookup_base * Map_lookup::operator->()
02285 {
02286     return m_map_lookup;
02287 }
02288 
02289 } // namespace shader_v3
02290 } // namespace mi
02291 
02292 #endif //SHADER_MAP_H

Copyright © 1986-2011 by mental images GmbH