| 45 | |
| 46 | template<typename T> |
| 47 | fg_chart setup_surface(fg_window window, const af_array xVals, |
| 48 | const af_array yVals, const af_array zVals, |
| 49 | const af_cell* const props) { |
| 50 | ForgeModule& _ = forgePlugin(); |
| 51 | Array<T> xIn = getArray<T>(xVals); |
| 52 | Array<T> yIn = getArray<T>(yVals); |
| 53 | Array<T> zIn = getArray<T>(zVals); |
| 54 | |
| 55 | const ArrayInfo& Xinfo = getInfo(xVals); |
| 56 | const ArrayInfo& Yinfo = getInfo(yVals); |
| 57 | const ArrayInfo& Zinfo = getInfo(zVals); |
| 58 | |
| 59 | dim4 X_dims = Xinfo.dims(); |
| 60 | dim4 Y_dims = Yinfo.dims(); |
| 61 | dim4 Z_dims = Zinfo.dims(); |
| 62 | |
| 63 | if (Xinfo.isVector()) { |
| 64 | // Convert xIn is a column vector |
| 65 | xIn = modDims(xIn, xIn.elements()); |
| 66 | // Now tile along second dimension |
| 67 | dim4 x_tdims(1, Y_dims[0], 1, 1); |
| 68 | xIn = arrayfire::common::tile(xIn, x_tdims); |
| 69 | |
| 70 | // Convert yIn to a row vector |
| 71 | yIn = modDims(yIn, dim4(1, yIn.elements())); |
| 72 | // Now tile along first dimension |
| 73 | dim4 y_tdims(X_dims[0], 1, 1, 1); |
| 74 | yIn = arrayfire::common::tile(yIn, y_tdims); |
| 75 | } |
| 76 | |
| 77 | // Flatten xIn, yIn and zIn into row vectors |
| 78 | dim4 rowDims = dim4(1, zIn.elements()); |
| 79 | xIn = modDims(xIn, rowDims); |
| 80 | yIn = modDims(yIn, rowDims); |
| 81 | zIn = modDims(zIn, rowDims); |
| 82 | |
| 83 | // Now join along first dimension, skip reorder |
| 84 | std::vector<Array<T>> inputs{xIn, yIn, zIn}; |
| 85 | |
| 86 | dim4 odims(3, rowDims[1]); |
| 87 | Array<T> out = createEmptyArray<T>(odims); |
| 88 | join(out, 0, inputs); |
| 89 | Array<T> Z = out; |
| 90 | |
| 91 | ForgeManager& fgMngr = forgeManager(); |
| 92 | |
| 93 | // Get the chart for the current grid position (if any) |
| 94 | fg_chart chart = NULL; |
| 95 | if (props->col > -1 && props->row > -1) { |
| 96 | chart = fgMngr.getChart(window, props->row, props->col, FG_CHART_3D); |
| 97 | } else { |
| 98 | chart = fgMngr.getChart(window, 0, 0, FG_CHART_3D); |
| 99 | } |
| 100 | |
| 101 | fg_surface surface = |
| 102 | fgMngr.getSurface(chart, Z_dims[0], Z_dims[1], getGLType<T>()); |
| 103 | |
| 104 | FG_CHECK(_.fg_set_surface_color(surface, 0.0, 1.0, 0.0, 1.0)); |
nothing calls this directly
no test coverage detected