本文整理汇总了C++中openstudio::convertToStandardForm方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::convertToStandardForm方法的具体用法?C++ openstudio::convertToStandardForm怎么用?C++ openstudio::convertToStandardForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio
的用法示例。
在下文中一共展示了openstudio::convertToStandardForm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resourcesPath
TEST(Table, UnitConversion) {
openstudio::path p = resourcesPath()/toPath("utilities/Table/HeightWeight.csv");
Table table = Table::load(p);
table.setTitle("Height and Weight");
table.setNHead(1);
table.setNLeft(1);
EXPECT_FALSE(table.convertUnits(0));
EXPECT_FALSE(table.convertUnits(1));
// expanded test to help debug on gcc
ASSERT_TRUE(table.nRows() >= 2);
ASSERT_TRUE(table.nCols() >= 3);
EXPECT_EQ("lb_m",table.units(2));
std::stringstream ss;
ss << table[0][2];
std::string tmp = extractUnitString(ss.str());
EXPECT_EQ("lb_m",tmp);
tmp = convertToStandardForm(tmp);
EXPECT_EQ("lb_m",tmp);
EXPECT_TRUE(containsRegisteredBaseUnit(tmp));
ASSERT_TRUE(table[1][2].isInt());
double d = table[1][2].toDouble();
Quantity q = createQuantity(d,tmp).get();
EXPECT_TRUE(table.convertUnits(2));
std::string unitStr = table.units(2);
EXPECT_EQ("kg",unitStr);
p = resourcesPath()/toPath("utilities/Table/HeightWeightSI.csv");
boost::filesystem::ofstream outFile(p);
ASSERT_TRUE(outFile);
table.printToStream(outFile,TableFormat(TableFormat::CSV));
outFile.close();
p = resourcesPath()/toPath("utilities/Table/EUI.csv");
table = Table::load(p);
table.setTitle("EUIs");
table.setCaption("EUIs of several buildings");
table.setNHead(2);
table.setNLeft(2);
EXPECT_TRUE(table.convertUnits(2));
unitStr = table.units(2);
EXPECT_EQ("kJ/m^2",unitStr);
// now cols 2 and 3 should be equal except for kJ/m^2 v. MJ/m^2.
for (unsigned i = 0, n = table.nRows(); i < n; ++i) {
if (table.isRowIndex(i,Table::BODY)) {
double d2 = table[i][2].toDouble();
double d3 = table[i][3].toDouble();
EXPECT_NEAR((d2-(d3*1000.0))/(d2),0.0,1.0E-3);
}
}
p = resourcesPath()/toPath("utilities/Table/EUISI.csv");
outFile.open(p);
ASSERT_TRUE(outFile);
table.printToStream(outFile,TableFormat(TableFormat::CSV));
outFile.close();
}