Changeset 5605


Ignore:
Timestamp:
Aug 5, 2008, 11:12:01 AM (11 years ago)
Author:
jack
Message:

Extract the height data from the NetCDF file.

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

Legend:

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

    r5600 r5605  
    1414#  include <OpenGL/glu.h>
    1515#endif
     16#include <netcdf.h>
    1617#include "height_quantity.hh"
    1718
     
    4647
    4748void HeightQuantity::set_SWWFile(const shared_ptr<SWWFile> &file){
     49  int ncstatus;
    4850  this->sww_file = file;
    4951  this->points = \
    5052    shared_array<float>(new float[this->sww_file->number_of_points]);
    5153  this->dynamic = this->sww_file->nc_inq_varndims_by_name(this->name) == 2;
     54  if((ncstatus = nc_inq_varid(this->sww_file->netcdf_id, this->name.c_str(),
     55                              &this->varid)) != NC_NOERR)
     56    throw nc_strerror(ncstatus);
    5257}
    5358
    5459void HeightQuantity::compile(int frame){
    55  
     60  size_t start_1[1] = {0};
     61  size_t start_2[2] = {0, 0};
     62  size_t span_1[1];
     63  size_t span_2[2] = {1, 0};
     64  int ncstatus;
     65  if(this->dynamic){
     66    span_2[1] = this->sww_file->number_of_points;
     67    ncstatus = nc_get_vara_float(this->sww_file->netcdf_id, this->varid,
     68                                 start_2, span_2, this->points.get());
     69  }else{
     70    span_1[0] = this->sww_file->number_of_points;
     71    ncstatus = nc_get_vara_float(this->sww_file->netcdf_id, this->varid,
     72                                 start_1, span_1, this->points.get());
     73  }
     74  if(ncstatus != NC_NOERR) throw nc_strerror(ncstatus);
     75  /* TODO: Compile the triangles into an OGL displaylist. */
    5676}
  • anuga_work/development/anugavis/src/height_quantity.hh

    r5600 r5605  
    4646  int frame_number; /* The most recently drawn frame (i.e., the one
    4747                       cached in the display list. */
     48  int varid;
    4849  bool dynamic;
    4950  GLuint display_list;
Note: See TracChangeset for help on using the changeset viewer.