| 42 | } |
| 43 | |
| 44 | static LN_NurbsSurface_C ToCAPI(const LN_NurbsSurface& s) { |
| 45 | g_knot_u_buffer = s.KnotVectorU; |
| 46 | g_knot_v_buffer = s.KnotVectorV; |
| 47 | g_cp_2d_buffer = s.ControlPoints; |
| 48 | int rows = static_cast<int>(g_cp_2d_buffer.size()); |
| 49 | int cols = rows > 0 ? static_cast<int>(g_cp_2d_buffer[0].size()) : 0; |
| 50 | g_cp_flat_buffer.clear(); |
| 51 | g_cp_flat_buffer.reserve(rows * cols); |
| 52 | for (int i = 0; i < rows; ++i) { |
| 53 | for (int j = 0; j < cols; ++j) { |
| 54 | g_cp_flat_buffer.push_back(g_cp_2d_buffer[i][j]); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | LN_NurbsSurface_C c; |
| 59 | c.degree_u = s.DegreeU; |
| 60 | c.degree_v = s.DegreeV; |
| 61 | c.knot_vector_u = g_knot_u_buffer.data(); |
| 62 | c.knot_vector_count_u = static_cast<int>(g_knot_u_buffer.size()); |
| 63 | c.knot_vector_v = g_knot_v_buffer.data(); |
| 64 | c.knot_vector_count_v = static_cast<int>(g_knot_v_buffer.size()); |
| 65 | c.control_points = reinterpret_cast<const XYZW_C*>(g_cp_flat_buffer.data()); |
| 66 | c.cp_rows = rows; |
| 67 | c.cp_cols = cols; |
| 68 | return c; |
| 69 | } |
| 70 | |
| 71 | XYZ_C LNLIB_NURBSSUR_get_point_on_surface(LN_NurbsSurface_C surface, UV_C uv) { |
| 72 | return FromXYZ(NurbsSurface::GetPointOnSurface(FromCAPI(surface), ToUV(uv))); |
no outgoing calls
no test coverage detected