Commit 9658f63d authored by Edward Vigmond's avatar Edward Vigmond

Merged in HDF5 branch.

parent dbb48505
......@@ -27,8 +27,103 @@ int get_num( gzFile in )
return number;
}
class AuxGridFetcher
{
public:
AuxGridFetcher():_model(NULL),_frame(-1),_data(NULL){}
virtual Model *GetModel(int) =0;
virtual int num_tm() =0;
virtual bool plottable() =0;
virtual int time_series( int v, double *&d ) =0;
Model *_model;
float *_data; //!< current frame data
protected:
int _frame;
};
class AuxGridHDF5 : public AuxGridFetcher {
public:
AuxGridHDF5(const char * fn)
{
#ifdef USE_HDF5
string gtype;
parse_HDF5_grid( fn, gtype, _indx );
string af = fn;
if( ch5_open( af.substr(0,af.find_last_of(":")).c_str(), &_hin ) )
throw 1;
ch5s_aux_grid info;
ch5s_aux_grid_info( _hin, _indx, &info );
_max_frame = info.time_steps;
ch5s_aux_free_grid_info( &info );
#else
assert(0);
#endif
}
~AuxGridHDF5()
{
#ifdef USE_HDF5
ch5_close( _hin );
#endif
}
/** load model from frame in timepoints
*
* \param frame to load
* \return pointer to model
*/
Model *GetModel(int frame)
{
#ifdef USE_HDF5
// check if we have the frame loaded, if so just return the current model
if (frame == _frame) {
return _model;
}
// ensure the frame requested is valid
if ( frame >= _max_frame ) {
std::cerr << "GetModel() request to invalid frame number" << std::endl;
throw 3;
}
// delete previous model
if (_model) {
delete _model;
_model = NULL;
}
// delete previous data
if (_data) {
delete _data;
_data = NULL;
}
_model = new Model();
_model->read_instance(_hin, _indx, frame, _data);
// update internal frame number
_frame = frame;
return _model;
#else
assert(0);
#endif
}
int num_tm(){return _max_frame; }
bool plottable(){ return false; }
int time_series( int v, double *&d ){d=NULL; return 0;}
private:
#ifdef USE_HDF5
hid_t _hin;
#endif
unsigned int _indx; //!< grid index
int _max_frame;
};
/** private internal helper function that indexes frames to file positions */
class AuxGridIndexer
class AuxGridIndexer : public AuxGridFetcher
{
public:
......@@ -38,12 +133,9 @@ public:
*
* \param filename to index (without extention)
*/
AuxGridIndexer(char * filename)
: _model(0),
_data(0),
_frame(-1)
AuxGridIndexer(const char * filename)
{
char *ext = strstr( filename, ".pts_t" );
char *ext = strdup(strstr( filename, ".pts_t" ));
if( ext )
*ext = '\0';
......@@ -57,6 +149,7 @@ public:
std::cerr << "Failed to open .pts_t file" << std::endl;
throw 2;
}
free( ext );
}
/** destructor
......@@ -101,11 +194,6 @@ public:
// delete previous model
if (_model) {
// @todo (gd) : figure out why this is segfaulting, MEMORY LEAK!!!
// well turns out Models aren't really good in their destructors, and
// parent classes are missing virtual keywords in their destructors and
// I think generally it's kindof a mess, fix that then, uncomment the
// following line.
delete _model;
_model = 0;
}
......@@ -278,10 +366,6 @@ private:
std::vector<z_off_t> _vec_pts_pos; //!< frame indexed vector of positions into points file
std::vector<z_off_t> _vec_elem_pos; //!< frame indexed vector of positions into element file
std::vector<z_off_t> _vec_dat_pos; //!< frame indexed vector of positions into data file
int _frame; //!< current frame (-1 if no frame loaded)
public:
Model * _model; //!< current frame model
DATA_TYPE *_data; //!< current frame data
};
......@@ -295,10 +379,17 @@ public:
*
* \throw 1 if any error in input
*/
AuxGrid::AuxGrid( char *fn )
AuxGrid::AuxGrid( const char *fn )
: _display(true), _hilight(false), _hiVert(0), _plottable(false),
_indexer(new AuxGridIndexer(fn)),_timeplot(NULL)
_indexer(NULL),_timeplot(NULL)
{
if( strstr( fn, ".pts_t" ) )
_indexer = new AuxGridIndexer(fn);
else if( strstr( fn, ".datH5:" ) )
_indexer = new AuxGridHDF5(fn);
else
throw 1;
for (int i=0; i<sizeof(*_3D); i++)
_3D[i] = true;
......@@ -309,6 +400,7 @@ AuxGrid::AuxGrid( char *fn )
}
_plottable = _indexer->plottable();
if( _plottable ){
_timeplot = new PlotWin("Aux Time Series");
_sz_ts = _indexer->time_series(0,_time_series);
......@@ -317,7 +409,9 @@ AuxGrid::AuxGrid( char *fn )
threeD( Cnnx, true );
threeD( Vertex, true );
_indexer->GetModel(0);
if( _indexer )
_indexer->GetModel(0);
}
......@@ -334,7 +428,9 @@ AuxGrid :: draw( int t )
if( t >= num_tm() ) t = num_tm()-1;
Model *m = _indexer->GetModel(t);
Model *m;
m = _indexer->GetModel(t);
m->pt.size(size(Vertex));
m->pt.threeD(threeD(Vertex));
m->_cnnx->threeD(threeD(Cnnx));
......@@ -402,7 +498,7 @@ AuxGrid :: draw( int t )
AuxGrid::~AuxGrid()
{
delete _indexer;
_indexer = 0;
_indexer = NULL;
if( _timeplot )
delete _timeplot;
_timeplot = NULL;
......
......@@ -12,12 +12,11 @@
#include "DrawingObjects.h"
#include "plottingwin.h"
class AuxGridIndexer;
class AuxGridFetcher;
class AuxGrid {
private:
AuxGridIndexer * _indexer; //!< private implementation of indexer
AuxGridFetcher * _indexer; //!< private implementation of indexer
bool _display;
bool _datafied[maxobject];
bool _surf_fill; //!< if false, draw outline
......@@ -35,7 +34,7 @@ class AuxGrid {
double* _time_series;
public:
AuxGrid( char *fn );
AuxGrid( const char *fn );
virtual ~AuxGrid();
Colourscale cs;
......
# data file for the Fltk User Interface Designer (fluid)
version 1.0106
version 1.0300
header_name {.h}
code_name {.cc}
decl {\#include "TBmeshWin.h"} {public
decl {\#include "TBmeshWin.h"} {public local
}
decl {\#include <math.h>} {public
decl {\#include <math.h>} {public local
}
decl {\#define SAVE_CP(A) xdir\#\#A->value()<<" "<<ydir\#\#A->value()<<" "<<zdir\#\#A->value()<<" "<<intercept\#\#A->value()<<" "<<dispas\#\#A->value()} {}
decl {\#define SAVE_CP(A) xdir\#\#A->value()<<" "<<ydir\#\#A->value()<<" "<<zdir\#\#A->value()<<" "<<intercept\#\#A->value()<<" "<<dispas\#\#A->value()} {private local
}
decl {\#define READ_CP(A,S) {double val; S>>val; xdir\#\#A->value(val); S>>val; ydir\#\#A->value(val); S>>val; zdir\#\#A->value(val);S>>val; intercept\#\#A->value(val); S>>val; dispas\#\#A->value(int(val));}}{}
decl {\#define READ_CP(A,S) {double val; S>>val; xdir\#\#A->value(val); S>>val; ydir\#\#A->value(val); S>>val; zdir\#\#A->value(val);S>>val; intercept\#\#A->value(val); S>>val; dispas\#\#A->value(int(val));}} {private local
}
decl {\#define CHECK_CP(A) {int val=dispas\#\#A->value();if(val==3||val==4)tbmw->determine_cutplane(A);}} {}
decl {\#define CHECK_CP(A) {int val=dispas\#\#A->value();if(val==3||val==4)tbmw->determine_cutplane(A);}} {private local
}
class ClipPlane {open
} {
......@@ -20,7 +23,7 @@ class ClipPlane {open
} {
Fl_Window window {
label {Clipping Plane} open
xywh {229 164 575 495} type Double hide
xywh {863 23 575 495} type Double visible
} {
Fl_Group Clip0 {
label {Clipping Plane 1} open
......@@ -59,38 +62,38 @@ normcb(0);}
}
Fl_Value_Slider intercept0 {
label Intercept
callback {normcb(0);}
callback {normcb(0);} selected
tooltip {control intercept of plane with axes} xywh {145 25 25 195} selection_color 10 minimum -1
}
Fl_Choice dispas0 {
xywh {20 30 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 0, false );
tbmw->redraw();}
xywh {0 0 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 0, false );
tbmw->redraw();}
xywh {0 0 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 0, false );
tbmw->redraw();}
xywh {0 0 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 0, true );
tbmw->determine_cutplane(0);
tbmw->redraw();}
xywh {0 0 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 0, true );
tbmw->determine_cutplane(0);
......@@ -142,32 +145,32 @@ normcb(1);}
Fl_Choice dispas1 {
xywh {210 30 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 1, false );
tbmw->redraw();}
xywh {10 10 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 1, false );
tbmw->redraw();}
xywh {10 10 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 1, false );
tbmw->redraw();}
xywh {10 10 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 1, true );
tbmw->determine_cutplane(1);
tbmw->redraw();}
xywh {10 10 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 1, true );
tbmw->determine_cutplane(1);
......@@ -219,32 +222,32 @@ normcb(2);}
Fl_Choice dispas2 {
xywh {395 30 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 2, false );
tbmw->redraw();}
xywh {20 20 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 2, false );
tbmw->redraw();}
xywh {20 20 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 2, false );
tbmw->redraw();}
xywh {20 20 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 2, true );
tbmw->determine_cutplane(2);
tbmw->redraw();}
xywh {20 20 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 2, true );
tbmw->determine_cutplane(2);
......@@ -258,7 +261,7 @@ tbmw->redraw();}
xywh {5 250 185 220} box UP_BOX align 2
} {
Fl_Group {} {
label {Plane Normal4} open
label {Plane Normal4}
xywh {15 305 115 145} box UP_BOX
} {
Fl_Value_Input xdir3 {
......@@ -296,32 +299,32 @@ normcb(3);}
Fl_Choice dispas3 {
xywh {20 260 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 3, false );
tbmw->redraw();}
xywh {30 30 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 3, false );
tbmw->redraw();}
xywh {30 30 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 3, false );
tbmw->redraw();}
xywh {30 30 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 3, true );
tbmw->determine_cutplane(3);
tbmw->redraw();}
xywh {30 30 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 3, true );
tbmw->determine_cutplane(3);
......@@ -373,32 +376,32 @@ normcb(4);}
Fl_Choice dispas4 {
xywh {210 260 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 4, false );
tbmw->redraw();}
xywh {40 40 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 4, false );
tbmw->redraw();}
xywh {40 40 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 4, false );
tbmw->redraw();}
xywh {40 40 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 4, true );
tbmw->determine_cutplane(4);
tbmw->redraw();}
xywh {40 40 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 4, true );
tbmw->determine_cutplane(4);
......@@ -450,32 +453,32 @@ normcb(5);}
Fl_Choice dispas5 {
xywh {400 260 110 20} down_box BORDER_BOX
} {
menuitem {} {
MenuItem {} {
label Off
callback {drawIntercept( 5, false );
tbmw->redraw();}
xywh {50 50 30 20}
}
menuitem {} {
MenuItem {} {
label On
callback {drawIntercept( 5, false );
tbmw->redraw();}
xywh {50 50 30 20}
}
menuitem {} {
MenuItem {} {
label {Whole Plane}
callback {drawIntercept( 5, false );
tbmw->redraw();}
xywh {50 50 30 20}
}
menuitem {} {
MenuItem {} {
label Intersection
callback {drawIntercept( 5, true );
tbmw->determine_cutplane(5);
tbmw->redraw();}
xywh {50 50 30 20}
}
menuitem {} {
MenuItem {} {
label Datified
callback {drawIntercept( 5, true );
tbmw->determine_cutplane(5);
......@@ -497,12 +500,20 @@ x[3][0] = -1;
x[4][1] = -1;
x[5][2] = -1;
for( int i=0; i<6; i++ ) intercept[i] = 0;} {}
for( int i=0; i<6; i++ ){
intercept[i] = 0;
}} {}
}
decl {GLdouble x[6][4];} {private local
}
decl {bool intercept[6];} {private local
}
decl {float dim;} {private local
}
decl {TBmeshWin* tbmw;} {private local
}
decl {float ctr_intercept[6];} {private local
}
decl {GLdouble x[6][4];} {}
decl {bool intercept[6];} {}
decl {float dim;} {}
decl {TBmeshWin* tbmw;} {}
Function {on(int cp)} {return_type bool
} {
code {if( cp==0 )
......@@ -518,52 +529,52 @@ else if( cp==4 )
else if( cp==5 )
return dispas5->value()>0;} {}
}
Function {plane(int cp)} {return_type {GLdouble*}
Function {plane(int cp)} {open return_type {GLdouble*}
} {
code {return x[cp];} {}
}
Function {normcb( int cp)} {private return_type void
Function {normcb( int cp)} {open private return_type void
} {
code {if( !cp ) {
x[cp][0] = xdir0->value();
x[cp][1] = ydir0->value();
x[cp][2] = zdir0->value();
x[cp][3] = intercept0->value()*dim;
x[cp][3] = intercept0->value()*dim+ctr_intercept[0];
if( drawIntercept(0) ) tbmw->determine_cutplane( 0 );
if( dispas0->value()>0 ) tbmw->redraw();
} else if (cp==1) {
x[cp][0] = xdir1->value();
x[cp][1] = ydir1->value();
x[cp][2] = zdir1->value();
x[cp][3] = intercept1->value()*dim;
x[cp][3] = intercept1->value()*dim+ctr_intercept[1];
if( drawIntercept(1) ) tbmw->determine_cutplane( 1 );
if( dispas1->value()>0 ) tbmw->redraw();
}else if (cp==2) {
x[cp][0] = xdir2->value();
x[cp][1] = ydir2->value();
x[cp][2] = zdir2->value();
x[cp][3] = intercept2->value()*dim;
x[cp][3] = intercept2->value()*dim+ctr_intercept[2];
if( drawIntercept(2) ) tbmw->determine_cutplane( 2 );
if( dispas2->value()>0 ) tbmw->redraw();
}else if (cp==3) {
x[cp][0] = xdir3->value();
x[cp][1] = ydir3->value();
x[cp][2] = zdir3->value();
x[cp][3] = intercept3->value()*dim;
x[cp][3] = intercept3->value()*dim+ctr_intercept[3];
if( drawIntercept(3) ) tbmw->determine_cutplane( 3 );
if( dispas3->value()>0 ) tbmw->redraw();
}else if (cp==4) {
x[cp][0] = xdir4->value();
x[cp][1] = ydir4->value();
x[cp][2] = zdir4->value();
x[cp][3] = intercept4->value()*dim;
x[cp][3] = intercept4->value()*dim+ctr_intercept[4];
if( drawIntercept(4) ) tbmw->determine_cutplane( 4 );
if( dispas4->value()>0 ) tbmw->redraw();
}else if (cp==5) {
x[cp][0] = xdir5->value();
x[cp][1] = ydir5->value();
x[cp][2] = zdir5->value();
x[cp][3] = intercept5->value()*dim;
x[cp][3] = intercept5->value()*dim+ctr_intercept[5];
if( drawIntercept(5) ) tbmw->determine_cutplane( 5 );
if( dispas5->value()>0 ) tbmw->redraw();
}} {}
......@@ -632,11 +643,11 @@ else if( cp==5 )
}
normcb(cp);} {}
}
Function {drawIntercept( int cp, bool b )} {private
Function {drawIntercept( int cp, bool b )} {open private
} {
code {intercept[cp] = b;} {}
}
Function {drawIntercept( int cp )} {return_type bool
Function {drawIntercept( int cp )} {open return_type bool
} {
code {return intercept[cp];} {}
}
......@@ -655,8 +666,7 @@ else if( cp==4 )
else if( cp==5 )
return dispas5->value()==4;} {}
}
Function {save(ostream& ofs)} {open
} {
Function {save(ostream& ofs)} {} {
code {ofs << SAVE_CP(0) << endl;
ofs << SAVE_CP(1) << endl;
ofs << SAVE_CP(2) << endl;
......@@ -669,8 +679,7 @@ for( int i=0; i<6; i++ ) {
ofs << intercept[i] << endl;
}} {}
}
Function {read(istream& ifs)} {open
} {
Function {read(istream& ifs)} {} {
code {READ_CP(0,ifs);
READ_CP(1,ifs);
READ_CP(2,ifs);
......@@ -687,11 +696,20 @@ CHECK_CP(1);
CHECK_CP(2);
CHECK_CP(3);
CHECK_CP(4);
CHECK_CP(5);} {selected
}
CHECK_CP(5);} {}
}
Function {calc_intercept()} {open
} {