Commit 1370259c authored by Jonathan Lambrechts's avatar Jonathan Lambrechts

scontactplot : iteration on fig

parent a2169f9e
......@@ -8,6 +8,7 @@
#include <iomanip>
#include <GL/gl.h>
#include <FL/gl.h>
std::vector<int> visible_flag(10, 3);
bool clip = false;
......@@ -94,9 +95,11 @@ class ObjectCollection {
std::vector<float> coord, segcoord, tricoord;
std::vector<float> circleGeom;
int dim;
int _step;
public :
ObjectCollection() {
dim = -1;
_step = -1;
circleGeom.push_back(0);
circleGeom.push_back(0);
for(unsigned int i = 0; i <= 100; ++i) {
......@@ -124,9 +127,9 @@ class ObjectCollection {
}
}
}
int step() const {return _step;}
int read(const std::string fbasename, int step)
{
printf("%i\n", step);
std::string filename;
std::ostringstream oss;
oss << fbasename << "/part-" <<std::setw(5)<<std::setfill('0')<< step;
......@@ -187,6 +190,7 @@ class ObjectCollection {
}
if (coordorig.empty() && dim == 3)
coordorig = coord;
_step = step;
return 1;
}
......@@ -214,9 +218,9 @@ class ObjectCollection {
glColor4f(1, 0.5, 0, 1);
glPushMatrix();
double S = *std::max_element(radius.begin(), radius.end())/2;
SolidSphere sphere(S, 15, 15);
size_t zidx = 0;
if (dim == 3) {
SolidSphere sphere(S, 15, 15);
for(size_t i = 0; i < radius.size(); ++i) {
if (coord[i * 3 + 1] < 0 && clip) continue;
glPushMatrix();
......@@ -271,8 +275,8 @@ std::string fbasename;
FILE* ffmpeg = NULL;
ObjectCollection collection;
int paused = 0;
int istep = -1, lstep = 0;
int paused = 1;
int istep = 1;
int step = 1;
double alpha = 0, beta = 0, scale = 1, shift[2] = {0, 0};
......@@ -337,7 +341,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
case 's' :{
if (sscanf(arg, "%d", &step) != 1)
return ARGP_ERR_UNKNOWN;
lstep = istep = step;
istep = step;
}
break;
case 'l' :{
......@@ -347,7 +351,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
case 'i' :{
if (sscanf(arg, "%d", &istep) != 1)
return ARGP_ERR_UNKNOWN;
lstep = istep;
}
case ARGP_KEY_ARG :
fbasename = arg;
......@@ -369,8 +372,8 @@ static struct argp argp = {options, parse_opt, args_doc, doc};
class ScontactPlotWindow : public Fl_Gl_Window {
public:
void draw() {
if (istep != lstep && collection.read(fbasename, istep))
lstep = istep;
if (istep != collection.step())
collection.read(fbasename, istep);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
......@@ -384,6 +387,16 @@ class ScontactPlotWindow : public Fl_Gl_Window {
glRotatef(alpha, 0, 0, 1);
}
collection.display();
char s[40];
sprintf(s, "%i", collection.step());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRasterPos2f(-0.95, -0.95);
glColor3f(0., 0., 0.);
gl_font(1, 12);
gl_draw(s, strlen(s));
if (ffmpeg) {
int *data = new int[w() * h()];
glReadPixels(0, 0, w(), h(), GL_RGBA, GL_UNSIGNED_BYTE, data);
......@@ -432,11 +445,10 @@ class ScontactPlotWindow : public Fl_Gl_Window {
return Fl_Gl_Window::handle(event);
}
static void Timer_CB(void *data) {
if (! paused && lstep == istep) {
if (! paused && collection.step() == istep) {
istep += step;
}
if (collection.read(fbasename, istep)) {
lstep = istep;
((ScontactPlotWindow*)(data))->redraw();
}
Fl::repeat_timeout(1./24, Timer_CB, data);
......@@ -449,9 +461,9 @@ class ScontactPlotWindow : public Fl_Gl_Window {
};
int main(int argc, char **argv) {
lstep = istep = step;
scale = -1;
argp_parse(&argp, argc, argv, 0, 0, 0);
istep = step;
collection.read(fbasename, istep);
float bbox[6];
collection.compute_bbox(bbox);
......
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