1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * Copyright (c) 2004-2013 HUBzero Foundation, LLC |
---|
4 | * |
---|
5 | * Authors: |
---|
6 | * Wei Qiao <qiaow@purdue.edu> |
---|
7 | * Insoo Woo <iwoo@purdue.edu> |
---|
8 | * George A. Howlett <gah@purdue.edu> |
---|
9 | * Leif Delgass <ldelgass@purdue.edu> |
---|
10 | */ |
---|
11 | #ifndef NV_FLOWPARTICLES_H |
---|
12 | #define NV_FLOWPARTICLES_H |
---|
13 | |
---|
14 | #include <cassert> |
---|
15 | #include <string> |
---|
16 | |
---|
17 | #include <tcl.h> |
---|
18 | |
---|
19 | #include <vrmath/Vector3f.h> |
---|
20 | |
---|
21 | #include "FlowTypes.h" |
---|
22 | #include "Switch.h" |
---|
23 | #include "ParticleRenderer.h" |
---|
24 | #include "Volume.h" |
---|
25 | |
---|
26 | namespace nv { |
---|
27 | |
---|
28 | struct FlowParticlesValues { |
---|
29 | FlowPosition position; ///< Position on axis of particle plane |
---|
30 | FlowColor color; ///< Color of particles |
---|
31 | int isHidden; ///< Is particle injection plane active |
---|
32 | float particleSize; ///< Size of the particles |
---|
33 | }; |
---|
34 | |
---|
35 | class FlowParticles |
---|
36 | { |
---|
37 | public: |
---|
38 | FlowParticles(const char *name); |
---|
39 | |
---|
40 | ~FlowParticles(); |
---|
41 | |
---|
42 | const char *name() const |
---|
43 | { |
---|
44 | return _name.c_str(); |
---|
45 | } |
---|
46 | |
---|
47 | bool visible() const |
---|
48 | { |
---|
49 | return !_sv.isHidden; |
---|
50 | } |
---|
51 | |
---|
52 | int parseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) |
---|
53 | { |
---|
54 | if (nv::ParseSwitches(interp, _switches, objc, objv, &_sv, |
---|
55 | SWITCH_DEFAULTS) < 0) { |
---|
56 | return TCL_ERROR; |
---|
57 | } |
---|
58 | return TCL_OK; |
---|
59 | } |
---|
60 | |
---|
61 | void advect() |
---|
62 | { |
---|
63 | assert(_renderer->active()); |
---|
64 | _renderer->advect(); |
---|
65 | } |
---|
66 | |
---|
67 | void render(); |
---|
68 | |
---|
69 | void reset() |
---|
70 | { |
---|
71 | _renderer->reset(); |
---|
72 | } |
---|
73 | |
---|
74 | void initialize() |
---|
75 | { |
---|
76 | _renderer->initialize(); |
---|
77 | } |
---|
78 | |
---|
79 | void setVectorField(Volume *volume) |
---|
80 | { |
---|
81 | _volume = volume; |
---|
82 | _renderer->setVectorField(volume); |
---|
83 | } |
---|
84 | |
---|
85 | float getRelativePosition(FlowPosition *position); |
---|
86 | |
---|
87 | bool configure(); |
---|
88 | |
---|
89 | private: |
---|
90 | /** |
---|
91 | * Name of particle injection plane. Actual character string is |
---|
92 | * stored in hash table. |
---|
93 | */ |
---|
94 | std::string _name; |
---|
95 | nv::ParticleRenderer *_renderer; ///< Particle renderer |
---|
96 | Volume *_volume; |
---|
97 | FlowParticlesValues _sv; |
---|
98 | |
---|
99 | static SwitchSpec _switches[]; |
---|
100 | }; |
---|
101 | |
---|
102 | } |
---|
103 | |
---|
104 | #endif |
---|