当前位置: 首页>>代码示例>>C++>>正文


C++ openstudio::containsRegisteredBaseUnit方法代码示例

本文整理汇总了C++中openstudio::containsRegisteredBaseUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ openstudio::containsRegisteredBaseUnit方法的具体用法?C++ openstudio::containsRegisteredBaseUnit怎么用?C++ openstudio::containsRegisteredBaseUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openstudio的用法示例。


在下文中一共展示了openstudio::containsRegisteredBaseUnit方法的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();

}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:59,代码来源:Table_GTest.cpp


注:本文中的openstudio::containsRegisteredBaseUnit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。