First checkin for OpenMesh 2.0

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@2 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2009-02-06 13:37:46 +00:00
parent c3321ebdd9
commit 97f515985d
417 changed files with 76182 additions and 0 deletions

View File

@@ -0,0 +1,131 @@
//=============================================================================
//
// OpenMesh
// Copyright (C) 2003 by Computer Graphics Group, RWTH Aachen
// www.openmesh.org
//
//-----------------------------------------------------------------------------
//
// License
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, version 2.1.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//-----------------------------------------------------------------------------
//
// $Revision: 1.1 $
// $Date: 2008-03-11 09:19:45 $
//
//=============================================================================
#ifndef OPENMESHAPPS_VIEWERWIDGET_HH
#define OPENMESHAPPS_VIEWERWIDGET_HH
//== INCLUDES =================================================================
#include <QWidget>
#include <QString>
#include <QMessageBox>
#include <QFileDialog>
#include <OpenMesh/Tools/Utils/getopt.h>
#include <OpenMesh/Tools/Utils/Timer.hh>
#include <OpenMesh/Apps/QtViewer/MeshViewerWidgetT.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
//== CLASS DEFINITION =========================================================
using namespace OpenMesh;
using namespace OpenMesh::Attributes;
struct MyTraits : public OpenMesh::DefaultTraits
{
HalfedgeAttributes(OpenMesh::Attributes::PrevHalfedge);
};
typedef OpenMesh::TriMesh_ArrayKernelT<MyTraits> MyMesh;
//== CLASS DEFINITION =========================================================
class MeshViewerWidget : public MeshViewerWidgetT<MyMesh>
{
Q_OBJECT
public:
/// default constructor
MeshViewerWidget(QWidget* parent=0) : MeshViewerWidgetT<MyMesh>(parent)
{}
OpenMesh::IO::Options& options() { return _options; }
const OpenMesh::IO::Options& options() const { return _options; }
void setOptions(const OpenMesh::IO::Options& opts) { _options = opts; }
void open_mesh_gui(QString fname)
{
OpenMesh::Utils::Timer t;
t.start();
if ( fname.isEmpty() || !open_mesh(fname.toLocal8Bit(), _options) )
{
QString msg = "Cannot read mesh from file:\n '";
msg += fname;
msg += "'";
QMessageBox::critical( NULL, windowTitle(), msg);
}
t.stop();
std::cout << "Loaded mesh in ~" << t.as_string() << std::endl;
}
void open_texture_gui(QString fname)
{
if ( fname.isEmpty() || !open_texture( fname.toLocal8Bit() ) )
{
QString msg = "Cannot load texture image from file:\n '";
msg += fname;
msg += "'\n\nPossible reasons:\n";
msg += "- Mesh file didn't provide texture coordinates\n";
msg += "- Texture file does not exist\n";
msg += "- Texture file is not accessible.\n";
QMessageBox::warning( NULL, windowTitle(), msg );
}
}
public slots:
void query_open_mesh_file() {
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open mesh file"),
tr(""),
tr("OBJ Files (*.obj);;"
"OFF Files (*.off);;"
"STL Files (*.stl);;"
"All Files (*)"));
if (!fileName.isEmpty())
open_mesh_gui(fileName);
}
void query_open_texture_file() {
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open texture file"),
tr(""),
tr("PNG Files (*.png);;"
"BMP Files (*.bmp);;"
"GIF Files (*.gif);;"
"JPEG Files (*.jpg);;"
"TIFF Files (*.tif);;"
"All Files (*)"));
if (!fileName.isEmpty())
open_texture_gui(fileName);
}
private:
OpenMesh::IO::Options _options;
};
#endif