This commit is contained in:
Nico Pietroni 2009-06-10 08:44:22 +00:00
parent 39156cafe4
commit a3eee3aa3c
7 changed files with 0 additions and 762 deletions

View File

@ -1,131 +0,0 @@
#ifndef __GLWRAPBAR__
#define __GLWRAPBAR__
#include<GL/GL.h>
#include <vcg/space/color4.h>
#include <vcg/physics/methods/lem/lem.h>
#include <wrap/gl/space.h>
namespace vcg {
template < class STL_BAR_CONT >
class GLWrapBar{
public:
/// The bar container
typedef STL_BAR_CONT BarContainer;
/// The bar type
typedef typename STL_BAR_CONT::value_type BarType;
/// The type of bar iterator
typedef typename STL_BAR_CONT::iterator BarIterator;
///the type of coordinates
typedef typename BarType::CoordType CoordType;
///the type of scalar
typedef typename CoordType::ScalarType ScalarType;
/* typedef typename MESH_TYPE MeshType;
typedef typename MeshType::FaceType FaceType;
typedef typename MeshType::VertexType VertexType;
typedef typename MeshType::CoordType CoordType;
typedef typename MeshType::ScalarType ScalarType;
typedef typename vcg::LemSolver<MeshType,FaceType> LemSolver;
typedef typename LemSolver::BarType BarType;*/
GLWrapBar(BarContainer & _b):Bars(_b){}
BarContainer & Bars;
public:
void Draw()
{
BarIterator Bi;
glLineWidth(3.f);
glPushAttrib(GL_CURRENT_BIT|GL_ENABLE_BIT );
glDisable(GL_NORMALIZE);
glDisable(GL_LIGHTING);
for (Bi=Bars.begin();Bi<Bars.end();Bi++)
{
CoordType direction=CoordType(0,0,0);
ScalarType verse=1.f;
//invert verse of axis bar
if (Bi->D>2)
verse=-1.f;
direction.V(Bi->D%3)=verse;
if (Bi->D==0)
glColor3d(1,1,1);
else
if (Bi->D==1)
glColor3d(1,0,0);
else
if (Bi->D==2)
glColor3d(0,1,0);
else
if (Bi->D==3)
glColor3d(0,0,1);
else
if (Bi->D==4)
glColor3d(0,1,1);
else
glColor3d(1,0,1);
if (Bi->IsTouched())
glColor3d(0,0,0);
glBegin(GL_LINE_STRIP);
vcg::glVertex(Bi->P);
vcg::glVertex(Bi->P+(direction*Bi->L));
// vcg::glVertex(Bi->P+direction);
glEnd();
/*glBegin(GL_LINE_STRIP);
vcg::glVertex(Bi->V0->P());
vcg::glVertex(Bi->V1->P());
glEnd();*/
}
glPopAttrib();
}
template<class MESH_TYPE>
void DrawMesh(MESH_TYPE *m)
{
MESH_TYPE::FaceIterator Fi;
glPushAttrib(GL_COLOR_BUFFER_BIT);
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);
glEnable(GL_NORMALIZE);
glBegin(GL_TRIANGLES);
glNormal(Fi->NormalizedNormal());
glVertex(Fi->V(0)->P());
glVertex(Fi->V(1)->P());
glVertex(Fi->V(2)->P());
glEnd();
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
glDisable(GL_NORMALIZE);
glColor3d(0,0,0);
glBegin(GL_LINE_LOOP);
glVertex(Fi->V(0)->P());
glVertex(Fi->V(1)->P());
glVertex(Fi->V(2)->P());
glEnd();
}
}
glPopAttrib();
}
};
}
#endif

View File

@ -1,50 +0,0 @@
/****************************************************************************
** Form implementation generated from reading ui file 'form1.ui'
**
** Created: Mon Aug 2 16:35:19 2004
** by: The User Interface Compiler ($Id: form1.cpp,v 1.1 2004-08-04 20:59:13 pietroni Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "form1.h"
#include <qvariant.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a Form1 as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
Form1::Form1( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "Form1" );
languageChange();
resize( QSize(909, 714).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
}
/*
* Destroys the object and frees any allocated resources
*/
Form1::~Form1()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void Form1::languageChange()
{
setCaption( tr( "TetraWraP" ) );
}

View File

@ -1,37 +0,0 @@
/****************************************************************************
** Form interface generated from reading ui file 'form1.ui'
**
** Created: Mon Aug 2 16:35:19 2004
** by: The User Interface Compiler ($Id: form1.h,v 1.1 2004-08-04 20:59:13 pietroni Exp $)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef FORM1_H
#define FORM1_H
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class Form1 : public QDialog
{
Q_OBJECT
public:
Form1( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~Form1();
protected:
protected slots:
virtual void languageChange();
};
#endif // FORM1_H

View File

@ -1,20 +0,0 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>Form1</class>
<widget class="QDialog">
<property name="name">
<cstring>Form1</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>909</width>
<height>714</height>
</rect>
</property>
<property name="caption">
<string>TetraWraP</string>
</property>
</widget>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1,237 +0,0 @@
/****************************************************************************
* VCGLib o o *
* Visual and Computer Graphics Library o o *
* _ O _ *
* Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | *
* \ *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* *
****************************************************************************/
/****************************************************************************
History
****************************************************************************/
#ifndef __VCG_TRI_INSERT_VERTEX
#define __VCG_TRI_INSERT_VERTEX
#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 FACE_TYPE>
void FFAttach(FACE_TYPE *f0,int z0,FACE_TYPE *f1,int z1)
{
f0->FFp(z0)=f1;
f0->FFi(z0)=z1;
f1->FFp(z1)=f0;
f1->FFi(z1)=z0;
}
template <class MESH_TYPE>
///insert a vertex iside a face and re-triangolarize v will be pointer to inserted vertex
void InsertVertEdge(MESH_TYPE &m,typename MESH_TYPE::FaceType** f,int edge,typename MESH_TYPE::VertexType *&v)
{
std::vector<MESH_TYPE::FaceType **> local_var;
local_var.push_back(f);
MESH_TYPE::VertexIterator Vi=vcg::tri::Allocator<MESH_TYPE>::AddVertices(m,1);
MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator<MESH_TYPE>::AddFaces(m,4,local_var);
if (MESH_TYPE::HasVFTopology())
Vi->VFp()=0;
MESH_TYPE::FaceIterator Fi=Finit;
//take new faces added
MESH_TYPE::FaceType *Fr0=&(*Fi);
Fi++;
MESH_TYPE::FaceType *Fr1=&(*Fi);
Fi++;
MESH_TYPE::FaceType *Fl0=&(*Fi);
Fi++;
MESH_TYPE::FaceType *Fl1=&(*Fi);
//old faces
MESH_TYPE::FaceType *fdl=(*f);
MESH_TYPE::FaceType *fdr=(*f)->FFp(edge);
int edgel=edge;
int edger=(*f)->FFi(edge);
//opposite vertex used to build new triangles
MESH_TYPE::VertexType *voppl=fdl->V((edgel+2)%3);
MESH_TYPE::VertexType *voppr=fdr->V((edger+2)%3);
//inizialize the for new faces
Fl0->V(0)=voppl;
Fl0->V(1)=fdl->V(edgel);
Fl0->V(2)=&(*Vi);
Fl1->V(0)=voppl;
Fl1->V(1)=&(*Vi);
Fl1->V(2)=fdl->V((edgel+1)%3);
Fr0->V(0)=voppr;
Fr0->V(1)=&(*Vi);
Fr0->V(2)=fdr->V((edger+1)%3);
Fr1->V(0)=voppr;
Fr1->V(1)=fdr->V(edger);
Fr1->V(2)=&(*Vi);
//VFTopology setting
if (MESH_TYPE::HasVFTopology())
{
for (int i=0;i<3;i++)
{
//initial settings
Fl0->VFp(i)=0;
Fl1->VFp(i)=0;
Fr0->VFp(i)=0;
Fr1->VFp(i)=0;
//append new faces to VF topology
vcg::face::VFAppend<MESH_TYPE::FaceType>(Fl0,i);
vcg::face::VFAppend<MESH_TYPE::FaceType>(Fl1,i);
vcg::face::VFAppend<MESH_TYPE::FaceType>(Fr0,i);
vcg::face::VFAppend<MESH_TYPE::FaceType>(Fr1,i);
//erase old faces from VF topology
vcg::face::VFDetach<MESH_TYPE::FaceType>((*fdl),i);
vcg::face::VFDetach<MESH_TYPE::FaceType>((*fdr),i);
}
}
//FFTopology setting
if (MESH_TYPE::HasFFTopology())
{
//attach old faces that was attached by
//the one that should be substituted
FFAttach(Fl0,0,fdl->FFp((edgel+2)%3),fdl->FFi((edgel+2)%3));
FFAttach(Fl1,2,fdl->FFp((edgel+1)%3),fdl->FFi((edgel+1)%3));
FFAttach(Fr0,2,fdr->FFp((edger+1)%3),fdr->FFi((edger+1)%3));
FFAttach(Fr1,0,fdr->FFp((edger+2)%3),fdr->FFi((edger+2)%3));
//then connect between thenselfes
FFAttach(Fl0,2,Fl1,0);
FFAttach(Fl0,1,Fr0,1);
FFAttach(Fl1,1,Fr1,1);
FFAttach(Fr0,0,Fr1,2);
}
//finally set as deleted the old faces
fdl->SetD();
fdr->SetD();
v=&(*Vi);
}
template <class MESH_TYPE>
///insert a vertex iside a face and re-triangolarize v will be pointer to inserted vertex
void InsertVertFace(MESH_TYPE &m,typename MESH_TYPE::FaceType** f,typename MESH_TYPE::VertexType *&v)
{
assert(!(*f)->IsD());
std::vector<MESH_TYPE::FaceType **> local_var;
local_var.push_back(f);
MESH_TYPE::VertexIterator Vi=vcg::tri::Allocator<MESH_TYPE>::AddVertices(m,1);
MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator<MESH_TYPE>::AddFaces(m,3,local_var);
if (MESH_TYPE::HasVFTopology())
Vi->VFp()=0;
MESH_TYPE::FaceIterator Fi=Finit;
MESH_TYPE::FaceType *F;
MESH_TYPE::FaceType *fd=(*f);
//set vertex pointer of new face
for (int i=0;i<3;i++)
{
F=&(*Fi);
assert(!fd->V(i)->IsD());
assert(!Vi->IsD());
F->V(0)=fd->V(i);
F->V(1)=fd->V((i+1)%3);
F->V(2)=&(*Vi);
//assign topology in substitution of the old one
if (MESH_TYPE::HasFFTopology())
{
FFAttach(F,0,fd->FFp(i),fd->FFi(i));
}
if (MESH_TYPE::HasVFTopology())
{
F->VFp(0)=0;
F->VFp(1)=0;
F->VFp(2)=0;
//put new faces on list of the old vertex and new one
vcg::face::VFAppend<MESH_TYPE::FaceType>(F,0);
vcg::face::VFAppend<MESH_TYPE::FaceType>(F,1);
vcg::face::VFAppend<MESH_TYPE::FaceType>(F,2);
vcg::face::VFDetach<MESH_TYPE::FaceType>((*fd),i);
}
Fi++;
}
//then attach the faces between themselfes
Fi=Finit;
MESH_TYPE::FaceIterator Fsucc=Fi;
Fsucc++;
MESH_TYPE::FaceType *F0=&(*Fi);
MESH_TYPE::FaceType *F1=&(*Fsucc);
FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
Fi++;
Fsucc++;
F0=&(*Fi);
F1=&(*Fsucc);
FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
Fsucc=Finit;
Fi++;
F0=&(*Fi);
F1=&(*Fsucc);
FFAttach<MESH_TYPE::FaceType>(F0,1,F1,2);
//at the end set as deleted the old face that was substituted
fd->SetD();
v=&(*Vi);
}
}
}
#endif

View File

@ -1,186 +0,0 @@
//#include <wrap\gl\trimesh.h>
#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 <bardrawer.h>
#include <simplex\vertex\with\afvn.h>
#include <simplex\face\with\afav.h>
#include <complex\trimesh\base.h>
#include <wrap\io_trimesh\import_ply.h>
#include <complex\trimesh\update\topology.h>
#include <complex\trimesh\update\bounding.h>
#include "form1.h"
class MyFace;
class MyVertex: public vcg::VertexAFVNd<vcg::DUMMYEDGETYPE,MyFace,vcg::DUMMYTETRATYPE>
{
public:
///we suppose at maximum 4 bars for each direction
vcg::Bar<MyVertex>* B[6];
double Delta[6];
double Num[6];
//int Num;
};
class MyFace:public vcg::FaceAFAV<MyVertex,vcg::DUMMYEDGETYPE,MyFace>
{
public:
///we suppose at maximum 4 bars for each direction
vcg::Bar<MyFace>* B[6];
};
typedef vcg::tri::TriMesh< std::vector<MyVertex> ,std::vector<MyFace> > MyTriMesh;
//typedef vcg::Lem_Face<MyTriMesh> LemType;
typedef vcg::Lem_Vertex<MyTriMesh> LemType;
typedef vcg::Lem_Remesher<MyTriMesh> LemRemesherType;
LemType LS;
LemRemesherType LR;
vcg::tri::UpdateTopology<MyTriMesh> UT;
MyTriMesh *tm;
vcg::tri::UpdateBounding<MyTriMesh> UB;
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);
}
};
int main( int argc, char ** argv )
{ LS=LemType(0.01,0.1,0.01);
//LS=LemType(0.01,200,0.01);
LS._SetDir(0);
LS._SetDir(1);
LS._SetDir(2);
LS._SetDir(3);
LS._SetDir(4);
LS._SetDir(5);
tm=new MyTriMesh();
vcg::tri::io::ImporterPLY<MyTriMesh> Imp=vcg::tri::io::ImporterPLY<MyTriMesh>();
char *name="cube.ply";
Imp.Open((*tm),name);
UT.FaceFace(*tm);
UT.VertexFace(*tm);
UB.Box(*tm);
LR._SetDir(0);
/*LR._SetDir(1);
LR._SetDir(2);
LR._SetDir(3);
LR._SetDir(4);
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);*/
/* glT=new vcg::GlTrimesh<MyTriMesh>();
glT->m=tm;*/
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();
}

View File

@ -1,101 +0,0 @@
/****************************************************************************
** Form1 meta object code from reading C++ file 'form1.h'
**
** Created: Mon Aug 2 16:35:19 2004
** by: The Qt MOC ($Id: moc_form1.cpp,v 1.1 2004-08-04 20:59:13 pietroni Exp $)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#undef QT_NO_COMPAT
#include "form1.h"
#include <qmetaobject.h>
#include <qapplication.h>
#include <private/qucomextra_p.h>
#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26)
#error "This file was generated using the moc from 3.3.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
const char *Form1::className() const
{
return "Form1";
}
QMetaObject *Form1::metaObj = 0;
static QMetaObjectCleanUp cleanUp_Form1( "Form1", &Form1::staticMetaObject );
#ifndef QT_NO_TRANSLATION
QString Form1::tr( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "Form1", s, c, QApplication::DefaultCodec );
else
return QString::fromLatin1( s );
}
#ifndef QT_NO_TRANSLATION_UTF8
QString Form1::trUtf8( const char *s, const char *c )
{
if ( qApp )
return qApp->translate( "Form1", s, c, QApplication::UnicodeUTF8 );
else
return QString::fromUtf8( s );
}
#endif // QT_NO_TRANSLATION_UTF8
#endif // QT_NO_TRANSLATION
QMetaObject* Form1::staticMetaObject()
{
if ( metaObj )
return metaObj;
QMetaObject* parentObject = QDialog::staticMetaObject();
static const QUMethod slot_0 = {"languageChange", 0, 0 };
static const QMetaData slot_tbl[] = {
{ "languageChange()", &slot_0, QMetaData::Protected }
};
metaObj = QMetaObject::new_metaobject(
"Form1", parentObject,
slot_tbl, 1,
0, 0,
#ifndef QT_NO_PROPERTIES
0, 0,
0, 0,
#endif // QT_NO_PROPERTIES
0, 0 );
cleanUp_Form1.setMetaObject( metaObj );
return metaObj;
}
void* Form1::qt_cast( const char* clname )
{
if ( !qstrcmp( clname, "Form1" ) )
return this;
return QDialog::qt_cast( clname );
}
bool Form1::qt_invoke( int _id, QUObject* _o )
{
switch ( _id - staticMetaObject()->slotOffset() ) {
case 0: languageChange(); break;
default:
return QDialog::qt_invoke( _id, _o );
}
return TRUE;
}
bool Form1::qt_emit( int _id, QUObject* _o )
{
return QDialog::qt_emit(_id,_o);
}
#ifndef QT_NO_PROPERTIES
bool Form1::qt_property( int id, int f, QVariant* v)
{
return QDialog::qt_property( id, f, v);
}
bool Form1::qt_static_property( QObject* , int , int , QVariant* ){ return FALSE; }
#endif // QT_NO_PROPERTIES