source: trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp @ 3596

Last change on this file since 3596 was 3502, checked in by ldelgass, 12 years ago

Add basic VTK structured points reader to nanovis, update copyright dates.

  • Property svn:eol-style set to native
File size: 7.9 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 * NvFlowVisRenderer.cpp: particle system class
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16
17#include <vrmath/Vector3f.h>
18
19#include "NvFlowVisRenderer.h"
20
21using namespace vrmath;
22
23#define NV_32
24
25NvFlowVisRenderer::NvFlowVisRenderer(int w, int h) :
26    _activated(true)
27{
28    _psys_width = w;
29    _psys_height = h;
30}
31
32NvFlowVisRenderer::~NvFlowVisRenderer()
33{
34    std::map<std::string, NvVectorField *>::iterator iter;
35    for (iter = _vectorFieldMap.begin(); iter != _vectorFieldMap.end(); ++iter) {
36        delete (*iter).second;
37    }
38}
39
40void
41NvFlowVisRenderer::initialize()
42{
43    std::map<std::string, NvVectorField *>::iterator iter;
44    for (iter = _vectorFieldMap.begin(); iter != _vectorFieldMap.end(); ++iter) {
45        (*iter).second->initialize();
46    }
47}
48
49void
50NvFlowVisRenderer::reset()
51{
52    std::map<std::string, NvVectorField *>::iterator iter;
53    for (iter = _vectorFieldMap.begin(); iter != _vectorFieldMap.end(); ++iter) {
54        (*iter).second->reset();
55    }
56}
57
58void
59NvFlowVisRenderer::initialize(const std::string& vfName)
60{
61    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
62    if (iter != _vectorFieldMap.end()) {
63        if ((*iter).second) {
64            (*iter).second->initialize();
65        }
66    }
67}
68
69void
70NvFlowVisRenderer::advect()
71{
72    std::map<std::string, NvVectorField *>::iterator iter;
73    for (iter = _vectorFieldMap.begin(); iter != _vectorFieldMap.end(); ++iter) {
74        if ((*iter).second && (*iter).second->active())
75            (*iter).second->advect();
76    }
77}
78
79void
80NvFlowVisRenderer::render()
81{
82    std::map<std::string, NvVectorField *>::iterator iter;
83    for (iter = _vectorFieldMap.begin(); iter != _vectorFieldMap.end(); ++iter) {
84        if ((*iter).second && (*iter).second->active())
85            (*iter).second->render();
86    }
87}
88
89void
90NvFlowVisRenderer::addVectorField(const std::string& vfName, Volume* volPtr,
91                                  const Vector3f& ori,
92                                  float scaleX, float scaleY, float scaleZ, float max)
93{
94    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
95    if (iter != _vectorFieldMap.end()) {
96        if ((*iter).second) {
97            ((*iter).second)->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max);
98        } else {
99            NvVectorField *vf = new NvVectorField();
100            _vectorFieldMap[vfName] = vf;
101            vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max);
102        }
103    } else {
104        NvVectorField *vf = new NvVectorField();
105        _vectorFieldMap[vfName] = vf;
106        vf->setVectorField(volPtr, ori, scaleX, scaleY, scaleZ, max);
107    }
108}
109
110void
111NvFlowVisRenderer::activateVectorField(const std::string& vfName)
112{
113    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
114    if (iter != _vectorFieldMap.end()) {
115        if ((*iter).second)
116            (*iter).second->active(true);
117    }
118}
119
120void
121NvFlowVisRenderer::deactivateVectorField(const std::string& vfName)
122{
123    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
124    if (iter != _vectorFieldMap.end()) {
125        if ((*iter).second)
126            (*iter).second->active(false);
127    }
128}
129
130void
131NvFlowVisRenderer::activatePlane(const std::string& vfName, const std::string& name)
132{
133    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
134    if (iter != _vectorFieldMap.end()) {
135        if ((*iter).second)
136            (*iter).second->activatePlane(name);
137    }
138}
139
140void
141NvFlowVisRenderer::deactivatePlane(const std::string& vfName, const std::string& name)
142{
143    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
144    if (iter != _vectorFieldMap.end()) {
145        if ((*iter).second)
146            (*iter).second->deactivatePlane(name);
147    }
148}
149
150void
151NvFlowVisRenderer::setPlaneAxis(const std::string& vfName, const std::string& planeName, int axis)
152{
153    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
154    if (iter != _vectorFieldMap.end()) {
155        if ((*iter).second)
156            (*iter).second->setPlaneAxis(planeName, axis);
157    }
158}
159
160void
161NvFlowVisRenderer::setPlanePos(const std::string& vfName, const std::string& name, float pos)
162{
163    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
164    if (iter != _vectorFieldMap.end()) {
165        if ((*iter).second)
166            (*iter).second->setPlanePos(name, pos);
167    }
168}
169
170void
171NvFlowVisRenderer::setParticleColor(const std::string& vfName, const std::string& name, const Vector4& color)
172{
173    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
174    if (iter != _vectorFieldMap.end()) {
175        if ((*iter).second)
176            (*iter).second->setParticleColor(name, color);
177    }
178}
179
180void
181NvFlowVisRenderer::removeVectorField(const std::string& vfName)
182{
183    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
184    if (iter != _vectorFieldMap.end()) {
185        delete (*iter).second;
186        _vectorFieldMap.erase(iter);
187    }
188}
189
190void
191NvFlowVisRenderer::addPlane(const std::string& vfName, const std::string& name)
192{
193    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
194    if (iter != _vectorFieldMap.end()) {
195        if ((*iter).second)
196            (*iter).second->addPlane(name);
197    }
198}
199
200void
201NvFlowVisRenderer::removePlane(const std::string& vfName, const std::string& name)
202{
203    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
204    if (iter != _vectorFieldMap.end()) {
205        if ((*iter).second)
206            (*iter).second->removePlane(name);
207    }
208}
209
210void
211NvFlowVisRenderer::activateDeviceShape(const std::string& vfName, const std::string& name)
212{
213    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
214    if (iter != _vectorFieldMap.end()) {
215        if ((*iter).second)
216            (*iter).second->activateDeviceShape(name);
217    }
218}
219
220void
221NvFlowVisRenderer::deactivateDeviceShape(const std::string& vfName, const std::string& name)
222{
223    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
224    if (iter != _vectorFieldMap.end()) {
225        if ((*iter).second)
226            (*iter).second->deactivateDeviceShape(name);
227    }
228}
229
230void
231NvFlowVisRenderer::activateDeviceShape(const std::string& vfName)
232{
233    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
234    if (iter != _vectorFieldMap.end()) {
235        if ((*iter).second)
236            (*iter).second->activateDeviceShape();
237    }
238}
239
240void
241NvFlowVisRenderer::deactivateDeviceShape(const std::string& vfName)
242{
243    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
244    if (iter != _vectorFieldMap.end()) {
245        if ((*iter).second)
246            (*iter).second->deactivateDeviceShape();
247    }
248}
249
250void
251NvFlowVisRenderer::addDeviceShape(const std::string& vfName, const std::string& name, const NvDeviceShape& shape)
252{
253    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
254    if (iter != _vectorFieldMap.end()) {
255        if ((*iter).second)
256            (*iter).second->addDeviceShape(name, shape);
257    }
258}
259
260void
261NvFlowVisRenderer::removeDeviceShape(const std::string& vfName, const std::string& name)
262{
263    std::map<std::string, NvVectorField *>::iterator iter = _vectorFieldMap.find(vfName);
264    if (iter != _vectorFieldMap.end()) {
265        if ((*iter).second)
266            (*iter).second->removeDeviceShape(name);
267    }
268}
Note: See TracBrowser for help on using the repository browser.