added VFIterator (Pos is disabled in this version)
This commit is contained in:
parent
cbe27a6f0e
commit
b88a447671
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.2 2006/12/10 22:17:18 ganovelli
|
||||
cvs problem during frist committ. repeated
|
||||
|
||||
*/
|
||||
|
||||
#include <QtGui>
|
||||
|
@ -52,6 +55,9 @@ GLWidget::GLWidget(QWidget *parent)
|
|||
track.SetIdentity();
|
||||
track.radius = 0.4;
|
||||
pos.f=NULL;
|
||||
vfite.f = NULL;
|
||||
doPickVfIte = false;
|
||||
doPickPos = false;
|
||||
}
|
||||
|
||||
GLWidget::~GLWidget()
|
||||
|
@ -77,7 +83,9 @@ void GLWidget::LoadTriMesh(QString &namefile)
|
|||
vcg::tri::UpdateNormals<MyStraightMesh>::PerFace(mesh);
|
||||
vcg::tri::UpdateNormals<MyStraightMesh>::PerVertex(mesh);
|
||||
vcg::tri::UpdateTopology<MyStraightMesh>::FaceFace(mesh);
|
||||
vcg::tri::UpdateTopology<MyStraightMesh>::VertexFace(mesh);
|
||||
pos.f=0;
|
||||
vfite.f=NULL;
|
||||
}
|
||||
|
||||
void GLWidget::OpenFile(){
|
||||
|
@ -108,16 +116,34 @@ void GLWidget::nextE( ){
|
|||
if(pos.f) pos.NextE();
|
||||
repaint();
|
||||
}
|
||||
void GLWidget::nextB( ){
|
||||
if(pos.f) pos.NextB();
|
||||
repaint();
|
||||
}
|
||||
|
||||
void GLWidget::nextVfite( ){
|
||||
if(vfite.F()) ++vfite;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void GLWidget::initializeGL()
|
||||
{
|
||||
qglClearColor(trolltechPurple.dark());
|
||||
object = makeObject();
|
||||
glShadeModel(GL_FLAT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
template <class VertexType>
|
||||
void drawVertex(VertexType & v){
|
||||
glPushAttrib(0xffffffff);
|
||||
glPointSize(2.0);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex(v.P());
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void GLWidget::paintGL()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -134,7 +160,8 @@ void GLWidget::paintGL()
|
|||
|
||||
// to do some picking
|
||||
MyStraightMesh::FaceType* fp=NULL;
|
||||
if(doPick)
|
||||
MyStraightMesh::VertexType* vp=NULL;
|
||||
if(doPickPos)
|
||||
{
|
||||
std::vector<MyStraightMesh::FaceType*> res;
|
||||
int yes = vcg::Pick<MyStraightMesh::FaceContainer>(pic_x,ScreenH-pic_y+1,mesh.face,res,vcg::glTriangle3<MyStraightMesh::FaceType>,1,1);
|
||||
|
@ -142,7 +169,19 @@ void GLWidget::paintGL()
|
|||
{fp = res[0];
|
||||
pos.Set(fp,0,fp->V(0));
|
||||
}
|
||||
doPick=false;
|
||||
doPickPos=false;
|
||||
}else
|
||||
if(doPickVfIte)
|
||||
{
|
||||
std::vector<MyStraightMesh::VertexType*> res;
|
||||
int yes = vcg::Pick<MyStraightMesh::VertContainer>(pic_x,ScreenH-pic_y+1,mesh.vert,res,drawVertex<MyStraightMesh::VertexType>,3,3);
|
||||
if(yes)
|
||||
{vp = res[0];
|
||||
MyStraightMesh::FaceType* g = vp->VFp();
|
||||
vfite=vcg::face::VFIterator<typename MyStraightMesh::FaceType>(vp);
|
||||
}
|
||||
|
||||
doPickVfIte = false;
|
||||
}
|
||||
|
||||
glWrap.Draw<vcg::GLW::DMFlatWire,vcg::GLW::CMNone,vcg::GLW::TMNone> ();
|
||||
|
@ -155,6 +194,15 @@ void GLWidget::paintGL()
|
|||
vcg::GlPos<vcg::face::Pos<MyStraightMesh::FaceType> >::Draw(pos);
|
||||
glPopAttrib();
|
||||
}
|
||||
if(vfite.F()!=NULL) {
|
||||
glPushAttrib(0xffffffff);
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor3f(0.0,1.0,0.0);
|
||||
glDepthRange(0.0,0.999);
|
||||
vcg::GlVfIterator<vcg::face::VFIterator<MyStraightMesh::FaceType> >::Draw(vfite);
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -180,95 +228,6 @@ void GLWidget::mouseMoveEvent(QMouseEvent *e)
|
|||
keypress = e->key();
|
||||
}
|
||||
|
||||
GLuint GLWidget::makeObject()
|
||||
{
|
||||
GLuint list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
GLdouble x1 = +0.06;
|
||||
GLdouble y1 = -0.14;
|
||||
GLdouble x2 = +0.14;
|
||||
GLdouble y2 = -0.06;
|
||||
GLdouble x3 = +0.08;
|
||||
GLdouble y3 = +0.00;
|
||||
GLdouble x4 = +0.30;
|
||||
GLdouble y4 = +0.22;
|
||||
|
||||
quad(x1, y1, x2, y2, y2, x2, y1, x1);
|
||||
quad(x3, y3, x4, y4, y4, x4, y3, x3);
|
||||
|
||||
extrude(x1, y1, x2, y2);
|
||||
extrude(x2, y2, y2, x2);
|
||||
extrude(y2, x2, y1, x1);
|
||||
extrude(y1, x1, x1, y1);
|
||||
extrude(x3, y3, x4, y4);
|
||||
extrude(x4, y4, y4, x4);
|
||||
extrude(y4, x4, y3, x3);
|
||||
|
||||
const double Pi = 3.14159265358979323846;
|
||||
const int NumSectors = 200;
|
||||
|
||||
for (int i = 0; i < NumSectors; ++i) {
|
||||
double angle1 = (i * 2 * Pi) / NumSectors;
|
||||
GLdouble x5 = 0.30 * sin(angle1);
|
||||
GLdouble y5 = 0.30 * cos(angle1);
|
||||
GLdouble x6 = 0.20 * sin(angle1);
|
||||
GLdouble y6 = 0.20 * cos(angle1);
|
||||
|
||||
double angle2 = ((i + 1) * 2 * Pi) / NumSectors;
|
||||
GLdouble x7 = 0.20 * sin(angle2);
|
||||
GLdouble y7 = 0.20 * cos(angle2);
|
||||
GLdouble x8 = 0.30 * sin(angle2);
|
||||
GLdouble y8 = 0.30 * cos(angle2);
|
||||
|
||||
quad(x5, y5, x6, y6, x7, y7, x8, y8);
|
||||
|
||||
extrude(x6, y6, x7, y7);
|
||||
extrude(x8, y8, x5, y5);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
return list;
|
||||
}
|
||||
|
||||
void GLWidget::quad(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2,
|
||||
GLdouble x3, GLdouble y3, GLdouble x4, GLdouble y4)
|
||||
{
|
||||
qglColor(trolltechGreen);
|
||||
|
||||
glVertex3d(x1, y1, -0.05);
|
||||
glVertex3d(x2, y2, -0.05);
|
||||
glVertex3d(x3, y3, -0.05);
|
||||
glVertex3d(x4, y4, -0.05);
|
||||
|
||||
glVertex3d(x4, y4, +0.05);
|
||||
glVertex3d(x3, y3, +0.05);
|
||||
glVertex3d(x2, y2, +0.05);
|
||||
glVertex3d(x1, y1, +0.05);
|
||||
}
|
||||
|
||||
void GLWidget::extrude(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
|
||||
{
|
||||
qglColor(trolltechGreen.dark(250 + int(100 * x1)));
|
||||
|
||||
glVertex3d(x1, y1, +0.05);
|
||||
glVertex3d(x2, y2, +0.05);
|
||||
glVertex3d(x2, y2, -0.05);
|
||||
glVertex3d(x1, y1, -0.05);
|
||||
}
|
||||
|
||||
void GLWidget::normalizeAngle(int *angle)
|
||||
{
|
||||
while (*angle < 0)
|
||||
*angle += 360 * 16;
|
||||
while (*angle > 360 * 16)
|
||||
*angle -= 360 * 16;
|
||||
}
|
||||
|
||||
void GLWidget:: mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if( (keypress==Qt::Key_Control) && (e->button() == Qt::LeftButton) )
|
||||
|
@ -279,7 +238,7 @@ void GLWidget::normalizeAngle(int *angle)
|
|||
else
|
||||
if(e->button() == Qt::RightButton)
|
||||
{
|
||||
doPick=true;
|
||||
doPickVfIte=true;
|
||||
pic_x = e->x();
|
||||
pic_y = e->y();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.2 2006/12/10 22:17:18 ganovelli
|
||||
cvs problem during frist committ. repeated
|
||||
|
||||
*/
|
||||
#ifndef GLWIDGET_H_POS_DEMO
|
||||
#define GLWIDGET_H_POS_DEMO
|
||||
|
@ -34,6 +37,7 @@ $Log: not supported by cvs2svn $
|
|||
#include <wrap/gui/trackball.h>
|
||||
#include <wrap/gl/trimesh.h>
|
||||
#include <vcg/simplex/face/pos.h>
|
||||
#include <vcg/simplex/face/topology.h>
|
||||
|
||||
class GLWidget : public QGLWidget
|
||||
{
|
||||
|
@ -50,13 +54,18 @@ public:
|
|||
vcg::GlTrimesh<MyStraightMesh> glWrap;
|
||||
vcg::Trackball track;
|
||||
int ScreenH,ScreenW,pic_x,pic_y,keypress;
|
||||
bool doPick;
|
||||
bool doPickPos,doPickVfIte;
|
||||
vcg::face::Pos<typename MyStraightMesh::FaceType> pos;
|
||||
vcg::face::VFIterator<typename MyStraightMesh::FaceType> vfite;
|
||||
|
||||
public slots:
|
||||
void flipV( );
|
||||
void flipE( );
|
||||
void flipF( );
|
||||
void nextE( );
|
||||
void nextB( );
|
||||
void nextVfite( );
|
||||
|
||||
void LoadTriMesh(QString& namefile);
|
||||
void OpenFile();
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.1 2006/12/10 19:55:09 ganovelli
|
||||
first draft. Working but ugly interface. right mouse of the button to place a pos, then prss buttons.
|
||||
|
||||
*/
|
||||
#pragma once
|
||||
/** the definition of vertex */
|
||||
|
@ -44,10 +47,10 @@ class StraightFace;
|
|||
/* DEFINITION OF A VERY STRAIGHT MESH. No optional atributes, just normals in the vertices and flags in vertices and faces*/
|
||||
|
||||
/** definition of a very simple vertex type. Just coordinates and normal as attributes*/
|
||||
class StraightVertex: public vcg::VertexSimp2< StraightVertex, DummyEdge, StraightFace, vcg::vert::Coord3f,vcg::vert::Normal3f,vcg::vert::BitFlags>{};
|
||||
class StraightVertex: public vcg::VertexSimp2< StraightVertex, DummyEdge, StraightFace, vcg::vert::Coord3f,vcg::vert::VFAdj,vcg::vert::Normal3f,vcg::vert::BitFlags>{};
|
||||
|
||||
/** definition of a very simple face type. Just color and reference to vertices as attribute*/
|
||||
class StraightFace: public vcg::FaceSimp2< StraightVertex, DummyEdge, StraightFace, vcg:: face::VertexRef, vcg:: face::FFAdj,vcg:: face::Normal3f,vcg::face::BitFlags > {};
|
||||
class StraightFace: public vcg::FaceSimp2< StraightVertex, DummyEdge, StraightFace, vcg:: face::VertexRef, vcg:: face::FFAdj, vcg:: face::VFAdj,vcg:: face::Normal3f,vcg::face::BitFlags > {};
|
||||
|
||||
/** definition of a very simple mesh*/
|
||||
class MyStraightMesh: public vcg::tri::TriMesh< std::vector<StraightVertex>,std::vector<StraightFace> >{};
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.2 2006/12/10 22:17:18 ganovelli
|
||||
cvs problem during frist committ. repeated
|
||||
|
||||
*/
|
||||
#include <QtGui>
|
||||
|
||||
|
@ -39,8 +42,10 @@ Window::Window()
|
|||
fvButton = createButton("FlipV()",SLOT(flipV( )));
|
||||
feButton = createButton("FlipE()",SLOT(flipE( )));
|
||||
ffButton = createButton("FlipF()",SLOT(flipF( )));
|
||||
neButton = createButton("NextE()",SLOT(nextE( )));
|
||||
ldButton = createButton("Load",SLOT(OpenFile( )));
|
||||
neButton = createButton("NextE() {FlipE() + FlipF() }",SLOT(nextE( )));
|
||||
nbButton = createButton("NextB() ",SLOT(nextB( )));
|
||||
ldButton = createButton("Load TriMesh",SLOT(OpenFile( )));
|
||||
vfButton = createButton("++()",SLOT(nextVfite()));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(glWidget);
|
||||
|
@ -48,7 +53,8 @@ Window::Window()
|
|||
mainLayout->addWidget(feButton);
|
||||
mainLayout->addWidget(ffButton);
|
||||
mainLayout->addWidget(neButton);
|
||||
|
||||
mainLayout->addWidget(nbButton);
|
||||
mainLayout->addWidget(vfButton);
|
||||
mainLayout->addWidget(ldButton);
|
||||
setLayout(mainLayout);
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
History
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.2 2006/12/10 22:17:18 ganovelli
|
||||
cvs problem during frist committ. repeated
|
||||
|
||||
*/
|
||||
#ifndef WINDOW_H_POS_DEMO
|
||||
#define WINDOW_H_POS_DEMO
|
||||
|
@ -45,7 +48,7 @@ private:
|
|||
QPushButton *createButton(const char *changedSignal, const char *setterSlot);
|
||||
|
||||
GLWidget *glWidget;
|
||||
QPushButton * fvButton,*feButton,*ffButton,*neButton,*ldButton;
|
||||
QPushButton * fvButton,*feButton,*ffButton,*neButton,*ldButton,*nbButton,*vfButton;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue