diff --git a/apps/test/lem/bardrawer.h b/apps/test/lem/bardrawer.h index ec5e79d0..ce22c922 100644 --- a/apps/test/lem/bardrawer.h +++ b/apps/test/lem/bardrawer.h @@ -99,6 +99,8 @@ public: glColor4d(0.8,0.8,0.8,0.9); for (Fi=m->face.begin();Fiface.end();Fi++) { + if (!Fi->IsD()) + { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); glEnable(GL_LIGHTING); @@ -119,6 +121,7 @@ public: glVertex(Fi->V(1)->P()); glVertex(Fi->V(2)->P()); glEnd(); + } } glPopAttrib(); } diff --git a/apps/test/lem/insert_vertex.h b/apps/test/lem/insert_vertex.h index 7592a43a..4c3c529f 100644 --- a/apps/test/lem/insert_vertex.h +++ b/apps/test/lem/insert_vertex.h @@ -30,19 +30,26 @@ #include #include +#include #include /// This Class is used for insertiong a vertex in a face namespace vcg{ namespace tri{ - + template ///insert a vertex iside a face and re-triangolarize v will be pointer to inserted vertex - void InsertVert(MESH_TYPE &m,typename MESH_TYPE::FaceType *f,typename MESH_TYPE::VertexType* &v) + void InsertVert(MESH_TYPE &m,typename MESH_TYPE::FaceType* &f,typename MESH_TYPE::VertexType* &v) { - MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator::AddFaces(m,3); + std::vector local_var; + local_var.push_back(&f); + MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator::AddFaces(m,3,local_var); MESH_TYPE::VertexIterator Vi=vcg::tri::Allocator::AddVertices(m,1); + + if (MESH_TYPE::HasVFTopology()) + Vi->VFp()=0; + MESH_TYPE::FaceIterator Fi=Finit; MESH_TYPE::FaceType *F; //set vertex pointer of new face @@ -56,7 +63,9 @@ namespace vcg{ //assign topology in substitution of the old one if (MESH_TYPE::HasFFTopology()) - vcg::face::Attach(F,0,f->FFp(i),f->FFi(i)); + { + vcg::face::FFAttach(F,0,f->FFp(i),f->FFi(i)); + } if (MESH_TYPE::HasVFTopology()) { vcg::face::VFDetach(f,i); @@ -76,20 +85,24 @@ namespace vcg{ MESH_TYPE::FaceType *F0=&(*Fi); MESH_TYPE::FaceType *F1=&(*Fsucc); - /*vcg::face::Attach(F0,1,F1,2);*/ + vcg::face::FFAttach(F0,1,F1,2); + Fi++; Fsucc++; F0=&(*Fi); F1=&(*Fsucc); - /*vcg::face::Attach(F0,1,F1,2);*/ + + vcg::face::FFAttach(F0,1,F1,2); Fsucc=Finit; Fi++; F0=&(*Fi); F1=&(*Fsucc); - /*vcg::face::Attach(F0,1,F1,2);*/ + + vcg::face::FFAttach(F0,1,F1,2); //at the end set as deleted the old face that was substituted f->SetD(); v=&(*Vi); + } diff --git a/apps/test/lem/main.cpp b/apps/test/lem/main.cpp index b1a01ce4..e650be8c 100644 --- a/apps/test/lem/main.cpp +++ b/apps/test/lem/main.cpp @@ -2,10 +2,10 @@ #include //#include #include -//#include -//#include +#include +#include -//#include +#include #include @@ -17,7 +17,7 @@ -//#include "form1.h" +#include "form1.h" class MyFace; @@ -50,94 +50,94 @@ vcg::tri::UpdateTopology UT; MyTriMesh *tm; vcg::tri::UpdateBounding UB; -//vcg::GLWrapBar *WB; +vcg::GLWrapBar *WB; //vcg::GlTrimesh *glT; -//struct MyGl: public QGLWidget{ -// MyGl( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 ) -// :QGLWidget(parent,name){} -// //void QGLWidget::paintEvent ( QPaintEvent * ) [virtual protected] -// double lr,ud,tz; -// int cx,cy,z; -// -// virtual void glDraw(){ -// -// glClearColor(0.2,0.2,0.2,1); -// glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); -// glMatrixMode(GL_PROJECTION); -// glLoadIdentity(); -// gluPerspective(45,1,0.01,20); -// glMatrixMode(GL_MODELVIEW); -// glLoadIdentity(); -// gluLookAt(0,0,1,0,0,0,0,10,0); -// -// -// glTranslatef(0,0,tz); -// glRotatef(lr,0,1,0); -// glRotatef(ud,1,0,0); -// -// glScalef(1/tm->bbox.Diag(),1/tm->bbox.Diag(),1/tm->bbox.Diag()); -// vcg::Point3d p=tm->bbox.Center(); -// glTranslate(-p); -// -// WB->Draw(); -// WB->DrawMesh(tm); -// -// /*glT->Draw ();*/ -// QGLWidget::glDraw(); -// } -// -// void resizeGL( int w, int h ) -// { -// //// setup viewport, projection etc.: -// glViewport( 0, 0, (GLint)w, (GLint)h ); -// } -// -// virtual void mousePressEvent ( QMouseEvent * e ){ -// cx = e->x(); -// cy = e->y(); -// -// //tr.MouseDown(e->x(),e->y(),(Trackball::Button)(int)(e->button())); -// //QWidget::mousePressEvent(e); -// } -// -// virtual void mouseMoveEvent ( QMouseEvent * e ){ -// //tr.MouseMove(e->x(),e->y()); -// //QWidget::mouseMoveEvent(e); -// lr+=e->x()-cx; -// ud-=e->y()-cy; -// cx = e->x(); -// cy = e->y(); -// repaint(); -// } -// -// virtual void wheelEvent ( QWheelEvent * e ){ -// tz +=e->delta()/360.f; -// repaint(); -// QWidget::wheelEvent(e); -// } -// -// virtual void initializeGL(){ -// -// -// GLfloat f[4]={0.2,0.2,0.2,1.f}; -// GLfloat p[4]={3,3,5,0}; -// glLightfv(GL_LIGHT0, GL_AMBIENT,f); -// glLightfv(GL_LIGHT1, GL_POSITION,p); -// glLightfv(GL_LIGHT1, GL_DIFFUSE,f); -// glLightfv(GL_LIGHT1, GL_SPECULAR,f); -// -// glEnable(GL_LIGHT0); -// glEnable(GL_LIGHT1); -// glEnable(GL_LIGHTING); -// glEnable(GL_DEPTH_TEST); -// glDepthFunc(GL_LESS); -// glPolygonMode(GL_FRONT,GL_FILL); -// glEnable(GL_BACK); -// glCullFace(GL_BACK); -// } -// -//}; +struct MyGl: public QGLWidget{ + MyGl( QWidget * parent = 0, const char * name = 0, const QGLWidget * shareWidget = 0, WFlags f = 0 ) + :QGLWidget(parent,name){} + //void QGLWidget::paintEvent ( QPaintEvent * ) [virtual protected] + double lr,ud,tz; + int cx,cy,z; + + virtual void glDraw(){ + + glClearColor(0.2,0.2,0.2,1); + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45,1,0.01,20); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + gluLookAt(0,0,1,0,0,0,0,10,0); + + + glTranslatef(0,0,tz); + glRotatef(lr,0,1,0); + glRotatef(ud,1,0,0); + + glScalef(1/tm->bbox.Diag(),1/tm->bbox.Diag(),1/tm->bbox.Diag()); + vcg::Point3d p=tm->bbox.Center(); + glTranslate(-p); + + //WB->Draw(); + WB->DrawMesh(tm); + + /*glT->Draw ();*/ + QGLWidget::glDraw(); + } + + void resizeGL( int w, int h ) + { + //// setup viewport, projection etc.: + glViewport( 0, 0, (GLint)w, (GLint)h ); + } + + virtual void mousePressEvent ( QMouseEvent * e ){ + cx = e->x(); + cy = e->y(); + + //tr.MouseDown(e->x(),e->y(),(Trackball::Button)(int)(e->button())); + //QWidget::mousePressEvent(e); + } + + virtual void mouseMoveEvent ( QMouseEvent * e ){ + //tr.MouseMove(e->x(),e->y()); + //QWidget::mouseMoveEvent(e); + lr+=e->x()-cx; + ud-=e->y()-cy; + cx = e->x(); + cy = e->y(); + repaint(); + } + + virtual void wheelEvent ( QWheelEvent * e ){ + tz +=e->delta()/360.f; + repaint(); + QWidget::wheelEvent(e); + } + + virtual void initializeGL(){ + + + GLfloat f[4]={0.2,0.2,0.2,1.f}; + GLfloat p[4]={3,3,5,0}; + glLightfv(GL_LIGHT0, GL_AMBIENT,f); + glLightfv(GL_LIGHT1, GL_POSITION,p); + glLightfv(GL_LIGHT1, GL_DIFFUSE,f); + glLightfv(GL_LIGHT1, GL_SPECULAR,f); + + glEnable(GL_LIGHT0); + glEnable(GL_LIGHT1); + glEnable(GL_LIGHTING); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glPolygonMode(GL_FRONT,GL_FILL); + glEnable(GL_BACK); + glCullFace(GL_BACK); + } + +}; int main( int argc, char ** argv ) @@ -161,26 +161,26 @@ int main( int argc, char ** argv ) UB.Box(*tm); LR._SetDir(0); - LR._SetDir(1); + /*LR._SetDir(1); LR._SetDir(2); LR._SetDir(3); LR._SetDir(4); - LR._SetDir(5); - LR.Remesh((*tm),0.5,0.2); - LS.Init(tm,0.5); + LR._SetDir(5);*/ + LR.Remesh((*tm),0.5,0.05); + //LS.Init(tm,0.5); /*WB=new vcg::GLWrapBar >(LS.LEM.Bars);*/ - LS.SetTouchedBar(&LS.LEM.Bars[9],1); - LS.ComputeStep(tm); + /*LS.SetTouchedBar(&LS.LEM.Bars[9],1); + LS.ComputeStep(tm);*/ /* glT=new vcg::GlTrimesh(); glT->m=tm;*/ - /*QApplication a( argc, argv );*/ - /* Form1 w;*/ - /*MyGl *gl = new MyGl(&w); + QApplication a( argc, argv ); + Form1 w; + MyGl *gl = new MyGl(&w); gl->setMinimumSize(800,800); w.show(); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); - return a.exec();*/ + return a.exec(); }