Free Electron
SplatLineSystem.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __moa_SplatLineSystem_h__
8 #define __moa_SplatLineSystem_h__
9 
10 #include <complex>
11 
12 namespace fe
13 {
14 namespace ext
15 {
16 
17 /* WHY ----------------------------------------------------------------------
18 
19 why image
20  * human sensory
21  * RT screen
22  * image tool ecosystem use
23  * ML
24  * fixed data size size != fn(t)
25  * lookup / cache / etc
26  * common currency ?
27 
28 -------------------------------------------------------------------------- */
29 
30 /* WHAT ---------------------------------------------------------------------
31 
32 -------------------------------------------------------------------------- */
33 
34 /* HOW ----------------------------------------------------------------------
35 
36 
37  * Add a SplatterI System to the Orchestrator
38 
39 Splatters (VIEW)
40  "SystemI.NyquistLineSystem.fe"
41  "SystemI.SplatLineSystem.fe"
42 
43 Test System
44  "SystemI.MultiSweep.fe"
45  "SystemI.FrequencyResponse.fe"
46 OR
47  sending signals
48 
49 overlays
50 
51 
52 
53 Continuous State HUD Use Case
54 -----------------------------
55 
56 Can also instrument continuous running -- HUD example
57 
58 Physics Acceleration Use Case
59 -----------------------------
60 
61 This is splatting direct -- not even as a System, but direct via solve splat
62 This is why core splat is located in solve (at the moment)
63 
64 
65 The Test Suite Case
66 -------------------
67 
68 This use case involves two separate concepts:
69  * capturing data and presenting clear results
70  * generating data as useful test cases
71 
72 
73 
74 VIEWING/SPLATTING
75 
76 Given
77  * An Orchestrator configured to run a MOA simulation
78  * An available SplatterI System to view results
79 
80 Summary
81  * Add a splatter to the Orchestrator
82  * Add splat configuration to dataset
83 
84 
85 spOrchestrator->append(spRegistry->create("SystemI.SplatLineSystem.fe"));
86 
87 Multiple splat specifications can apply to the same image
88 
89 splat:x_range -- minimum and maximum value of X
90 splat:y_range -- minimum and maximum value of Y
91 splat:expression -- eval script run every data point
92 splat:splat -- name of splat image to splat to
93 splat:color -- color of data applied
94 
95 Cover using color via splat:expression
96 
97 RECORD * alpha_splat
98  name "αFy"
99  splat:splat "αFyFzMz"
100  splat:x_range "-30.0 30.0"
101  splat:y_range "-7000.0 7000.0"
102  splat:expression " (X (get 'base_rig.rig:alpha') )
103  (Y (get 'base_rig.mnt:0.tire:force[1]') )"
104  splat:color "1 0 0.6"
105 
106 
107 
108 
109 
110 
111 
112 RUNNING TESTS
113 
114 spOrchestrator->append(spRegistry->create("SystemI.MultiSweep.fe"));
115 
116 RECORD * multisweep
117  name "alphakappa"
118  composer:inner "-20.0 20.0 1.0"
119  composer:outer "-20.0 20.0 10.0"
120  composer:step " (set 'base_rig.rig:kappa' INNER)
121  (set 'base_rig.rig:alpha' OUTER) "
122 
123 
124 -------------------------------------------------------------------------- */
125 
126 /// @brief A System to capture data via splatting
127 class FE_DL_EXPORT SplatterSystem :
128  virtual public SystemI,
129  virtual public SplatterI,
130  public Initialize<SplatterSystem>
131 {
132  public:
133  SplatterSystem(void);
134 virtual ~SplatterSystem(void);
135  void initialize(void);
136 
137 virtual void compile(const t_note_id &a_note_id);
138 
139 virtual bool match(const Record &r_splat) = 0;
140 
141 virtual void image(void);
142 
143 virtual void connectOrchestrator(sp<OrchestratorI> a_spOrchestrator);
144 
145  class Annotation
146  {
147  public:
148  Annotation(t_moa_real a_x, t_moa_real a_y,
149  const String &a_text) :
150  m_x(a_x), m_y(a_y), m_text(a_text) {}
151  t_moa_real m_x;
152  t_moa_real m_y;
153  String m_text;
154  };
155 
156  class Context : public Counted
157  {
158  public:
159  Context(void);
160  SplatterSystem *m_parent;
161  sp<Evaluator> m_spMyEval;
162  WeakRecord r_x;
163  WeakRecord r_y;
164  WeakRecord r_r;
165  WeakRecord r_g;
166  WeakRecord r_b;
167  WeakRecord r_splat;
168  bool m_line_started;
169  t_image_splat::t_span m_loc;
170  void setReal(const String &a_name, t_moa_real a_value);
171  void dot(t_moa_real a_x, t_moa_real a_y);
172  void mark(t_moa_real a_x, t_moa_real a_y);
173  void line(t_moa_real a_x, t_moa_real a_y);
174  void annotate(t_moa_real a_x, t_moa_real a_y,
175  const String &a_text);
176  void annotate(t_moa_real a_x, t_moa_real a_y,
177  t_moa_real a_value);
178 
179  void newline(void);
180  t_moa_v3 m_y_max;
181  std::vector<t_moa_real> m_x_run;
182  std::vector<t_moa_real> m_y_run;
183  t_moa_real m_x_n;
184  t_moa_real m_y_n;
185  t_moa_v3 m_color;
186  sp<t_image_splat> m_splat;
187  std::vector< Annotation > m_annotations;
188  String m_splatname;
189  String m_splatlabel;
190  };
191 
192  void updateContext(sp<Context> a_context);
193 
194 
195  protected:
196  class SplatTarget
197  {
198  public:
199  sp<t_image_splat> m_splat;
200  std::vector< sp<Context> > m_contexts;
201  };
202  sp<RecordGroup> rg_dataset;
203  sp<Scope> m_spScope;
204  AsSplat m_asSplat;
205  typedef std::map< String, SplatTarget > t_splatmap;
206  t_splatmap m_splatMap;
207  AsDatasetMeta m_asDatasetMeta;
208  std::vector< sp<Context> > m_contexts;
209  t_note_id m_note_image;
210  t_note_id m_note_datapoint;
211  t_note_id m_note_run_stop;
212  t_note_id m_note_line_start;
213  t_note_id m_note_line_stop;
214  t_note_id m_note_loop_start;
215  t_note_id m_note_loop_stop;
216  t_note_id m_note_dt_change;
217 };
218 
219 class FE_DL_EXPORT SplatLineSystem :
220  virtual public SplatterSystem,
221  public Initialize<SplatLineSystem>
222 {
223  public:
224  SplatLineSystem(void);
225 virtual ~SplatLineSystem(void);
226  void initialize(void) {}
227 
228 virtual void perform(const t_note_id &a_note_id);
229 virtual bool match(const Record &r_splat);
230 
231 };
232 
233 class FE_DL_EXPORT NyquistLineSystem :
234  virtual public SplatterSystem,
235  public Initialize<NyquistLineSystem>
236 {
237  public:
238  NyquistLineSystem(void);
239 virtual ~NyquistLineSystem(void);
240  void initialize(void);
241 
242 virtual void perform(const t_note_id &a_note_id);
243 virtual void compile(const t_note_id &a_note_id);
244 virtual bool match(const Record &r_splat);
245 
246  class NyquistContext
247  {
248  public:
249  t_moa_real m_start_time;
250  };
251 
252  private:
253  Record a_r_time;
254  AsTime m_asTime;
255  std::vector<NyquistContext> m_nyquistContexts;
256  AsNyquistLine m_asNyquistLine;
257 };
258 
259 class Imager : virtual public t_image_splat::Functor
260 {
261  public:
262  Imager(FILE *a_fp)
263  {
264  m_fp = a_fp;
265  }
266  virtual ~Imager(void)
267  {
268  }
269  virtual void process(t_image_splat &a_splat,
270  typename t_image_splat::t_index &a_index)
271  {
272  typename t_image_splat::t_span loc;
273  t_moa_v3 color = a_splat.direct(a_index);
274  a_splat.location(loc, a_index);
275  int R = (int)(color[0]*255.0);
276  int G = (int)(color[1]*255.0);
277  int B = (int)(color[2]*255.0);
278  fputc(R, m_fp);
279  fputc(G, m_fp);
280  fputc(B, m_fp);
281  }
282  FILE *m_fp;
283 };
284 
285 } /* namespace ext */
286 } /* namespace fe */
287 
288 #endif /* __moa_SplatLineSystem_h__ */
289 
Interface to attach a 2D splat.
Definition: SplatterI.h:16
N dimensional state buffer.
Definition: Splat.h:28
Heap-based support for classes participating in fe::ptr <>
Definition: Counted.h:35
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
A System to capture data via splatting.
Definition: SplatLineSystem.h:127
Clock.
Definition: moaAS.h:104
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Splat Configuration.
Definition: moaAS.h:169
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
System Interface for MOA.
Definition: SystemI.h:18
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17