first release compiled but not tested

This commit is contained in:
Nico Pietroni 2004-08-04 20:59:13 +00:00
parent f610bf209c
commit ac5354fb66
7 changed files with 620 additions and 0 deletions

128
apps/test/lem/bardrawer.h Normal file
View File

@ -0,0 +1,128 @@
#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++)
{
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

50
apps/test/lem/form1.cpp Normal file
View File

@ -0,0 +1,50 @@
/****************************************************************************
** 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" ) );
}

37
apps/test/lem/form1.h Normal file
View File

@ -0,0 +1,37 @@
/****************************************************************************
** 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

20
apps/test/lem/form1.ui Normal file
View File

@ -0,0 +1,20 @@
<!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

@ -0,0 +1,98 @@
/****************************************************************************
* 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\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)
{
MESH_TYPE::FaceIterator Finit=vcg::tri::Allocator<MESH_TYPE>::AddFaces(m,3);
MESH_TYPE::VertexIterator Vi=vcg::tri::Allocator<MESH_TYPE>::AddVertices(m,1);
MESH_TYPE::FaceIterator Fi=Finit;
MESH_TYPE::FaceType *F;
//set vertex pointer of new face
for (int i=0;i<3;i++)
{
Fi->V(0)=f->V(i);
Fi->V(1)=f->V((i+1)%3);
Fi->V(2)=&(*Vi);
F=&(*Fi);
//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));
if (MESH_TYPE::HasVFTopology())
{
vcg::face::VFDetach(f,i);
//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);
}
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);
/*vcg::face::Attach<MESH_TYPE::FaceType>(F0,1,F1,2);*/
Fi++;
Fsucc++;
F0=&(*Fi);
F1=&(*Fsucc);
/*vcg::face::Attach<MESH_TYPE::FaceType>(F0,1,F1,2);*/
Fsucc=Finit;
Fi++;
F0=&(*Fi);
F1=&(*Fsucc);
/*vcg::face::Attach<MESH_TYPE::FaceType>(F0,1,F1,2);*/
//at the end set as deleted the old face that was substituted
f->SetD();
v=&(*Vi);
}
}
}
#endif

186
apps/test/lem/main.cpp Normal file
View File

@ -0,0 +1,186 @@
//#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.2);
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();*/
}

101
apps/test/lem/moc_form1.cpp Normal file
View File

@ -0,0 +1,101 @@
/****************************************************************************
** 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