MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / setup_vector_field

Function setup_vector_field

src/api/c/vector_field.cpp:46–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45template<typename T>
46fg_chart setup_vector_field(fg_window window, const vector<af_array>& points,
47 const vector<af_array>& directions,
48 const af_cell* const props,
49 const bool transpose_ = true) {
50 ForgeModule& _ = forgePlugin();
51 vector<Array<T>> pnts;
52 vector<Array<T>> dirs;
53
54 Array<T> pIn = getArray<T>(points[0]);
55 Array<T> dIn = getArray<T>(directions[0]);
56 if (points.size() > 1) {
57 for (unsigned i = 0; i < points.size(); ++i) {
58 pnts.push_back(getArray<T>(points[i]));
59 dirs.push_back(getArray<T>(directions[i]));
60 }
61
62 // Join for set up vector
63 const dim4 odims(pIn.dims()[0], points.size());
64 pIn = createEmptyArray<T>(odims);
65 dIn = createEmptyArray<T>(odims);
66 detail::join<T>(pIn, 1, pnts);
67 detail::join<T>(dIn, 1, dirs);
68 }
69 // do transpose if required
70 if (transpose_) {
71 pIn = transpose<T>(pIn, false);
72 dIn = transpose<T>(dIn, false);
73 }
74
75 ForgeManager& fgMngr = forgeManager();
76
77 // Get the chart for the current grid position (if any)
78 fg_chart chart = NULL;
79
80 if (pIn.dims()[0] == 2) {
81 if (props->col > -1 && props->row > -1) {
82 chart =
83 fgMngr.getChart(window, props->row, props->col, FG_CHART_2D);
84 } else {
85 chart = fgMngr.getChart(window, 0, 0, FG_CHART_2D);
86 }
87 } else {
88 if (props->col > -1 && props->row > -1) {
89 chart =
90 fgMngr.getChart(window, props->row, props->col, FG_CHART_3D);
91 } else {
92 chart = fgMngr.getChart(window, 0, 0, FG_CHART_3D);
93 }
94 }
95
96 fg_vector_field vfield =
97 fgMngr.getVectorField(chart, pIn.dims()[1], getGLType<T>());
98
99 // ArrayFire LOGO dark blue shade
100 FG_CHECK(_.fg_set_vector_field_color(vfield, 0.130f, 0.173f, 0.263f, 1.0));
101
102 // If chart axes limits do not have a manual override
103 // then compute and set axes limits

Callers

nothing calls this directly

Calls 6

step_roundFunction · 0.85
getChartMethod · 0.80
getVectorFieldMethod · 0.80
getChartAxesOverrideMethod · 0.80
copyDataFunction · 0.70
dimsMethod · 0.45

Tested by

no test coverage detected