本文整理汇总了C++中Units类的典型用法代码示例。如果您正苦于以下问题:C++ Units类的具体用法?C++ Units怎么用?C++ Units使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Units类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseComment
Integer ParseNonbondedFile::parse(StringParser *sp)
{
ParseComment parseComment("[#;");
ParseSigmaEpsilonCharge parseSEC;
Units *DU = Units::distanceUnits();
Units *EU = Units::energyUnits();
int NParsed = 0;
do{
sp->skipChars(" \t\n");
if(sp->isOver()) return 1;
if(expectStatement(sp,&parseComment)) continue;
if(!expectStatement(sp,&parseSEC)) return NParsed>0;
SigmaEpsilonCharge sec;
sec.sigma = parseSEC.m_sigma * DU->unit2unit("nm","Angstr");
sec.epsilon = parseSEC.m_epsilon * EU->unit2unit("kJ/mol","kcal/mol");
sec.charge = parseSEC.m_charge;
(*m_ff)[parseSEC.m_atomType] = sec;
NParsed++;
}while(1);
}
示例2:
bool
VerticalDatum::transform(const VerticalDatum* from,
const VerticalDatum* to,
double lat_deg,
double lon_deg,
double& in_out_z)
{
if ( from == to )
return true;
if ( from )
{
in_out_z = from->msl2hae( lat_deg, lon_deg, in_out_z );
}
Units fromUnits = from ? from->getUnits() : Units::METERS;
Units toUnits = to ? to->getUnits() : Units::METERS;
in_out_z = fromUnits.convertTo(toUnits, in_out_z);
if ( to )
{
in_out_z = to->hae2msl( lat_deg, lon_deg, in_out_z );
}
return true;
}
示例3: GetNumberOfUnits
int PSPower::GetNumberOfUnits(PSData* pData)
{
if (!pData)
pData = TG.GetData();
Units vUnits = pData->GetUnits(this);
return vUnits.size();
}
示例4: is_2D_char_2D_type
bool
is_2D_char_2D_type(MContext *mc, DNode *t)
{
Units *units = (dale::Units*) mc->units;
Node *n = units->top()->dnc->toNode(t);
n = units->top()->mp->parsePotentialMacroCall(n);
return (n && n->token && !n->token->str_value.compare("char"));
}
示例5: MergeFrom
void Units::MergeFrom(const Units& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from._has_bit(0)) {
set_ret(from.ret());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
示例6:
void MDAtomsTyped<T>::setUnits(const Units& units,const Units& MDUnits){
double lscale=units.getLength()/MDUnits.getLength();
double escale=units.getEnergy()/MDUnits.getEnergy();
// scalep and scaleb are used to convert MD to plumed
scalep=1.0/lscale;
scaleb=1.0/lscale;
// scalef and scalev are used to convert plumed to MD
scalef=escale/lscale;
scalev=escale;
}
示例7: in
BD_convert::BD_convert (const Units& units, const symbol has, const symbol want,
const symbol bulk_unit)
: in (units.get_convertion (has, bulk_unit)),
out (units.get_convertion (Units::dry_soil_fraction (), want)),
bulk (-42.42e42)
{
#if 0
std::ostringstream tmp;
tmp << "has = " << has << ", bulk_unit = " << bulk_unit
<< ", dsf = " << Units::dry_soil_fraction () << ", want = " << want;
Assertion::message (tmp.str ());
#endif
}
示例8: is_2D_pointer_2D_to_2D_type
bool
is_2D_pointer_2D_to_2D_type(MContext *mc, DNode *t, DNode *pointee)
{
Units *units = (dale::Units*) mc->units;
Node *n = units->top()->dnc->toNode(t);
n = units->top()->mp->parsePotentialMacroCall(n);
if (!n) {
return false;
}
Node *n2 = units->top()->dnc->toNode(pointee);
n2 = units->top()->mp->parsePotentialMacroCall(n2);
if (!n2) {
return false;
}
int error_count_begin =
units->top()->ctx->er->getErrorTypeCount(ErrorType::Error);
Type *type = FormTypeParse(units, n, false, false);
Type *type2 = FormTypeParse(units, n2, false, false);
units->top()->ctx->er->popErrors(error_count_begin);
if (!type || !type2) {
return false;
}
return (type->points_to->isEqualTo(type2));
}
示例9: types_2D_equal
bool
types_2D_equal(MContext *mc, DNode *t1, DNode *t2)
{
Units *units = (dale::Units*) mc->units;
Node *n = units->top()->dnc->toNode(t1);
n = units->top()->mp->parsePotentialMacroCall(n);
if (!n) {
return false;
}
Node *n2 = units->top()->dnc->toNode(t2);
n2 = units->top()->mp->parsePotentialMacroCall(n2);
if (!n2) {
return false;
}
int error_count_begin =
units->top()->ctx->er->getErrorTypeCount(ErrorType::Error);
Type *type1 = FormTypeParse(units, n, false, false);
Type *type2 = FormTypeParse(units, n2, false, false);
units->top()->ctx->er->popErrors(error_count_begin);
if (!type1 || !type2) {
return 0;
}
return (type1->isEqualTo(type2));
}
示例10: write
void SED::write(const QString& filename) const
{
WavelengthGrid* lambdagrid = find<WavelengthGrid>();
Units* units = find<Units>();
ofstream file(filename.toLocal8Bit().constData());
file << setprecision(8) << scientific;
for (int ell=0; ell<lambdagrid->Nlambda(); ell++)
{
double lambda = lambdagrid->lambda(ell);
double dlambda = lambdagrid->dlambda(ell);
file << units->owavelength(lambda)
<< '\t'
<< _Lv[ell]/dlambda*lambda
<< endl;
}
file.close();
}
示例11: return
// class methods
double Units::convertValue(double value, const Units& fromUnits, const Units& toUnits) {
if (fromUnits.isSameDimensionAs(toUnits)) {
return (value * fromUnits._conversion / toUnits._conversion);
}
else {
cerr << "Units are not dimensionally consistent" << endl;
return 0.;
}
}
示例12: Action
ContourFindingBase::ContourFindingBase(const ActionOptions&ao):
Action(ao),
ActionWithInputGrid(ao),
mymin(this),
mydata(NULL)
{
if( ingrid->noDerivatives() ) error("cannot find contours if input grid has no derivatives");
parse("CONTOUR",contour);
log.printf(" calculating dividing surface along which function equals %f \n", contour);
if( keywords.exists("FILE") ){
std::string file; parse("FILE",file);
if(file.length()==0 && keywords.style("FILE","compulsory") ) error("name out output file was not specified");
else if( file.length()>0 ){
std::string type=Tools::extension(file);
log<<" file name "<<file<<"\n";
if(type!="xyz") error("can only print xyz file type with contour finding");
fmt_xyz="%f";
std::string precision; parse("PRECISION",precision);
if(precision.length()>0){
int p; Tools::convert(precision,p);
log<<" with precision "<<p<<"\n";
std::string a,b;
Tools::convert(p+5,a);
Tools::convert(p,b);
fmt_xyz="%"+a+"."+b+"f";
}
std::string unitname; parse("UNITS",unitname);
if(unitname!="PLUMED"){
Units myunit; myunit.setLength(unitname);
lenunit=plumed.getAtoms().getUnits().getLength()/myunit.getLength();
}
else lenunit=1.0;
of.link(*this); of.open(file);
// Now create a store data vessel to hold the points
mydata=buildDataStashes( NULL );
}
}
}
示例13: QString
QString FrameCd::sizeDescription( const Units& units ) const
{
if ( units.toEnum() == Units::IN )
{
QString dStr = StrUtil::formatFraction( 2 * mR1.in() );
return QString().sprintf( "%s %s %s",
qPrintable(dStr),
qPrintable(units.toTrName()),
qPrintable(tr("diameter")) );
}
else
{
return QString().sprintf( "%.5g %s %s",
2 * mR1.inUnits(units),
qPrintable(units.toTrName()),
qPrintable(tr("diameter")) );
}
}
示例14:
bool
VCheck::Compatible::valid (const Units& units, symbol value, Treelog& msg) const
{
if (units.can_convert (dimension, value))
return true;
std::ostringstream tmp;
tmp << "Cannot convert [" << dimension << "] to [" << value << "]";
msg.error (tmp.str ());
return false;
}
示例15: calibrateAndWriteDataFrames
void InstrumentFrame::calibrateAndWriteDataFrames(int ell, QList<Array*> farrays, QStringList fnames)
{
Units* units = find<Units>();
WavelengthGrid* lambdagrid = find<WavelengthGrid>();
// conversion from bolometric luminosities (units W) to monochromatic luminosities (units W/m)
// --> divide by delta-lambda
double dlambda = lambdagrid->dlambda(ell);
// correction for the area of the pixels of the images; the units are now W/m/sr
// --> divide by area
double xpresang = 2.0*atan(_xpres/(2.0*_distance));
double ypresang = 2.0*atan(_ypres/(2.0*_distance));
double area = xpresang*ypresang;
// calibration step 3: conversion of the flux per pixel from monochromatic luminosity units (W/m/sr)
// to flux density units (W/m3/sr) by taking into account the distance
// --> divide by fourpid2
double fourpid2 = 4.0*M_PI*_distance*_distance;
// conversion from program SI units (at this moment W/m3/sr) to the correct output units
// --> multiply by unit conversion factor
double unitfactor = units->osurfacebrightness(lambdagrid->lambda(ell), 1.);
// Perform the conversion, in place
foreach (Array* farr, farrays)
{
(*farr) *= (unitfactor / (dlambda * area * fourpid2));
}
// Write a FITS file for each array
for (int q = 0; q < farrays.size(); q++)
{
QString filename = _instrument->instrumentName() + "_" + fnames[q] + "_" + QString::number(ell);
QString description = fnames[q] + " flux " + QString::number(ell);
// Create the image and save it
Image image(this, _Nxp, _Nyp, 1, _xpres, _ypres, "surfacebrightness");
image.saveto(this, *(farrays[q]), filename, description);
}
}