2007-10-18 10:52:06 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2007 \/)\/ *
|
|
|
|
* 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
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2007-11-01 12:33:06 +01:00
|
|
|
Revision 1.1 2007/10/18 08:52:06 benedetti
|
|
|
|
Initial release.
|
2007-10-18 10:52:06 +02:00
|
|
|
|
|
|
|
|
2007-11-01 12:33:06 +01:00
|
|
|
****************************************************************************/
|
2007-10-18 10:52:06 +02:00
|
|
|
|
|
|
|
#ifndef GLAREA_H_
|
|
|
|
#define GLAREA_H_
|
|
|
|
|
|
|
|
/// Opengl related imports
|
|
|
|
#include <GL/glew.h>
|
2013-11-28 12:04:59 +01:00
|
|
|
#include <QGLWidget>
|
2007-10-18 10:52:06 +02:00
|
|
|
|
|
|
|
/// vcg imports
|
2011-04-01 19:07:57 +02:00
|
|
|
#include <vcg/complex/complex.h>
|
|
|
|
#include <vcg/complex/algorithms/update/bounding.h>
|
|
|
|
#include <vcg/complex/algorithms/update/normal.h>
|
|
|
|
#include <vcg/complex/algorithms/create/platonic.h>
|
2007-10-18 10:52:06 +02:00
|
|
|
|
|
|
|
/// wrapper imports
|
|
|
|
#include <wrap/io_trimesh/import.h>
|
|
|
|
#include <wrap/gl/trimesh.h>
|
|
|
|
#include <wrap/gui/trackball.h>
|
|
|
|
|
|
|
|
/// declaring edge and face type
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:44:40 +01:00
|
|
|
|
|
|
|
using namespace vcg;
|
2007-10-18 10:52:06 +02:00
|
|
|
class CFace;
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:44:40 +01:00
|
|
|
class CVertex;
|
|
|
|
|
|
|
|
struct MyUsedTypes : public UsedTypes< Use<CVertex> ::AsVertexType,
|
|
|
|
Use<CFace> ::AsFaceType>{};
|
2007-10-18 10:52:06 +02:00
|
|
|
|
|
|
|
/// compositing wanted proprieties
|
[ Changes in definition of TriMesh: PART I ]
Note for the developers: the change to make to existing projects is very little
but strictly necessary to compile. This change IS NOT backward compliant.
==== OLD ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
class MyVertex: public VertexSimp2 < MyVertex, MyEdge, MyFace, vertex::Coord3f,...other components>{};
class MyFace: public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
==== NEW ==== way to define a TriMesh:
// forward declarations
class MyVertex;
class MyEdge;
class MyFace;
// declaration of which types is used as VertexType, which type is used as FaceType and so on...
class MyUsedTypes: public vcg::UsedType < vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyFace>::AsFaceType>{};
class MyVertex: public Vertex < MyUsedTypes, vertex::Coord3f,...other components>{};
class MyFace: public Face < MyUsedTypes, face::VertexRef,...other components>{};
class MyMesh: public TriMesh<vector<MyVertex>,vector<MyFace> >{};
===== classes introduced
[vcg::UsedType] : it is a class containing all the types that must be passed to the definition of Vertex, Face, Edge... This
class replaces the list of typenames to pass as first templates and the need to specify the maximal simplicial. So
<MyVertex, MyEdge, MyFace becomes <MyUsedTypes<
and
VertexSimp2 becomes Vertex
[vcg::Use] : an auxiliary class to give a simple way to specify the role of a type
Note 2: the order of templates parameters to vcg::UsedTypes is unimportant, e.g:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyVertex>::AsVertexType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyFace>::AsFaceType>{};
is the same as:
class MyUsedTypes: public vcg::UsedType <vcg::Use<MyFace>::AsFaceType,
vcg::Use<MyEdge>::AsEdgeType,
vcg::Use<MyVertex>::AsVertexType>{};
Note 3: you only need to specify the type you use. If you do not have edges you do not need
to include vcg::Use<MyEdge>::AsEdgeType in the template list of UsedTypes.
==== the Part II will be a tiny change to the class TriMesh it self.
2010-03-15 11:44:40 +01:00
|
|
|
class CVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags>{};
|
|
|
|
class CFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {};
|
2007-10-18 10:52:06 +02:00
|
|
|
class CMesh : public vcg::tri::TriMesh< std::vector<CVertex>, std::vector<CFace> > {};
|
|
|
|
|
|
|
|
class GLArea:public QGLWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
GLArea (QWidget * parent = 0);
|
|
|
|
/// we choosed a subset of the avaible drawing modes
|
|
|
|
enum DrawMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,HIDDEN,FLAT};
|
|
|
|
public slots:
|
|
|
|
/// widget-based user interaction slots
|
|
|
|
void selectDrawMode(int mode);
|
|
|
|
void loadMesh(QString filename);
|
|
|
|
void loadTetrahedron();
|
|
|
|
void loadDodecahedron();
|
|
|
|
signals:
|
|
|
|
/// signal for setting the statusbar message
|
|
|
|
void setStatusBar(QString message);
|
|
|
|
protected:
|
|
|
|
/// opengl initialization and drawing calls
|
|
|
|
void initializeGL ();
|
|
|
|
void resizeGL (int w, int h);
|
|
|
|
void paintGL ();
|
|
|
|
/// keyboard and mouse event callbacks
|
|
|
|
void keyReleaseEvent(QKeyEvent * e);
|
|
|
|
void keyPressEvent(QKeyEvent * e);
|
|
|
|
void mousePressEvent(QMouseEvent*e);
|
|
|
|
void mouseMoveEvent(QMouseEvent*e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent*e);
|
|
|
|
void wheelEvent(QWheelEvent*e);
|
|
|
|
private:
|
|
|
|
/// the active mesh instance
|
|
|
|
CMesh mesh;
|
|
|
|
/// the active mesh opengl wrapper
|
|
|
|
vcg::GlTrimesh<CMesh> glWrap;
|
|
|
|
/// the active manipulator
|
|
|
|
vcg::Trackball track;
|
|
|
|
/// the current drawmode
|
|
|
|
DrawMode drawmode;
|
|
|
|
/// mesh data structure initializer
|
|
|
|
void initMesh(QString message);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*GLAREA_H_ */
|