本文整理汇总了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();
}
}