minor changes

This commit is contained in:
Nico Pietroni 2004-08-05 16:46:13 +00:00
parent 7f0b7037ac
commit fe1ec241f0
3 changed files with 123 additions and 107 deletions

View File

@ -99,6 +99,8 @@ public:
glColor4d(0.8,0.8,0.8,0.9);
for (Fi=m->face.begin();Fi<m->face.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();
}

View File

@ -30,19 +30,26 @@
#include<vcg\simplex\face\pos.h>
#include<vcg\simplex\face\topology.h>
#include<vcg\complex\trimesh\update\topology.h>
#include<vcg\complex\trimesh\allocate.h>
/// This Class is used for insertiong a vertex in a face
namespace vcg{
namespace tri{
template <class MESH_TYPE>
///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<MESH_TYPE>::AddFaces(m,3);
std::vector<MESH_TYPE::FaceType **> local_var;
local_var.push_back(&f);
MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator<MESH_TYPE>::AddFaces(m,3,local_var);
MESH_TYPE::VertexIterator Vi=vcg::tri::Allocator<MESH_TYPE>::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<MESH_TYPE::FaceType>(F,0,f->FFp(i),f->FFi(i));
{
vcg::face::FFAttach<MESH_TYPE::FaceType>(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<MESH_TYPE::FaceType>(F0,1,F1,2);*/
vcg::face::FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
Fi++;
Fsucc++;
F0=&(*Fi);
F1=&(*Fsucc);
/*vcg::face::Attach<MESH_TYPE::FaceType>(F0,1,F1,2);*/
vcg::face::FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
Fsucc=Finit;
Fi++;
F0=&(*Fi);
F1=&(*Fsucc);
/*vcg::face::Attach<MESH_TYPE::FaceType>(F0,1,F1,2);*/
vcg::face::FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
//at the end set as deleted the old face that was substituted
f->SetD();
v=&(*Vi);
}

View File

@ -2,10 +2,10 @@
#include <vcg\physics\methods\lem\interface_lem_vertex.h>
//#include <vcg\physics\methods\lem\interface_lem_face.h>
#include <vcg\physics\methods\lem\interface_lem_remesher.h>
//#include <qapplication.h>
//#include <qgl.h>
#include <qapplication.h>
#include <qgl.h>
//#include <bardrawer.h>
#include <bardrawer.h>
#include <simplex\vertex\with\afvn.h>
@ -17,7 +17,7 @@
//#include "form1.h"
#include "form1.h"
class MyFace;
@ -50,94 +50,94 @@ vcg::tri::UpdateTopology<MyTriMesh> UT;
MyTriMesh *tm;
vcg::tri::UpdateBounding<MyTriMesh> UB;
//vcg::GLWrapBar<LemType::LemModel::vectBar> *WB;
vcg::GLWrapBar<LemType::LemModel::vectBar> *WB;
//vcg::GlTrimesh<MyTriMesh> *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<MyTriMesh>(tm);
//
// /*glT->Draw<vcg::GLW:: DMFlatWire,vcg::GLW:: CMNone,vcg::GLW:: TMNone> ();*/
// 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<MyTriMesh>(tm);
/*glT->Draw<vcg::GLW:: DMFlatWire,vcg::GLW:: CMNone,vcg::GLW:: TMNone> ();*/
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<std::vector<LemType::BarType> >(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<MyTriMesh>();
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();
}