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)
90
90
if (formatName.toUpper() == tr("PTX"))
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"));
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*/)
105
106
bool normalsUpdated = false;
172
173
tri::io::ImporterPTX<CMeshO>::Info importparams;
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();
183
184
// if color, add to mesh
184
185
if(importparams.savecolor)
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*/)
244
245
QString errorMsgFormat = "Error encountered while exportering file %1:\n%2";
245
246
string filename = QFile::encodeName(fileName).constData ();
349
void BaseMeshIOPlugin::initOpenParameter(const QString &format, MeshModel &/*m*/, FilterParameterSet &par)
363
void BaseMeshIOPlugin::initOpenParameter(const QString &format, MeshModel &/*m*/, RichParameterSet &par)
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"));
355
void BaseMeshIOPlugin::initSaveParameter(const QString &format, MeshModel &/*m*/, FilterParameterSet &par)
369
void BaseMeshIOPlugin::initSaveParameter(const QString &format, MeshModel &/*m*/, RichParameterSet &par)
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"));
361
void BaseMeshIOPlugin::applyOpenParameter(const QString &format, MeshModel &m, const FilterParameterSet &par)
375
void BaseMeshIOPlugin::applyOpenParameter(const QString &format, MeshModel &m, const RichParameterSet &par)
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);
383
const QString BaseMeshIOPlugin::filterInfo( FilterIDType filter )
388
const QString BaseMeshIOPlugin::filterName( FilterIDType filter )
368
392
Q_EXPORT_PLUGIN(BaseMeshIOPlugin)