File indexing completed on 2026-04-09 07:48:58
0001
0002 #include "scuda.h"
0003
0004 #include "CSGSolid.h"
0005
0006 #if defined(__CUDACC__) || defined(__CUDABE__)
0007 #else
0008
0009 #include <sstream>
0010 #include <iostream>
0011 #include <iomanip>
0012 #include <cstring>
0013
0014 #include "sstr.h"
0015 #include "SLOG.hh"
0016
0017 const plog::Severity CSGSolid::LEVEL = SLOG::EnvLevel("CSGSolid", "DEBUG") ;
0018
0019
0020 bool CSGSolid::IsDiff( const CSGSolid& a , const CSGSolid& b )
0021 {
0022 return false ;
0023 }
0024
0025 CSGSolid CSGSolid::Make( const char* label_, int numPrim_, int primOffset_ )
0026 {
0027 CSGSolid so = {} ;
0028
0029
0030 sstr::truncated_copy( so.label, label_, sizeof(so.label) );
0031
0032 so.numPrim = numPrim_ ;
0033 so.primOffset = primOffset_ ;
0034 so.type = STANDARD_SOLID ;
0035 so.center_extent = make_float4(0.f, 0.f, 0.f, 0.f) ;
0036
0037 return so ;
0038 }
0039
0040
0041 std::string CSGSolid::desc() const
0042 {
0043 std::string label16(label, 16);
0044 std::stringstream ss ;
0045 ss << "CSGSolid "
0046 << std::setw(16) << label16.c_str()
0047 << " primNum/Offset "
0048 << std::setw(5) << numPrim
0049 << std::setw(5) << primOffset
0050 << " ce " << center_extent
0051 ;
0052
0053 if( type == ONE_PRIM_SOLID ) ss << " ONE_PRIM_SOLID " ;
0054 if( type == ONE_NODE_SOLID ) ss << " ONE_NODE_SOLID " ;
0055 if( type == DEEP_COPY_SOLID ) ss << " DEEP_COPY_SOLID " ;
0056 if( type == KLUDGE_BBOX_SOLID ) ss << " KLUDGE_BBOX_SOLID " ;
0057
0058 std::string s = ss.str();
0059 return s ;
0060 }
0061
0062 const char* CSGSolid::getLabel() const
0063 {
0064 std::string lab(label, 16);
0065 return strdup(lab.c_str()) ;
0066 }
0067
0068 bool CSGSolid::labelMatch(const char* label_) const
0069 {
0070 return strncmp(label, label_, sizeof(label)) == 0 ;
0071 }
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 char CSGSolid::getIntent() const
0083 {
0084 return intent ;
0085 }
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 void CSGSolid::setIntent(char _intent)
0106 {
0107 assert(_intent == 'R' || _intent == 'F' || _intent == 'T' );
0108 intent = _intent ;
0109 }
0110
0111 void CSGSolid::CopyIntent( CSGSolid* d, const CSGSolid* s )
0112 {
0113 d->intent = s->intent ;
0114 d->pad0 = s->pad0 ;
0115 d->pad1 = s->pad1 ;
0116 d->pad2 = s->pad2 ;
0117 }
0118
0119
0120
0121 std::string CSGSolid::MakeLabel(const char* typ0, unsigned idx0, char delim )
0122 {
0123 std::stringstream ss ;
0124 ss << typ0 ;
0125 if(delim != '\0') ss << delim ;
0126 ss << idx0 ;
0127 std::string s = ss.str();
0128 return s ;
0129 }
0130
0131 std::string CSGSolid::MakeLabel(char typ0, unsigned idx0 )
0132 {
0133 std::stringstream ss ;
0134 ss << typ0 << idx0 ;
0135 std::string s = ss.str();
0136 return s ;
0137 }
0138
0139 int CSGSolid::ParseLabel( const char* label_, char& typ0, unsigned& idx0 )
0140 {
0141 size_t sz = strlen(label_);
0142 if( sz < 2 ) return 1 ;
0143 typ0 = label_[0] ;
0144 idx0 = std::atoi(label_+1) ;
0145 return 0 ;
0146 }
0147
0148 int CSGSolid::get_ridx() const
0149 {
0150 char typ0 ;
0151 unsigned idx0 ;
0152 int rc = ParseLabel(label, typ0, idx0 );
0153 return rc == 0 ? idx0 : -1 ;
0154 }
0155
0156
0157
0158
0159
0160
0161
0162 std::string CSGSolid::MakeLabel(char typ0, unsigned idx0, char typ1, unsigned idx1 )
0163 {
0164 std::stringstream ss ;
0165 ss << typ0 << idx0 << typ1 << idx1 ;
0166 std::string s = ss.str();
0167 return s ;
0168 }
0169 std::string CSGSolid::MakeLabel(char typ0, unsigned idx0, char typ1, unsigned idx1, char typ2, unsigned idx2 )
0170 {
0171 std::stringstream ss ;
0172 ss << typ0 << idx0 << typ1 << idx1 << typ2 << idx2 ;
0173 std::string s = ss.str();
0174 return s ;
0175 }
0176
0177
0178
0179
0180 #endif
0181