Changeset 5600


Ignore:
Timestamp:
Aug 4, 2008, 10:21:33 AM (11 years ago)
Author:
jack
Message:

More restructuring to use boost::shared_ptr.

Location:
anuga_work/development/anugavis/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/anugavis/src/anugavis.cc

    r5598 r5600  
    55#include <iostream>
    66#include <string>
     7#include <boost/shared_ptr.hpp>
    78#ifdef HAVE_GL_GL_H
    89#  include <GL/gl.h>
     
    1819#include "anugavis.hh"
    1920#include "height_quantity.hh"
     21#include "sww_file.hh"
    2022
     23using boost::shared_ptr;
    2124using std::string;
    2225
    2326AnugaVis::AnugaVis(const string &file_name, int width, int height):
    24   screen(NULL), sww_file(file_name){
     27  screen(NULL), sww_file(new SWWFile(file_name)){
    2528  init_SDL(width, height);
    2629  init_OpenGL(width, height);
     
    3134}
    3235
    33 void AnugaVis::add_HeightQuantity(HeightQuantity &height){
    34   height.set_dynamic(this->sww_file.nc_inq_varndims_by_name(height.get_name()) \
    35                      == 2);
     36void AnugaVis::add_HeightQuantity(shared_ptr<HeightQuantity> &height){
     37  height->set_SWWFile(this->sww_file);
    3638  this->heights.push_back(height);
    3739}
  • anuga_work/development/anugavis/src/anugavis.hh

    r5598 r5600  
    66#include <list>
    77#include <string>
     8#include <boost/shared_ptr.hpp>
    89#include <SDL.h>
    910#include "height_quantity.hh"
    1011#include "sww_file.hh"
    1112
     13using boost::shared_ptr;
    1214using std::list;
    1315using std::string;
     
    1719  AnugaVis(const string &sww_file, int width, int height);
    1820  ~AnugaVis(void);
    19   void add_HeightQuantity(HeightQuantity &height);
     21  void add_HeightQuantity(shared_ptr<HeightQuantity> &height);
    2022  void run(void);
    2123private:
     
    2325  void init_OpenGL(int width, int height);
    2426  SDL_Surface *screen;
    25   SWWFile sww_file;
    26   list<HeightQuantity> heights;
     27  shared_ptr<SWWFile> sww_file;
     28  list<shared_ptr<HeightQuantity> > heights;
    2729};
    2830
  • anuga_work/development/anugavis/src/anugavis_simple_cxx.cc

    r5598 r5600  
    11#include <iostream>
    22#include <sstream>
     3#include <boost/shared_ptr.hpp>
    34#include <SDL.h>
    45#include "anugavis.hh"
    56#include "output.hh"
    67
     8using boost::shared_ptr;
    79using std::cout;
    810using std::endl;
     
    1921  try{
    2022    AnugaVis anuga(argv[1], 640, 480);
    21     HeightQuantity elevation("elevation", 0, 1, 0.5, 0.5, 0.5);
    22     HeightQuantity stage("stage", 0, 1, 0, 0, 0.8);
     23    shared_ptr<HeightQuantity> elevation(new HeightQuantity("elevation", 0, 1,
     24                                                            0.5, 0.5, 0.5));
     25    shared_ptr<HeightQuantity> stage(new HeightQuantity("stage", 0, 1,
     26                                                        0, 0, 0.8));
    2327    anuga.add_HeightQuantity(elevation);
    2428    anuga.add_HeightQuantity(stage);
  • anuga_work/development/anugavis/src/height_quantity.cc

    r5598 r5600  
    4545}
    4646
    47 const string &HeightQuantity::get_name(void){
    48   return this->name;
    49 }
    50 
    51 void HeightQuantity::set_dynamic(bool dynamic){
    52   this->dynamic = dynamic;
     47void HeightQuantity::set_SWWFile(const shared_ptr<SWWFile> &file){
     48  this->sww_file = file;
     49  this->points = \
     50    shared_array<float>(new float[this->sww_file->number_of_points]);
     51  this->dynamic = this->sww_file->nc_inq_varndims_by_name(this->name) == 2;
    5352}
    5453
  • anuga_work/development/anugavis/src/height_quantity.hh

    r5598 r5600  
    99
    1010#include <string>
    11 
     11#include <boost/shared_array.hpp>
     12#include <boost/shared_ptr.hpp>
    1213#ifdef HAVE_GL_GL_H
    1314#  include <GL/gl.h>
     
    1516#  include <OpenGL/gl.h>
    1617#endif
     18#include "sww_file.hh"
    1719
     20using boost::shared_array;
     21using boost::shared_ptr;
    1822using std::string;
    1923
     
    3135  ~HeightQuantity(void);
    3236  void draw(int frame);
    33   const string &get_name(void);
    34   void set_dynamic(bool dynamic);
     37  void set_SWWFile(const shared_ptr<SWWFile> &file);
    3538  GLdouble offset;
    3639  GLdouble scale;
     
    4548  bool dynamic;
    4649  GLuint display_list;
     50  shared_array<float> points;
     51  shared_ptr<SWWFile> sww_file;
    4752};
    4853
  • anuga_work/development/anugavis/src/sww_file.hh

    r5502 r5600  
    1818
    1919class SWWFile{
     20  friend class HeightQuantity;
    2021public:
    2122  SWWFile(const string &file_name);
Note: See TracChangeset for help on using the changeset viewer.