Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:31

0001 #pragma once
0002 /**
0003 SCAM.h :
0004 =====================
0005 **/
0006 
0007 
0008 enum { CAM_PERSPECTIVE, CAM_ORTHOGRAPHIC, CAM_EQUIRECTANGULAR } ;
0009 
0010 
0011 #ifndef __CUDACC__
0012 #include <cstring>
0013 #include <cstdlib>
0014 #include <cassert>
0015 
0016 struct SCAM
0017 {
0018     static const char* Name(int cam);
0019     static int        Type(const char* name);
0020     static int        Next(int curr);
0021     static constexpr const char* PERSPECTIVE_ = "perspective" ;
0022     static constexpr const char* ORTHOGRAPHIC_ = "orthographic" ;
0023     static constexpr const char* EQUIRECTANGULAR_ = "equirectangular" ;
0024     static int EGet(const char* ekey, const char* fallback);
0025 };
0026 
0027 
0028 inline int SCAM::EGet(const char* ekey, const char* fallback)
0029 {
0030     const char* name_ = getenv(ekey) ;
0031     const char* name = name_ ? name_ : fallback ;
0032     assert( name );
0033     int cam = SCAM::Type(name );
0034     const char* name2 = SCAM::Name(cam) ;
0035     bool consistent = strcmp( name, name2) == 0 ;
0036     if(!consistent) printf("SCAM::EGet ERROR unknown name [%s]\n", name ) ;
0037     assert(consistent );
0038     return cam ;
0039 }
0040 
0041 inline const char* SCAM::Name(int cam )
0042 {
0043     const char* s = nullptr ;
0044     switch(cam)
0045     {
0046         case CAM_PERSPECTIVE:     s = PERSPECTIVE_     ; break ;
0047         case CAM_ORTHOGRAPHIC:    s = ORTHOGRAPHIC_    ; break ;
0048         case CAM_EQUIRECTANGULAR: s = EQUIRECTANGULAR_ ; break ;
0049     }
0050     return s ;
0051 }
0052 inline int SCAM::Type(const char* name)
0053 {
0054     int type = CAM_PERSPECTIVE ;
0055     if(strcmp(name,PERSPECTIVE_) == 0 )     type = CAM_PERSPECTIVE ;
0056     if(strcmp(name,ORTHOGRAPHIC_) == 0 )    type = CAM_ORTHOGRAPHIC ;
0057     if(strcmp(name,EQUIRECTANGULAR_) == 0 ) type = CAM_EQUIRECTANGULAR ;
0058     return type ;
0059 }
0060 
0061 inline int SCAM::Next(int curr)
0062 {
0063      assert( curr == CAM_PERSPECTIVE || curr == CAM_ORTHOGRAPHIC );
0064      return curr == CAM_PERSPECTIVE ? CAM_ORTHOGRAPHIC : CAM_PERSPECTIVE ;
0065 }
0066 
0067 
0068 
0069 
0070 
0071 
0072 
0073 #endif
0074