Commit cefb54a0 authored by Edward Vigmond's avatar Edward Vigmond
Browse files

Fixed indexing error.

parent fac95ef7
......@@ -4,7 +4,37 @@
*/
#include "DrawingObjects.h"
#define USE_QUADRIC_OBJS
#include "VecData.h"
//#define USE_QUADRIC_OBJS
#ifdef USE_QUADRIC_OBJS
void draw_cylinder( const GLfloat *start, const GLfloat* end, int radius )
{
GLUquadric* quado = gluNewQuadric();
gluQuadricDrawStyle( quado, GLU_FILL );
gluQuadricOrientation(quado, GLU_INSIDE);
glPushAttrib( GL_POLYGON_BIT );
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
GLfloat rotvect[3], zaxis[]={0,0,1};
glPushMatrix();
glTranslatef( start[0], start[1], start[2] );
GLfloat h[3];
sub( end, start, h );
float height = magnitude(h);
// determine angle between z-axis and data vector
float angle = -acos( dot( h, zaxis )/height )*180./M_PI;
// determine rotation axis
cross( h, zaxis, rotvect );
glRotatef( angle, rotvect[0], rotvect[1], rotvect[2] );
gluCylinder( quado, radius, radius, height, 10, 2 );
glPopMatrix();
gluDeleteQuadric(quado);
glPopAttrib( );
}
#endif
/** draw many Points
*
......@@ -19,21 +49,34 @@ void Connection::draw( int p0, int p1, GLfloat *colour, Colourscale* cs,
{
if( p0>=_n || p1>=_n ) return;
#ifndef USE_QUADRIC_OBJS
glBegin(GL_LINES);
#endif
for( int i=p0; i<=p1; i+=stride ) {
if( !_pt->vis(_node[i*2]) || !_pt->vis(_node[i*2+1]) )
continue;
if( data != NULL ) {
#ifdef USE_QUADRIC_OBJS
cs->colourize( data[_node[i*2]], colour[3] );
draw_cylinder( _pt->pt(_node[i*2]), _pt->pt(_node[i*2+1]), 0.4 );
#else
cs->colourize( data[_node[i*2]], colour[3] );
glVertex3fv(_pt->pt(_node[i*2]));
cs->colourize( data[_node[i*2+1]], colour[3] );
glVertex3fv(_pt->pt(_node[i*2+1]));
#endif
} else {
#ifdef USE_QUADRIC_OBJS
draw_cylinder( _pt->pt(_node[i*2]), _pt->pt(_node[i*2+1]), 0.4 );
#else
glVertex3fv(_pt->pt(_node[i*2]));
glVertex3fv(_pt->pt(_node[i*2+1]));
#endif
}
}
#ifndef USE_QUADRIC_OBJS
glEnd();
#endif
}
......@@ -48,10 +91,14 @@ void Connection :: draw( int p, GLfloat *colour, float size )
if( p<_n ) {
glColor3fv( colour );
glLineWidth(size);
#ifdef USE_QUADRIC_OBJS
draw_cylinder( _pt->pt(_node[p*2]), _pt->pt(_node[p*2+1]), 0.4 );
#else
glBegin( GL_LINES );
glVertex3fv( _pt->pt(_node[p*2] ) );
glVertex3fv( _pt->pt(_node[p*2+1] ) );
glEnd();
#endif
glLineWidth(1);
}
}
......
......@@ -135,7 +135,7 @@ DataAllInMem<T>::DataAllInMem( const char *fn, int slsz, bool base1 )
filename = fn;
// ugly but I don't know what else to do besides specialization which is ugly
char *scanstr;
const char *scanstr;
if( typeid(T) == typeid(double) ) scanstr = "%lf";
else if( typeid(T) == typeid(float) ) scanstr = "%f";
else if( typeid(T) == typeid(int) ) scanstr = "%d";
......
......@@ -140,6 +140,22 @@ class Triangle : public SurfaceElement {
};
class Quadrilateral : public SurfaceElement {
public:
Quadrilateral(Point *p):SurfaceElement(p,4) {}
virtual void draw( int, GLfloat*, float size=1 );
virtual void draw( int, int, GLfloat*, Colourscale*, DATA_TYPE*,
int stride=1, dataOpac* dopac=NULL );
virtual void draw( int, int, GLfloat*, Colourscale*, DATA_TYPE*,
int stride, dataOpac* dopac, const GLfloat *);
virtual bool read( const char * );
virtual void compute_normals( int, int );
bool add( const char * );
protected:
int countTrisInFile( const char * );
};
//! Volume elements
class VolElement : public MultiPoint {
public:
......
......@@ -238,7 +238,7 @@ int my_fputs( FILE *, char * );
int Header_Quiet = 0;
char Header_Message[256];
char *Header_Type[] = {
const char *Header_Type[] = {
"", "byte", "char", "short", "long", "float", "double", "complex",
"double_complex", "rgba", "structure", "pointer", "list","int","uint"
};
......@@ -287,7 +287,7 @@ long unsigned
IGB_LITTLE_ENDIAN
};
char
const char
*Header_Systeme[] = {
"unix",
"system_v",
......@@ -419,7 +419,7 @@ int IGBheader::write()
v_type);
return (0);
}
char *type = Header_Type[v_type];
const char *type = Header_Type[v_type];
if (v_type==IGB_STRUCTURE && v_taille<1) {
if (!Header_Quiet)
......@@ -1364,7 +1364,7 @@ void IGBheader::comment(char *ligne)
bool_comment = true;
}
char *IGBheader::systemestr( void )
const char *IGBheader::systemestr( void )
{
int i;
......
......@@ -195,9 +195,9 @@ typedef union rgba {
#ifndef HEADER_GLOBALS
extern int Header_Quiet;
extern char *Header_Type[IGB_MAX_TYPE+1];
extern const char *Header_Type[IGB_MAX_TYPE+1];
extern unsigned short Data_Size[IGB_MAX_TYPE+1];
extern char *Header_Systeme[N_SYSTEMES];
extern const char *Header_Systeme[N_SYSTEMES];
extern unsigned long Header_Systeme_No[N_SYSTEMES];
extern char Header_Message[256];
#endif
......@@ -304,7 +304,7 @@ public:
inline int trame(void){ return v_trame; }
inline int trame( bool &set ){ set=bool_trame; return v_trame; }
inline void trame( int a ){ v_trame = a; bool_trame = true;}
char* systemestr(void);
const char* systemestr(void);
inline int systeme( void ){ return v_systeme; }
inline unsigned int lut(void){ return v_lut; }
inline unsigned int lut( bool &set ){ set=bool_x; return v_x; }
......
......@@ -4,7 +4,7 @@ HOSTMACHINE := $(shell uname)
FLTK_INC := $(shell fltk-config --use-gl --cxxflags)
FLTK_LD_FLAGS := $(shell fltk-config --use-gl --ldflags)
COMMON_LIBS = -lpng -lpthread -lm -lz
COMMON_INC = -I. -O3 -DOBJ_CLASS
COMMON_INC = -I. -O0 -g -DOBJ_CLASS
ifeq ($(HOSTMACHINE),Linux)
LIBS = $(FLTK_LD_FLAGS) $(COMMON_LIBS)
......
......@@ -711,7 +711,7 @@ bool Model :: read_elem_file( const char *fname )
_vol = new VolElement*[_numVol];
for( int i=0; i< _numVol; i++ ) {
for( int i=0; i<_numVol; i++ ) {
if( gzgets(in, buf, bufsize) == Z_NULL ) return false;
int n[9];
if( tets )
......@@ -733,7 +733,12 @@ bool Model :: read_elem_file( const char *fname )
_vol[i]->add( n, n[6] );
} else {
fprintf( stderr, "Unsupported element type\n" );
exit(1);
delete[] _vol;
_numVol = 0;
_vol = NULL;
gzclose(in);
return false;
}
}
gzclose(in);
}
......@@ -429,7 +429,7 @@ void TBmeshWin::draw_cables(Region* sf)
if( dataopac->dop[Cable].on() ) translucency(false);
glPopAttrib();
} else
model->_cable->register_vertices(0,model->_cable->num(),ptDrawn);
model->_cable->register_vertices(0,model->_cable->num()-1,ptDrawn);
}
......@@ -486,7 +486,7 @@ void TBmeshWin::draw_axes()
gluQuadricOrientation(quado, GLU_INSIDE);
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
char *axis_label[] = { "X", "Y", "Z" };
const char *axis_label[] = { "X", "Y", "Z" };
for( int i=0; i< 3; i++ ) {
glPushMatrix();
......
......@@ -67,7 +67,7 @@ class Master{
Master(const char *fn,int s):slsz(s),fname(fn),maxtm(0),maxmin(NULL){}
FileType ftype; //!< What type of file is it?
string fname; //!< Argument sent to the class
char* scanstr; //!< Scan string
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
......
......@@ -86,7 +86,7 @@ VecData::VecData(const GLfloat *pt_offset, char* vptfile):_length(1),maxmag(0.),
if( gzgets( in, buff, bufsize ) == Z_NULL ) return;
float tscal[4];
int npl = sscanf(buff,"%f %f %f %f", tscal, tscal+1, tscal+2, tscal+3 );
char *scanstr;
const char *scanstr;
if( npl==4 )
scanstr="%f %f %f %f";
else if( npl==3 )
......
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