2005-02-01 19:07:14 +01:00
|
|
|
#include <GL/glew.h>
|
2004-12-17 12:17:36 +01:00
|
|
|
#include <qgl.h>
|
2005-02-01 19:07:14 +01:00
|
|
|
#include <wrap/gl/trimesh.h>
|
|
|
|
#include <wrap/gui/trackball.h>
|
2004-12-17 12:17:36 +01:00
|
|
|
#include <segmentator.h>
|
|
|
|
#include <sim/tri_pde_integrator.h>
|
|
|
|
#include <vcg/complex/trimesh/update/bounding.h>
|
|
|
|
#include <wrap/io_trimesh/export_ply.h>
|
|
|
|
#include <segmentform.h>
|
2004-12-21 18:38:42 +01:00
|
|
|
#include <qpushbutton.h>
|
2005-02-01 19:07:14 +01:00
|
|
|
#include <qtimer.h>
|
2004-12-17 12:17:36 +01:00
|
|
|
|
|
|
|
class SimpleGLWidget: public QGLWidget{
|
|
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private :
|
|
|
|
int _H;
|
|
|
|
int _W;
|
2005-02-01 19:07:14 +01:00
|
|
|
vcg::Trackball TrackM;
|
|
|
|
vcg::Trackball TrackS;
|
2004-12-17 12:17:36 +01:00
|
|
|
double zoom;
|
|
|
|
GLdouble projection[16];
|
|
|
|
GLdouble modelMatrix[16];
|
|
|
|
GLint viewport[4];
|
|
|
|
bool _showslides;
|
|
|
|
int _numslide;
|
|
|
|
bool wire;
|
|
|
|
bool blocked;
|
|
|
|
bool extForces;
|
|
|
|
bool intForces;
|
|
|
|
bool resultForces;
|
|
|
|
bool continue_int;
|
2005-07-18 17:46:23 +02:00
|
|
|
bool rawImage;
|
2004-12-21 18:38:42 +01:00
|
|
|
GLuint texName;
|
2005-04-20 17:20:13 +02:00
|
|
|
|
2005-02-01 19:07:14 +01:00
|
|
|
//Segmentator *s;
|
|
|
|
//QTimer *timer;
|
2004-12-17 12:17:36 +01:00
|
|
|
//vcg::GlTrimesh<Segmentator::MyTriMesh> *Wrap;
|
|
|
|
|
|
|
|
public:
|
2005-04-20 17:20:13 +02:00
|
|
|
vcg::Point3f CenterExtraction;
|
2004-12-21 18:38:42 +01:00
|
|
|
QString path;
|
2004-12-17 12:17:36 +01:00
|
|
|
SegmentForm *w;
|
|
|
|
SimpleGLWidget( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 );
|
|
|
|
|
|
|
|
virtual void glDraw();
|
|
|
|
//virtual void paintEvent ( QPaintEvent * ) ;
|
|
|
|
void resizeGL( int w, int h );
|
|
|
|
virtual void mousePressEvent ( QMouseEvent * e );
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent * e );
|
|
|
|
virtual void mouseMoveEvent ( QMouseEvent * e );
|
|
|
|
virtual void wheelEvent ( QWheelEvent * e );
|
2005-04-11 11:26:22 +02:00
|
|
|
virtual void keyPressEvent(QKeyEvent *k);
|
2004-12-17 12:17:36 +01:00
|
|
|
virtual void initializeGL();
|
|
|
|
virtual void SaveMatrix();
|
|
|
|
virtual void Save();
|
|
|
|
void LoadMatrix();
|
2005-07-18 17:46:23 +02:00
|
|
|
void LoadTextureJpg(QString path,int level);
|
|
|
|
void LoadTextureRaw(int level);
|
2004-12-17 12:17:36 +01:00
|
|
|
void drawSlide();
|
|
|
|
void SmoothMesh();
|
|
|
|
void Step();
|
|
|
|
void SetExtractionParameters();
|
|
|
|
void WriteInfo();
|
|
|
|
void ClearMesh();
|
|
|
|
void OpenDirectory();
|
2005-07-18 17:46:23 +02:00
|
|
|
void OpenRaw();
|
2005-02-01 19:07:14 +01:00
|
|
|
void MarchingCube();
|
|
|
|
void UpdateBBMesh();
|
2005-02-08 18:47:50 +01:00
|
|
|
void setColor();
|
2005-07-18 17:46:23 +02:00
|
|
|
//void MarchingCubesExtraction();
|
2004-12-17 12:17:36 +01:00
|
|
|
//virtual void keyPressEvent(QKeyEvent *qk);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void Open()
|
|
|
|
{
|
|
|
|
OpenDirectory();
|
|
|
|
}
|
2005-07-18 17:46:23 +02:00
|
|
|
|
|
|
|
void OpenRawFile()
|
|
|
|
{
|
|
|
|
OpenRaw();
|
|
|
|
}
|
2004-12-17 12:17:36 +01:00
|
|
|
|
|
|
|
void ShowSlides()
|
|
|
|
{
|
|
|
|
_showslides=!_showslides;
|
2005-02-01 19:07:14 +01:00
|
|
|
UpdateBBMesh();
|
2004-12-17 12:17:36 +01:00
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWire()
|
|
|
|
{
|
|
|
|
wire=!wire;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShowBlocked()
|
|
|
|
{
|
|
|
|
blocked=!blocked;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowExternalForces()
|
|
|
|
{
|
|
|
|
extForces=!extForces;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowInternalForces()
|
|
|
|
{
|
|
|
|
intForces=!intForces;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowResultForces()
|
|
|
|
{
|
|
|
|
resultForces=!resultForces;
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Smooth()
|
|
|
|
{
|
|
|
|
SmoothMesh();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SavePly()
|
|
|
|
{
|
|
|
|
Save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Apply()
|
|
|
|
{
|
|
|
|
SetExtractionParameters();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Extract()
|
|
|
|
{
|
2005-04-20 17:20:13 +02:00
|
|
|
//UpdateBBMesh();
|
2004-12-17 12:17:36 +01:00
|
|
|
continue_int=!continue_int;
|
2005-04-20 17:20:13 +02:00
|
|
|
//if (continue_int)
|
|
|
|
//{
|
|
|
|
// _showslides=false;
|
|
|
|
// w->SlidesButton->setOn(false);
|
|
|
|
// //((SegmentForm *)this->parent())->SlidesButton->setOn(false);
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
// _showslides=true;
|
|
|
|
// w->SlidesButton->setOn(true);
|
|
|
|
// //((SegmentForm *)this->parent())->SlidesButton->setOn(true);
|
|
|
|
//}
|
2005-02-01 19:07:14 +01:00
|
|
|
repaint();
|
2004-12-17 12:17:36 +01:00
|
|
|
}
|
2005-07-18 17:46:23 +02:00
|
|
|
|
|
|
|
//void Extract()
|
|
|
|
//{
|
|
|
|
// //UpdateBBMesh();
|
|
|
|
// continue_int=!continue_int;
|
|
|
|
// //if (continue_int)
|
|
|
|
// //{
|
|
|
|
// // _showslides=false;
|
|
|
|
// // w->SlidesButton->setOn(false);
|
|
|
|
// // //((SegmentForm *)this->parent())->SlidesButton->setOn(false);
|
|
|
|
// //}
|
|
|
|
// //else
|
|
|
|
// //{
|
|
|
|
// // _showslides=true;
|
|
|
|
// // w->SlidesButton->setOn(true);
|
|
|
|
// // //((SegmentForm *)this->parent())->SlidesButton->setOn(true);
|
|
|
|
// //}
|
|
|
|
// repaint();
|
|
|
|
//}
|
2004-12-17 12:17:36 +01:00
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
Step();
|
|
|
|
}
|
|
|
|
|
2005-02-01 19:07:14 +01:00
|
|
|
|
2004-12-17 12:17:36 +01:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
ClearMesh();
|
2005-02-01 19:07:14 +01:00
|
|
|
repaint();
|
2004-12-17 12:17:36 +01:00
|
|
|
}
|
2005-02-01 19:07:14 +01:00
|
|
|
|
|
|
|
void CleanMesh()
|
|
|
|
{
|
|
|
|
MarchingCube();
|
2005-04-20 17:20:13 +02:00
|
|
|
#ifndef _TORUS
|
2005-02-01 19:07:14 +01:00
|
|
|
UpdateBBMesh();
|
2005-04-20 17:20:13 +02:00
|
|
|
#endif
|
2005-02-01 19:07:14 +01:00
|
|
|
repaint();
|
|
|
|
}
|
2005-07-18 17:46:23 +02:00
|
|
|
/*
|
|
|
|
void MCExtraction()
|
|
|
|
{
|
|
|
|
MarchingCubesExtraction();
|
|
|
|
}*/
|
|
|
|
|
2005-02-08 18:47:50 +01:00
|
|
|
void SetSegmentColor()
|
|
|
|
{
|
|
|
|
setColor();
|
|
|
|
}
|
2004-12-17 12:17:36 +01:00
|
|
|
};
|