[3567] | 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 | */ |
---|
[3613] | 11 | #ifndef NV_FLOWPARTICLES_H |
---|
| 12 | #define NV_FLOWPARTICLES_H |
---|
[3567] | 13 | |
---|
[3597] | 14 | #include <cassert> |
---|
[3567] | 15 | #include <string> |
---|
| 16 | |
---|
| 17 | #include <tcl.h> |
---|
| 18 | |
---|
| 19 | #include <vrmath/Vector3f.h> |
---|
| 20 | |
---|
| 21 | #include "FlowTypes.h" |
---|
| 22 | #include "Switch.h" |
---|
[3611] | 23 | #include "ParticleRenderer.h" |
---|
[3567] | 24 | #include "Volume.h" |
---|
| 25 | |
---|
[3611] | 26 | namespace nv { |
---|
| 27 | |
---|
[3567] | 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 | |
---|
[3568] | 47 | bool visible() const |
---|
[3567] | 48 | { |
---|
| 49 | return !_sv.isHidden; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | int parseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) |
---|
| 53 | { |
---|
| 54 | if (Rappture::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 | |
---|
[3630] | 79 | void setVectorField(Volume *volume) |
---|
[3567] | 80 | { |
---|
[3630] | 81 | _volume = volume; |
---|
| 82 | _renderer->setVectorField(volume); |
---|
[3567] | 83 | } |
---|
| 84 | |
---|
[3630] | 85 | float getRelativePosition(FlowPosition *position); |
---|
[3567] | 86 | |
---|
[3630] | 87 | bool configure(); |
---|
| 88 | |
---|
[3567] | 89 | private: |
---|
| 90 | /** |
---|
| 91 | * Name of particle injection plane. Actual character string is |
---|
| 92 | * stored in hash table. |
---|
| 93 | */ |
---|
| 94 | std::string _name; |
---|
[3611] | 95 | nv::ParticleRenderer *_renderer; ///< Particle renderer |
---|
[3630] | 96 | Volume *_volume; |
---|
[3567] | 97 | FlowParticlesValues _sv; |
---|
| 98 | |
---|
| 99 | static Rappture::SwitchSpec _switches[]; |
---|
| 100 | }; |
---|
| 101 | |
---|
[3611] | 102 | } |
---|
| 103 | |
---|
[3567] | 104 | #endif |
---|