Commit 3e5d460d authored by Edward Vigmond's avatar Edward Vigmond
Browse files

Fix porting to Mac. There was an issue with the static initialization of

the Controls object. I worked around this by declaring a static pointer
which I assigned after I instantiated the object from within main().

There was a name clash with a Mac framework so I had to rename Point to
PPoint.
parent ef1b57ce
......@@ -81,7 +81,7 @@ initializeCyltexture( GLubyte *cgrad, GLuint *tn )
}
/** draw many Points
/** draw many PPoints
*
* \param p0 first connection of region
* \param p1 last connection of region
......
......@@ -35,7 +35,7 @@ CutSurfaces :: addEle( SurfaceElement *se, GLfloat *n, Interpolator<DATA_TYPE> *
(_numele/ADD_INC+1)*ADD_INC*sizeof(GLfloat)*3 ));
}
_ele.push_back(se);
_ptarr[_numele] = const_cast<GLfloat *>(const_cast<Point*>(se->pt())->pt());
_ptarr[_numele] = const_cast<GLfloat *>(const_cast<PPoint*>(se->pt())->pt());
_interp[_numele] = ni;
memcpy( _norm+3*_numele, n, sizeof(GLfloat)*3 );
}
......
......@@ -19,7 +19,7 @@ class CutSurfaces : public Surfaces
CutSurfaces();
~CutSurfaces();
void get_vert_norms( GLfloat *vn ){}
void determine_vert_norms( Point & ){}
void determine_vert_norms( PPoint & ){}
void addEle( SurfaceElement *e, GLfloat *n, Interpolator<DATA_TYPE>* );
DATA_TYPE interpolate( int e, DATA_TYPE *d, int p )
{
......
......@@ -125,7 +125,7 @@ DataAllInMem<T>::DataAllInMem( const char *fn, int slsz, bool base1 )
slice_size = slsz;
FileType ftype=FileTypeFinder( fn );
fileType ftype=FileTypeFinder( fn );
if ( (in=gzopen(fname.c_str(), "r")) == NULL ) {
fname += ".gz";
......
......@@ -7,10 +7,10 @@
#include <string>
using namespace std;
enum FileType{ FTIGB=1, FTascii, FTfileSeqCG, FTother };
enum DataReaderEnum {AllInMem, Threaded };
enum fileType { FTIGB=1, FTascii, FTfileSeqCG, FTother };
FileType FileTypeFinder ( const char *fn );
fileType FileTypeFinder ( const char *fn );
void CG_file_list( map<int,string>&filelist, const char *fn );
......
......@@ -286,7 +286,7 @@ VolElement::planecut( char *pd, GLfloat* cp,
}
// make new element
Point *pt = new Point;
PPoint *pt = new PPoint;
pt->add( intersect, num_int );
pt->setVis( true );
pt->offset( _pt->offset() );
......@@ -377,7 +377,7 @@ MultiPoint ** MultiPoint::isosurf( DATA_TYPE *dat, DATA_TYPE val, int &npoly,
if( interp )
interp->push_back(new Interpolator<DATA_TYPE>( n0, n1, d ));
}
Point *pts = new Point;
PPoint *pts = new PPoint;
pts->add( pt, npts );
pts->setVis(true);
pts->offset(_pt->offset());
......
......@@ -40,11 +40,11 @@ class DrawingObj
};
class Point: public DrawingObj
class PPoint: public DrawingObj
{
public:
Point() : _pts(NULL), _base1(false) {}
virtual ~Point() { if ( _pts ) free(_pts); _pts = 0; }
PPoint() : _pts(NULL), _base1(false) {}
virtual ~PPoint() { if ( _pts ) free(_pts); _pts = 0; }
virtual void draw( int, GLfloat*, float size=1 );
virtual void draw( int, int, GLfloat*, Colourscale*, DATA_TYPE*,
......@@ -75,21 +75,21 @@ class Point: public DrawingObj
class MultiPoint : public DrawingObj
{
public:
MultiPoint( Point *p, int n, int e ):_pt(p),_ptsPerObj(n),_node(NULL), _nedge(e) {}
MultiPoint( PPoint *p, int n, int e ):_pt(p),_ptsPerObj(n),_node(NULL), _nedge(e) {}
virtual ~MultiPoint() { if ( _node ) delete[] _node; _node = 0; }
const int* obj( int n=0 ) { return _node+n*_ptsPerObj; }
int ptsPerObj(){ return _ptsPerObj; }
void register_vertices(int, int, vector<bool>& );
void add( int *n );
const Point* pt(){ return _pt; }
const PPoint* pt(){ return _pt; }
void define( const int *nl, int n=1 );
MultiPoint **isosurf( DATA_TYPE *d, DATA_TYPE val, int &,
vector<Interpolator<DATA_TYPE>*> *a=NULL );
virtual const int*iso_polys(unsigned int)=0;
protected:
int * _node; //!< list of nodes defining objects
Point* _pt; //!< pointer to point list
PPoint* _pt; //!< pointer to point list
int _ptsPerObj; //!< \#nodes to define one object
int _nedge; //!< \#edges
};
......@@ -98,7 +98,7 @@ class MultiPoint : public DrawingObj
class Connection : public MultiPoint
{
public:
Connection(Point *p):MultiPoint(p,2,1) {}
Connection(PPoint *p):MultiPoint(p,2,1) {}
virtual ~Connection() {}
void add( int, int ); //!< add a connection
......@@ -115,7 +115,7 @@ class Connection : public MultiPoint
class ContCable : public MultiPoint
{
public:
ContCable(Point *p):MultiPoint(p,1,1) {}
ContCable(PPoint *p):MultiPoint(p,1,1) {}
virtual ~ContCable() {}
const int* obj( int n=0 ) { return _node+n; }
......@@ -133,7 +133,7 @@ class ContCable : public MultiPoint
class SurfaceElement : public MultiPoint
{
public:
SurfaceElement(Point *p, int n):MultiPoint(p,n,n),_nrml(NULL) {}
SurfaceElement(PPoint *p, int n):MultiPoint(p,n,n),_nrml(NULL) {}
virtual ~SurfaceElement(){ if ( _nrml!=NULL ) delete[] _nrml; }
virtual void compute_normals( int, int )=0;
......@@ -153,7 +153,7 @@ class SurfaceElement : public MultiPoint
class PolyGon : public SurfaceElement
{
public:
PolyGon( Point *p, int n ) : SurfaceElement(p,n) {}
PolyGon( PPoint *p, int n ) : SurfaceElement(p,n) {}
virtual ~PolyGon() {}
virtual void compute_normals( int a, int b );
......@@ -171,7 +171,7 @@ class PolyGon : public SurfaceElement
class Triangle : public SurfaceElement
{
public:
Triangle(Point *p):SurfaceElement(p,3) {}
Triangle(PPoint *p):SurfaceElement(p,3) {}
virtual ~Triangle() {}
virtual void draw( int, GLfloat*, float size=1 );
......@@ -192,7 +192,7 @@ class Triangle : public SurfaceElement
class Quadrilateral : public SurfaceElement
{
public:
Quadrilateral(Point *p):SurfaceElement(p,4) {}
Quadrilateral(PPoint *p):SurfaceElement(p,4) {}
virtual ~Quadrilateral() {}
virtual void draw( int, GLfloat*, float size=1 );
......@@ -213,7 +213,7 @@ class Quadrilateral : public SurfaceElement
class VolElement : public MultiPoint
{
public:
VolElement( Point *p, int n, int e ):MultiPoint( p, n, e ) {}
VolElement( PPoint *p, int n, int e ):MultiPoint( p, n, e ) {}
virtual ~VolElement() {}
const int* region() const { return _region; }
......@@ -234,7 +234,7 @@ class VolElement : public MultiPoint
class Tetrahedral : public VolElement
{
public:
Tetrahedral(Point *p ): VolElement(p,4,6) {}
Tetrahedral(PPoint *p ): VolElement(p,4,6) {}
virtual ~Tetrahedral() {}
virtual void draw( int, GLfloat*, float size=1 );
......@@ -250,7 +250,7 @@ class Tetrahedral : public VolElement
class Prism : public VolElement
{
public:
Prism(Point *p ): VolElement(p,6,9) {}
Prism(PPoint *p ): VolElement(p,6,9) {}
virtual ~Prism() {}
virtual void draw( int, GLfloat*, float size=1 );
......@@ -267,7 +267,7 @@ class Prism : public VolElement
class Hexahedron : public VolElement
{
public:
Hexahedron(Point *p ): VolElement(p,8,12) {}
Hexahedron(PPoint *p ): VolElement(p,8,12) {}
virtual ~Hexahedron() {}
virtual void draw( int, GLfloat*, float size=1 );
......@@ -283,7 +283,7 @@ class Hexahedron : public VolElement
class Pyramid : public VolElement
{
public:
Pyramid(Point *p ): VolElement(p,5,8) {}
Pyramid(PPoint *p ): VolElement(p,5,8) {}
virtual ~Pyramid() {}
virtual void draw( int, GLfloat*, float size=1 );
......
......@@ -34,7 +34,7 @@ using namespace std;
*
* \return if everything fails, FTascii
*/
FileType FileTypeFinder ( const char *fn )
fileType FileTypeFinder ( const char *fn )
{
string fname = fn;
......
......@@ -6,8 +6,8 @@ COMMON_LIBS = -lpng -lpthread -lm -lz
COMMON_INC = -I. -O0 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX
ifeq ($(HOSTMACHINE),Darwin)
LIBS = -L/sw/lib $(FLTK_LD_FLAGS) $(COMMON_LIBS)
CFLAGS = -I/sw/include -I/usr/X11R6/include $(FLTK_INC) $(COMMON_INC)
LIBS = $(FLTK_LD_FLAGS) $(COMMON_LIBS)
CFLAGS = -I/usr/X11R6/include $(FLTK_INC) $(COMMON_INC)
else
LIBS = $(FLTK_LD_FLAGS) $(COMMON_LIBS)
CFLAGS = $(FLTK_INC) $(COMMON_INC)
......
......@@ -63,7 +63,7 @@ class Model
string file()const{return _file;}
bool twoD(){return _2D; }
Point pt;
PPoint pt;
Connection* _cnnx;
ContCable* _cable;
VolElement** _vol;
......
......@@ -20,6 +20,7 @@
PNGwrite :: PNGwrite( FILE *out )
{
/*
fp = out;
width = height = 0;
ctype = PNG_COLOR_TYPE_RGB;
......@@ -38,8 +39,9 @@ PNGwrite :: PNGwrite( FILE *out )
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return;
}
setjmp(png_ptr->jmpbuf);
setjmp(png_jmpbuf(png_ptr));
png_init_io(png_ptr, fp);
*/
}
PNGwrite :: ~PNGwrite( void )
......@@ -47,7 +49,7 @@ PNGwrite :: ~PNGwrite( void )
int PNGwrite :: write( void *data )
{
setjmp(png_jmpbuf(png_ptr));
/*setjmp(png_jmpbuf(png_ptr));
png_set_IHDR( png_ptr, info_ptr, width, height, colour_depth, ctype,
interlace_type, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
......@@ -75,5 +77,6 @@ int PNGwrite :: write( void *data )
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fclose( fp );
return 1;
*/
}
......@@ -24,7 +24,7 @@ void draw_sphere( const GLfloat *ctr, float radius )
}
/** draw many Points
/** draw many PPoints
*
* \param p0 first index of point to draw
* \param p1 last index of point to draw
......@@ -32,7 +32,7 @@ void draw_sphere( const GLfloat *ctr, float radius )
* \param data data associated with nodes (NULL for no data display)
* \param stride draw every n'th point
*/
void Point::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
void PPoint::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
DATA_TYPE* data, int stride, dataOpac* dataopac )
{
if ( p0>=_n || p1>=_n ) return;
......@@ -87,7 +87,7 @@ void Point::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
* \param colour colour to use
* \param size size of point
*/
void Point :: draw( int p, GLfloat *colour, float size )
void PPoint :: draw( int p, GLfloat *colour, float size )
{
if ( p<_n ) {
glColor3fv( colour );
......@@ -108,7 +108,7 @@ void Point :: draw( int p, GLfloat *colour, float size )
* \param p point to register
* \param ptDrawn list of nodes registered or not
*/
void Point::register_vertex( int p, vector<bool>& ptDrawn )
void PPoint::register_vertex( int p, vector<bool>& ptDrawn )
{
if ( !ptDrawn[p] ) { // only register once
ptDrawn[p] = true;
......@@ -121,7 +121,7 @@ void Point::register_vertex( int p, vector<bool>& ptDrawn )
/** read in the point file */
bool Point :: read( const char *fname )
bool PPoint :: read( const char *fname )
{
gzFile in = openFile( fname, "pts" );
......@@ -170,7 +170,7 @@ bool Point :: read( const char *fname )
* \param p points stored in array as x1 y1 z1 x2 y2 z2 ... xn yn zn
*/
void
Point :: add( GLfloat *p, int n )
PPoint :: add( GLfloat *p, int n )
{
_n += n;
_pts = (GLfloat *)realloc( _pts, _n*3*sizeof(GLfloat) );
......
......@@ -2,7 +2,7 @@
#include <string.h>
#include <VecData.h>
Surfaces::Surfaces( Point *pl ) : _p(pl), is_visible(true),_filled(true),
Surfaces::Surfaces( PPoint *pl ) : _p(pl), is_visible(true),_filled(true),
_outline(false),_vertnorm(NULL)
{
fillcolor( 1., 0.5, 0.1 );
......@@ -53,7 +53,7 @@ void Surfaces::get_vert_norms( GLfloat *vn )
* \param pt all points
*
*/
void Surfaces::determine_vert_norms( Point& pt )
void Surfaces::determine_vert_norms( PPoint& pt )
{
vector<bool> has_norm(pt.num()); // if elements attached to node
......
......@@ -9,7 +9,7 @@
class Surfaces
{
public:
Surfaces( Point *pl);
Surfaces( PPoint *pl);
Surfaces():_p(NULL){}
GLfloat* fillcolor( ){ return _fillcolor; }
void fillcolor(float r, float g, float b, float a=1);
......@@ -22,7 +22,7 @@ class Surfaces
inline bool outline( void ){ return _outline; }
inline void outline( bool a ){ _outline=a; }
void get_vert_norms( GLfloat *vn );
void determine_vert_norms( Point & );
void determine_vert_norms( PPoint & );
SurfaceElement*& ele( int a ){ return _ele[a]; }
int num() const {return _ele.size();}
void num(int a){_ele.resize(a);}
......@@ -34,7 +34,7 @@ class Surfaces
string label( void ) { return _label; }
void flip_norms();
protected:
Point *_p;
PPoint *_p;
GLfloat _fillcolor[4];
GLfloat _outlinecolor[4];
bool is_visible;
......
......@@ -70,12 +70,12 @@ class Master
{
public:
Master(const char *fn,int s):slsz(s),fname(fn),maxtm(0),maxmin(NULL){}
FileType ftype; //!< What type of file is it?
fileType ftype; //!< What type of file is it?
string fname; //!< Argument sent to the class
const char* scanstr; //!< Scan string
int slsz; //!< \#points in a time slice (not bytes)
int maxtm; //!< Max time (=\#slices-1)
Maxmin<T>* maxmin; //!< Pointer to maxmin structure
Maxmin<T>* maxmin; //!< PPointer to maxmin structure
};
......@@ -91,7 +91,7 @@ class Slave
public:
Slave(Master<T>*m=NULL, int datasize=0);
~Slave(){ pthread_cancel( threadID ); delete datareader; delete[] data; }
Master<T>* mthread; // Pointer to master
Master<T>* mthread; // PPointer to master
int rdtm; // Read time
T* data; // thread data buffer
int size; // size of data buffer
......@@ -141,14 +141,14 @@ class ThreadedData : public DataClass<T>
virtual T max(); //!< Maximum value of the entire series
virtual T min(int); //!< Minimum value at a slice of time
virtual T min(); //!< Minimum value of the entire series
virtual T* slice(int); //!< Pointer to slice of data at a time
virtual void time_series( int, T* ); //!< Pointer to time series
virtual T* slice(int); //!< PPointer to slice of data at a time
virtual void time_series( int, T* ); //!< PPointer to time series
virtual void increment(int increment); //!< Sets increment
private:
Master<T>* mthread; //!< master thread
Slave<T>* sthread; //!< slice reading threads
Slave<T>* stmsr; //!< thread to read time series
Maxmin<T>* maxmin; //!< Pointer to maxmin
Maxmin<T>* maxmin; //!< PPointer to maxmin
int incrementation; //!< Increment value
pthread_mutex_t mutex_incrementation; //!< Mutex to incrementation
int element; //!< Value to decide the next thread
......
......@@ -12,7 +12,7 @@
#include <sys/stat.h>
static Meshwin win;
static Controls control;
static Controls *ctrl_ptr;
sem_t *meshProcSem; // global semaphore for temporal linking
/** animate in response to a signal received: SIGUSR1 for forward,
......@@ -22,18 +22,18 @@ sem_t *meshProcSem; // global semaphore for temporal linking
*/
void animate_signal( int sig, siginfo_t *si, void *v )
{
int fs = control.frameskip->value();
int fs = ctrl_ptr->frameskip->value();
fs *= sig==SIGUSR1 ? 1 : -1;
int newtm = control.tmslider->value() + fs;
int newtm = ctrl_ptr->tmslider->value() + fs;
if( newtm<0 )
newtm = control.tmslider->maximum();
if( newtm> control.tmslider->maximum() )
newtm = ctrl_ptr->tmslider->maximum();
if( newtm> ctrl_ptr->tmslider->maximum() )
newtm = 0;
win.trackballwin->set_time( newtm );
control.tmslider->value(newtm);
ctrl_ptr->tmslider->value(newtm);
sem_post( meshProcSem );
}
......@@ -161,6 +161,9 @@ main( int argc, char *argv[] )
break;
}
Controls control;
ctrl_ptr = &control;
int model_index=optind;
while( model_index<argc && argv[model_index][0]=='-' )
model_index++;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment