Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:54

0001 #pragma once
0002 
0003 enum { 
0004      CTRL_RETURN_MISS    = 0,
0005      CTRL_RETURN_A       = 1,
0006      CTRL_RETURN_B       = 2,
0007      CTRL_RETURN_FLIP_B  = 3,
0008      CTRL_LOOP_A         = 4,   
0009      CTRL_LOOP_B         = 5
0010 };  
0011 
0012 
0013 /*
0014 // moved to common action enum sflow.h 
0015 // typedef enum { 
0016 //     UNDEFINED=0, 
0017 //     CONTINUE=1, 
0018 //     BREAK=2 
0019 // } Action_t ;
0020 */
0021 
0022 #if defined(DEBUG)  || defined(DEBUG_RECORD)
0023 static const char* CTRL_RETURN_MISS_   = "RETURN_MISS" ; 
0024 static const char* CTRL_RETURN_A_      = "RETURN_A" ; 
0025 static const char* CTRL_RETURN_B_      = "RETURN_B" ; 
0026 static const char* CTRL_RETURN_FLIP_B_ = "RETURN_FLIP_B" ; 
0027 static const char* CTRL_LOOP_A_        = "LOOP_A" ; 
0028 static const char* CTRL_LOOP_B_        = "LOOP_B" ; 
0029 struct CTRL
0030 {
0031     static const char* Name( int ctrl )
0032     {
0033         const char* s = NULL ; 
0034         switch(ctrl)
0035         {
0036             case CTRL_RETURN_MISS:     s = CTRL_RETURN_MISS_   ; break ; 
0037             case CTRL_RETURN_A:        s = CTRL_RETURN_A_      ; break ; 
0038             case CTRL_RETURN_B:        s = CTRL_RETURN_B_      ; break ; 
0039             case CTRL_RETURN_FLIP_B:   s = CTRL_RETURN_FLIP_B_ ; break ; 
0040             case CTRL_LOOP_A:          s = CTRL_LOOP_A_        ; break ; 
0041             case CTRL_LOOP_B:          s = CTRL_LOOP_B_        ; break ; 
0042         }
0043         return s ; 
0044     }
0045 };
0046 #endif
0047 
0048 
0049 typedef enum { 
0050     State_Enter = 0, 
0051     State_Exit  = 1, 
0052     State_Miss  = 2 
0053 } IntersectionState_t ;
0054 
0055 #define CSG_CLASSIFY( ise, dir, tmin )   (fabsf((ise).w) > (tmin) ?  ( (ise).x*(dir).x + (ise).y*(dir).y + (ise).z*(dir).z < 0.f ? State_Enter : State_Exit ) : State_Miss )
0056 
0057 
0058 #if defined(DEBUG) || defined(DEBUG_RECORD) 
0059 static const char* State_Enter_  = "Enter" ; 
0060 static const char* State_Exit_   = "Exit" ; 
0061 static const char* State_Miss_   = "Miss" ; 
0062 struct IntersectionState
0063 {
0064     static const char* Name( IntersectionState_t type )
0065     {
0066         const char* s = NULL ; 
0067         switch(type)
0068         {
0069             case State_Enter:   s = State_Enter_   ; break ; 
0070             case State_Exit:    s = State_Exit_    ; break ; 
0071             case State_Miss:    s = State_Miss_    ; break ; 
0072         }
0073         return s ; 
0074     }
0075 };
0076 #endif
0077 
0078 
0079 #if defined(__CUDACC__) || defined(__CUDABE__)
0080    #define LUT_METHOD __device__ __forceinline__ 
0081 #else
0082    #define LUT_METHOD inline
0083 #endif 
0084 
0085 
0086 struct LUT
0087 {
0088     // generated from /Users/blyth/opticks/optixrap/cu by boolean_h.py on Sat Mar  4 20:37:03 2017 
0089     unsigned packed_boolean_lut_ACloser[4] = { 0x22121141, 0x00014014, 0x00141141, 0x00000000 } ;
0090     unsigned packed_boolean_lut_BCloser[4] = { 0x22115122, 0x00022055, 0x00133155, 0x00000000 } ;
0091 
0092     LUT_METHOD
0093     int lookup( OpticksCSG_t operation, IntersectionState_t stateA, IntersectionState_t stateB, bool ACloser ) const 
0094     {
0095         const unsigned* lut = ACloser ? packed_boolean_lut_ACloser : packed_boolean_lut_BCloser ;  
0096         unsigned offset = 3*(unsigned)stateA + (unsigned)stateB ; 
0097         unsigned index = (unsigned)operation - (unsigned)CSG_UNION ; 
0098         return offset < 8 ? (( lut[index] >> (offset*4)) & 0xf) : CTRL_RETURN_MISS ;
0099     }
0100 
0101 };
0102 
0103