| 404 | } |
| 405 | |
| 406 | v8::Local<v8::Object> Edge::polygonize(double factor) |
| 407 | { |
| 408 | |
| 409 | const TopoDS_Edge& edge = TopoDS::Edge(this->shape()); |
| 410 | |
| 411 | if (factor == 0.0) { |
| 412 | extractEdgePolygon(edge, m_positions); |
| 413 | int length = (int)m_positions.size(); |
| 414 | return makeFloat32Array(m_positions.data(), length); |
| 415 | } |
| 416 | |
| 417 | BRepAdaptor_Curve curve_adaptor(edge); |
| 418 | GCPnts_UniformDeflection discretizer; |
| 419 | discretizer.Initialize(curve_adaptor, 0.05); |
| 420 | |
| 421 | m_positions.clear(); |
| 422 | m_positions.reserve(discretizer.NbPoints() * 3); |
| 423 | for (int i = 0; i < discretizer.NbPoints(); i++) { |
| 424 | gp_Pnt pt = curve_adaptor.Value(discretizer.Parameter(i + 1)); |
| 425 | m_positions.push_back(static_cast<float>(pt.X())); |
| 426 | m_positions.push_back(static_cast<float>(pt.Y())); |
| 427 | m_positions.push_back(static_cast<float>(pt.Z())); |
| 428 | } |
| 429 | int length = (int)m_positions.size(); |
| 430 | return makeFloat32Array(m_positions.data(), length); |
| 431 | |
| 432 | } |
| 433 | |
| 434 | NAN_METHOD(Edge::getVertices) |
| 435 | { |
no test coverage detected