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


C++ Value::getNumber方法代码示例

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


在下文中一共展示了Value::getNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: contour

/***
 * Creates a list of all contours at the level given by "level".
 *
 * It starts by loading each facet and looking at each edge of the triangle
 * to determine whether the facet crosses "level".
 *
 * If so, it determines the line segment that is formed by the intersection
 * of z = level and the facet.
 *
 * It uses normal to determine the direction of the line segment (i.e. which
 * is x1,y1 and which is x2,y2).  When traveling from x1,y1 to x2,y2, the normal
 * vector must always lean to the right to ensure that the polygon progresses
 * counterclockwise direction.
 *
 * After all line segments have been recorder, they are sorted to form closed
 * polygons.args.
 *
 * Each time a polygon closes, it is recorded into the return string
 * and a new polygon is started.
 *
 * If any polygons fail to close (within tolerance), an error is generated.
 *
 * The returned data is of the form:
 *
 *  [
 *    [{X: x1, Y: y1}, . . ., {X: xn, Y: yn}],
 *    . . .
 *    [{X: x1, Y: y1}, . . ., {X: xn, Y: yn}]
 *  ]
 */
void STLModule::contour(const js::Value &args, js::Sink &sink) {
  // Read facets
  vector<STL::Facet> facets;
  readFacets(facets, *args.get("stl")->get("facets"));

  // Process one level
  if (args.get("level")->isNumber())
    contourLevel(sink, facets, args.getNumber("level"));

  // Process multiple levels
  if (args.get("start")->isNumber() && args.get("end")->isNumber() &&
      args.get("steps")->isNumber()) {
    float start = args.getNumber("start");
    float end = args.getNumber("end");
    int steps = args.getInteger("steps");

    if (start == end || steps <= 1) return;

    float delta = (end - start) / (steps - 1);

    sink.beginList();
    for (int i = 0; i < steps; i++) {
      float level = start + delta * i;

      sink.appendDict();
      sink.insert("Z", level);
      sink.beginInsert("contours");
      contourLevel(sink, facets, level);
      sink.endDict();
    }
    sink.endList();
  }
}
开发者ID:CauldronDevelopmentLLC,项目名称:CAMotics,代码行数:63,代码来源:STLModule.cpp


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