Changeset 2831 for trunk/packages/vizservers
- Timestamp:
- Mar 9, 2012, 10:12:14 AM (13 years ago)
- Location:
- trunk/packages/vizservers/nanovis
- Files:
-
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/CmdProc.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <string.h> 3 2 4 #include <tcl.h> 5 3 6 #include "CmdProc.h" 4 #include <string.h>5 7 6 8 /* -
trunk/packages/vizservers/nanovis/CmdProc.h
r2798 r2831 46 46 #define CMDSPEC_BINARY_SEARCH 0 47 47 48 extern Tcl_ObjCmdProc *GetOpFromObj(Tcl_Interp *interp, int nSpecs, 49 CmdSpec *specs, int operPos, int objc, Tcl_Obj *const *objv, int flags); 48 extern Tcl_ObjCmdProc * 49 GetOpFromObj(Tcl_Interp *interp, int nSpecs, 50 CmdSpec *specs, int operPos, int objc, Tcl_Obj *const *objv, int flags); 50 51 51 52 #define NumCmdSpecs(s) (sizeof(s) / sizeof(Rappture::CmdSpec)) … … 53 54 } 54 55 55 56 56 #endif /* CMDSPEC_H */ -
trunk/packages/vizservers/nanovis/Command.cpp
r2828 r2831 24 24 /* 25 25 * TODO: In no particular order... 26 * x Convert to Tcl_CmdObj interface. (done)27 26 * o Use Tcl command option parser to reduce size of procedures, remove 28 27 * lots of extra error checking code. (almost there) … … 33 32 * the vector. 1) Use a list instead of a vector. 2) carry 34 33 * an id field that's a number that gets incremented each new volume. 35 * x Create R2, matrix, etc. libraries. (done)36 34 * o Add bookkeeping for volumes, heightmaps, flows, etc. to track 37 35 * 1) id # 2) simulation # 3) include/exclude. The include/exclude … … 40 38 */ 41 39 42 43 44 40 #include <assert.h> 45 41 #include <stdlib.h> 42 46 43 #include <tcl.h> 47 44 … … 53 50 #include <RpBuffer.h> 54 51 55 #include "Trace.h"56 52 #include "nanovis.h" 57 53 #include "CmdProc.h" 58 #include "PointSetRenderer.h" 59 #include "PointSet.h" 60 #include "ZincBlendeVolume.h" 61 #include "NvColorTableRenderer.h" 62 #include "NvEventLog.h" 54 #include "Trace.h" 55 56 #if PLANE_CMD 57 #include "PlaneRenderer.h" 58 #endif 59 #include "Grid.h" 60 #include "HeightMap.h" 61 #include "NvCamera.h" 63 62 #include "NvZincBlendeReconstructor.h" 64 #include "VolumeInterpolator.h"65 #include "HeightMap.h"66 #include "Grid.h"67 #include "NvCamera.h"68 #include "RenderContext.h"69 #include "NvLIC.h"70 63 #include "Unirect.h" 71 72 #define PLANE_CMD 0 73 74 // EXTERN DECLARATIONS 75 // in Nv.cpp 76 77 // in nanovis.cpp 78 extern std::vector<PointSet*> g_pointSet; 79 80 extern PlaneRenderer* plane_render; 81 extern Texture2D* plane[10]; 82 83 // Tcl interpreter for incoming messages 64 #include "VelocityArrowsSlice.h" 65 #include "VolumeRenderer.h" 84 66 85 67 // default transfer function … … 1506 1488 tfPtr->name()); 1507 1489 (*iter)->transferFunction(tfPtr); 1508 #ifdef POINTSET1490 #ifdef USE_POINTSET_RENDERER 1509 1491 // TBD.. 1510 // POINTSET 1511 if ((*iter)->pointsetIndex != -1) { 1512 g_pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256); 1513 } 1514 #endif /*POINTSET*/ 1492 // if ((*iter)->pointsetIndex != -1) { 1493 // NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256); 1494 // } 1495 #endif 1515 1496 } 1516 1497 return TCL_OK; … … 2013 1994 2014 1995 static Rappture::CmdSpec heightMapOps[] = { 2015 {"create", 2, HeightMapCreateOp, 10, 10, 2016 "tag xmin ymin xmax ymax xnum ynum values",}, 1996 {"create", 2, HeightMapCreateOp, 10, 10, "tag xmin ymin xmax ymax xnum ynum values",}, 2017 1997 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 2018 1998 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, … … 2193 2173 //Now read w*h*4 bytes. The server expects the plane to be a stream of 2194 2174 //floats 2195 char *tmp = new char[int(w*h*sizeof(float))];2175 char *tmp = new char[int(w*h*sizeof(float))]; 2196 2176 if (tmp == NULL) { 2197 2177 Tcl_AppendResult(interp, "can't allocate stream data", (char *)NULL); … … 2204 2184 // error and return a non-zero exit status. 2205 2185 } 2206 plane[index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp);2186 NanoVis::plane[index] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, (float*)tmp); 2207 2187 delete[] tmp; 2208 2188 return TCL_OK; 2209 2189 } 2210 2211 2190 2212 2191 static int … … 2229 2208 return TCL_ERROR; 2230 2209 } 2231 // plane_render->add_plane(plane[plane_index], tf[tf_index]);2210 //NanoVis::plane_renderer->add_plane(NanoVis::plane[plane_index], tf[tf_index]); 2232 2211 return TCL_OK; 2233 2212 } … … 2257 2236 plane_index = -1; 2258 2237 } 2259 plane_render->set_active_plane(plane_index);2238 NanoVis::plane_renderer->set_active_plane(plane_index); 2260 2239 return TCL_OK; 2261 2240 } … … 2328 2307 initTcl() 2329 2308 { 2330 2331 2309 /* 2332 2310 * Ideally the connection is authenticated by nanoscale. I still like the … … 2350 2328 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, NULL, NULL); 2351 2329 Tcl_CreateObjCommand(interp, "legend", LegendCmd, NULL, NULL); 2330 #if PLANE_CMD 2331 Tcl_CreateObjCommand(interp, "plane", PlaneCmd, NULL, NULL); 2332 #endif 2352 2333 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 2353 2334 Tcl_CreateObjCommand(interp, "snapshot", SnapshotCmd, NULL, NULL); -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r2822 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <nvconf.h>3 #if defined(HAVE_LIBAVCODEC) || defined(HAVE_LIBAVFORMAT)4 #define HAVE_FFMPEG 15 #endif6 2 7 3 #include <assert.h> … … 11 7 #include <stdint.h> 12 8 #include <poll.h> 9 13 10 #include <tcl.h> 14 #include "Switch.h" 11 15 12 #include <RpField1D.h> 16 13 #include <RpFieldRect3D.h> 17 14 #include <RpFieldPrism3D.h> 18 15 #include <RpOutcome.h> 16 17 #include "nvconf.h" 18 19 #if defined(HAVE_LIBAVCODEC) || defined(HAVE_LIBAVFORMAT) 20 #define HAVE_FFMPEG 1 21 #endif 22 19 23 #ifdef HAVE_FFMPEG 20 #include <RpAVTranslate.h>24 #include "RpAVTranslate.h" 21 25 #endif 26 27 #include "nanovis.h" 28 #include "FlowCmd.h" 29 #include "CmdProc.h" 30 #include "Switch.h" 31 #include "TransferFunction.h" 32 #include "NvLIC.h" 22 33 #include "Trace.h" 23 #include "TransferFunction.h"24 25 #include "nanovis.h"26 #include "CmdProc.h"27 28 #include "NvLIC.h"29 30 34 #include "Unirect.h" 31 #include " FlowCmd.h"35 #include "VelocityArrowsSlice.h" 32 36 33 37 #define RELPOS 0 -
trunk/packages/vizservers/nanovis/FlowCmd.h
r2798 r2831 22 22 * ====================================================================== 23 23 */ 24 #ifndef FLOWCMD_H 25 #define FLOWCMD_H 26 27 #include <tcl.h> 28 29 #include "Switch.h" 30 #include "NvLIC.h" 31 #include "NvParticleRenderer.h" 32 #include "NvVectorField.h" 33 #include "Unirect.h" 34 #include "Volume.h" 24 35 25 36 struct FlowColor { … … 51 62 }; 52 63 53 class FlowParticles { 64 class FlowParticles 65 { 66 public: 67 FlowParticles(const char *name, Tcl_HashEntry *hPtr); 68 69 ~FlowParticles(); 70 71 const char *name() 72 { 73 return _name; 74 } 75 76 void disconnect() 77 { 78 _hashPtr = NULL; 79 } 80 81 bool visible() 82 { 83 return !_sv.isHidden; 84 } 85 86 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 87 { 88 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv, 89 SWITCH_DEFAULTS) < 0) { 90 return TCL_ERROR; 91 } 92 return TCL_OK; 93 } 94 95 void Advect() 96 { 97 assert(_rendererPtr->active()); 98 _rendererPtr->advect(); 99 } 100 101 void Render(); 102 103 void Reset() 104 { 105 _rendererPtr->reset(); 106 } 107 108 void Initialize() 109 { 110 _rendererPtr->initialize(); 111 } 112 113 void SetVectorField(Volume *volPtr) 114 { 115 _rendererPtr-> 116 setVectorField(volPtr->id, 117 volPtr->location(), 118 1.0f, 119 volPtr->height / (float)volPtr->width, 120 volPtr->depth / (float)volPtr->width, 121 volPtr->wAxis.max()); 122 } 123 124 void Configure(); 125 126 private: 54 127 const char *_name; /* Name of particle injection 55 128 * plane. Actual character string is … … 60 133 61 134 static Rappture::SwitchSpec _switches[]; 62 public:63 64 FlowParticles(const char *name, Tcl_HashEntry *hPtr);65 ~FlowParticles(void);66 const char *name(void) {67 return _name;68 }69 void disconnect(void) {70 _hashPtr = NULL;71 }72 bool visible(void) {73 return !_sv.isHidden;74 }75 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) {76 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv,77 SWITCH_DEFAULTS) < 0) {78 return TCL_ERROR;79 }80 return TCL_OK;81 }82 void Advect(void) {83 assert(_rendererPtr->active());84 _rendererPtr->advect();85 }86 void Render(void);87 void Reset(void) {88 _rendererPtr->reset();89 }90 void Initialize(void) {91 _rendererPtr->initialize();92 }93 void SetVectorField(Volume *volPtr) {94 _rendererPtr->setVectorField(volPtr->id,95 volPtr->location(),96 1.0f,97 volPtr->height / (float)volPtr->width,98 volPtr->depth / (float)volPtr->width,99 volPtr->wAxis.max());100 }101 void Configure(void);102 135 }; 103 136 … … 118 151 }; 119 152 120 class FlowBox { 153 class FlowBox 154 { 155 public: 156 FlowBox(const char *name, Tcl_HashEntry *hPtr); 157 158 ~FlowBox() 159 { 160 Rappture::FreeSwitches(_switches, &_sv, 0); 161 if (_hashPtr != NULL) { 162 Tcl_DeleteHashEntry(_hashPtr); 163 } 164 } 165 166 const char *name() 167 { 168 return _name; 169 } 170 171 bool visible() 172 { 173 return !_sv.isHidden; 174 } 175 176 void disconnect() 177 { 178 _hashPtr = NULL; 179 } 180 181 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 182 { 183 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv, 184 SWITCH_DEFAULTS) < 0) { 185 return TCL_ERROR; 186 } 187 return TCL_OK; 188 } 189 190 void Render(Volume *volPtr); 191 192 private: 121 193 const char *_name; /* Name of this box in the hash 122 194 * table. */ … … 125 197 FlowBoxValues _sv; 126 198 static Rappture::SwitchSpec _switches[]; 127 public: 128 129 FlowBox(const char *name, Tcl_HashEntry *hPtr); 130 ~FlowBox(void) { 131 Rappture::FreeSwitches(_switches, &_sv, 0); 132 if (_hashPtr != NULL) { 133 Tcl_DeleteHashEntry(_hashPtr); 134 } 135 } 136 const char *name(void) { 137 return _name; 138 } 139 bool visible(void) { 140 return !_sv.isHidden; 141 } 142 void disconnect(void) { 143 _hashPtr = NULL; 144 } 145 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) { 146 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv, 147 SWITCH_DEFAULTS) < 0) { 148 return TCL_ERROR; 149 } 150 return TCL_OK; 151 } 152 void Render(Volume *volPtr); 199 153 200 }; 154 201 … … 172 219 }; 173 220 174 class FlowCmd { 221 class FlowCmd 222 { 223 public: 224 enum SliceAxis { AXIS_X, AXIS_Y, AXIS_Z }; 225 226 FlowCmd(Tcl_Interp *interp, const char *name, Tcl_HashEntry *hPtr); 227 228 ~FlowCmd(); 229 230 int CreateParticles(Tcl_Interp *interp, Tcl_Obj *objPtr); 231 232 int GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr, 233 FlowParticles **particlePtrPtr); 234 235 void Render(); 236 237 void Advect(); 238 239 void ResetParticles(); 240 241 void InitializeParticles(); 242 243 FlowParticles *FirstParticles(FlowParticlesIterator *iterPtr); 244 245 FlowParticles *NextParticles(FlowParticlesIterator *iterPtr); 246 247 int CreateBox(Tcl_Interp *interp, Tcl_Obj *objPtr); 248 249 int GetBox(Tcl_Interp *interp, Tcl_Obj *objPtr, FlowBox **boxPtrPtr); 250 251 FlowBox *FirstBox(FlowBoxIterator *iterPtr); 252 253 FlowBox *NextBox(FlowBoxIterator *iterPtr); 254 255 float *GetScaledVector(); 256 257 Volume *MakeVolume(float *data); 258 259 void InitVectorField(); 260 261 NvVectorField *VectorField() 262 { 263 return _fieldPtr; 264 } 265 266 bool ScaleVectorField(); 267 268 bool visible() 269 { 270 return !_sv.isHidden; 271 } 272 273 const char *name() 274 { 275 return _name; 276 } 277 278 void disconnect() 279 { 280 _hashPtr = NULL; 281 } 282 283 bool isDataLoaded() 284 { 285 return (_dataPtr != NULL); 286 } 287 288 Rappture::Unirect3d *data() 289 { 290 return _dataPtr; 291 } 292 293 void data(Rappture::Unirect3d *dataPtr) 294 { 295 if (_dataPtr != NULL) { 296 delete _dataPtr; 297 } 298 _dataPtr = dataPtr; 299 } 300 301 void ActivateSlice() 302 { 303 /* Must set axis before offset or position goes to wrong axis. */ 304 NanoVis::licRenderer->set_axis(_sv.slicePos.axis); 305 NanoVis::licRenderer->set_offset(_sv.slicePos.value); 306 NanoVis::licRenderer->active(true); 307 } 308 309 void DeactivateSlice() 310 { 311 NanoVis::licRenderer->active(false); 312 } 313 314 SliceAxis GetAxis() 315 { 316 return (SliceAxis)_sv.slicePos.axis; 317 } 318 319 TransferFunction *GetTransferFunction() 320 { 321 return _sv.tfPtr; 322 } 323 324 float GetRelativePosition(); 325 326 void SetAxis() 327 { 328 NanoVis::licRenderer->set_axis(_sv.slicePos.axis); 329 } 330 331 void SetAxis(FlowCmd::SliceAxis axis) 332 { 333 _sv.slicePos.axis = axis; 334 NanoVis::licRenderer->set_axis(_sv.slicePos.axis); 335 } 336 337 void SetCurrentPosition(float position) 338 { 339 _sv.slicePos.value = position; 340 NanoVis::licRenderer->set_offset(_sv.slicePos.value); 341 } 342 343 void SetCurrentPosition() 344 { 345 NanoVis::licRenderer->set_offset(_sv.slicePos.value); 346 } 347 348 void SetActive(bool state) 349 { 350 _sv.sliceVisible = state; 351 NanoVis::licRenderer->active(state); 352 } 353 354 void SetActive() 355 { 356 NanoVis::licRenderer->active(_sv.sliceVisible); 357 } 358 359 void SetVectorField(NvVectorField *fieldPtr) 360 { 361 DeleteVectorField(); 362 _fieldPtr = fieldPtr; 363 } 364 365 void DeleteVectorField() 366 { 367 if (_fieldPtr != NULL) { 368 delete _fieldPtr; 369 _fieldPtr = NULL; 370 } 371 } 372 373 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) 374 { 375 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv, 376 SWITCH_DEFAULTS) < 0) { 377 return TCL_ERROR; 378 } 379 return TCL_OK; 380 } 381 382 static float GetRelativePosition(FlowPosition *posPtr); 383 384 static Rappture::SwitchSpec videoSwitches[]; 385 386 private: 387 void Configure(); 388 389 void RenderBoxes(); 390 175 391 Tcl_Interp *_interp; 176 392 Tcl_HashEntry *_hashPtr; … … 203 419 * with each field. */ 204 420 205 void Configure(void);206 207 421 static Rappture::SwitchSpec _switches[]; 208 422 FlowValues _sv; 209 210 void RenderBoxes(void);211 public:212 static Rappture::SwitchSpec videoSwitches[];213 enum SliceAxis { AXIS_X, AXIS_Y, AXIS_Z };214 FlowCmd(Tcl_Interp *interp, const char *name, Tcl_HashEntry *hPtr);215 ~FlowCmd(void);216 217 int CreateParticles(Tcl_Interp *interp, Tcl_Obj *objPtr);218 int GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr,219 FlowParticles **particlePtrPtr);220 void Render(void);221 void Advect(void);222 void ResetParticles(void);223 void InitializeParticles(void);224 225 FlowParticles *FirstParticles(FlowParticlesIterator *iterPtr);226 FlowParticles *NextParticles(FlowParticlesIterator *iterPtr);227 228 int CreateBox(Tcl_Interp *interp, Tcl_Obj *objPtr);229 int GetBox(Tcl_Interp *interp, Tcl_Obj *objPtr, FlowBox **boxPtrPtr);230 FlowBox *FirstBox(FlowBoxIterator *iterPtr);231 FlowBox *NextBox(FlowBoxIterator *iterPtr);232 233 float *GetScaledVector(void);234 Volume *MakeVolume(float *data);235 236 void InitVectorField(void);237 238 NvVectorField *VectorField(void) {239 return _fieldPtr;240 }241 242 bool ScaleVectorField(void);243 244 bool visible(void) {245 return !_sv.isHidden;246 }247 const char *name(void) {248 return _name;249 }250 void disconnect(void) {251 _hashPtr = NULL;252 }253 bool isDataLoaded(void) {254 return (_dataPtr != NULL);255 }256 Rappture::Unirect3d *data(void) {257 return _dataPtr;258 }259 void data(Rappture::Unirect3d *dataPtr) {260 if (_dataPtr != NULL) {261 delete _dataPtr;262 }263 _dataPtr = dataPtr;264 }265 void ActivateSlice(void) {266 /* Must set axis before offset or position goes to wrong axis. */267 NanoVis::licRenderer->set_axis(_sv.slicePos.axis);268 NanoVis::licRenderer->set_offset(_sv.slicePos.value);269 NanoVis::licRenderer->active(true);270 }271 void DeactivateSlice(void) {272 NanoVis::licRenderer->active(false);273 }274 SliceAxis GetAxis(void) {275 return (SliceAxis)_sv.slicePos.axis;276 }277 TransferFunction *GetTransferFunction(void) {278 return _sv.tfPtr;279 }280 float GetRelativePosition(void);281 void SetAxis(void) {282 NanoVis::licRenderer->set_axis(_sv.slicePos.axis);283 }284 void SetAxis(FlowCmd::SliceAxis axis) {285 _sv.slicePos.axis = axis;286 NanoVis::licRenderer->set_axis(_sv.slicePos.axis);287 }288 void SetCurrentPosition(float position) {289 _sv.slicePos.value = position;290 NanoVis::licRenderer->set_offset(_sv.slicePos.value);291 }292 void SetCurrentPosition(void) {293 NanoVis::licRenderer->set_offset(_sv.slicePos.value);294 }295 void SetActive(bool state) {296 _sv.sliceVisible = state;297 NanoVis::licRenderer->active(state);298 }299 void SetActive(void) {300 NanoVis::licRenderer->active(_sv.sliceVisible);301 }302 void SetVectorField(NvVectorField *fieldPtr) {303 DeleteVectorField();304 _fieldPtr = fieldPtr;305 }306 void DeleteVectorField(void) {307 if (_fieldPtr != NULL) {308 delete _fieldPtr;309 _fieldPtr = NULL;310 }311 }312 int ParseSwitches(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv) {313 if (Rappture::ParseSwitches(interp, _switches, objc, objv, &_sv,314 SWITCH_DEFAULTS) < 0) {315 return TCL_ERROR;316 }317 return TCL_OK;318 }319 static float GetRelativePosition(FlowPosition *posPtr);320 423 }; 321 424 322 425 extern int GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf, int nBytes); 323 426 324 extern int GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 325 bool *boolPtr); 326 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 327 float *floatPtr); 328 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 329 int *axisPtr); 330 extern int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 331 Volume **volumePtrPtr); 332 333 427 extern int GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 428 bool *boolPtr); 429 430 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 431 float *floatPtr); 432 433 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 434 int *axisPtr); 435 436 extern int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 437 Volume **volumePtrPtr); 438 439 #endif -
trunk/packages/vizservers/nanovis/HeightMap.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef _HEIGHT_MAP_H_3 #define _HEIGHT_MAP_H_2 #ifndef HEIGHTMAP_H 3 #define HEIGHTMAP_H 4 4 5 5 #include <Cg/cgGL.h> 6 6 #include <Cg/cg.h> 7 7 8 #include <R2/graphics/R2Geometry.h> 9 8 10 #include "TransferFunction.h" 9 11 #include "NvShader.h" 10 12 #include "Vector3.h" 11 #include <RenderContext.h>13 #include "RenderContext.h" 12 14 #include "AxisRange.h" 13 15 … … 22 24 *@brief Create a surface from height map and line contour of the generated surface 23 25 */ 26 class HeightMap 27 { 28 public: 29 HeightMap(); 24 30 25 class HeightMap { 31 ~HeightMap(); 32 33 void render(graphics::RenderContext *renderContext); 34 35 void render_topview(graphics::RenderContext *renderContext, 36 int render_width, int render_height); 37 38 /** 39 *@brief Create a height map with heigh values 40 *@param startX a x position of the first height value 41 *@param startY a y position of the first height value 42 *@param endX a x position of the last height value 43 *@param endY a y position of the last height value 44 *@param xCount the number of columns of height values 45 *@param yCount the number of rows of height values 46 *@param height a pointer value adrressing xCount * yCount values of heights 47 */ 48 void setHeight(float startX, float startY, float endX, float endY, 49 int xCount, int yCount, float *height); 50 51 /** 52 *@brief Create a height map with a set of points 53 *@param xCount the number of columns of height values 54 *@param yCount the number of rows of height values 55 */ 56 void setHeight(int xCount, int yCount, Vector3 *heights); 57 58 void MapToGrid(Grid *gridPtr); 59 60 /** 61 *@brief Define a color map for color shading of heightmap 62 */ 63 void transferFunction(TransferFunction *tfPtr) 64 { 65 _tfPtr = tfPtr; 66 } 67 68 /** 69 *@brief Get the color map defined for shading of this heightmap 70 */ 71 TransferFunction *transferFunction() 72 { 73 return _tfPtr; 74 } 75 76 /** 77 *@brief Set the visibility of the height map 78 */ 79 void setVisible(bool visible) 80 { 81 _visible = visible; 82 } 83 84 /** 85 *@brief Return the status of the visibility 86 */ 87 bool isVisible() const 88 { 89 return _visible; 90 } 91 92 /** 93 *@brief Set the visibility of the line contour 94 */ 95 void setLineContourVisible(bool visible) 96 { 97 _contourVisible = visible; 98 } 99 100 void setTopLineContourVisible(bool visible) 101 { 102 _topContourVisible = visible; 103 } 104 105 void opacity(float opacity) 106 { 107 _opacity = opacity; 108 } 109 110 float opacity() 111 { 112 return _opacity; 113 } 114 115 /** 116 *@brief Defind the color of the line contour 117 */ 118 void setLineContourColor(float *rgb) 119 { 120 _contourColor.x = rgb[0]; 121 _contourColor.y = rgb[1]; 122 _contourColor.z = rgb[2]; 123 } 124 125 AxisRange xAxis, yAxis, zAxis, wAxis; 126 static bool update_pending; 127 static double valueMin, valueMax; 128 129 private: 130 void createIndexBuffer(int xCount, int zCount, float* heights); 131 Vector3 *createHeightVertices(float startX, float startY, 132 float endX, float endY, 133 int xCount, int yCount, float *height); 134 void reset(); 135 26 136 unsigned int _vertexBufferObjectID; 27 137 unsigned int _textureBufferObjectID; … … 29 139 CGparameter _tfParam; 30 140 CGparameter _opacityParam; 31 R2Geometry *_contour;32 R2Geometry *_topContour;33 TransferFunction *_tfPtr;141 R2Geometry *_contour; 142 R2Geometry *_topContour; 143 TransferFunction *_tfPtr; 34 144 float _opacity; 35 NvShader *_shader;145 NvShader *_shader; 36 146 int *_indexBuffer; 37 147 int _indexCount; … … 47 157 float *_heights; // Array of original (unscaled) heights 48 158 // (y-values) 49 public :50 AxisRange xAxis, yAxis, zAxis, wAxis;51 static bool update_pending;52 static double valueMin, valueMax;53 54 /**55 *@brief Constructor56 */57 HeightMap();58 /**59 *@brief Destructor60 */61 ~HeightMap();62 63 private :64 void createIndexBuffer(int xCount, int zCount, float* heights);65 Vector3* createHeightVertices(float startX, float startY, float endX, float endY, int xCount, int yCount, float* height);66 void reset();67 public :68 void render(graphics::RenderContext* renderContext);69 void render_topview(graphics::RenderContext* renderContext, int render_width, int render_height);70 /**71 *@brief Create a height map with heigh values72 *@param startX a x position of the first height value73 *@param startY a y position of the first height value74 *@param endX a x position of the last height value75 *@param endY a y position of the last height value76 *@param xCount the number of columns of height values77 *@param yCount the number of rows of height values78 *@param height a pointer value adrressing xCount * yCount values of heights79 */80 void setHeight(float startX, float startY, float endX, float endY,81 int xCount, int yCount, float* height);82 83 /**84 *@brief Create a height map with a set of points85 *@param xCount the number of columns of height values86 *@param yCount the number of rows of height values87 */88 void setHeight(int xCount, int yCount, Vector3* heights);89 90 void MapToGrid(Grid *gridPtr);91 /**92 *@brief Define a color map for color shading of heightmap93 */94 void transferFunction(TransferFunction* tfPtr) {95 _tfPtr = tfPtr;96 }97 /**98 *@brief Get the color map defined for shading of this heightmap99 */100 TransferFunction *transferFunction(void) {101 return _tfPtr;102 }103 /**104 *@brief Set the visibility of the height map105 */106 void setVisible(bool visible) {107 _visible = visible;108 }109 110 /**111 *@brief Return the status of the visibility112 */113 bool isVisible() const {114 return _visible;115 }116 /**117 *@brief Set the visibility of the line contour118 */119 void setLineContourVisible(bool visible) {120 _contourVisible = visible;121 }122 123 void setTopLineContourVisible(bool visible) {124 _topContourVisible = visible;125 }126 127 void opacity(float opacity) {128 _opacity = opacity;129 }130 float opacity(void) {131 return _opacity;132 }133 /**134 *@brief Defind the color of the line contour135 */136 void setLineContourColor(float *rgb) {137 _contourColor.x = rgb[0];138 _contourColor.y = rgb[1];139 _contourColor.z = rgb[2];140 }141 159 }; 142 160 -
trunk/packages/vizservers/nanovis/NvColorTableShader.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #include <R2/R2FilePath.h> 3 3 4 #include "NvColorTableShader.h" 4 #include <Trace.h>5 #include <global.h>5 #include "Trace.h" 6 #include "global.h" 6 7 7 8 NvColorTableShader::NvColorTableShader() -
trunk/packages/vizservers/nanovis/NvFlowVisRenderer.cpp
r2798 r2831 21 21 22 22 #include <R2/R2FilePath.h> 23 23 24 #include "NvFlowVisRenderer.h" 24 25 #include "NvVectorField.h" 25 #include <Trace.h> 26 26 #include "Trace.h" 27 27 28 28 #define NV_32 -
trunk/packages/vizservers/nanovis/NvLIC.cpp
r2798 r2831 14 14 * ====================================================================== 15 15 */ 16 17 18 16 #include <stdlib.h> 19 17 #include <math.h> … … 21 19 22 20 #include <R2/R2FilePath.h> 21 23 22 #include "NvLIC.h" 24 #include <Trace.h>23 #include "Trace.h" 25 24 #include "global.h" 26 25 -
trunk/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #include <R2/R2FilePath.h> 3 #include <Trace.h> 3 4 4 #include "NvParticleAdvectionShader.h" 5 #include <global.h> 5 #include "Trace.h" 6 #include "global.h" 6 7 7 8 NvParticleAdvectionShader::NvParticleAdvectionShader() : -
trunk/packages/vizservers/nanovis/NvParticleRenderer.cpp
r2798 r2831 19 19 #include <malloc.h> 20 20 #include <string.h> 21 #include <stdlib.h> 21 22 22 23 #include <R2/R2FilePath.h> 24 23 25 #include "NvParticleRenderer.h" 24 #include <Trace.h> 25 #include <stdlib.h> 26 #include "Trace.h" 26 27 27 28 #define NV_32 -
trunk/packages/vizservers/nanovis/NvRegularVolumeShader.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #include "NvRegularVolumeShader.h" 3 #include <global.h>3 #include "global.h" 4 4 5 5 NvRegularVolumeShader::NvRegularVolumeShader() -
trunk/packages/vizservers/nanovis/ParticleSystem.cpp
r2818 r2831 7 7 #include <pthread.h> 8 8 9 #ifdef _WIN3210 #include <GL/glaux.h>11 #else12 9 #ifdef HAVE_OPENCV_H 13 10 #include <opencv/cv.h> … … 15 12 #ifdef HAVE_OPENCV_HIGHGUI_H 16 13 #include <opencv/highgui.h> 17 #endif18 14 #endif 19 15 … … 318 314 _arrows->setWrapT(TW_MIRROR); 319 315 320 #ifdef _WIN32321 #ifndef USE_RGBA_ARROW322 std::string path = vrFilePath::getInstance()->getPath("arrows.bmp");323 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad(path.c_str());324 _arrows->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data);325 #else326 std::string path = vrFilePath::getInstance()->getPath("arrows_red_bg.bmp");327 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad(path.c_str());328 unsigned char* pixels = new unsigned char [pTextureImage->sizeX * pTextureImage->sizeY * sizeof(unsigned char) * 4];329 unsigned char* srcPixels = pTextureImage->data;330 unsigned char* dstPixels = pixels;331 for (int i = 0; i < pTextureImage->sizeX * pTextureImage->sizeY; ++i) {332 *dstPixels = *srcPixels; ++srcPixels;333 *(dstPixels + 1) = *srcPixels; ++srcPixels;334 *(dstPixels + 2) = *srcPixels; ++srcPixels;335 336 if ((*dstPixels > 127) && (*(dstPixels + 1) < 127) && (*(dstPixels + 2) < 127)) {337 *(dstPixels + 3) = 0;338 } else {339 *(dstPixels + 3) = 255;340 }341 342 dstPixels += 4;343 }344 _arrows->setPixels(CF_RGBA, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pixels);345 #endif346 347 #else348 316 #ifndef USE_RGBA_ARROW 349 317 IplImage* pTextureImage = cvLoadImage("arrows_flip2.png"); 350 _arrows->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, (void*)pTextureImage->imageData);318 _arrows->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, pTextureImage->imageData); 351 319 #else 352 320 #ifdef notdef … … 375 343 376 344 #endif // USE_RGBA_ARROW 377 #endif // _WIN32378 345 379 346 #ifdef TEST -
trunk/packages/vizservers/nanovis/PointSet.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __POINT_SET_H__3 #define __POINT_SET_H__2 #ifndef POINT_SET_H 3 #define POINT_SET_H 4 4 5 #include <PCASplit.h>6 #include <Vector4.h>7 #include <Vector3.h>5 #include "PCASplit.h" 6 #include "Vector4.h" 7 #include "Vector3.h" 8 8 9 class PointSet { 9 class PointSet 10 { 11 public : 12 PointSet() : 13 _sortLevel(4), 14 _cluster(0), 15 _max(1.0f), 16 _min(0.0f), 17 _visible(false) 18 { 19 } 20 21 ~PointSet() { 22 if (_cluster) { 23 delete _cluster; 24 } 25 } 26 27 void initialize(Vector4 *values, const unsigned int count, 28 const Vector3& scale, const Vector3& origin, 29 float min, float max); 30 31 void updateColor(float *color, int count); 32 33 bool isVisible() const 34 { 35 return _visible; 36 } 37 38 void setVisible(bool visible) 39 { 40 _visible = visible; 41 } 42 43 unsigned int getSortLevel() const 44 { 45 return _sortLevel; 46 } 47 48 PCA::ClusterAccel* getCluster() 49 { 50 return _cluster; 51 } 52 53 Vector3& getScale() 54 { 55 return _scale; 56 } 57 58 const Vector3& getScale() const 59 { 60 return _scale; 61 } 62 63 Vector3& getOrigin() 64 { 65 return _origin; 66 } 67 68 const Vector3& getOrigin() const 69 { 70 return _origin; 71 } 72 73 private: 10 74 unsigned int _sortLevel; 11 75 PCA::ClusterAccel* _cluster; … … 16 80 float _min; 17 81 bool _visible; 18 public :19 void initialize(Vector4* values, const unsigned int count,20 const Vector3& scale, const Vector3& origin,21 float min, float max);22 void updateColor(float* color, int count);23 24 PointSet() :25 _sortLevel(4),26 _cluster(0),27 _max(1.0f),28 _min(0.0f),29 _visible(false)30 {31 /*empty*/32 }33 ~PointSet() {34 if (_cluster) {35 delete _cluster;36 }37 }38 39 bool isVisible() const {40 return _visible;41 }42 void setVisible(bool visible) {43 _visible = visible;44 }45 unsigned int getSortLevel(void) const {46 return _sortLevel;47 }48 PCA::ClusterAccel* getCluster(void) {49 return _cluster;50 }51 Vector3& getScale(void) {52 return _scale;53 }54 const Vector3& getScale(void) const {55 return _scale;56 }57 Vector3& getOrigin(void) {58 return _origin;59 }60 const Vector3& getOrigin(void) const {61 return _origin;62 }63 82 }; 64 83 65 #endif /*__POINT_SET_H__*/84 #endif -
trunk/packages/vizservers/nanovis/PointSetRenderer.cpp
r2822 r2831 22 22 return; 23 23 } 24 25 ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp");26 Image *image = loader->load(path, Image::IMG_RGBA);24 25 ImageLoader *loader = ImageLoaderFactory::getInstance()->createLoader("bmp"); 26 Image *image = loader->load(path, Image::IMG_RGBA); 27 27 delete [] path; 28 unsigned char * bytes = (unsigned char*)image->getImageBuffer();28 unsigned char *bytes = (unsigned char *)image->getImageBuffer(); 29 29 if (bytes) { 30 30 for (unsigned int y = 0; y < image->getHeight(); ++y) { 31 for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) {32 bytes[3] = (bytes[0] == 0) ? 0 : 255;31 for (unsigned int x = 0; x < image->getWidth(); ++x, bytes += 4) { 32 bytes[3] = (bytes[0] == 0) ? 0 : 255; 33 33 } 34 34 } … … 38 38 _pointTexture = new Texture2D(image->getWidth(), image->getHeight(), 39 39 GL_UNSIGNED_BYTE, GL_LINEAR, 40 4, (float*)image->getImageBuffer());40 4, image->getImageBuffer()); 41 41 } else { 42 42 ERROR("fail to load image [%s]\n", "particles2.bmp"); … … 47 47 } 48 48 49 void PointSetRenderer::renderPoints(PCA::Point *points, int length)49 void PointSetRenderer::renderPoints(PCA::Point *points, int length) 50 50 { 51 PCA::Point* p = points; 52 for (int i = 0; i < length; ++i) 53 { 51 PCA::Point *p = points; 52 for (int i = 0; i < length; ++i, ++p) { 54 53 glColor4f(p->color.x, p->color.y, p->color.z, p->color.w); 55 54 glVertex3f(p->position.x, p->position.y, p->position.z); 56 57 ++p;58 55 } 59 56 } … … 78 75 79 76 PCA::ClusterList* p; 80 for (int i = size - 1; i >= 0; --i) 81 { 77 for (int i = size - 1; i >= 0; --i) { 82 78 p = bucket[i]; 83 if (p) 84 { 85 if (!setSize) 86 { 79 if (p) { 80 if (!setSize) { 87 81 #ifdef USE_SHADER 88 82 _shader->setScale(p->data->points[0].size); … … 92 86 } 93 87 94 while (p) 95 { 88 while (p) { 96 89 renderPoints(p->data->points, p->data->numOfPoints); 97 90 98 91 p = p->next; 99 92 } 100 101 93 } 102 94 … … 105 97 glDisable(GL_POINT_SPRITE_ARB); 106 98 glPointSize(1); 107 108 99 } 109 100 110 void PointSetRenderer::render(PCA::ClusterAccel* cluster, const Mat4x4& mat, int sortLevel, const Vector3& scale, const Vector3& origin) 101 void PointSetRenderer::render(PCA::ClusterAccel *cluster, const Mat4x4& mat, 102 int sortLevel, const Vector3& scale, const Vector3& origin) 111 103 { 112 104 _bucketSort->init(); … … 134 126 135 127 //glTranslatef(-shift.x, -shift.y, -shift.z); 136 128 137 129 #ifdef USE_SHADER 138 130 _shader->bind(); … … 140 132 glPointSize(POINT_SIZE); 141 133 #endif 142 134 renderCluster(_bucketSort->getBucket(), _bucketSort->getSize(), 4); 143 135 #ifdef USE_SHADER 144 136 _shader->unbind(); … … 146 138 glPointSize(1.0f); 147 139 #endif 148 140 149 141 glPopMatrix(); 150 142 … … 159 151 #endif 160 152 } 161 -
trunk/packages/vizservers/nanovis/PointSetRenderer.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __POINT_SET_RENDERER_H__3 #define __POINT_SET_RENDERER_H__2 #ifndef POINT_SET_RENDERER_H 3 #define POINT_SET_RENDERER_H 4 4 5 5 #include "PCASplit.h" … … 7 7 #include "PointShader.h" 8 8 #include "Texture2D.h" 9 #include <Mat4x4.h>9 #include "Mat4x4.h" 10 10 11 class PointSetRenderer { 12 PCA::BucketSort* _bucketSort; 13 PointShader* _shader; 14 Texture2D* _pointTexture; 15 public : 11 class PointSetRenderer 12 { 13 public: 16 14 PointSetRenderer(); 17 15 ~PointSetRenderer(); 18 16 19 private : 20 void renderPoints(PCA::Point* points, int length); 21 void renderCluster(PCA::ClusterList** bucket, int size, int level); 17 void render(PCA::ClusterAccel *cluster, const Mat4x4& mat, 18 int sortLevel, const Vector3& scale, const Vector3& origin); 22 19 23 public : 24 void render(PCA::ClusterAccel* cluster, const Mat4x4& mat, int sortLevel, const Vector3& scale, const Vector3& origin); 20 private: 21 void renderPoints(PCA::Point *points, int length); 22 23 void renderCluster(PCA::ClusterList **bucket, int size, int level); 24 25 PCA::BucketSort *_bucketSort; 26 PointShader *_shader; 27 Texture2D *_pointTexture; 25 28 }; 26 29 -
trunk/packages/vizservers/nanovis/RenderContext.cpp
r2798 r2831 4 4 namespace graphics { 5 5 6 RenderContext::RenderContext() 7 : _cullMode(NO_CULL), _fillMode(FILL), _shadingModel(SMOOTH) 6 RenderContext::RenderContext() : 7 _cullMode(NO_CULL), 8 _fillMode(FILL), 9 _shadingModel(SMOOTH) 8 10 { 9 11 } … … 13 15 } 14 16 15 }; 16 17 } -
trunk/packages/vizservers/nanovis/RenderContext.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __RENDER_CONTEXT_H__3 #define __RENDER_CONTEXT_H__2 #ifndef RENDER_CONTEXT_H 3 #define RENDER_CONTEXT_H 4 4 5 5 #include <GL/gl.h> … … 7 7 namespace graphics { 8 8 9 class RenderContext { 10 public : 9 class RenderContext 10 { 11 public: 11 12 enum ShadingModel { 12 13 FLAT = GL_FLAT , //!< Flat Shading 13 SMOOTH = GL_SMOOTH //!< Smooth shading (Go raud shading model)14 SMOOTH = GL_SMOOTH //!< Smooth shading (Gouraud shading model) 14 15 }; 15 16 … … 25 26 }; 26 27 28 RenderContext(); 29 30 ~RenderContext(); 31 32 /** 33 *@brief Set the shading model such as flat, smooth 34 */ 35 void setShadingModel(const ShadingModel shadeModel) 36 { 37 _shadingModel = shadeModel; 38 } 39 40 ShadingModel getShadingModel() const 41 { 42 return _shadingModel; 43 } 44 45 void setCullMode(const CullMode cullMode) 46 { 47 _cullMode = cullMode; 48 } 49 50 CullMode getCullMode() const 51 { 52 return _cullMode; 53 } 54 55 void setPolygonMode(const PolygonMode fillMode) 56 { 57 _fillMode = fillMode; 58 } 59 60 PolygonMode getPolygonMode() const 61 { 62 return _fillMode; 63 } 64 27 65 private : 28 66 CullMode _cullMode; 29 67 PolygonMode _fillMode; 30 68 ShadingModel _shadingModel; 31 32 public :33 /**34 *@brief constructor35 */36 RenderContext();37 38 /**39 *@brief Destructor40 */41 ~RenderContext();42 43 public :44 /**45 *@brief Set the shading model such as flat, smooth46 */47 void setShadingModel(const ShadingModel shadeModel);48 ShadingModel getShadingModel() const;49 50 void setCullMode(const CullMode cullMode);51 CullMode getCullMode() const;52 53 void setPolygonMode(const PolygonMode fillMode);54 PolygonMode getPolygonMode() const;55 56 69 }; 57 58 inline void RenderContext::setShadingModel(const RenderContext::ShadingModel shadeModel)59 {60 _shadingModel = shadeModel;61 }62 63 inline RenderContext::ShadingModel RenderContext::getShadingModel() const64 {65 return _shadingModel;66 }67 68 inline void RenderContext::setCullMode(const RenderContext::CullMode cullMode)69 {70 _cullMode = cullMode;71 }72 73 inline RenderContext::CullMode RenderContext::getCullMode() const74 {75 return _cullMode;76 }77 78 inline void RenderContext::setPolygonMode(const RenderContext::PolygonMode fillMode)79 {80 _fillMode = fillMode;81 }82 83 inline RenderContext::PolygonMode RenderContext::getPolygonMode() const84 {85 return _fillMode;86 }87 70 88 71 } 89 72 90 #endif //73 #endif -
trunk/packages/vizservers/nanovis/Texture1D.cpp
r2798 r2831 15 15 */ 16 16 17 #include "Texture1D.h"18 #include "Trace.h"19 17 #include <stdio.h> 20 18 #include <assert.h> 21 19 #include <math.h> 22 20 21 #include "Texture1D.h" 22 #include "Trace.h" 23 23 24 Texture1D::Texture1D(){ 25 id = -1; 26 gl_resource_allocated = false; 24 Texture1D::Texture1D() : 25 gl_resource_allocated(false), 26 id(0) 27 { 27 28 } 28 29 29 Texture1D::Texture1D(int width, int type) 30 Texture1D::Texture1D(int width, 31 GLuint type, GLuint interp, 32 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 30 35 { 31 assert(type == GL_UNSIGNED_BYTE || type == GL_FLOAT ||32 type == GL_UNSIGNED_INT);33 34 36 this->width = width; 35 37 this->type = type; 38 this->interp_type = interp; 39 this->n_components = numComponents; 36 40 37 i d = -1;38 gl_resource_allocated = false;41 if (data != NULL) 42 initialize(data); 39 43 } 40 44 41 GLuint Texture1D::initialize_float_rgba(float *data)45 Texture1D::~Texture1D() 42 46 { 43 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 47 glDeleteTextures(1, &id); 48 } 49 50 GLuint Texture1D::initialize(void *data) 51 { 52 if (gl_resource_allocated) 53 glDeleteTextures(1, &id); 44 54 45 55 glGenTextures(1, &id); 46 glBindTexture(GL_TEXTURE_1D, id);47 assert(id != (GLuint)-1);48 56 49 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 50 51 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 52 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 53 54 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, width, 0, GL_RGBA, GL_FLOAT, data); 55 assert(glGetError()==0); 57 update(data); 56 58 57 59 gl_resource_allocated = true; … … 59 61 } 60 62 61 void Texture1D::update_float_rgba(float* data){ 63 void Texture1D::update(void *data) 64 { 62 65 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 66 63 67 glBindTexture(GL_TEXTURE_1D, id); 64 68 65 69 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 70 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, interp_type); 71 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, interp_type); 66 72 67 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 68 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 73 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 69 74 70 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, width, 0, GL_RGBA, GL_FLOAT, data); 75 glTexImage1D(GL_TEXTURE_1D, 0, format[n_components], width, 0, 76 format[n_components], type, data); 77 71 78 assert(glGetError()==0); 72 79 } … … 83 90 } 84 91 85 Texture1D::~Texture1D()92 void Texture1D::check_max_size() 86 93 { 87 glDeleteTextures(1, &id);88 }89 90 void Texture1D::check_max_size(){91 94 GLint max = 0; 92 95 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); 93 94 //TRACE("%d", glGetError()); 96 95 97 TRACE("max texture size: %d\n", max); 96 98 } 97 99 98 void Texture1D::check_max_unit(){ 100 void Texture1D::check_max_unit() 101 { 99 102 int max; 100 103 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &max); -
trunk/packages/vizservers/nanovis/Texture1D.h
r2798 r2831 14 14 * ====================================================================== 15 15 */ 16 #ifndef _TEXTURE_1D_H_17 #define _TEXTURE_1D_H_16 #ifndef TEXTURE1D_H 17 #define TEXTURE1D_H 18 18 19 19 #include <GL/glew.h> 20 20 21 class Texture1D { 21 class Texture1D 22 { 22 23 public: 24 Texture1D(); 25 26 Texture1D(int width, 27 GLuint type = GL_FLOAT, 28 GLuint interp = GL_LINEAR, 29 int numComponents = 4, 30 void *data = NULL); 31 32 ~Texture1D(); 33 34 GLuint initialize(void *data); 35 36 void update(void *data); 37 38 void activate(); 39 40 void deactivate(); 41 42 static void check_max_size(); 43 44 static void check_max_unit(); 45 23 46 int width; 47 48 int n_components; 49 24 50 bool gl_resource_allocated; 25 51 GLuint id; 26 52 GLuint type; 27 GLuint id; 28 GLuint tex_unit; 53 GLuint interp_type; 29 54 30 Texture1D(); 31 Texture1D(int length, int type = GL_UNSIGNED_BYTE); 32 ~Texture1D(); 33 34 void activate(); 35 void deactivate(); 36 GLuint initialize_float_rgba(float* data); 37 void update_float_rgba(float* data); 38 static void check_max_size(); 39 static void check_max_unit(); 55 //GLuint tex_unit; 40 56 }; 41 57 -
trunk/packages/vizservers/nanovis/Texture2D.cpp
r2798 r2831 23 23 #include "config.h" 24 24 25 Texture2D::Texture2D(){} 25 Texture2D::Texture2D() : 26 gl_resource_allocated(false), 27 id(0) 28 {} 26 29 27 Texture2D::Texture2D(int width, int height, GLuint type=GL_FLOAT, 28 GLuint interp=GL_LINEAR, int n=4, float* data = 0) 30 Texture2D::Texture2D(int width, int height, 31 GLuint type, GLuint interp, 32 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 29 35 { 30 assert(type == GL_UNSIGNED_BYTE ||31 type == GL_FLOAT ||32 type ==GL_UNSIGNED_INT);33 assert(interp == GL_LINEAR || interp == GL_NEAREST);34 35 36 this->width = width; 36 37 this->height = height; 37 38 this->type = type; 38 39 this->interp_type = interp; 39 this->n_components = n ;40 this->n_components = numComponents; 40 41 41 this->id = 0; 42 43 if(data != 0) 42 if (data != NULL) 44 43 initialize(data); 45 44 } 46 45 47 GLuint 48 Texture2D::initialize(float *data) 46 Texture2D::~Texture2D() 49 47 { 50 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 48 glDeleteTextures(1, &id); 49 } 50 51 GLuint Texture2D::initialize(void *data) 52 { 53 if (gl_resource_allocated) 54 glDeleteTextures(1, &id); 51 55 52 56 glGenTextures(1, &id); 57 58 update(data); 59 60 gl_resource_allocated = true; 61 return id; 62 } 63 64 void Texture2D::update(void *data) 65 { 53 66 glBindTexture(GL_TEXTURE_2D, id); 54 assert(id != (GLuint)-1); 67 68 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 55 69 56 70 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 57 71 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 58 59 if(interp_type == GL_LINEAR){ 60 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 61 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 62 } else { 63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 65 } 72 73 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, interp_type); 74 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, interp_type); 66 75 67 76 //to do: add handling to more formats 68 if (type==GL_FLOAT) {69 switch(n_components){70 77 #ifdef NV40 71 case 1: 72 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16F_ARB, width, height, 73 0, GL_LUMINANCE, GL_FLOAT, data); 74 break; 75 case 2: 76 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA16F_ARB, width, 77 height, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 78 break; 79 case 3: 80 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F_ARB, width, height, 0, 81 GL_RGB, GL_FLOAT, data); 82 break; 83 case 4: 84 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, width, height, 0, 85 GL_RGBA, GL_FLOAT, data); 86 break; 87 #else 88 case 1: 89 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, 90 GL_LUMINANCE, GL_FLOAT, data); 91 break; 92 case 2: 93 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, width, height, 94 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 95 break; 96 case 3: 97 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, 98 GL_FLOAT, data); 99 break; 100 case 4: 101 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, 102 GL_FLOAT, data); 103 break; 78 if (type == GL_FLOAT) { 79 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 80 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 81 glTexImage2D(GL_TEXTURE_2D, 0, targetFormat[n_components], width, height, 0, 82 format[n_components], type, data); 83 } else { 104 84 #endif 105 default: 106 break; 107 } 108 } else { 109 int comp[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 110 glTexImage2D(GL_TEXTURE_2D, 0, comp[n_components], width, height, 0, 111 GL_RGBA, type, data); 85 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 86 glTexImage2D(GL_TEXTURE_2D, 0, format[n_components], width, height, 0, 87 format[n_components], type, data); 88 #ifdef NV40 112 89 } 113 assert(glGetError()==0); 114 return id; 90 #endif 91 assert(glGetError() == 0); 92 93 gl_resource_allocated = true; 115 94 } 116 117 95 118 96 void … … 123 101 } 124 102 125 126 103 void 127 104 Texture2D::deactivate() … … 130 107 } 131 108 132 133 Texture2D:: ~Texture2D()109 void 110 Texture2D::check_max_size() 134 111 { 135 glDeleteTextures(1, &id);136 }137 138 139 void140 Texture2D::check_max_size(){141 112 GLint max = 0; 142 113 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max); … … 146 117 147 118 void 148 Texture2D::check_max_unit(){ 149 int max; 119 Texture2D::check_max_unit() 120 { 121 int max = 0; 150 122 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &max); 151 123 152 124 TRACE("max texture units: %d.\n", max); 153 125 } 154 -
trunk/packages/vizservers/nanovis/Texture2D.h
r2818 r2831 14 14 * ====================================================================== 15 15 */ 16 17 #ifndef _TEXTURE_2D_H_ 18 #define _TEXTURE_2D_H_ 16 #ifndef TEXTURE2D_H 17 #define TEXTURE2D_H 19 18 20 19 #include <GL/glew.h> … … 23 22 { 24 23 public: 25 int width; 26 int height; 24 Texture2D(); 27 25 28 GLuint type; 29 GLuint id; 30 GLuint interp_type; 31 int n_components; 26 Texture2D(int width, int height, 27 GLuint type = GL_FLOAT, 28 GLuint interp = GL_LINEAR, 29 int numComponents = 4, 30 void *data = NULL); 32 31 33 Texture2D(); 34 Texture2D(int width, int height, GLuint type, GLuint interp, int n, float* data); 35 ~Texture2D(); 36 37 void activate(); 38 void deactivate(); 39 void enable(); 40 void disable(); 41 GLuint initialize(float* data); 42 static void check_max_size(); 43 static void check_max_unit(); 32 ~Texture2D(); 33 34 GLuint initialize(void *data); 35 36 void update(void *data); 37 38 void activate(); 39 40 void deactivate(); 41 42 static void check_max_size(); 43 44 static void check_max_unit(); 45 46 int width; 47 int height; 48 49 int n_components; 50 51 bool gl_resource_allocated; 52 GLuint id; 53 GLuint type; 54 GLuint interp_type; 44 55 }; 45 56 -
trunk/packages/vizservers/nanovis/Texture3D.cpp
r2798 r2831 23 23 #include "config.h" 24 24 25 Texture3D::Texture3D(){ id=0; gl_resource_allocated = false; } 25 Texture3D::Texture3D() : 26 gl_resource_allocated(false), 27 id(0) 28 {} 26 29 27 Texture3D::Texture3D(int width, int height, int depth, GLuint type=GL_FLOAT, GLuint interp=GL_LINEAR, int components=4) 30 Texture3D::Texture3D(int width, int height, int depth, 31 GLuint type, GLuint interp, 32 int numComponents, void *data) : 33 gl_resource_allocated(false), 34 id(0) 28 35 { 29 assert(type == GL_UNSIGNED_BYTE || type == GL_FLOAT|| type ==GL_UNSIGNED_INT);30 assert(interp == GL_LINEAR || interp == GL_NEAREST);31 32 36 this->width = width; 33 37 this->height = height; … … 48 52 this->type = type; 49 53 this->interp_type = interp; 50 this->n_components = components;54 this->n_components = numComponents; 51 55 52 this->id = 0;53 gl_resource_allocated = false;56 if (data != NULL) 57 initialize(data); 54 58 } 55 59 56 void Texture3D::update(float* data)60 Texture3D::~Texture3D() 57 61 { 58 //load texture with 16 bit half floating point precision if card is 6 series NV40 59 //half float with linear interpolation is only supported by 6 series and up cards 60 //If NV40 not defined, data is quantized to 8-bit from 32-bit. 61 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 62 63 glBindTexture(GL_TEXTURE_3D, id); 64 assert(id != (GLuint)-1); 65 66 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 67 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 68 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); 69 70 if(interp_type==GL_LINEAR){ 71 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 72 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 73 } 74 else{ 75 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 76 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 77 } 78 79 //to do: add handling to more formats 80 if(type==GL_FLOAT){ 81 switch(n_components){ 82 #ifdef NV40 83 case 1: 84 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE16F_ARB, width, height, depth, 0, GL_LUMINANCE, GL_FLOAT, data); 85 break; 86 case 2: 87 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE_ALPHA16F_ARB, width, height, depth, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 88 break; 89 case 3: 90 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB, width, height, depth, 0, GL_RGB, GL_FLOAT, data); 91 break; 92 case 4: 93 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA16F_ARB, width, height, depth, 0, GL_RGBA, GL_FLOAT, data); 94 break; 95 #else 96 case 1: 97 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, width, height, depth, 0, GL_LUMINANCE, GL_FLOAT, data); 98 break; 99 case 2: 100 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE_ALPHA, width, height, depth, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 101 break; 102 case 3: 103 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, width, height, depth, 0, GL_RGB, GL_FLOAT, data); 104 break; 105 case 4: 106 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, width, height, depth, 0, GL_RGBA, GL_FLOAT, data); 107 break; 108 #endif 109 default: 110 break; 111 } 112 } 113 114 115 assert(glGetError()==0); 116 117 gl_resource_allocated = true; 118 62 glDeleteTextures(1, &id); 119 63 } 120 64 121 GLuint Texture3D::initialize( float*data)65 GLuint Texture3D::initialize(void *data) 122 66 { 123 if (id != 0) glDeleteTextures(1, &id); 67 if (id != 0) 68 glDeleteTextures(1, &id); 69 70 glGenTextures(1, &id); 71 72 update(data); 73 74 return id; 75 } 76 77 void Texture3D::update(void *data) 78 { 79 assert(id > 0 && id != (GLuint)-1); 80 glBindTexture(GL_TEXTURE_3D, id); 124 81 125 82 //load texture with 16 bit half floating point precision if card is 6 series NV40 … … 128 85 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 129 86 130 glGenTextures(1, &id);131 glBindTexture(GL_TEXTURE_3D, id);132 assert(id != (GLuint)-1);133 134 87 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 135 88 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 136 89 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); 137 90 138 if(interp_type==GL_LINEAR){ 139 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 140 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 141 } 142 else{ 143 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 144 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 145 } 91 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, interp_type); 92 glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, interp_type); 146 93 147 94 //to do: add handling to more formats 148 if(type==GL_FLOAT){149 switch(n_components){150 95 #ifdef NV40 151 case 1: 152 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE16F_ARB, width, height, depth, 0, GL_LUMINANCE, GL_FLOAT, data); 153 break; 154 case 2: 155 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE_ALPHA16F_ARB, width, height, depth, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 156 break; 157 case 3: 158 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB16F_ARB, width, height, depth, 0, GL_RGB, GL_FLOAT, data); 159 break; 160 case 4: 161 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA16F_ARB, width, height, depth, 0, GL_RGBA, GL_FLOAT, data); 162 break; 163 #else 164 case 1: 165 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE, width, height, depth, 0, GL_LUMINANCE, GL_FLOAT, data); 166 break; 167 case 2: 168 glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE_ALPHA, width, height, depth, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data); 169 break; 170 case 3: 171 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB, width, height, depth, 0, GL_RGB, GL_FLOAT, data); 172 break; 173 case 4: 174 glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, width, height, depth, 0, GL_RGBA, GL_FLOAT, data); 175 break; 96 if (type == GL_FLOAT) { 97 GLuint targetFormat[5] = { -1, GL_LUMINANCE16F_ARB, GL_LUMINANCE_ALPHA16F_ARB, GL_RGB16F_ARB, GL_RGBA16F_ARB }; 98 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 99 glTexImage3D(GL_TEXTURE_3D, 0, targetFormat[n_components], 100 width, height, depth, 0, 101 format[n_components], type, data); 102 } else { 176 103 #endif 177 default: 178 break; 179 } 104 GLuint format[5] = { -1, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; 105 glTexImage3D(GL_TEXTURE_3D, 0, format[n_components], 106 width, height, depth, 0, 107 format[n_components], type, data); 108 #ifdef NV40 180 109 } 181 110 #endif 182 111 183 112 assert(glGetError()==0); 184 113 185 114 gl_resource_allocated = true; 186 return id;187 115 } 188 116 … … 198 126 } 199 127 200 Texture3D::~Texture3D()128 void Texture3D::check_max_size() 201 129 { 202 glDeleteTextures(1, &id);203 }204 205 void Texture3D::check_max_size(){206 130 GLint max = 0; 207 131 glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT, &max); 208 209 //TRACE("%d", glGetError()); 132 210 133 TRACE("max 3d texture size: %d\n", max); 211 134 } 212 135 213 void Texture3D::check_max_unit(){ 136 void Texture3D::check_max_unit() 137 { 214 138 int max; 215 139 glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &max); -
trunk/packages/vizservers/nanovis/Texture3D.h
r2798 r2831 14 14 * ====================================================================== 15 15 */ 16 #ifndef _TEXTURE_3D_H_17 #define _TEXTURE_3D_H_16 #ifndef TEXTURE3D_H 17 #define TEXTURE3D_H 18 18 19 19 #include <GL/glew.h> 20 #include "config.h"21 20 22 class Texture3D{ 23 21 class Texture3D 22 { 23 public: 24 Texture3D(); 24 25 25 public: 26 int width; 27 int height; 28 int depth; 26 Texture3D(int width, int height, int depth, 27 GLuint type = GL_FLOAT, 28 GLuint interp = GL_LINEAR, 29 int numComponents = 4, 30 void *data = NULL); 29 31 30 double aspect_ratio_width; 31 double aspect_ratio_height; 32 double aspect_ratio_depth; 32 ~Texture3D(); 33 33 34 GLuint type; 35 GLuint interp_type; 36 int n_components; 37 bool gl_resource_allocated; 34 GLuint initialize(void *data); 38 35 39 GLuint id; 40 GLuint tex_unit; 36 void update(void *data); 41 37 42 Texture3D(); 43 Texture3D(int width, int height, int depth, GLuint type, GLuint interp, int n); 44 ~Texture3D(); 45 46 void activate(); 47 void deactivate(); 48 GLuint initialize(float* data); 49 static void check_max_size(); 50 static void check_max_unit(); 38 void activate(); 51 39 52 void update(float* data);40 void deactivate(); 53 41 42 static void check_max_size(); 43 44 static void check_max_unit(); 45 46 int width; 47 int height; 48 int depth; 49 50 double aspect_ratio_width; 51 double aspect_ratio_height; 52 double aspect_ratio_depth; 53 54 int n_components; 55 56 bool gl_resource_allocated; 57 GLuint id; 58 GLuint type; 59 GLuint interp_type; 60 //GLuint tex_unit; 54 61 }; 55 62 -
trunk/packages/vizservers/nanovis/Trace.cpp
r2822 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "nanovis.h"3 #include <Trace.h>4 2 #include <stdio.h> 5 3 #include <stdarg.h> 4 #include <syslog.h> 6 5 7 6 #include <GL/glew.h> 8 7 9 #include <syslog.h> 8 #include "nanovis.h" 9 #include "Trace.h" 10 10 11 11 static const char *syslogLevels[] = { -
trunk/packages/vizservers/nanovis/TransferFunction.cpp
r2820 r2831 21 21 TransferFunction::TransferFunction(int size, float *data) 22 22 { 23 _tex = new Texture1D(size, GL_FLOAT);24 25 23 // _size : # of slot, 4 : rgba 26 24 _size = size * 4; 27 25 _data = new float[_size]; 28 26 memcpy(_data, data, sizeof(float) * _size); 29 _tex->initialize_float_rgba(_data); 27 28 _tex = new Texture1D(size, GL_FLOAT, GL_LINEAR, 4, data); 30 29 _id = _tex->id; 31 30 } 32 33 31 34 32 TransferFunction::~TransferFunction() … … 38 36 } 39 37 40 void 41 TransferFunction::update(float *data)38 void 39 TransferFunction::update(float *data) 42 40 { 43 41 memcpy(_data, data, sizeof(float) * _size); 44 _tex->update _float_rgba(_data);42 _tex->update(_data); 45 43 } 46 44 47 48 void 45 void 49 46 TransferFunction::update(int size, float *data) 50 47 { -
trunk/packages/vizservers/nanovis/TransferFunction.h
r2820 r2831 24 24 class TransferFunction : public R2Object 25 25 { 26 int _size; //the resolution of the color map, how many 26 public: 27 TransferFunction(int size, float *data); 28 29 void update(float *data); 30 31 void update(int size, float *data); 32 33 GLuint id() 34 { 35 return _id; 36 } 37 38 void id(GLuint id) 39 { 40 _id = id; 41 } 42 43 Texture1D *getTexture() 44 { 45 return _tex; 46 } 47 48 float *getData() 49 { 50 return _data; 51 } 52 53 int getSize() const 54 { 55 return _size; 56 } 57 58 const char *name() const 59 { 60 return _name; 61 } 62 63 void name(const char *name) 64 { 65 _name = name; 66 } 67 68 static void sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret); 69 70 static void sample(float fraction, float *key, int count, float *keyValue, float *ret); 71 72 protected : 73 ~TransferFunction(); 74 75 private: 76 int _size; //the resolution of the color map, how many 27 77 //(RGBA) quadraples 28 78 float* _data; … … 30 80 const char *_name; 31 81 GLuint _id; //OpenGL's texture identifier 32 33 protected :34 ~TransferFunction();35 36 public:37 TransferFunction(int size, float *data);38 void update(float *data);39 void update(int size, float *data);40 GLuint id(void) {41 return _id;42 }43 void id(GLuint id) {44 _id = id;45 }46 Texture1D* getTexture(void) {47 return _tex;48 }49 float* getData(void) {50 return _data;51 }52 int getSize() const {53 return _size;54 }55 const char *name(void) const {56 return _name;57 }58 void name(const char *name) {59 _name = name;60 }61 62 static void sample(float fraction, float *key, int count, Vector3 *keyValue, Vector3 *ret);63 static void sample(float fraction, float *key, int count, float *keyValue, float *ret);64 82 }; 65 83 -
trunk/packages/vizservers/nanovis/Unirect.cpp
r2827 r2831 10 10 11 11 extern int GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 12 float *valuePtr); 12 float *valuePtr); 13 13 14 extern int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr); 14 15 -
trunk/packages/vizservers/nanovis/Unirect.h
r2822 r2831 13 13 class Unirect2d; 14 14 15 class Unirect3d { 15 class Unirect3d 16 { 17 public: 18 Unirect3d(float xMin, float xMax, size_t xNum, 19 float yMin, float yMax, size_t yNum, 20 float zMin, float zMax, size_t zNum, 21 size_t nValues, float *values, size_t nComponents) : 22 _xNum(xNum), _yNum(yNum), _zNum(zNum), 23 _nValues(nValues), 24 _nComponents(nComponents), 25 _xMin(xMin), _xMax(xMax), 26 _yMin(yMin), _yMax(yMax), 27 _zMin(zMin), _zMax(zMax), 28 _xValueMin(FLT_MAX), _xValueMax(-FLT_MAX), 29 _yValueMin(FLT_MAX), _yValueMax(-FLT_MAX), 30 _zValueMin(FLT_MAX), _zValueMax(-FLT_MAX), 31 _magMin(DBL_MAX), _magMax(-DBL_MAX), 32 _xUnits(NULL), _yUnits(NULL), _zUnits(NULL), _vUnits(NULL), 33 _values(NULL), 34 _initialized(false) 35 { 36 _initialized = true; 37 } 38 39 Unirect3d(size_t nComponents = 1) : 40 _nValues(0), 41 _nComponents(nComponents), 42 _xValueMin(FLT_MAX), _xValueMax(-FLT_MAX), 43 _yValueMin(FLT_MAX), _yValueMax(-FLT_MAX), 44 _zValueMin(FLT_MAX), _zValueMax(-FLT_MAX), 45 _magMin(DBL_MAX), _magMax(-DBL_MAX), 46 _xUnits(NULL), _yUnits(NULL), _zUnits(NULL), _vUnits(NULL), 47 _values(NULL), 48 _initialized(false) 49 { 50 _nComponents = nComponents; 51 } 52 53 ~Unirect3d() 54 { 55 if (_values != NULL) { 56 free(_values); 57 } 58 if (_xUnits != NULL) { 59 free(_xUnits); 60 } 61 if (_yUnits != NULL) { 62 free(_yUnits); 63 } 64 if (_zUnits != NULL) { 65 free(_zUnits); 66 } 67 if (_vUnits != NULL) { 68 free(_vUnits); 69 } 70 } 71 72 size_t xNum() 73 { 74 return _xNum; 75 } 76 77 size_t yNum() 78 { 79 return _yNum; 80 } 81 82 size_t zNum() 83 { 84 return _zNum; 85 } 86 87 float xMin() 88 { 89 return _xMin; 90 } 91 92 float yMin() 93 { 94 return _yMin; 95 } 96 97 float zMin() 98 { 99 return _zMin; 100 } 101 102 float xMax() 103 { 104 return _xMax; 105 } 106 107 float yMax() 108 { 109 return _yMax; 110 } 111 112 float zMax() 113 { 114 return _zMax; 115 } 116 117 float xValueMin() 118 { 119 return _xValueMin; 120 } 121 122 float yValueMin() 123 { 124 return _yValueMin; 125 } 126 127 float zValueMin() 128 { 129 return _zValueMin; 130 } 131 132 float xValueMax() 133 { 134 return _xValueMax; 135 } 136 137 float yValueMax() 138 { 139 return _yValueMax; 140 } 141 142 float zValueMax() 143 { 144 return _zValueMax; 145 } 146 147 size_t nComponents() 148 { 149 return _nComponents; 150 } 151 152 const char *xUnits() 153 { 154 return _xUnits; 155 } 156 157 const char *yUnits() 158 { 159 return _yUnits; 160 } 161 const char *zUnits() 162 { 163 return _zUnits; 164 } 165 166 const char *vUnits() 167 { 168 return _vUnits; 169 } 170 171 const float *values() 172 { 173 return _values; 174 } 175 176 double magMin() 177 { 178 if (_magMin == DBL_MAX) { 179 GetVectorRange(); 180 } 181 TRACE("magMin=%g %g\n", _magMin, DBL_MAX); 182 return _magMin; 183 } 184 185 double magMax() 186 { 187 if (_magMax == -DBL_MAX) { 188 GetVectorRange(); 189 } 190 TRACE("magMax=%g %g\n", _magMax, -DBL_MAX); 191 return _magMax; 192 } 193 194 const float *SaveValues() 195 { 196 float *values; 197 values = _values; 198 _values = NULL; 199 _nValues = 0; 200 return values; 201 } 202 203 size_t nValues() 204 { 205 return _nValues; 206 } 207 208 int LoadData(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); 209 210 int ParseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf); 211 212 bool ImportDx(Rappture::Outcome &result, size_t nComponents, 213 size_t length, char *string); 214 215 bool Convert(Unirect2d *dataPtr); 216 217 bool Resample(Rappture::Outcome &context, size_t nSamples = 30); 218 219 bool isInitialized() 220 { 221 return _initialized; 222 } 223 224 private: 225 void GetVectorRange(); 226 16 227 size_t _xNum, _yNum, _zNum; 17 228 size_t _nValues; … … 30 241 float *_values; 31 242 bool _initialized; 32 void GetVectorRange(void); 33 243 }; 244 245 class Unirect2d 246 { 34 247 public: 35 Unirect3d(float xMin, float xMax, size_t xNum, 36 float yMin, float yMax, size_t yNum, 37 float zMin, float zMax, size_t zNum, 38 size_t nValues, float *values, size_t nComponents) : 39 _xNum(xNum), _yNum(yNum), _zNum(zNum), 40 _nValues(nValues), 41 _nComponents(nComponents), 42 _xMin(xMin), _xMax(xMax), 43 _yMin(yMin), _yMax(yMax), 44 _zMin(zMin), _zMax(zMax), 45 _xValueMin(FLT_MAX), _xValueMax(-FLT_MAX), 46 _yValueMin(FLT_MAX), _yValueMax(-FLT_MAX), 47 _zValueMin(FLT_MAX), _zValueMax(-FLT_MAX), 48 _magMin(DBL_MAX), _magMax(-DBL_MAX), 49 _xUnits(NULL), _yUnits(NULL), _zUnits(NULL), _vUnits(NULL), 50 _values(NULL), 51 _initialized(false) 52 { 53 _initialized = true; 54 } 55 56 Unirect3d(size_t nComponents = 1) : 57 _nValues(0), 58 _nComponents(nComponents), 59 _xValueMin(FLT_MAX), _xValueMax(-FLT_MAX), 60 _yValueMin(FLT_MAX), _yValueMax(-FLT_MAX), 61 _zValueMin(FLT_MAX), _zValueMax(-FLT_MAX), 62 _magMin(DBL_MAX), _magMax(-DBL_MAX), 63 _xUnits(NULL), _yUnits(NULL), _zUnits(NULL), _vUnits(NULL), 64 _values(NULL), 65 _initialized(false) 66 { 67 _nComponents = nComponents; 68 } 69 ~Unirect3d(void) { 70 if (_values != NULL) { 71 free(_values); 72 } 73 if (_xUnits != NULL) { 74 free(_xUnits); 75 } 76 if (_yUnits != NULL) { 77 free(_yUnits); 78 } 79 if (_zUnits != NULL) { 80 free(_zUnits); 81 } 82 if (_vUnits != NULL) { 83 free(_vUnits); 84 } 85 } 86 size_t xNum(void) { 87 return _xNum; 88 } 89 size_t yNum(void) { 90 return _yNum; 91 } 92 size_t zNum(void) { 93 return _zNum; 94 } 95 float xMin(void) { 96 return _xMin; 97 } 98 float yMin(void) { 99 return _yMin; 100 } 101 float zMin(void) { 102 return _zMin; 103 } 104 float xMax(void) { 105 return _xMax; 106 } 107 float yMax(void) { 108 return _yMax; 109 } 110 float zMax(void) { 111 return _zMax; 112 } 113 float xValueMin(void) { 114 return _xValueMin; 115 } 116 float yValueMin(void) { 117 return _yValueMin; 118 } 119 float zValueMin(void) { 120 return _zValueMin; 121 } 122 float xValueMax(void) { 123 return _xValueMax; 124 } 125 float yValueMax(void) { 126 return _yValueMax; 127 } 128 float zValueMax(void) { 129 return _zValueMax; 130 } 131 size_t nComponents(void) { 132 return _nComponents; 133 } 134 const char *xUnits(void) { 135 return _xUnits; 136 } 137 const char *yUnits(void) { 138 return _yUnits; 139 } 140 const char *zUnits(void) { 141 return _zUnits; 142 } 143 const char *vUnits(void) { 144 return _vUnits; 145 } 146 const float *values(void) { 147 return _values; 148 } 149 double magMin(void) { 150 if (_magMin == DBL_MAX) { 151 GetVectorRange(); 152 } 153 TRACE("magMin=%g %g\n", _magMin, DBL_MAX); 154 return _magMin; 155 } 156 double magMax(void) { 157 if (_magMax == -DBL_MAX) { 158 GetVectorRange(); 159 } 160 TRACE("magMax=%g %g\n", _magMax, -DBL_MAX); 161 return _magMax; 162 } 163 const float *SaveValues(void) { 164 float *values; 165 values = _values; 166 _values = NULL; 167 _nValues = 0; 168 return values; 169 } 170 size_t nValues(void) { 171 return _nValues; 172 } 248 Unirect2d(size_t nComponents = 1) : 249 _xNum(0), _yNum(0), 250 _nValues(0), 251 _nComponents(nComponents), 252 _xUnits(NULL), _yUnits(NULL), _vUnits(NULL), 253 _values(NULL), 254 _initialized(false) 255 { 256 } 257 258 ~Unirect2d() 259 { 260 if (_values != NULL) { 261 free(_values); 262 } 263 if (_xUnits != NULL) { 264 free(_xUnits); 265 } 266 if (_yUnits != NULL) { 267 free(_yUnits); 268 } 269 if (_vUnits != NULL) { 270 free(_vUnits); 271 } 272 } 273 274 size_t xNum() 275 { 276 return _xNum; 277 } 278 279 size_t yNum() 280 { 281 return _yNum; 282 } 283 284 float xMin() 285 { 286 return _xMin; 287 } 288 289 float yMin() 290 { 291 return _yMin; 292 } 293 294 float xMax() 295 { 296 return _xMax; 297 } 298 299 float yMax() 300 { 301 return _yMax; 302 } 303 304 const char *xUnits() 305 { 306 return _xUnits; 307 } 308 309 const char *yUnits() 310 { 311 return _yUnits; 312 } 313 314 const char *vUnits() 315 { 316 return _vUnits; 317 } 318 319 float *values() 320 { 321 return _values; 322 } 323 324 float xValueMin() 325 { 326 return _xValueMin; 327 } 328 329 float yValueMin() 330 { 331 return _yValueMin; 332 } 333 334 float xValueMax() 335 { 336 return _xValueMax; 337 } 338 339 float yValueMax() 340 { 341 return _yValueMax; 342 } 343 344 size_t nComponents() 345 { 346 return _nComponents; 347 } 348 349 float *transferValues() 350 { 351 float *values; 352 values = _values; 353 _values = NULL; 354 _nValues = 0; 355 return values; 356 } 357 358 size_t nValues() 359 { 360 return _nValues; 361 } 362 173 363 int LoadData(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); 364 174 365 int ParseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf); 175 176 bool ImportDx(Rappture::Outcome &result, size_t nComponents, 177 size_t length, char *string); 178 bool Convert(Unirect2d *dataPtr); 179 bool Resample(Rappture::Outcome &context, size_t nSamples = 30); 180 bool isInitialized(void) { 181 return _initialized; 182 } 183 }; 184 185 class Unirect2d { 366 367 bool isInitialized() 368 { 369 return _initialized; 370 } 371 372 private: 186 373 size_t _xNum, _yNum; 187 374 size_t _nValues; … … 199 386 float *_values; 200 387 bool _initialized; 201 202 public:203 Unirect2d(size_t nComponents = 1) {204 _values = NULL;205 _initialized = false;206 _xNum = _yNum = 0;207 _nValues = 0;208 _xUnits = _yUnits = _vUnits = NULL;209 _nComponents = nComponents;210 }211 ~Unirect2d(void) {212 if (_values != NULL) {213 free(_values);214 }215 if (_xUnits != NULL) {216 free(_xUnits);217 }218 if (_yUnits != NULL) {219 free(_yUnits);220 }221 if (_vUnits != NULL) {222 free(_vUnits);223 }224 }225 size_t xNum(void) {226 return _xNum;227 }228 size_t yNum(void) {229 return _yNum;230 }231 float xMin(void) {232 return _xMin;233 }234 float yMin(void) {235 return _yMin;236 }237 float xMax(void) {238 return _xMax;239 }240 float yMax(void) {241 return _yMax;242 }243 const char *xUnits(void) {244 return _xUnits;245 }246 const char *yUnits(void) {247 return _yUnits;248 }249 const char *vUnits(void) {250 return _vUnits;251 }252 float *values(void) {253 return _values;254 }255 float xValueMin(void) {256 return _xValueMin;257 }258 float yValueMin(void) {259 return _yValueMin;260 }261 float xValueMax(void) {262 return _xValueMax;263 }264 float yValueMax(void) {265 return _yValueMax;266 }267 size_t nComponents(void) {268 return _nComponents;269 }270 float *transferValues(void) {271 float *values;272 values = _values;273 _values = NULL;274 _nValues = 0;275 return values;276 }277 size_t nValues(void) {278 return _nValues;279 }280 int LoadData(Tcl_Interp *interp, int objc, Tcl_Obj *const *objv);281 int ParseBuffer(Tcl_Interp *interp, Rappture::Buffer &buf);282 bool isInitialized(void) {283 return _initialized;284 }285 388 }; 286 389 287 390 } 288 391 289 #endif /*_UNIRECT_H*/290 392 #endif 393 -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.cpp
r2822 r2831 3 3 4 4 #include <GL/glew.h> 5 #ifdef _WIN326 #include <windows.h>7 #endif8 5 #include <GL/gl.h> 9 #ifdef WIN3210 #include <GL/glaux.h>11 #else12 6 #ifdef HAVE_OPENCV_H 13 7 #include <opencv/cv.h> … … 16 10 #include <opencv/highgui.h> 17 11 #endif 18 #endif 12 13 #include <R2/R2FilePath.h> 19 14 20 15 #include "VelocityArrowsSlice.h" 21 22 #ifdef USE_NANOVIS_LIB23 16 #include "global.h" 24 #include "R2/R2FilePath.h"25 #endif26 27 #define USE_VERTEX_BUFFER28 17 29 18 VelocityArrowsSlice::VelocityArrowsSlice() … … 38 27 //_renderMode = GLYPHS; 39 28 _renderMode = LINES; 40 29 41 30 _tickCountForMinSizeAxis = 10; 42 31 43 32 _queryVelocityFP = 44 #ifdef USE_NANOVIS_LIB45 33 LoadCgSourceProgram(_context, "queryvelocity.cg", CG_PROFILE_FP30, "main"); 46 #else 47 cgCreateProgramFromFile(_context, CG_SOURCE, "queryvelocity.cg", 48 CG_PROFILE_FP30, "main", NULL); 49 cgGLLoadProgram(_queryVelocityFP); 50 #endif 34 51 35 _qvVectorFieldParam = cgGetNamedParameter(_queryVelocityFP, "vfield"); 52 36 … … 70 54 /* 71 55 _particleVP = 72 #ifdef USE_NANOVIS_LIB73 56 LoadCgSourceProgram(_context, "velocityslicevp.cg", CG_PROFILE_VP40, "vpmain"); 74 #else 75 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicevp.cg", 76 CG_PROFILE_VP40, "vpmain", NULL); 77 cgGLLoadProgram(_particleVP); 78 #endif 57 79 58 _mvpParticleParam = cgGetNamedParameter(_particleVP, "mvp"); 80 59 _mvParticleParam = cgGetNamedParameter(_particleVP, "modelview"); … … 83 62 // TBD.. 84 63 _particleFP = 85 #ifdef USE_NANOVIS_LIB86 64 LoadCgSourceProgram(_context, "velocityslicefp.cg", CG_PROFILE_FP40, "fpmain"); 87 #else 88 cgCreateProgramFromFile(_context, CG_SOURCE, "velocityslicefp.cg", 89 CG_PROFILE_FP40, "fpmain", NULL); 90 cgGLLoadProgram(_particleFP); 91 #endif 65 92 66 _vectorParticleParam = cgGetNamedParameter(_particleVP, "vfield"); 93 67 */ 94 68 95 #ifdef USE_NANOVIS_LIB96 97 #ifdef WIN3298 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp");99 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data);100 101 _arrowsTex = new Texture2D(pTextureImage->sizeX, pTextureImage->sizeY, GL_FLOAT, GL_LINEAR, 3, (void*) pTextureImage->data);102 103 //delete pTextureImage;104 #else105 69 /* 106 70 TRACE("test1\n"); … … 115 79 if (pTextureImage) { 116 80 TRACE("file(%s) has been loaded\n", path); 117 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, (float*) pTextureImage->imageData); 81 _arrowsTex = new Texture2D(pTextureImage->width, pTextureImage->height, GL_FLOAT, GL_LINEAR, 3, pTextureImage->imageData); 82 //_arrowsTex->setWrapS(TW_MIRROR); 83 //_arrowsTex->setWrapT(TW_MIRROR); 118 84 TRACE("file(%s) has been loaded\n", path); 119 85 //cvReleaseImage(&pTextureImage); … … 124 90 */ 125 91 126 #endif127 128 #else129 _arrowsTex = new Texture2D();130 _arrowsTex->setWrapS(TW_MIRROR);131 _arrowsTex->setWrapT(TW_MIRROR);132 #ifdef WIN32133 AUX_RGBImageRec *pTextureImage = auxDIBImageLoad("arrows.bmp");134 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->sizeX, pTextureImage->sizeY, (void*) pTextureImage->data);135 136 //delete pTextureImage;137 #else138 IplImage* pTextureImage = cvLoadImage("arrows_flip2.png");139 _arrowsTex->setPixels(CF_RGB, DT_UBYTE, pTextureImage->width, pTextureImage->height, (void*) pTextureImage->imageData);140 141 //cvReleaseImage(&pTextureImage);142 #endif143 144 #endif145 92 _arrowColor.set(1, 1, 0); 146 93 … … 155 102 glDeleteFramebuffersEXT(1, &_fbo); 156 103 157 #ifdef USE_NANOVIS_LIB158 104 delete _arrowsTex; 159 #else 160 _arrowsTex->unref(); 161 #endif 105 162 106 cgDestroyProgram(_particleFP); 163 107 cgDestroyProgram(_particleVP); … … 173 117 174 118 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbo); 175 119 176 120 glViewport(0, 0, _renderTargetWidth, _renderTargetHeight); 177 121 glMatrixMode(GL_PROJECTION); … … 190 134 _renderTargetWidth, _renderTargetHeight, 0, 191 135 GL_RGBA, GL_FLOAT, NULL); 192 136 193 137 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 194 138 GL_TEXTURE_RECTANGLE_NV, _tex, 0); … … 280 224 281 225 glPushMatrix(); 282 226 283 227 glScalef(_vfXscale,_vfYscale, _vfZscale); 284 228 glTranslatef(-0.5f, -0.5f, -0.5f); … … 317 261 pos = _samplingPositions[index]; 318 262 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 319 263 320 264 glVertex3f(pos.x, pos.y, pos.z); 321 265 glVertex3f(pos2.x, pos2.y, pos2.z); … … 328 272 pos = _samplingPositions[index]; 329 273 pos2 = this->_velocities[index].scale(_projectionVector).scale(_maxVelocityScale) + pos; 330 274 331 275 glVertex3f(pos.x, pos.y, pos.z); 332 276 glVertex3f(pos2.x, pos2.y, pos2.z); … … 344 288 glPointSize(20); 345 289 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 346 347 #ifdef USE_NANOVIS_LIB 290 348 291 _arrowsTex->activate(); 349 #else350 _arrowsTex->bind(0);351 292 glEnable(GL_TEXTURE_2D); 352 #endif 293 353 294 glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 0.0f ); 354 295 355 296 glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, 1.0f); 356 297 glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, 100.0f); 357 298 glTexEnvf( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE ); 358 299 359 300 cgGLBindProgram(_particleVP); 360 301 cgGLBindProgram(_particleFP); 361 302 cgGLEnableProfile(CG_PROFILE_VP40); 362 303 cgGLEnableProfile(CG_PROFILE_FP40); 363 304 364 305 cgGLSetTextureParameter(_vectorParticleParam, _vectorFieldGraphicsID); 365 306 cgGLEnableTextureParameter(_vectorParticleParam); 366 367 307 368 308 //cgSetParameter1f(_mvTanHalfFOVParam, -tan(_fov * 0.5) * _screenHeight * 0.5); 369 309 370 310 cgGLSetStateMatrixParameter(_mvpParticleParam, 371 311 CG_GL_MODELVIEW_PROJECTION_MATRIX, … … 374 314 CG_GL_MODELVIEW_MATRIX, 375 315 CG_GL_MATRIX_IDENTITY); 376 316 377 317 glEnableClientState(GL_VERTEX_ARRAY); 378 318 glBindBufferARB(GL_ARRAY_BUFFER_ARB, _vertexBufferGraphicsID); 379 319 glVertexPointer(3, GL_FLOAT, 0, 0); 380 320 //glEnableClientState(GL_COLOR_ARRAY); 381 321 382 322 // TBD.. 383 323 glDrawArrays(GL_POINTS, 0, _pointCount); 384 324 glPointSize(1); 385 325 glDrawArrays(GL_POINTS, 0, _pointCount); 386 326 387 327 glDisableClientState(GL_VERTEX_ARRAY); 388 328 389 329 cgGLDisableProfile(CG_PROFILE_VP40); 390 330 cgGLDisableProfile(CG_PROFILE_FP40); 391 331 392 332 glDepthMask(GL_TRUE); 393 333 394 334 glDisable(GL_POINT_SPRITE_NV); 395 335 glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_NV); 396 336 397 337 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 398 338 glDisable(GL_BLEND); 399 #ifdef USE_NANOVIS_LIB 400 _arrowsTex->deactivate(); 401 #else 402 _arrowsTex->unbind(); 403 #endif 339 _arrowsTex->deactivate(); 404 340 } 405 341 glPopMatrix(); 406 342 } 407 408 343 409 344 void … … 416 351 _vfZscale = zScale; 417 352 418 //_dirty = true;419 }420 421 void VelocityArrowsSlice::tickCountForMinSizeAxis(int tickCount)422 {423 _tickCountForMinSizeAxis = tickCount;424 425 353 //_dirty = true; 426 354 } … … 561 489 } 562 490 } 563 564 void VelocityArrowsSlice::slicePos(float pos)565 {566 _slicePos = pos;567 _dirty = true;568 } -
trunk/packages/vizservers/nanovis/VelocityArrowsSlice.h
r2822 r2831 7 7 #include <vector> 8 8 9 #define USE_NANOVIS_LIB10 11 #ifdef USE_NANOVIS_LIB12 9 #include "Texture2D.h" 13 10 #include "Vector3.h" 14 #else15 #include <vr3d/vrTexture2D.h>16 17 typedef vrTexture2D Texture2D;18 19 class Vector320 {21 public:22 float x, y, z;23 24 Vector3() :25 x(0.0f), y(0.0f), z(0.0f)26 {}27 28 Vector3(float x1, float y1, float z1) :29 x(x1), y(y1), z(z1)30 {}31 32 Vector3 operator*(float scale)33 {34 Vector3 vec;35 vec.x = x * scale;36 vec.y = y * scale;37 vec.z = z * scale;38 return vec;39 }40 41 Vector3 scale(const Vector3& scale)42 {43 Vector3 vec;44 vec.x = x * scale.x;45 vec.y = y * scale.y;46 vec.z = z * scale.z;47 return vec;48 }49 50 Vector3 operator*(const Vector3& scale)51 {52 Vector3 vec;53 vec.x = x * scale.x;54 vec.y = y * scale.y;55 vec.z = z * scale.z;56 return vec;57 }58 59 friend Vector3 operator+(const Vector3& value1, const Vector3& value2);60 61 void set(float x1, float y1, float z1)62 {63 x = x1; y = y1; z = z1;64 }65 };66 67 inline Vector3 operator+(const Vector3& value1, const Vector3& value2)68 {69 return Vector3(value1.x + value2.x, value1.y + value2.y, value1.z + value2.z);70 }71 72 #endif73 74 11 75 12 class VelocityArrowsSlice … … 80 17 GLYPHS, 81 18 }; 19 20 VelocityArrowsSlice(); 21 22 ~VelocityArrowsSlice(); 23 24 void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale); 25 26 void axis(int axis); 27 28 int axis() const 29 { 30 return _axis; 31 } 32 33 void slicePos(float pos) 34 { 35 _slicePos = pos; 36 _dirty = true; 37 } 38 39 float slicePos() const 40 { 41 return _slicePos; 42 } 43 44 void queryVelocity(); 45 46 void render(); 47 48 void enabled(bool enabled) 49 { 50 _enabled = enabled; 51 } 52 53 bool enabled() const 54 { 55 return _enabled; 56 } 57 58 void tickCountForMinSizeAxis(int tickCount) 59 { 60 _tickCountForMinSizeAxis = tickCount; 61 } 62 63 int tickCountForMinSizeAxis() const 64 { 65 return _tickCountForMinSizeAxis; 66 } 67 68 void arrowColor(const Vector3& color) 69 { 70 _arrowColor = color; 71 } 72 73 void renderMode(RenderMode mode) 74 { 75 _renderMode = mode; 76 _dirty = true; 77 } 78 79 RenderMode renderMode() const 80 { 81 return _renderMode; 82 } 82 83 83 84 private: … … 133 134 134 135 void createRenderTarget(); 136 135 137 void computeSamplingTicks(); 136 137 public:138 VelocityArrowsSlice();139 ~VelocityArrowsSlice();140 141 void vectorField(unsigned int vfGraphicsID, float xScale, float yScale, float zScale);142 void axis(int axis);143 int axis() const;144 void slicePos(float pos);145 float slicePos() const;146 void queryVelocity();147 void render();148 void enabled(bool enabled)149 {150 _enabled = enabled;151 }152 bool enabled() const153 {154 return _enabled;155 }156 void tickCountForMinSizeAxis(int tickCount);157 int tickCountForMinSizeAxis() const;158 void arrowColor(const Vector3& color);159 void renderMode(RenderMode mode);160 RenderMode renderMode() const;161 138 }; 162 139 163 inline int VelocityArrowsSlice::axis() const164 {165 return _axis;166 }167 168 inline float VelocityArrowsSlice::slicePos() const169 {170 return _slicePos;171 }172 173 174 inline int VelocityArrowsSlice::tickCountForMinSizeAxis() const175 {176 return _tickCountForMinSizeAxis;177 }178 179 inline void VelocityArrowsSlice::arrowColor(const Vector3& color)180 {181 _arrowColor = color;182 }183 184 inline void VelocityArrowsSlice::renderMode(VelocityArrowsSlice::RenderMode mode)185 {186 _renderMode = mode;187 _dirty = true;188 }189 190 inline VelocityArrowsSlice::RenderMode VelocityArrowsSlice::renderMode() const191 {192 return _renderMode;193 }194 195 140 #endif -
trunk/packages/vizservers/nanovis/config.h
r2827 r2831 31 31 * we'll rely on developers to set this in their respective sandboxes. 32 32 */ 33 //#define PROTOTYPE 0 34 #define PROTOTYPE 1 33 #define PROTOTYPE 0 35 34 36 35 #define NEW_FLOW_ENGINE 1 -
trunk/packages/vizservers/nanovis/define.h
r2822 r2831 14 14 * ====================================================================== 15 15 */ 16 #ifndef _DEFINE_H_17 #define _DEFINE_H_16 #ifndef DEFINE_H 17 #define DEFINE_H 18 18 19 19 #include <GL/glew.h> -
trunk/packages/vizservers/nanovis/dxReader.cpp
r2828 r2831 18 18 * ====================================================================== 19 19 */ 20 21 // common dx functions22 #include "dxReaderCommon.h"23 24 20 #include <stdio.h> 25 21 #include <math.h> … … 31 27 #include <unistd.h> 32 28 29 #include <RpField1D.h> 30 #include <RpFieldRect3D.h> 31 #include <RpFieldPrism3D.h> 32 33 // common dx functions 34 #include "dxReaderCommon.h" 35 33 36 #include "nanovis.h" 34 #include "RpField1D.h" 35 #include "RpFieldRect3D.h" 36 #include "RpFieldPrism3D.h" 37 #include <Unirect.h> 38 39 //transfer function headers 37 #include "Unirect.h" 40 38 #include "ZincBlendeVolume.h" 41 39 #include "NvZincBlendeReconstructor.h" -
trunk/packages/vizservers/nanovis/global.h
r2822 r2831 11 11 * ====================================================================== 12 12 */ 13 #ifndef _GLOBAL_H_14 #define _GLOBAL_H_13 #ifndef GLOBAL_H 14 #define GLOBAL_H 15 15 16 16 #include <GL/glew.h> 17 17 #include <Cg/cgGL.h> 18 18 19 #include <Trace.h>19 #include "Trace.h" 20 20 21 21 inline void … … 42 42 43 43 extern CGprogram LoadCgSourceProgram(CGcontext context, const char *filename, 44 44 CGprofile profile, const char *entryPoint); 45 45 46 46 #endif -
trunk/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "BMPImageLoaderImpl.h"3 #include "Image.h"4 2 #include <stdio.h> 5 3 #include <memory.h> 6 4 #include <stdlib.h> 5 6 #include "BMPImageLoaderImpl.h" 7 #include "Image.h" 7 8 8 9 BMPImageLoaderImpl::BMPImageLoaderImpl() … … 15 16 16 17 // I referred to cjbackhouse@hotmail.com www.backhouse.tk 17 Image * BMPImageLoaderImpl::load(const char*fileName)18 Image *BMPImageLoaderImpl::load(const char *fileName) 18 19 { 19 20 printf("BMP loader\n"); 20 21 fflush(stdout); 21 Image * image = 0;22 Image *image = NULL; 22 23 23 24 printf("opening image file \"%s\"\n", fileName); 24 FILE *f = fopen(fileName, "rb");25 FILE *f = fopen(fileName, "rb"); 25 26 26 27 if (!f) { … … 31 32 char header[54]; 32 33 if (fread(&header, 54, 1, f) != 1) { 33 34 35 } ;34 printf("can't read header of BMP file\n"); 35 return 0; 36 } 36 37 37 38 if (header[0] != 'B' || header[1] != 'M') { 38 39 39 printf("File is not BMP format\n"); 40 return 0; 40 41 } 41 42 42 43 //it seems gimp sometimes makes its headers small, so we have to do 43 44 //this. hence all the fseeks 44 int offset=*(unsigned int*)(header+10); 45 46 const unsigned int width =*(int*) (header+18); 47 const unsigned int height =*(int*) (header+22); 45 int offset = *(unsigned int*)(header+10); 48 46 49 int bits=int(header[28]); //colourdepth 47 const unsigned int width = *(int*)(header+18); 48 const unsigned int height = *(int*)(header+22); 49 50 int bits = int(header[28]); //colourdepth 50 51 51 52 printf("image width = %d height = %d bits=%d\n", width, height, bits); 52 53 fflush(stdout); 53 54 54 55 image = new Image(width, height, _targetImageFormat, 55 Image::IMG_UNSIGNED_BYTE, 0);56 Image::IMG_UNSIGNED_BYTE, NULL); 56 57 57 58 printf("image created\n"); 58 59 fflush(stdout); 59 60 60 unsigned char * bytes = (unsigned char*)image->getImageBuffer();61 unsigned char *bytes = (unsigned char *)image->getImageBuffer(); 61 62 memset(bytes, 0, sizeof(unsigned char) * width * height * _targetImageFormat); 62 63 … … 64 65 fflush(stdout); 65 66 66 unsigned int x, y;67 unsigned int x, y; 67 68 unsigned char cols[256*4]; //colourtable 68 switch (bits) {69 switch (bits) { 69 70 case 24: 70 fseek(f,offset,SEEK_SET);71 72 if (fread(bytes,width*height*3,1,f) != 1) {73 74 75 for(x=0;x<width*height*3;x+=3) { //except the format is BGR, grr76 77 78 79 80 81 char* buff = (char*)malloc(width * height * sizeof(unsigned char) * 3);82 if (fread(buff,width*height*3,1,f) != 1) {83 84 85 for(x=0, y = 0;x<width*height*3;x+=3, y+=4){ //except the format is BGR, grr86 87 88 89 90 91 92 71 fseek(f, offset, SEEK_SET); 72 if (_targetImageFormat == Image::IMG_RGB) { 73 if (fread(bytes, width*height*3, 1, f) != 1) { 74 fprintf(stderr, "can't read image data\n"); 75 } 76 for (x = 0; x < width*height*3; x += 3) { //except the format is BGR, grr 77 unsigned char temp = bytes[x]; 78 bytes[x] = bytes[x+2]; 79 bytes[x+2] = temp; 80 } 81 } else if (_targetImageFormat == Image::IMG_RGBA) { 82 char *buff = (char*)malloc(width * height * sizeof(unsigned char) * 3); 83 if (fread(buff, width*height*3, 1, f) != 1) { 84 fprintf(stderr, "can't read BMP image data\n"); 85 } 86 for (x = 0, y = 0; x < width*height*3; x += 3, y += 4) { //except the format is BGR, grr 87 bytes[y] = buff[x+2]; 88 bytes[y+2] = buff[x]; 89 bytes[y+3] = 255; 90 } 91 free(buff); 92 } 93 break; 93 94 case 32: 94 fseek(f,offset,SEEK_SET); 95 if (_targetImageFormat == Image::IMG_RGBA) { 96 if (fread(bytes,width*height*4,1,f) != 1) { 97 fprintf(stderr, "can't read image data\n"); 98 } 99 for(x=0;x<width*height*4;x+=4) { //except the format is BGR, grr 100 unsigned char temp = bytes[x]; 101 bytes[x] = bytes[x+2]; 102 bytes[x+2] = temp; 103 } 104 } 105 else if (_targetImageFormat == Image::IMG_RGB) { 106 char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3); 107 if (fread(buff,width*height*4,1,f) != 1) { 108 fprintf(stderr, "can't read BMP image data\n"); 109 } 110 for(x=0, y = 0;x<width*height*4;x+=4, y+=3) { //except the format is BGR, grr 111 bytes[y] = buff[x+2]; 112 bytes[y+2] = buff[x]; 113 } 114 free(buff); 115 } 116 break; 95 fseek(f, offset, SEEK_SET); 96 if (_targetImageFormat == Image::IMG_RGBA) { 97 if (fread(bytes, width*height*4, 1, f) != 1) { 98 fprintf(stderr, "can't read image data\n"); 99 } 100 for (x = 0; x < width*height*4; x += 4) { //except the format is BGR, grr 101 unsigned char temp = bytes[x]; 102 bytes[x] = bytes[x+2]; 103 bytes[x+2] = temp; 104 } 105 } else if (_targetImageFormat == Image::IMG_RGB) { 106 char *buff = (char*)malloc(width * height * sizeof(unsigned char) * 3); 107 if (fread(buff, width*height*4, 1, f) != 1) { 108 fprintf(stderr, "can't read BMP image data\n"); 109 } 110 for (x = 0, y = 0; x < width*height*4; x += 4, y += 3) { //except the format is BGR, grr 111 bytes[y] = buff[x+2]; 112 bytes[y+2] = buff[x]; 113 } 114 free(buff); 115 } 116 break; 117 117 case 8: 118 if (fread(cols,256 * 4,1,f) != 1) { 119 fprintf(stderr, "can't read colortable from BMP file\n"); 120 } 121 fseek(f,offset,SEEK_SET); 122 for(y=0;y<height;++y) { //(Notice 4bytes/col for some reason) 123 for(x=0;x<width;++x) { 124 unsigned char byte; 125 if (fread(&byte,1,1,f) != 1) { 126 fprintf(stderr, "error reading BMP file\n"); 127 } 128 for(int c=0; c< 3; ++c) { 129 //bytes[(y*width+x)*3+c] = cols[byte*4+2-c]; //and look up in the table 130 bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c]; //and look up in the table 131 } 132 } 133 } 134 break; 135 /* 136 case(4): 137 fread(cols,16*4,1,f); 138 fseek(f,offset,SEEK_SET); 139 for(y=0;y<256;++y) 140 for(x=0;x<256;x+=2) 141 { 142 BYTE byte; 143 fread(&byte,1,1,f); //as above, but need to exract two 144 145 for(c=0;c<_targetImageFormat;++c) //pixels from each byte 146 bmp.pixel(x,y,c)=cols[byte/16*4+2-c]; 118 if (fread(cols, 256 * 4, 1, f) != 1) { 119 fprintf(stderr, "can't read colortable from BMP file\n"); 120 } 121 fseek(f,offset,SEEK_SET); 122 for (y = 0; y < height; ++y) { //(Notice 4bytes/col for some reason) 123 for (x = 0; x < width; ++x) { 124 unsigned char byte; 125 if (fread(&byte, 1, 1, f) != 1) { 126 fprintf(stderr, "error reading BMP file\n"); 127 } 128 for (int c = 0; c < 3; ++c) { 129 //bytes[(y*width+x)*3+c] = cols[byte*4+2-c]; //and look up in the table 130 bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c]; //and look up in the table 131 } 132 } 133 } 134 break; 135 } 147 136 148 for(c=0;c<_targetImageFormat;++c)149 bmp.pixel(x+1,y,c)=cols[byte%16*4+2-c];150 */151 }152 153 137 printf("image initialized\n"); 154 138 fflush(stdout); -
trunk/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __BMP_IMAGE_LOADER_IMPL_H__3 #define __BMP_IMAGE_LOADER_IMPL_H__2 #ifndef BMP_IMAGE_LOADER_IMPL_H 3 #define BMP_IMAGE_LOADER_IMPL_H 4 4 5 5 #include <ImageLoaderImpl.h> 6 6 7 class BMPImageLoaderImpl : public ImageLoaderImpl { 8 public : 7 class BMPImageLoaderImpl : public ImageLoaderImpl 8 { 9 public: 9 10 BMPImageLoaderImpl(); 10 ~BMPImageLoaderImpl();11 11 12 public : 13 virtual Image* load(const char* fileName); 12 virtual ~BMPImageLoaderImpl(); 14 13 14 virtual Image *load(const char *fileName); 15 15 }; 16 #endif /* __BMP_IMAGE_LOADER_IMPL_H__ */16 #endif -
trunk/packages/vizservers/nanovis/imgLoaders/Image.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include "Image.h"3 2 #include <memory.h> 4 3 #include <stdlib.h> 5 4 5 #include "Image.h" 6 6 7 Image::Image(const unsigned int width, const unsigned int height, 7 const ImageFormat format, const Image::DataType type, void * data ) :8 _width(width), 9 _height(height), 8 const ImageFormat format, const Image::DataType type, void *data) : 9 _width(width), 10 _height(height), 10 11 _format(format), 11 _dataType(type) 12 _dataType(type) 12 13 { 13 switch (type) 14 { 15 case IMG_UNSIGNED_BYTE : 14 switch (type) { 15 case IMG_UNSIGNED_BYTE: 16 16 _dataTypeByteSize = 1; 17 17 break; 18 case IMG_FLOAT 18 case IMG_FLOAT: 19 19 _dataTypeByteSize = 4; 20 20 break; … … 24 24 _dataBuffer = malloc(width * height * format * _dataTypeByteSize); 25 25 26 if (data != 0) 27 { 26 if (data != NULL) { 28 27 memcpy(_dataBuffer, data, width *height * format * _dataTypeByteSize); 29 } 30 else 31 { 28 } else { 32 29 memset(_dataBuffer, 0, width * height * format * _dataTypeByteSize); 33 30 } 34 31 } 35 36 32 37 33 Image::~Image() -
trunk/packages/vizservers/nanovis/imgLoaders/Image.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __IMAGE_H__3 #define __IMAGE_H__2 #ifndef IMAGE_H 3 #define IMAGE_H 4 4 5 class Image { 6 public : 5 class Image 6 { 7 public: 7 8 enum DataType { 8 9 IMG_UNSIGNED_BYTE, … … 15 16 }; 16 17 17 private : 18 Image(const unsigned int width, const unsigned int height, 19 const ImageFormat format, const DataType dataType, void *data = NULL); 20 21 ~Image(); 22 23 unsigned int getWidth() const 24 { 25 return _width; 26 } 27 28 unsigned int getHeight() const 29 { 30 return _height; 31 } 32 33 unsigned int getComponentCount() const 34 { 35 return (unsigned int)_format; 36 } 37 38 unsigned int getDataTypeByteSize() const 39 { 40 return _dataTypeByteSize; 41 } 42 43 DataType getDataType() const 44 { 45 return _dataType; 46 } 47 48 void *getImageBuffer() 49 { 50 return _dataBuffer; 51 } 52 53 private: 18 54 const unsigned int _width; 19 55 const unsigned int _height; … … 21 57 DataType _dataType; 22 58 unsigned int _dataTypeByteSize; 23 void* _dataBuffer; 24 public : 25 26 Image(const unsigned int width, const unsigned int height, const ImageFormat format, const DataType dataType, void* data = 0); 27 ~Image(); 28 29 unsigned int getWidth() const; 30 unsigned int getHeight() const; 31 unsigned int getComponentCount() const; 32 unsigned int getDataTypeByteSize() const; 33 DataType getDataType() const; 34 void* getImageBuffer(); 59 void *_dataBuffer; 35 60 }; 36 61 37 inline void* Image::getImageBuffer() 38 { 39 return _dataBuffer; 40 } 62 #endif 41 63 42 inline unsigned int Image::getWidth() const43 {44 return _width;45 }46 47 inline unsigned int Image::getHeight() const48 {49 return _height;50 }51 52 inline unsigned int Image::getComponentCount() const53 {54 return (unsigned int) _format;55 }56 57 inline Image::DataType Image::getDataType() const58 {59 return _dataType;60 }61 62 inline unsigned int Image::getDataTypeByteSize() const63 {64 return _dataTypeByteSize;65 }66 67 #endif //68 -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoader.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <stdio.h> 3 4 #include <map> 5 #include <string> 6 2 7 #include "ImageLoader.h" 3 8 #include "ImageLoaderImpl.h" 4 #include <map>5 #include <string>6 #include <stdio.h>7 9 8 ImageLoader::ImageLoader() 9 : _loaderImpl(0)10 ImageLoader::ImageLoader() : 11 _loaderImpl(NULL) 10 12 { 11 13 } 12 14 13 Image * ImageLoader::load(const char* fileName)15 Image *ImageLoader::load(const char* fileName, const Image::ImageFormat format) 14 16 { 15 if (_loaderImpl) 16 { 17 _loaderImpl->_targetImageFormat = Image::IMG_RGB; 18 return _loaderImpl->load(fileName); 19 } 20 21 return 0; 22 } 23 24 Image* ImageLoader::load(const char* fileName, const Image::ImageFormat format) 25 { 26 if (_loaderImpl) 27 { 17 if (_loaderImpl) { 28 18 _loaderImpl->_targetImageFormat = format; 29 19 return _loaderImpl->load(fileName); 30 20 } 31 21 32 22 return 0; 33 23 } 34 35 -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoader.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __IMAGE_LOADER_H__3 #define __IMAGE_LOADER_H__2 #ifndef IMAGE_LOADER_H 3 #define IMAGE_LOADER_H 4 4 5 5 #include <map> 6 6 7 #include <Image.h> 7 8 … … 9 10 class Image; 10 11 11 class ImageLoader { 12 class ImageLoader 13 { 14 public: 12 15 friend class ImageLoaderFactory; 13 16 14 ImageLoaderImpl* _loaderImpl;15 public :16 17 ImageLoader(); 17 18 18 public : 19 Image* load(const char* fileName); 20 Image* load(const char* fileName, const Image::ImageFormat targetFormat); 19 Image *load(const char *fileName, const Image::ImageFormat targetFormat = Image::IMG_RGB); 21 20 22 private : 23 void setLoaderImpl(ImageLoaderImpl* loaderImpl); 21 private: 22 void setLoaderImpl(ImageLoaderImpl *loaderImpl) 23 { 24 _loaderImpl = loaderImpl; 25 } 26 27 ImageLoaderImpl * _loaderImpl; 24 28 }; 25 29 26 inline void ImageLoader::setLoaderImpl(ImageLoaderImpl* loaderImpl) 27 { 28 _loaderImpl= loaderImpl; 29 } 30 #endif 30 31 31 #endif //32 -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderFactory.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <stdio.h> 3 4 #include <map> 5 #include <string> 6 2 7 #include "ImageLoader.h" 3 8 #include "ImageLoaderImpl.h" 4 9 #include "ImageLoaderFactory.h" 5 #include <map>6 #include <string>7 #include <stdio.h>8 10 9 ImageLoaderFactory * ImageLoaderFactory::_instance = 0;11 ImageLoaderFactory *ImageLoaderFactory::_instance = NULL; 10 12 11 13 ImageLoaderFactory::ImageLoaderFactory() … … 13 15 } 14 16 15 ImageLoaderFactory *ImageLoaderFactory::getInstance()17 ImageLoaderFactory *ImageLoaderFactory::getInstance() 16 18 { 17 if (_instance == 0) 18 { 19 if (_instance == NULL) { 19 20 _instance = new ImageLoaderFactory(); 20 21 } … … 23 24 } 24 25 25 void ImageLoaderFactory::addLoaderImpl(const std::string& ext, ImageLoaderImpl *loaderImpl)26 void ImageLoaderFactory::addLoaderImpl(const std::string& ext, ImageLoaderImpl *loaderImpl) 26 27 { 27 std::map< std::string, ImageLoaderImpl*>::iterator iter;28 std::map<std::string, ImageLoaderImpl *>::iterator iter; 28 29 iter = _loaderImpls.find(ext); 29 if (iter == _loaderImpls.end()) 30 { 30 if (iter == _loaderImpls.end()) { 31 31 _loaderImpls[ext] = loaderImpl; 32 } 33 else 34 { 35 printf("conflick data loader for .%s files\n", ext.c_str()); 32 } else { 33 printf("conflicting data loader for .%s files\n", ext.c_str()); 36 34 return; 37 35 } 38 36 } 39 37 40 ImageLoader *ImageLoaderFactory::createLoader(const std::string& ext)38 ImageLoader *ImageLoaderFactory::createLoader(const std::string& ext) 41 39 { 42 std::map< std::string, ImageLoaderImpl*>::iterator iter;40 std::map<std::string, ImageLoaderImpl *>::iterator iter; 43 41 iter = _loaderImpls.find(ext); 44 if (iter != _loaderImpls.end()) 45 { 46 ImageLoader* imageLoader = new ImageLoader(); 42 if (iter != _loaderImpls.end()) { 43 ImageLoader *imageLoader = new ImageLoader(); 47 44 imageLoader->setLoaderImpl((*iter).second); 48 45 return imageLoader; 49 } 50 else 51 { 46 } else { 52 47 printf("%s file not supported\n", ext.c_str()); 53 48 } -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderFactory.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __IMAGE_LOADER_FACTORY_H__3 #define __IMAGE_LOADER_FACTORY_H__2 #ifndef IMAGE_LOADER_FACTORY_H 3 #define IMAGE_LOADER_FACTORY_H 4 4 5 5 #include <map> … … 10 10 class ImageLoader; 11 11 12 class ImageLoaderFactory { 13 std::map< std::string, ImageLoaderImpl*> _loaderImpls; 12 class ImageLoaderFactory 13 { 14 public: 15 void addLoaderImpl(const std::string& ext, ImageLoaderImpl *loaderImpl); 16 ImageLoader *createLoader(const std::string& ext); 14 17 15 static ImageLoaderFactory* _instance; 18 static ImageLoaderFactory *getInstance(); 19 16 20 protected : 17 21 ImageLoaderFactory(); 18 22 ~ImageLoaderFactory(); 19 23 20 public : 21 static ImageLoaderFactory* getInstance(); 22 23 public : 24 void addLoaderImpl(const std::string& ext, ImageLoaderImpl* loaderImpl); 25 ImageLoader* createLoader(const std::string& ext); 24 private: 25 std::map<std::string, ImageLoaderImpl *> _loaderImpls; 26 static ImageLoaderFactory *_instance; 26 27 }; 27 28 28 #endif //29 #endif -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderImpl.cpp
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #include <stdio.h> 3 2 4 #include "ImageLoaderImpl.h" 3 #include <stdio.h>4 5 5 6 ImageLoaderImpl::ImageLoaderImpl() … … 10 11 { 11 12 } 12 13 Image* ImageLoaderImpl::load(const char* filename)14 {15 Image* image = 0;16 printf("abstrac function is called ImageLoaderImpl::load\n");17 fflush(stdout);18 return image;19 } -
trunk/packages/vizservers/nanovis/imgLoaders/ImageLoaderImpl.h
r2798 r2831 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef __IMAGE_LOADER_IMPL_H__3 #define __IMAGE_LOADER_IMPL_H__2 #ifndef IMAGE_LOADER_IMPL_H 3 #define IMAGE_LOADER_IMPL_H 4 4 5 5 #include <Image.h> 6 6 7 class ImageLoaderImpl { 7 class ImageLoaderImpl 8 { 9 public: 8 10 friend class ImageLoader; 9 11 10 protected : 12 ImageLoaderImpl(); 13 14 virtual ~ImageLoaderImpl(); 15 16 protected: 11 17 Image::ImageFormat _targetImageFormat; 12 18 13 public : 14 ImageLoaderImpl(); 15 virtual ~ImageLoaderImpl(); 16 17 public : 18 virtual Image* load(const char* fileName); 19 public: 20 virtual Image *load(const char *fileName) = 0; 19 21 }; 20 22 -
trunk/packages/vizservers/nanovis/nanovis.cpp
r2828 r2831 19 19 #include <errno.h> 20 20 #include <fcntl.h> 21 #include <fstream>22 21 #include <getopt.h> 23 #include <iostream>24 #include <cmath>25 22 #include <memory.h> 26 23 #include <signal.h> 27 #include <sstream>28 #include <cstdio>29 #include <cstdlib>30 #include <string>31 24 #include <sys/resource.h> 32 25 #include <sys/stat.h> … … 38 31 #include <unistd.h> 39 32 33 #include <cstdlib> 34 #include <cstdio> 35 #include <cmath> 36 37 #include <iostream> 38 #include <fstream> 39 #include <sstream> 40 #include <string> 41 42 #include <RpField1D.h> 43 #include <RpFieldRect3D.h> 44 #include <RpFieldPrism3D.h> 45 #include <RpEncode.h> 46 47 #include <R2/R2FilePath.h> 48 #include <R2/R2Fonts.h> 49 50 #include <vrutil/vrFilePath.h> 51 52 #include <BMPImageLoaderImpl.h> 53 #include <ImageLoaderFactory.h> 54 55 #include <GL/glew.h> 56 #include <GL/glut.h> 57 58 #include "nanovis.h" 59 #include "define.h" 60 61 #include "FlowCmd.h" 62 #include "Grid.h" 63 #include "HeightMap.h" 64 #include "NvCamera.h" 65 #include "NvColorTableRenderer.h" 66 #include "NvEventLog.h" 67 #include "NvFlowVisRenderer.h" 68 #include "NvLIC.h" 69 #include "NvZincBlendeReconstructor.h" 70 #include "PerfQuery.h" 71 #include "PlaneRenderer.h" 40 72 #ifdef USE_POINTSET_RENDERER 41 73 #include "PointSetRenderer.h" 42 74 #include "PointSet.h" 43 75 #endif 44 45 #include <NvLIC.h> 46 #include <Trace.h> 47 48 #include "nanovis.h" 49 #include "define.h" 50 #include "RpField1D.h" 51 #include "RpFieldRect3D.h" 52 #include "RpFieldPrism3D.h" 53 #include "RpEncode.h" 54 76 #include "RenderContext.h" 77 #include "Switch.h" 78 #include "Trace.h" 79 #include "Unirect.h" 80 #include "VelocityArrowsSlice.h" 81 #include "VolumeInterpolator.h" 82 #include "VolumeRenderer.h" 55 83 #include "ZincBlendeVolume.h" 56 #include "NvColorTableRenderer.h"57 #include "NvEventLog.h"58 #include "NvZincBlendeReconstructor.h"59 #include "NvFlowVisRenderer.h"60 #include "HeightMap.h"61 #include "Grid.h"62 #include "VolumeInterpolator.h"63 #include <RenderContext.h>64 #include <vrutil/vrFilePath.h>65 66 #include <BMPImageLoaderImpl.h>67 #include <ImageLoaderFactory.h>68 69 // R2 headers70 #include <R2/R2FilePath.h>71 #include <R2/R2Fonts.h>72 73 #include "Unirect.h"74 #include "Switch.h"75 #include "FlowCmd.h"76 84 77 85 #define SIZEOF_BMP_HEADER 54 … … 105 113 Grid *NanoVis::grid = NULL; 106 114 int NanoVis::updir = Y_POS; 107 NvCamera *NanoVis::cam = NULL;115 NvCamera *NanoVis::cam = NULL; 108 116 Tcl_HashTable NanoVis::volumeTable; 109 117 Tcl_HashTable NanoVis::heightmapTable; 110 VolumeRenderer *NanoVis::vol_renderer = NULL;118 VolumeRenderer *NanoVis::vol_renderer = NULL; 111 119 #ifdef USE_POINTSET_RENDERER 112 PointSetRenderer* NanoVis::pointset_renderer = NULL; 113 std::vector<PointSet*> NanoVis::pointSet; 114 #endif 115 PlaneRenderer* NanoVis::plane_render = NULL; 116 Texture2D* NanoVis::plane[10]; 117 NvColorTableRenderer* NanoVis::color_table_renderer = NULL; 120 PointSetRenderer *NanoVis::pointset_renderer = NULL; 121 std::vector<PointSet *> NanoVis::pointSet; 122 #endif 123 PlaneRenderer *NanoVis::plane_renderer = NULL; 124 // pointers to 2D planes, currently handle up 10 125 Texture2D *NanoVis::plane[10]; 126 NvColorTableRenderer *NanoVis::color_table_renderer = NULL; 118 127 119 128 #ifndef NEW_FLOW_ENGINE 120 NvParticleRenderer *NanoVis::flowVisRenderer = NULL;129 NvParticleRenderer *NanoVis::flowVisRenderer = NULL; 121 130 #else 122 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL;123 #endif 124 VelocityArrowsSlice *NanoVis::velocityArrowsSlice = 0;125 126 graphics::RenderContext *NanoVis::renderContext = NULL;127 NvLIC *NanoVis::licRenderer = NULL;128 R2Fonts *NanoVis::fonts;131 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL; 132 #endif 133 VelocityArrowsSlice *NanoVis::velocityArrowsSlice = 0; 134 135 graphics::RenderContext *NanoVis::renderContext = NULL; 136 NvLIC *NanoVis::licRenderer = NULL; 137 R2Fonts *NanoVis::fonts; 129 138 130 139 FILE *NanoVis::stdin = NULL; … … 140 149 141 150 //frame buffer for final rendering 142 GLuint NanoVis:: final_color_tex = 0;143 GLuint NanoVis:: final_depth_rb = 0;144 GLuint NanoVis:: final_fbo = 0;151 GLuint NanoVis::_final_color_tex = 0; 152 GLuint NanoVis::_final_depth_rb = 0; 153 GLuint NanoVis::_final_fbo = 0; 145 154 int NanoVis::render_window = 0; /* GLUT handle for the render window */ 146 155 int NanoVis::win_width = NPIX; /* Width of the render window */ … … 177 186 Tcl_HashTable NanoVis::tfTable; 178 187 179 // pointers to 2D planes, currently handle up 10 180 181 182 PerfQuery* perf; //perfromance counter 188 PerfQuery *perf; //perfromance counter 183 189 184 190 CGprogram m_passthru_fprog; … … 509 515 int old_height = win_height; 510 516 511 plane_render ->set_screen_size(width, height);517 plane_renderer->set_screen_size(width, height); 512 518 resize_offscreen_buffer(width, height); 513 519 … … 518 524 } 519 525 plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 520 int index = plane_render ->add_plane(plane[0], tf);521 plane_render ->set_active_plane(index);526 int index = plane_renderer->add_plane(plane[0], tf); 527 plane_renderer->set_active_plane(index); 522 528 523 529 offscreen_buffer_capture(); 524 530 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 525 plane_render ->render();531 plane_renderer->render(); 526 532 527 533 // INSOO … … 539 545 assert(nWritten == 1); 540 546 } 541 plane_render ->remove_plane(index);547 plane_renderer->remove_plane(index); 542 548 resize_offscreen_buffer(old_width, old_height); 543 549 … … 553 559 TRACE("in init_offscreen_buffer\n"); 554 560 // Initialize a fbo for final display. 555 glGenFramebuffersEXT(1, & final_fbo);556 557 glGenTextures(1, & final_color_tex);558 glBindTexture(GL_TEXTURE_2D, final_color_tex);559 561 glGenFramebuffersEXT(1, &_final_fbo); 562 563 glGenTextures(1, &_final_color_tex); 564 glBindTexture(GL_TEXTURE_2D, _final_color_tex); 565 560 566 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 561 567 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); … … 567 573 GL_RGB, GL_INT, NULL); 568 574 #endif 569 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);570 glGenRenderbuffersEXT(1, & final_depth_rb);571 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);575 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo); 576 glGenRenderbuffersEXT(1, &_final_depth_rb); 577 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb); 572 578 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 573 579 win_width, win_height); 574 580 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 575 GL_TEXTURE_2D, final_color_tex, 0);581 GL_TEXTURE_2D, _final_color_tex, 0); 576 582 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 577 GL_RENDERBUFFER_EXT, final_depth_rb);583 GL_RENDERBUFFER_EXT, _final_depth_rb); 578 584 579 585 GLenum status; … … 585 591 // Check framebuffer completeness at the end of initialization. 586 592 //CHECK_FRAMEBUFFER_STATUS(); 587 593 588 594 //assert(glGetError()==0); 589 595 TRACE("leaving init_offscreen_buffer\n"); 590 596 } 591 592 597 593 598 //resize the offscreen buffer … … 601 606 win_width = w; 602 607 win_height = h; 603 608 604 609 if (fonts) { 605 610 fonts->resize(w, h); 606 611 } 607 612 TRACE("screen_buffer size: %d %d\n", w, h); 608 613 609 614 if (screen_buffer != NULL) { 610 615 delete [] screen_buffer; 611 616 screen_buffer = NULL; 612 617 } 613 618 614 619 screen_buffer = new unsigned char[4*win_width*win_height]; 615 620 assert(screen_buffer != NULL); 616 621 617 622 //delete the current render buffer resources 618 glDeleteTextures(1, & final_color_tex);619 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);620 glDeleteRenderbuffersEXT(1, & final_depth_rb);623 glDeleteTextures(1, &_final_color_tex); 624 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb); 625 glDeleteRenderbuffersEXT(1, &_final_depth_rb); 621 626 622 627 TRACE("before deleteframebuffers\n"); 623 glDeleteFramebuffersEXT(1, & final_fbo);628 glDeleteFramebuffersEXT(1, &_final_fbo); 624 629 625 630 TRACE("reinitialize FBO\n"); 626 631 //Reinitialize final fbo for final display 627 glGenFramebuffersEXT(1, & final_fbo);628 629 glGenTextures(1, & final_color_tex);630 glBindTexture(GL_TEXTURE_2D, final_color_tex);632 glGenFramebuffersEXT(1, &_final_fbo); 633 634 glGenTextures(1, &_final_color_tex); 635 glBindTexture(GL_TEXTURE_2D, _final_color_tex); 631 636 632 637 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); … … 640 645 #endif 641 646 TRACE("before bindframebuffer\n"); 642 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);647 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo); 643 648 TRACE("after bindframebuffer\n"); 644 glGenRenderbuffersEXT(1, & final_depth_rb);645 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, final_depth_rb);649 glGenRenderbuffersEXT(1, &_final_depth_rb); 650 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, _final_depth_rb); 646 651 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 647 652 win_width, win_height); 648 653 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, 649 GL_TEXTURE_2D, final_color_tex, 0);654 GL_TEXTURE_2D, _final_color_tex, 0); 650 655 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, 651 GL_RENDERBUFFER_EXT, final_depth_rb);652 656 GL_RENDERBUFFER_EXT, _final_depth_rb); 657 653 658 GLenum status; 654 659 if (!CheckFBO(&status)) { … … 661 666 //change the camera setting 662 667 cam->set_screen_size(0, 0, win_width, win_height); 663 plane_render ->set_screen_size(win_width, win_height);668 plane_renderer->set_screen_size(win_width, win_height); 664 669 665 670 TRACE("leaving resize_offscreen_buffer(%d, %d)\n", w, h); … … 677 682 int w = 300; 678 683 int h = 200; 679 float *data = new float[w*h];684 float *data = new float[w*h]; 680 685 681 686 //procedurally make a gradient plane 682 for (int j=0; j<h; j++){683 for (int i=0; i<w; i++){687 for (int j = 0; j < h; j++){ 688 for (int i = 0; i < w; i++){ 684 689 data[w*j+i] = float(i)/float(w); 685 690 } 686 691 } 692 687 693 NanoVis::plane[0] = new Texture2D(w, h, GL_FLOAT, GL_LINEAR, 1, data); 688 694 delete[] data; … … 820 826 // create 821 827 renderContext = new graphics::RenderContext(); 822 828 823 829 //create an 2D plane renderer 824 plane_render = new PlaneRenderer(g_context, win_width, win_height);830 plane_renderer = new PlaneRenderer(g_context, win_width, win_height); 825 831 #if PROTOTYPE 826 832 make_test_2D_data(); 827 #endif /* PROTOTYPE */ 828 plane_render->add_plane(plane[0], get_transfunc("default")); 833 plane_renderer->add_plane(plane[0], get_transfunc("default")); 834 #endif 829 835 830 836 //assert(glGetError()==0); … … 1192 1198 glEnable(GL_TEXTURE_2D); 1193 1199 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1194 glBindTexture(GL_TEXTURE_2D, final_color_tex);1200 glBindTexture(GL_TEXTURE_2D, _final_color_tex); 1195 1201 1196 1202 glViewport(0, 0, win_width, win_height); … … 1212 1218 TRACE("leaving display_offscreen_buffer\n"); 1213 1219 } 1214 1215 1216 1220 1217 1221 #if 0 … … 1296 1300 #endif 1297 1301 1298 1299 1302 void 1300 1303 draw_3d_axis() … … 1637 1640 //perf->disable(); 1638 1641 1639 TRACE("in display: render heightmap\n"); 1640 Tcl_HashEntry *hPtr; 1641 Tcl_HashSearch iter; 1642 for (hPtr = Tcl_FirstHashEntry(&heightmapTable, &iter); hPtr != NULL; 1643 hPtr = Tcl_NextHashEntry(&iter)) { 1644 HeightMap *hmPtr; 1645 hmPtr = (HeightMap *)Tcl_GetHashValue(hPtr); 1646 if (hmPtr->isVisible()) { 1647 hmPtr->render(renderContext); 1642 if (heightmapTable.numEntries > 0) { 1643 TRACE("in display: render heightmap\n"); 1644 Tcl_HashEntry *hPtr; 1645 Tcl_HashSearch iter; 1646 for (hPtr = Tcl_FirstHashEntry(&heightmapTable, &iter); hPtr != NULL; 1647 hPtr = Tcl_NextHashEntry(&iter)) { 1648 HeightMap *hmPtr; 1649 hmPtr = (HeightMap *)Tcl_GetHashValue(hPtr); 1650 if (hmPtr->isVisible()) { 1651 hmPtr->render(renderContext); 1652 } 1648 1653 } 1649 1654 } … … 1652 1657 //2D rendering mode 1653 1658 perf->enable(); 1654 plane_render ->render();1659 plane_renderer->render(); 1655 1660 perf->disable(); 1656 1661 } 1657 TRACE("in display: render heightmap\n"); 1662 1658 1663 perf->reset(); 1659 1664 CHECK_FRAMEBUFFER_STATUS(); … … 1755 1760 1.0f); 1756 1761 NanoVis::flowVisRenderer->activateVectorField(vf_name); 1757 1762 1758 1763 ////////////////////////////////// 1759 1764 // ADD Particle Injection Plane1 … … 1768 1773 NanoVis::flowVisRenderer->setParticleColor(vf_name, plane_name2, color2); 1769 1774 NanoVis::flowVisRenderer->initialize(vf_name); 1770 1775 1771 1776 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name1); 1772 1777 NanoVis::flowVisRenderer->activatePlane(vf_name, plane_name2); 1773 1774 NanoVis::licRenderer->setVectorField(volPtr->id, 1775 *(volPtr->get_location()), 1776 1.0f / volPtr->aspect_ratio_width, 1777 1.0f / volPtr->aspect_ratio_height, 1778 1.0f / volPtr->aspect_ratio_depth, 1779 volPtr->wAxis.max()); 1778 1779 NanoVis::licRenderer-> 1780 setVectorField(volPtr->id, 1781 *(volPtr->get_location()), 1782 1.0f / volPtr->aspect_ratio_width, 1783 1.0f / volPtr->aspect_ratio_height, 1784 1.0f / volPtr->aspect_ratio_depth, 1785 volPtr->wAxis.max()); 1780 1786 } 1781 1787 } … … 2353 2359 2354 2360 /* 2355 plane_render ->set_screen_size(width, height);2361 plane_renderer->set_screen_size(width, height); 2356 2362 2357 2363 // generate data for the legend … … 2361 2367 } 2362 2368 plane[0] = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 2363 int index = plane_render ->add_plane(plane[0], tf);2364 plane_render ->set_active_plane(index);2369 int index = plane_renderer->add_plane(plane[0], tf); 2370 plane_renderer->set_active_plane(index); 2365 2371 2366 2372 offscreen_buffer_capture(); 2367 2373 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear screen 2368 2374 2369 //plane_render ->render();2375 //plane_renderer->render(); 2370 2376 // INSOO : is going to implement here for the topview of the heightmap 2371 2377 heightmap->render(renderContext); … … 2384 2390 //ppm_write(prefix); 2385 2391 //write(1, "\n", 1); 2386 //plane_render ->remove_plane(index);2392 //plane_renderer->remove_plane(index); 2387 2393 2388 2394 // CURRENT -
trunk/packages/vizservers/nanovis/nanovis.h
r2822 r2831 14 14 * ====================================================================== 15 15 */ 16 #ifndef __NANOVIS_H__17 #define __NANOVIS_H__16 #ifndef NANOVIS_H 17 #define NANOVIS_H 18 18 19 19 #include <tcl.h> 20 20 21 21 #include <GL/glew.h> 22 #include <GL/glut.h> 23 #include <Cg/cgGL.h> 24 #include <stdlib.h> 22 25 23 #include <math.h> 26 #include <time.h> 24 #include <stddef.h> // For size_t 25 #include <stdio.h> 26 27 #include <vector> 27 28 #include <iostream> 28 #include <stdio.h>29 #include <assert.h>30 #include <float.h>31 #include <getopt.h>32 #include <stdio.h>33 #include <math.h>34 #include <fstream>35 #include <sstream>36 #include <string>37 #include <sys/time.h>38 #include <sys/types.h>39 #include <unistd.h>40 #include <fcntl.h>41 #include <signal.h>42 29 43 30 #include <rappture.h> … … 45 32 #include "define.h" 46 33 #include "global.h" 47 48 #include "NvCamera.h"49 #include "ConvexPolygon.h"50 #include "Texture3D.h"51 #include "Texture2D.h"52 #include "Texture1D.h"53 #include "TransferFunction.h"54 #include "Mat4x4.h"55 #include "Volume.h"56 #include "NvParticleRenderer.h"57 #include "NvFlowVisRenderer.h"58 #include "PerfQuery.h"59 #include "Event.h"60 #include "VolumeRenderer.h"61 #include "PlaneRenderer.h"62 #include "NvColorTableRenderer.h"63 #include "PointSetRenderer.h"64 #include "PointSet.h"65 #include "HeightMap.h"66 #include "Grid.h"67 #include "VolumeRenderer.h"68 #include "VelocityArrowsSlice.h"69 70 34 #include "config.h" 71 35 … … 79 43 #define SCALE 3.0 //scale for background pattern. small value -> fine texture 80 44 45 namespace graphics { 46 class RenderContext; 47 } 48 49 class VolumeRenderer; 50 class PointSetRenderer; 51 class NvParticleRenderer; 52 class NvFlowVisRenderer; 53 class PlaneRenderer; 54 class VelocityArrowsSlice; 55 class NvLIC; 56 class PointSet; 57 class Texture2D; 58 class NvColorTableRenderer; 59 class HeightMap; 81 60 class NvVectorField; 61 class Grid; 62 class R2Fonts; 63 class NvCamera; 64 class TransferFunction; 65 class Volume; 66 class FlowCmd; 67 class FlowIterator; 82 68 83 69 struct Vector2 { … … 85 71 float mag() 86 72 { 87 return sqrt(x*x +y*y);73 return sqrt(x*x + y*y); 88 74 } 89 75 }; … … 91 77 struct RegGrid2 { 92 78 int width, height; 93 Vector2 *field;94 79 Vector2 *field; 80 95 81 RegGrid2(int w, int h) 96 82 { … … 111 97 }; 112 98 113 class NvLIC;114 class FlowCmd;115 class FlowIterator;116 117 99 class NanoVis 118 100 { 119 //frame buffer for final rendering120 static GLuint final_fbo, final_color_tex, final_depth_rb;121 122 101 public: 123 static VolumeRenderer* vol_renderer; 124 static PointSetRenderer* pointset_renderer; 102 enum NanoVisFlags { 103 REDRAW_PENDING = (1 << 0), 104 MAP_FLOWS = (1 << 1), 105 MAP_VOLUMES = (1 << 2), 106 MAP_HEIGHTMAPS = (1 << 3), 107 }; 108 109 static VolumeRenderer *vol_renderer; 110 static PointSetRenderer *pointset_renderer; 125 111 #ifndef NEW_FLOW_ENGINE 126 static NvParticleRenderer *flowVisRenderer;112 static NvParticleRenderer *flowVisRenderer; 127 113 #else 128 static NvFlowVisRenderer *flowVisRenderer;114 static NvFlowVisRenderer *flowVisRenderer; 129 115 #endif 130 static VelocityArrowsSlice *velocityArrowsSlice;131 static NvLIC *licRenderer;132 static std::vector<PointSet*> pointSet;133 static PlaneRenderer* plane_render;116 static VelocityArrowsSlice *velocityArrowsSlice; 117 static NvLIC *licRenderer; 118 static PlaneRenderer *plane_renderer; 119 static std::vector<PointSet *> pointSet; 134 120 135 121 /** 136 * pointers to 2D planes , currently handle up 10122 * pointers to 2D planes 137 123 */ 138 static Texture2D * plane[10];139 static NvColorTableRenderer *color_table_renderer;140 static graphics::RenderContext *renderContext;141 static std::vector<HeightMap *> heightMap;142 static unsigned char *screen_buffer;124 static Texture2D *plane[]; 125 static NvColorTableRenderer *color_table_renderer; 126 static graphics::RenderContext *renderContext; 127 static std::vector<HeightMap *> heightMap; 128 static unsigned char *screen_buffer; 143 129 static Tcl_HashTable volumeTable; 144 130 static Tcl_HashTable heightmapTable; 145 static std::vector<NvVectorField *> flow;146 static Grid *grid;147 static R2Fonts *fonts;131 static std::vector<NvVectorField *> flow; 132 static Grid *grid; 133 static R2Fonts *fonts; 148 134 static int updir; 149 135 static NvCamera *cam; … … 165 151 static Tcl_DString cmdbuffer; 166 152 167 static TransferFunction *get_transfunc(const char *name);168 static TransferFunction *DefineTransferFunction(const char *name,169 size_t n, float *data);170 static void SetVolumeRanges( void);171 static void SetHeightmapRanges( void);172 static void init(const char *path);173 static void initGL( void);174 static void init_lic( void);175 static void init_offscreen_buffer( void);153 static TransferFunction *get_transfunc(const char *name); 154 static TransferFunction *DefineTransferFunction(const char *name, 155 size_t n, float *data); 156 static void SetVolumeRanges(); 157 static void SetHeightmapRanges(); 158 static void init(const char *path); 159 static void initGL(); 160 static void init_lic(); 161 static void init_offscreen_buffer(); 176 162 static void initParticle(); 177 163 static void resize_offscreen_buffer(int w, int h); … … 183 169 static void ppm_write(const char *prefix); 184 170 static void sendDataToClient(const char *command, const char *data, 185 size_t dlen);171 size_t dlen); 186 172 static void bmp_write(const char *prefix); 187 173 static void bmp_write_to_file(int frame_number, const char* directory_name); 188 static void display( void);189 static void idle( void);190 static void update( void);174 static void display(); 175 static void idle(); 176 static void update(); 191 177 static void display_offscreen_buffer(); 192 178 static int render_legend(TransferFunction *tf, double min, double max, 193 int width, int height, const char*volArg);179 int width, int height, const char *volArg); 194 180 static Volume *load_volume(const char *tag, int width, int height, 195 196 197 static void xinetd_listen( void);198 static int render_2d_contour(HeightMap *heightmap, int width, int height);181 int depth, int n, float* data, double vmin, double vmax, 182 double nzero_min); 183 static void xinetd_listen(); 184 static int render_2d_contour(HeightMap *heightmap, int width, int height); 199 185 static void pan(float dx, float dy); 200 186 … … 216 202 static void offscreen_buffer_capture() 217 203 { 218 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, final_fbo);204 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo); 219 205 } 220 206 … … 227 213 static FlowCmd *FirstFlow(FlowIterator *iterPtr); 228 214 static FlowCmd *NextFlow(FlowIterator *iterPtr); 229 static void InitFlows( void);230 static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr, 231 215 static void InitFlows(); 216 static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr, 217 FlowCmd **flowPtrPtr); 232 218 static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr); 233 219 static void DeleteFlows(Tcl_Interp *interp); 234 static bool MapFlows(void); 235 static void RenderFlows(void); 236 static void ResetFlows(void); 237 static bool UpdateFlows(void); 238 static void AdvectFlows(void); 239 enum NanoVisFlags { 240 REDRAW_PENDING=(1<<0), 241 MAP_FLOWS=(1<<1), 242 MAP_VOLUMES=(1<<2), 243 MAP_HEIGHTMAPS=(1<<3), 244 }; 220 static bool MapFlows(); 221 static void RenderFlows(); 222 static void ResetFlows(); 223 static bool UpdateFlows(); 224 static void AdvectFlows(); 225 245 226 static void EventuallyRedraw(unsigned int flag = 0); 246 227 static void remove_volume(Volume *volPtr); 247 228 static Tcl_HashTable tfTable; 229 230 private: 231 //frame buffer for final rendering 232 static GLuint _final_fbo, _final_color_tex, _final_depth_rb; 248 233 }; 249 234 250 235 extern Volume *load_volume_stream(Rappture::Outcome &status, const char *tag, 251 std::iostream& fin); 252 extern Volume *load_volume_stream_odx(Rappture::Outcome &status, 253 const char *tag, const char *buf, int nBytes); 254 extern Volume *load_volume_stream2(Rappture::Outcome &status, const char *tag, 255 std::iostream& fin); 256 257 extern Volume *load_vector_stream(Rappture::Outcome &result, const char *tag, 258 size_t length, char *bytes); 259 extern Volume *load_vector_stream2(Rappture::Outcome &result, const char *tag, 260 size_t length, char *bytes); 261 262 263 #endif /* __NANOVIS_H__ */ 236 std::iostream& fin); 237 238 extern Volume *load_volume_stream_odx(Rappture::Outcome& status, 239 const char *tag, const char *buf, int nBytes); 240 241 extern Volume *load_volume_stream2(Rappture::Outcome & status, const char *tag, 242 std::iostream& fin); 243 244 extern Volume *load_vector_stream(Rappture::Outcome& result, const char *tag, 245 size_t length, char *bytes); 246 247 extern Volume *load_vector_stream2(Rappture::Outcome& result, const char *tag, 248 size_t length, char *bytes); 249 250 #endif
Note: See TracChangeset
for help on using the changeset viewer.