static LVAL base_range() { int var, set = FALSE; double low, high; var = getfixnum(xlgafixnum()); if (moreargs()) { set = TRUE; low = makedouble(xlgetarg()); high = makedouble(xlgetarg()); } if (set) { if (range_type != 'S') IViewSetRange(wind, var, low, high); else IViewSetScaledRange(wind, var, low, high); } if (range_type != 'S') IViewGetRange(wind, var, &low, &high); else IViewGetScaledRange(wind, var, &low, &high); return(double_list_2(low, high)); }
CellCardImpl( InputDeck& deck, const token_list_t& tokens ) : CellCard( deck ), trcl(NULL), fill(NULL), universe(0), likenbut(false), likeness_cell_n(0), lat_type(NONE), lattice(NULL) { unsigned int idx = 0; ident = makeint(tokens.at(idx++)); if(tokens.at(idx) == "like"){ idx++; likenbut = true; likeness_cell_n = makeint(tokens.at(idx++)); idx++; // skip the "but" token while(idx < tokens.size()){ data.push_back(tokens[idx++]); } return; } material = makeint(tokens.at(idx++)); rho = 0.0; if(material != 0){ rho = makedouble(tokens.at(idx++)); // material density } token_list_t temp_geom; // while the tokens appear in geometry-specification syntax, store them into temporary list while(idx < tokens.size() && tokens.at(idx).find_first_of("1234567890:#-+()") == 0){ temp_geom.push_back(tokens[idx++]); } // retokenize the geometry list, which follows a specialized syntax. retokenize_geometry( temp_geom ); shunt_geometry(); // store the rest of the tokens into the data list while(idx < tokens.size()){ data.push_back(tokens[idx++]); } makeData(); }
/** parse the args of an MCNP geometry transform */ static std::vector<double> makeTransformArgs( const token_list_t tokens ){ std::vector<double> args; for( token_list_t::const_iterator i = tokens.begin(); i!=tokens.end(); ++i){ std::string token = *i; size_t idx; while( (idx = token.find_first_of("()")) != token.npos){ token.replace( idx, 1, "" ); // remove parentheses } if( token.find_first_of( "1234567890" ) != token.npos){ args.push_back( makedouble( token ) ); } else if( token.length() > 0) { std::cerr << "Warning: makeTransformArgs ignoring unrecognized input token [" << token << "]" << std::endl; } } return args; }
SurfaceCard::SurfaceCard( InputDeck& deck, const token_list_t tokens ): Card(deck) { size_t idx = 0; std::string token1 = tokens.at(idx++); if(token1.find_first_of("*+") != token1.npos){ std::cerr << "Warning: no special handling for reflecting or white-boundary surfaces" << std::endl; token1[0] = ' '; } ident = makeint(token1); std::string token2 = tokens.at(idx++); if(token2.find_first_of("1234567890-") != 0){ //token2 is the mnemonic coord_xform = new NullRef<Transform>(); mnemonic = token2; } else{ // token2 is a coordinate transform identifier int tx_id = makeint(token2); if( tx_id == 0 ){ std::cerr << "I don't think 0 is a valid surface transformation ID, so I'm ignoring it." << std::endl; coord_xform = new NullRef<Transform>(); } else if ( tx_id < 0 ){ // abs(tx_id) is the ID of surface with respect to which this surface is periodic. std::cerr << "Warning: surface " << ident << " periodic, but this program has no special handling for periodic surfaces"; } else{ // tx_id is positive and nonzero coord_xform = new CardRef<Transform>( deck, DataCard::TR, makeint(token2) ); } mnemonic = tokens.at(idx++); } while( idx < tokens.size() ){ args.push_back( makedouble(tokens[idx++]) ); } }
void makeData(){ for( token_list_t::iterator i = data.begin(); i!=data.end(); ++i ){ std::string token = *i; if( token == "trcl" || token == "*trcl" ){ bool degree_format = (token[0] == '*'); i++; trcl = parseTransform( parent_deck, i, degree_format ); } // token == {*}trcl else if( token == "u" ){ universe = makeint(*(++i)); } // token == "u" else if ( token == "lat" ){ int lat_designator = makeint(*(++i)); assert( lat_designator >= 0 && lat_designator <= 2 ); lat_type = static_cast<lattice_type_t>(lat_designator); if( OPT_DEBUG ) std::cout << "cell " << ident << " is lattice type " << lat_type << std::endl; } else if ( token == "mat" ){ material = makeint(*(++i)); } else if ( token == "rho" ){ rho = makedouble(*(++i)); } else if ( token.length() == 5 && token.substr(0,4) == "imp:" ){ double imp = makedouble(*(++i)); importances[token[4]] = imp; } else if( token == "fill" || token == "*fill" ){ bool degree_format = (token[0] == '*'); std::string next_token = *(++i); // an explicit lattice grid exists if // * the next token contains a colon, or // * the token after it exists and starts with a colon bool explicit_grid = next_token.find(":") != next_token.npos; explicit_grid = explicit_grid || (i+1 != data.end() && (*(i+1)).at(0) == ':' ); if( explicit_grid ){ // convert the grid specifiers (x1:x2, y1:y2, z1:z2) into three spaceless strings for easier parsing std::string gridspec[3]; for( int dim = 0; dim < 3; ++dim ){ std::string spec; // add tokens to the spec string until it contains a colon but does not end with one do{ spec += *i; i++; } while( spec.find(":") == spec.npos || spec.at(spec.length()-1) == ':' ); if(OPT_DEBUG) std::cout << "gridspec[" << dim << "]: " << spec << std::endl; gridspec[dim] = spec; } irange ranges[3]; const char* range_str; char *p; int num_elements = 1; for( int dim = 0; dim < 3; ++dim ){ range_str = gridspec[dim].c_str(); ranges[dim].first = strtol(range_str, &p, 10); ranges[dim].second = strtol(p+1, NULL, 10); if( ranges[dim].second != ranges[dim].first ){ num_elements *= ( ranges[dim].second - ranges[dim].first )+1; } } std::vector<FillNode> elements; for( int j = 0; j < num_elements; ++j ){ elements.push_back( parseFillNode( parent_deck, i, data.end(), degree_format ) ); i++; } i--; fill = new ImmediateRef< Fill >( Fill( ranges[0], ranges[1], ranges[2], elements) ); } else{ // no explicit grid; fill card is a single fill node FillNode filler = parseFillNode( parent_deck, i, data.end(), degree_format ); fill = new ImmediateRef< Fill >( Fill(filler) ); } } // token == {*}fill } // ensure data pointers are valid if( !trcl ) { trcl = new NullRef< Transform >(); } if( !fill ){ fill = new NullRef< Fill > (); } }