Exporter.cpp
Go to the documentation of this file.
00001 /*
00002  This file is part of the VRender library.
00003  Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
00004  Version 1.0.0, released on June 27, 2005.
00005 
00006  http://artis.imag.fr/Members/Cyril.Soler/VRender
00007 
00008  VRender is free software; you can redistribute it and/or modify
00009  it under the terms of the GNU General Public License as published by
00010  the Free Software Foundation; either version 2 of the License, or
00011  (at your option) any later version.
00012 
00013  VRender is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU General Public License for more details.
00017 
00018  You should have received a copy of the GNU General Public License
00019  along with VRender; if not, write to the Free Software Foundation, Inc.,
00020  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00021 */
00022 
00023 /****************************************************************************
00024 
00025  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00026 
00027  This file is part of the QGLViewer library version 2.4.0.
00028 
00029  http://www.libqglviewer.com - contact@libqglviewer.com
00030 
00031  This file may be used under the terms of the GNU General Public License 
00032  versions 2.0 or 3.0 as published by the Free Software Foundation and
00033  appearing in the LICENSE file included in the packaging of this file.
00034  In addition, as a special exception, Gilles Debunne gives you certain 
00035  additional rights, described in the file GPL_EXCEPTION in this package.
00036 
00037  libQGLViewer uses dual licensing. Commercial/proprietary software must
00038  purchase a libQGLViewer Commercial License.
00039 
00040  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00041  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00042 
00043 *****************************************************************************/
00044 
00045 #include "VRender.h"
00046 #include "Exporter.h"
00047 #include "../qglviewer.h"
00048 
00049 #if QT_VERSION >= 0x040000
00050 # include <QFile>
00051 # include <QMessageBox>
00052 #else
00053 # include <qfile.h>
00054 # include <qmessagebox.h>
00055 #endif
00056 
00057 using namespace vrender ;
00058 using namespace std ;
00059 
00060 Exporter::Exporter()
00061 {
00062         _xmin=_xmax=_ymin=_ymax=_zmin=_zmax = 0.0 ;
00063         _pointSize=1 ;
00064 }
00065 
00066 void Exporter::exportToFile(const QString& filename,
00067                                                         const vector<PtrPrimitive>& primitive_tab,
00068                                                         VRenderParams& vparams)
00069 {
00070         QFile file(filename);
00071 
00072 #if QT_VERSION >= 0x040000
00073         if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
00074 #else
00075         if (!file.open(IO_WriteOnly | IO_Translate)) {
00076 #endif
00077                 QMessageBox::warning(NULL, QGLViewer::tr("Exporter error", "Message box window title"), QGLViewer::tr("Unable to open file %1.").arg(filename));
00078                 return;
00079         }
00080 
00081         QTextStream out(&file);
00082 
00083         writeHeader(out) ;
00084 
00085         unsigned int N = primitive_tab.size()/200 + 1 ;
00086 
00087         for(unsigned int i=0;i<primitive_tab.size();++i)
00088         {
00089                 Point *p = dynamic_cast<Point *>(primitive_tab[i]) ;
00090                 Segment *s = dynamic_cast<Segment *>(primitive_tab[i]) ;
00091                 Polygone *P = dynamic_cast<Polygone *>(primitive_tab[i]) ;
00092 
00093                 if(p != NULL) spewPoint(p,out) ;
00094                 if(s != NULL) spewSegment(s,out) ;
00095                 if(P != NULL) spewPolygone(P,out) ;
00096 
00097                 if(i%N == 0)
00098                         vparams.progress(i/(float)primitive_tab.size(),QGLViewer::tr("Exporting to file %1").arg(filename)) ;
00099         }
00100 
00101         writeFooter(out) ;
00102 
00103         file.close();
00104 }
00105 
00106 void Exporter::setBoundingBox(float xmin,float ymin,float xmax,float ymax)
00107 {
00108         _xmin = xmin ;
00109         _ymin = ymin ;
00110         _xmax = xmax ;
00111         _ymax = ymax ;
00112 }
00113 
00114 void Exporter::setClearColor(float r, float g, float b) { _clearR=r; _clearG=g; _clearB=b; }
00115 void Exporter::setClearBackground(bool b) { _clearBG=b; }
00116 void Exporter::setBlackAndWhite(bool b) { _blackAndWhite = b; }
00117 


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26