~ubuntu-branches/ubuntu/lucid/meshlab/lucid

« back to all changes in this revision

Viewing changes to meshlab/src/meshlabplugins/io_base/baseio.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-10-08 16:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091008164041-0c2ealqv8b8uc20c
Tags: 1.2.2-1
* New upstream version
* Do not build filter_isoparametrization because liblevmar dependency
  is not (yet) in Debian
* Fix compilation with gcc-4.4, thanks to Jonathan Liu for the patch
  (closes: #539544)
* rules: Add compiler variables to the qmake call (for testing with new
  GCC versions)
* io_3ds.pro: Make LIBS and INCLUDEPATH point to Debian version of lib3ds
* io_epoch.pro: Make LIBS point to Debian version of libbz2
* control:
  - Move Homepage URL to the source package section
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
using namespace std;
86
86
using namespace vcg;
87
87
// initialize importing parameters
88
 
void BaseMeshIOPlugin::initPreOpenParameter(const QString &formatName, const QString &/*filename*/, FilterParameterSet &parlst)
 
88
void BaseMeshIOPlugin::initPreOpenParameter(const QString &formatName, const QString &/*filename*/, RichParameterSet &parlst)
89
89
{
90
90
        if (formatName.toUpper() == tr("PTX"))
91
91
        {
92
 
                parlst.addInt("meshindex",0,"Index of Range Map to be Imported","PTX files may contain more than one range map. 0 is the first range map. If the number if higher than the actual mesh number, the import will fail");
93
 
                parlst.addBool("anglecull",true,"Cull faces by angle","short");
94
 
                parlst.addFloat("angle",85.0,"Angle limit for face culling","short");
95
 
                parlst.addBool("usecolor",true,"import color","Read color from PTX, if color is not present, uses reflectance instead");
96
 
                parlst.addBool("pointcull",true,"delete unsampled points","Deletes unsampled points in the grid that are normally located in [0,0,0]");
97
 
                parlst.addBool("pointsonly",false,"Keep only points","Just import points, without triangulation");
98
 
                parlst.addBool("switchside",false,"Swap rows/columns","On some PTX, the rows and columns number are switched over");            
99
 
                parlst.addBool("flipfaces",false,"Flip all faces","Flip the orientation of all the triangles");
 
92
                parlst.addParam(new RichInt("meshindex",0,"Index of Range Map to be Imported",
 
93
                                                "PTX files may contain more than one range map. 0 is the first range map. If the number if higher than the actual mesh number, the import will fail"));
 
94
                parlst.addParam(new RichBool("anglecull",true,"Cull faces by angle","short"));
 
95
                parlst.addParam(new RichFloat("angle",85.0,"Angle limit for face culling","short"));
 
96
                parlst.addParam(new RichBool("usecolor",true,"import color","Read color from PTX, if color is not present, uses reflectance instead"));
 
97
                parlst.addParam(new RichBool("pointcull",true,"delete unsampled points","Deletes unsampled points in the grid that are normally located in [0,0,0]"));
 
98
                parlst.addParam(new RichBool("pointsonly",false,"Keep only points","Just import points, without triangulation"));
 
99
                parlst.addParam(new RichBool("switchside",false,"Swap rows/columns","On some PTX, the rows and columns number are switched over"));
 
100
                parlst.addParam(new RichBool("flipfaces",false,"Flip all faces","Flip the orientation of all the triangles"));
100
101
        }
101
102
}
102
103
 
103
 
bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const FilterParameterSet &parlst, CallBackPos *cb, QWidget * /*parent*/)
 
104
bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet &parlst, CallBackPos *cb, QWidget * /*parent*/)
104
105
{
105
106
        bool normalsUpdated = false;
106
107
 
171
172
        {
172
173
                tri::io::ImporterPTX<CMeshO>::Info importparams;
173
174
 
174
 
                importparams.meshnum = parlst.getInt("meshindex");
175
 
                importparams.anglecull =parlst.getBool("anglecull");
176
 
                importparams.angle = parlst.getFloat("angle");
177
 
                importparams.savecolor = parlst.getBool("usecolor");
178
 
                importparams.pointcull = parlst.getBool("pointcull");
179
 
                importparams.pointsonly = parlst.getBool("pointsonly");
180
 
                importparams.switchside = parlst.getBool("switchside");
181
 
                importparams.flipfaces = parlst.getBool("flipfaces");
 
175
                importparams.meshnum = parlst.findParameter("meshindex")->val->getInt();
 
176
                importparams.anglecull =parlst.findParameter("anglecull")->val->getBool(); 
 
177
                importparams.angle = parlst.findParameter("angle")->val->getFloat();
 
178
                importparams.savecolor = parlst.findParameter("usecolor")->val->getBool(); 
 
179
                importparams.pointcull = parlst.findParameter("pointcull")->val->getBool();  
 
180
                importparams.pointsonly = parlst.findParameter("pointsonly")->val->getBool();  
 
181
                importparams.switchside = parlst.findParameter("switchside")->val->getBool();  
 
182
                importparams.flipfaces = parlst.findParameter("flipfaces")->val->getBool();  
182
183
 
183
184
                // if color, add to mesh
184
185
                if(importparams.savecolor)
239
240
        return true;
240
241
}
241
242
 
242
 
bool BaseMeshIOPlugin::save(const QString &formatName,const QString &fileName, MeshModel &m, const int mask, const FilterParameterSet & par, CallBackPos *cb, QWidget */*parent*/)
 
243
bool BaseMeshIOPlugin::save(const QString &formatName,const QString &fileName, MeshModel &m, const int mask, const RichParameterSet & par, CallBackPos *cb, QWidget */*parent*/)
243
244
{
244
245
        QString errorMsgFormat = "Error encountered while exportering file %1:\n%2";
245
246
  string filename = QFile::encodeName(fileName).constData ();
247
248
        string ex = formatName.toUtf8().data();
248
249
        bool binaryFlag = false;
249
250
        if(formatName.toUpper() == tr("STL") || formatName.toUpper() == tr("PLY"))
250
 
                                        binaryFlag = par.getBool("Binary");
 
251
                                        binaryFlag = par.findParameter("Binary")->val->getBool();
251
252
                                        
252
253
        if(formatName.toUpper() == tr("PLY"))
253
254
        {
279
280
                }
280
281
                return true;
281
282
        }
282
 
        if( formatName.toUpper() == tr("OFF") || formatName.toUpper() == tr("DXF") || formatName.toUpper() == tr("OBJ") )
 
283
        if( formatName.toUpper() == tr("OFF"))
283
284
  {
 
285
                if(mask && tri::io::Mask::IOM_BITPOLYGONAL)
 
286
                        m.updateDataMask(MeshModel::MM_FACEFACETOPO);
284
287
    int result = tri::io::Exporter<CMeshO>::Save(m.cm,filename.c_str(),mask,cb);
285
288
        if(result!=0)
286
289
          {
289
292
          }
290
293
        return true;
291
294
  }
 
295
        if( formatName.toUpper() == tr("DXF") || formatName.toUpper() == tr("OBJ") )
 
296
  {
 
297
                int result = tri::io::Exporter<CMeshO>::Save(m.cm,filename.c_str(),mask,cb);
 
298
        if(result!=0)
 
299
          {
 
300
                        errorMessage = errorMsgFormat.arg(fileName, tri::io::Exporter<CMeshO>::ErrorMsg(result));
 
301
                  return false;
 
302
          }
 
303
        return true;
 
304
  }
 
305
 
292
306
  assert(0); // unknown format
293
307
        return false;
294
308
}
346
360
 
347
361
}
348
362
 
349
 
void BaseMeshIOPlugin::initOpenParameter(const QString &format, MeshModel &/*m*/, FilterParameterSet &par) 
 
363
void BaseMeshIOPlugin::initOpenParameter(const QString &format, MeshModel &/*m*/, RichParameterSet &par) 
350
364
{
351
365
        if(format.toUpper() == tr("STL"))
352
 
                par.addBool("Unify",true, "Unify Duplicated Vertices",
353
 
                                                                "The STL format is not an vertex-indexed format. Each triangle is composed by independent vertices, so, usually, duplicated vertices should be unified");               
 
366
                par.addParam(new RichBool("Unify",true, "Unify Duplicated Vertices",
 
367
                                                                "The STL format is not an vertex-indexed format. Each triangle is composed by independent vertices, so, usually, duplicated vertices should be unified"));              
354
368
}
355
 
void BaseMeshIOPlugin::initSaveParameter(const QString &format, MeshModel &/*m*/, FilterParameterSet &par) 
 
369
void BaseMeshIOPlugin::initSaveParameter(const QString &format, MeshModel &/*m*/, RichParameterSet &par) 
356
370
{
357
371
        if(format.toUpper() == tr("STL") || format.toUpper() == tr("PLY"))
358
 
                par.addBool("Binary",true, "Binary encoding",
359
 
                                                                "Save the mesh using a binary encoding. If false the mesh is saved in a plain, readable ascii format");         
 
372
                par.addParam(new RichBool("Binary",true, "Binary encoding",
 
373
                                                                "Save the mesh using a binary encoding. If false the mesh is saved in a plain, readable ascii format"));                
360
374
}
361
 
void BaseMeshIOPlugin::applyOpenParameter(const QString &format, MeshModel &m, const FilterParameterSet &par) 
 
375
void BaseMeshIOPlugin::applyOpenParameter(const QString &format, MeshModel &m, const RichParameterSet &par) 
362
376
{
363
377
        if(format.toUpper() == tr("STL"))
364
 
                if(par.getBool("Unify"))
 
378
                if(par.findParameter("Unify")->val->getBool())
365
379
                        tri::Clean<CMeshO>::RemoveDuplicateVertex(m.cm);
366
380
}
367
381
 
 
382
/*
 
383
const QString BaseMeshIOPlugin::filterInfo( FilterIDType filter )
 
384
{
 
385
        return QString("");
 
386
}
 
387
 
 
388
const QString BaseMeshIOPlugin::filterName( FilterIDType filter )
 
389
{
 
390
        return QString("");
 
391
}*/
368
392
Q_EXPORT_PLUGIN(BaseMeshIOPlugin)