Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FilePLY.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #include "FilePLY.hh"
51 
52 #if QT_VERSION >= 0x050000
53  #include <QtWidgets>
54 #else
55  #include <QtGui>
56 #endif
57 
58 
59 // Defines for the type handling drop down box
60 #define TYPEAUTODETECT 0
61 #define TYPEASK 1
62 #define TYPEPOLY 2
63 #define TYPETRIANGLE 3
64 
67 : loadOptions_(0),
68  saveOptions_(0),
69  saveBinary_(0),
70  saveVertexNormal_(0),
71  saveVertexColor_(0),
72  saveVertexTexCoord_(0),
73  saveFaceNormal_(0),
74  saveFaceColor_(0),
75  savePrecisionLabel_(0),
76  savePrecision_(0),
77  saveDefaultButton_(0),
78  triMeshHandling_(0),
79  loadVertexNormal_(0),
80  loadVertexColor_(0),
81  loadVertexTexCoord_(0),
82  loadFaceNormal_(0),
83  loadFaceColor_(0),
84  loadDefaultButton_(0),
85  trimeshOptions_(0) {
86 }
87 
88 //-----------------------------------------------------------------------------------------------------
89 
91 }
92 
93 //-----------------------------------------------------------------------------------------------------
94 
96  return QString( tr("Polygon File Format files ( *.ply )") );
97 };
98 
99 //-----------------------------------------------------------------------------------------------------
100 
102  return QString( tr("Polygon File Format files ( *.ply )") );
103 };
104 
105 //-----------------------------------------------------------------------------------------------------
106 
109  return type;
110 }
111 
112 //-----------------------------------------------------------------------------------------------------
113 int FilePLYPlugin::loadObject(QString _filename, DataType _type) {
114 
115  int objectId = -1;
116 
117  bool gui = OpenFlipper::Options::gui() && (loadVertexNormal_ != 0) /*buttons initialized*/;
118  // If in no gui mode -> request as much as possible
119  bool vNormals = ((gui && loadVertexNormal_->isChecked()) ||
120  (!gui && OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool()));
121  bool vColors = ((gui && loadVertexColor_->isChecked()) ||
122  (!gui && OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool()));
123  bool vTexCoords = ((gui && loadVertexTexCoord_->isChecked()) ||
124  (!gui && OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool()));
125  bool fNormals = ((gui && loadFaceNormal_->isChecked()) ||
126  (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool()));
127  bool fColors = ((gui && loadFaceColor_->isChecked()) ||
128  (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool()));
129 
131  if (vNormals)
133  if (vColors)
135  if (vTexCoords)
137  if (fNormals)
139  if (fColors)
142 
143  // Forced polymesh read
144  if ( _type == DATA_POLY_MESH ) {
145  objectId = loadPolyMeshObject(_filename, opt);
146 
147  PolyMeshObject* object(0);
148  if(PluginFunctions::getObject( objectId, object )) {
149  emit updatedObject(objectId, UPDATE_ALL);
150  emit openedFile( objectId );
151  }
152 
153 
154  return objectId;
155  } else if ( _type == DATA_TRIANGLE_MESH) {
156  // If always open as TriMesh is selected
157 
158  objectId = loadTriMeshObject(_filename, opt);
159 
160  TriMeshObject* object(0);
161  if(PluginFunctions::getObject( objectId, object )) {
162 
163  emit updatedObject(objectId, UPDATE_ALL);
164  emit openedFile( objectId );
165  }
166 
167 
168  return objectId;
169  } else {
170  emit log( LOGERR, tr("FilePLYPlugin::loadObject(): Tried loading with unknown forced data type"));
171  }
172 
173  return -1;
174 }
175 
176 //-----------------------------------------------------------------------------------------------------
177 
178 int FilePLYPlugin::loadObject(QString _filename) {
179 
180  int triMeshControl = TYPEAUTODETECT; // 0 == Auto-Detect
181 
182  bool gui = OpenFlipper::Options::gui() && (loadVertexNormal_ != 0) /*buttons initialized*/;
183  // If in no gui mode -> request as much as possible
184  bool vNormals = ((gui && loadVertexNormal_->isChecked()) ||
185  (!gui && OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool()));
186  bool vColors = ((gui && loadVertexColor_->isChecked()) ||
187  (!gui && OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool()));
188  bool vTexCoords = ((gui && loadVertexTexCoord_->isChecked()) ||
189  (!gui && OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool()));
190  bool fNormals = ((gui && loadFaceNormal_->isChecked()) ||
191  (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool()));
192  bool fColors = ((gui && loadFaceColor_->isChecked()) ||
193  (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool()));
194 
196  if (vNormals)
198  if (vColors)
200  if (vTexCoords)
202  if (fNormals)
204  if (fColors)
207 
208  if ( OpenFlipper::Options::gui() ){
209  if ( triMeshHandling_ != 0 ){
210  triMeshControl = triMeshHandling_->currentIndex();
211  } else {
212  triMeshControl = TYPEAUTODETECT;
213  }
214  }
215 
216  int objectId = -1;
217 
218 
219  if(triMeshControl == TYPEAUTODETECT || triMeshControl == TYPEASK) {
220 
221  objectId = loadPolyMeshObject(_filename, opt);
222 
223  PolyMeshObject *object = 0;
224  if(!PluginFunctions::getObject(objectId, object))
225  return -1;
226 
227  bool isTriMesh = true;
228  for ( PolyMesh::FaceIter f_it = object->mesh()->faces_begin(); f_it != object->mesh()->faces_end() && isTriMesh; ++f_it) {
229 
230  // Count number of vertices for the current face
231  unsigned count = 0;
232  for ( PolyMesh::FaceVertexIter fv_it( *(object->mesh()),*f_it); fv_it.is_valid(); ++fv_it )
233  ++count;
234 
235  // Check if it is a triangle. If not, this is really a poly mesh
236  isTriMesh = isTriMesh && (count == 3);
237  }
238 
239  if (triMeshControl == TYPEAUTODETECT)
240  {
241  if(!isTriMesh) {
242  PolyMeshObject* object(0);
243  if(PluginFunctions::getObject( objectId, object )) {
244  emit updatedObject(objectId, UPDATE_ALL);
245  emit openedFile( objectId );
246  }
247  return objectId;
248  }
249  }
250  else if (triMeshControl == TYPEASK) {
251 
252  // If Ask is selected -> show dialog
253  QMetaObject::invokeMethod(this,"handleTrimeshDialog",Qt::BlockingQueuedConnection);
254  if ((trimeshOptions_ == TYPEPOLY) ||
255  (trimeshOptions_ == TYPEASK && !isTriMesh)) {
256 
257  PolyMeshObject* object(0);
258  if(PluginFunctions::getObject( objectId, object )) {
259  emit updatedObject(object->id(), UPDATE_ALL);
260  emit openedFile( objectId );
261  }
262 
263  return objectId;
264  }
265 
266  }
267  } else if (triMeshControl == TYPEPOLY) {
268  // If always open as PolyMesh is selected
269 
270  objectId = loadPolyMeshObject(_filename, opt);
271 
272  PolyMeshObject* object(0);
273  if(PluginFunctions::getObject( objectId, object )) {
274  emit updatedObject(object->id(), UPDATE_ALL);
275  emit openedFile( objectId );
276  }
277 
278  return objectId;
279  } else {
280  // If always open as TriMesh is selected
281 
282  objectId = loadTriMeshObject(_filename, opt);
283 
284  TriMeshObject* object(0);
285  if(PluginFunctions::getObject( objectId, object )) {
286  emit updatedObject(object->id(), UPDATE_ALL);
287  emit openedFile( objectId );
288  }
289 
290 
291  return objectId;
292  }
293 
294  // Load object as triangle mesh
295 
296  if(objectId != -1) emit deleteObject(objectId);
297  objectId = loadTriMeshObject(_filename, opt);
298 
299  TriMeshObject* object(0);
300  if(PluginFunctions::getObject( objectId, object )) {
301  emit updatedObject(object->id(), UPDATE_ALL);
302  emit openedFile( objectId );
303  }
304 
305  return objectId;
306 };
307 
309 {
310  QMessageBox msgBox;
311  QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
312  QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
313  QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
314  msgBox.setWindowTitle( tr("Mesh types in file") );
315  msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
316  msgBox.setDefaultButton( detectButton );
317  msgBox.exec();
318 
319 
320  if (msgBox.clickedButton() == triButton)
321  trimeshOptions_ = TYPETRIANGLE ;
322  else if (msgBox.clickedButton() == polyButton)
323  trimeshOptions_ = TYPEPOLY ;
324  else
325  trimeshOptions_ = TYPEASK;
326 }
327 
328 //-----------------------------------------------------------------------------------------------------
329 
332 
333  int id = -1;
334  emit addEmptyObject(DATA_TRIANGLE_MESH, id);
335 
336  TriMeshObject* object(0);
337  if(PluginFunctions::getObject( id, object)) {
338 
339  if ( PluginFunctions::objectCount() == 1 )
340  object->target(true);
341 
342  object->setFromFileName(_filename);
343  object->setName(object->filename());
344 
345  // Get mesh
346  TriMesh* mesh = object->mesh();
347 
348  bool hadVNormals = mesh->has_vertex_normals();
349  bool hadVColors = mesh->has_vertex_colors();
350  bool hadVTexCoords = mesh->has_vertex_texcoords2D();
351  bool hadFNormals = mesh->has_face_normals();
352  bool hadFColors = mesh->has_face_colors();
353 
354  if(_opt.vertex_has_normal())
355  mesh->request_vertex_normals();
356  if(_opt.vertex_has_color())
357  mesh->request_vertex_colors();
358  if(_opt.vertex_has_texcoord())
359  mesh->request_vertex_texcoords2D();
360  if(_opt.face_has_normal())
361  mesh->request_face_normals();
362  if(_opt.face_has_color())
363  mesh->request_face_colors();
364 
365  bool ok = OpenMesh::IO::read_mesh( *mesh , _filename.toStdString(), _opt);
366  if (!ok)
367  {
368  emit log(LOGERR, "Error while reading PLY file!");
369  emit deleteObject(id);
370  return -1;
371  }
372 
373  //update normals if they aren't read
374  if (!_opt.vertex_has_normal() || !_opt.face_has_normal())
375  mesh->update_normals();
376 
377  //cleanup mesh if selected option could not be loaded
378  if (!hadVColors && !_opt.vertex_has_color() && mesh->has_vertex_colors())
379  mesh->release_vertex_colors();
380  if (!hadVTexCoords && !_opt.vertex_has_texcoord() && mesh->has_vertex_texcoords2D())
381  mesh->release_vertex_texcoords2D();
382  if (!hadFColors && !_opt.face_has_color() && mesh->has_face_colors())
383  mesh->release_face_colors();
384 
385  // Switch to point mode if mesh does not contain one single face
386  if(mesh->n_faces() == 0)
388 
390 
391  return object->id();
392 
393  } else {
394  emit log(LOGERR,"Error : Could not create new triangle mesh object.");
395  return -1;
396  }
397 }
398 
399 //-----------------------------------------------------------------------------------------------------
400 
403 
404  int id = -1;
405  emit addEmptyObject(DATA_POLY_MESH, id);
406 
407  PolyMeshObject* object(0);
408  if(PluginFunctions::getObject(id, object)) {
409 
410  if (PluginFunctions::objectCount() == 1 )
411  object->target(true);
412 
413  object->setFromFileName(_filename);
414  object->setName(object->filename());
415 
416  // Get mesh
417  PolyMesh* mesh = object->mesh();
418 
419  bool hadVNormals = mesh->has_vertex_normals();
420  bool hadVColors = mesh->has_vertex_colors();
421  bool hadVTexCoords = mesh->has_vertex_texcoords2D();
422  bool hadFNormals = mesh->has_face_normals();
423  bool hadFColors = mesh->has_face_colors();
424 
425  if(_opt.vertex_has_normal())
426  mesh->request_vertex_normals();
427  if(_opt.vertex_has_color())
428  mesh->request_vertex_colors();
429  if(_opt.vertex_has_texcoord())
430  mesh->request_vertex_texcoords2D();
431  if(_opt.face_has_normal())
432  mesh->request_face_normals();
433  if(_opt.face_has_color())
434  mesh->request_face_colors();
435 
436  bool ok = OpenMesh::IO::read_mesh( *mesh , _filename.toStdString(), _opt);
437  if (!ok)
438  {
439  emit log(LOGERR, "Error while reading PLY file!");
440  emit deleteObject(id);
441  return -1;
442  }
443 
444  //update normals if they aren't read
445  if (!_opt.vertex_has_normal() || !_opt.face_has_normal())
446  mesh->update_normals();
447 
448  //cleanup mesh if selected option could not be loaded
449  if (!hadVColors && !_opt.vertex_has_color() && mesh->has_vertex_colors())
450  mesh->release_vertex_colors();
451  if (!hadVTexCoords && !_opt.vertex_has_texcoord() && mesh->has_vertex_texcoords2D())
452  mesh->release_vertex_texcoords2D();
453  if (!hadFColors && !_opt.face_has_color() && mesh->has_face_colors())
454  mesh->release_face_colors();
455 
456 
457  // Switch to point mode if mesh does not contain one single face
458  if(mesh->n_faces() == 0)
460 
462 
463  return object->id();
464 
465  } else {
466  emit log(LOGERR,"Error : Could not create new poly mesh object.");
467  return -1;
468  }
469 
470  return id;
471 }
472 
473 //-----------------------------------------------------------------------------------------------------
474 
475 bool FilePLYPlugin::saveObject(int _id, QString _filename)
476 {
477  BaseObjectData* object;
478  if ( !PluginFunctions::getObject(_id,object) ) {
479  emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
480  return false;
481  }
482 
483  object->setFromFileName(_filename);
484  object->setName(object->filename());
485 
486 
488  bool gui = OpenFlipper::Options::gui() && (saveBinary_ != 0) /*buttons initialized?*/;
489  bool binary = ((gui && saveBinary_->isChecked()) ||
490  OpenFlipperSettings().value("FilePLY/Save/Binary",false).toBool());
491 
492  if (binary)
494 
495  bool vNormals = ((gui && saveVertexNormal_->isChecked())) ||
496  (!gui && OpenFlipperSettings().value("FilePLY/Save/Normals",true).toBool());
497  bool vColors = ((gui && saveVertexColor_->isChecked())) ||
498  (!gui && OpenFlipperSettings().value("FilePLY/Save/VertexColor",true).toBool());
499  bool vTexCoords = ((gui && saveVertexTexCoord_->isChecked())) ||
500  (!gui && OpenFlipperSettings().value("FilePLY/Save/TexCoords",true).toBool());
501  bool fNormals = ((gui && saveFaceNormal_->isChecked())) ||
502  (!gui && OpenFlipperSettings().value("FilePLY/Save/FaceNormal",true).toBool());
503  bool fColors = ((gui && saveFaceColor_->isChecked())) ||
504  (!gui && OpenFlipperSettings().value("FilePLY/Save/FaceColor",true).toBool());
505 
506 
507  bool ok = false;
508 
509  if ( object->dataType(DATA_POLY_MESH) ) {
510 
511  PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject*>(object);
512  PolyMesh* mesh = polyObj->mesh();
513 
514  if (vNormals && mesh->has_vertex_normals())
516  if (vColors && mesh->has_vertex_colors())
518  if (vTexCoords && mesh->has_vertex_texcoords2D())
520  if (fNormals && mesh->has_face_normals())
522  if (fColors && mesh->has_face_colors())
524 
525  ok = OpenMesh::IO::write_mesh(*mesh, _filename.toStdString() ,opt);
526 
527  } else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
528 
529  TriMeshObject* triObj = dynamic_cast<TriMeshObject*>(object);
530  TriMesh* mesh = triObj->mesh();
531 
532  if (vNormals && mesh->has_vertex_normals())
534  if (vColors && mesh->has_vertex_colors())
536  if (vTexCoords && mesh->has_vertex_texcoords2D())
538  if (fNormals && mesh->has_face_normals())
540  if (fColors && mesh->has_face_colors())
542 
543  ok = OpenMesh::IO::write_mesh(*mesh, _filename.toStdString() ,opt);
544  }
545 
546  if(!ok) {
547  emit log(LOGERR, tr("Unable to save ") + _filename);
548  return false;
549  }
550 
551  emit log(LOGINFO, tr("Saved object to ") + _filename );
552  return true;
553 }
554 
555 //-----------------------------------------------------------------------------------------------------
556 
557 QWidget* FilePLYPlugin::saveOptionsWidget(QString /*_currentFilter*/) {
558 
559  if (saveOptions_ == 0){
560  //generate widget
561  saveOptions_ = new QWidget();
562  QVBoxLayout* layout = new QVBoxLayout();
563  layout->setAlignment(Qt::AlignTop);
564 
565  saveBinary_ = new QCheckBox("Save Binary");
566  layout->addWidget(saveBinary_);
567 
568  saveVertexNormal_ = new QCheckBox("Save Vertex Normals");
569  layout->addWidget(saveVertexNormal_);
570 
571  saveVertexColor_ = new QCheckBox("Save Vertex Colors");
572  layout->addWidget(saveVertexColor_);
573 
574  saveVertexTexCoord_ = new QCheckBox("Save Vertex TexCoords");
575  layout->addWidget(saveVertexTexCoord_);
576 
577  saveFaceNormal_ = new QCheckBox("Save Face Normals");
578  layout->addWidget(saveFaceNormal_);
579 
580  saveFaceColor_ = new QCheckBox("Save Face Colors");
581  layout->addWidget(saveFaceColor_);
582 
583  savePrecisionLabel_ = new QLabel("Writer Precision");
584  layout->addWidget(savePrecisionLabel_);
585 
586  savePrecision_ = new QSpinBox();
587  savePrecision_->setMinimum(1);
588  savePrecision_->setMaximum(12);
589  savePrecision_->setValue(6);
590  layout->addWidget(savePrecision_);
591 
592  saveDefaultButton_ = new QPushButton("Make Default");
593  layout->addWidget(saveDefaultButton_);
594 
595  saveOptions_->setLayout(layout);
596 
597  connect(saveBinary_, SIGNAL(clicked(bool)), savePrecision_, SLOT(setDisabled(bool)));
598  connect(saveDefaultButton_, SIGNAL(clicked()), this, SLOT(slotSaveDefault()));
599 
600  saveBinary_->setChecked( OpenFlipperSettings().value("FilePLY/Save/Binary",true).toBool() );
601  savePrecision_->setDisabled(true);
602  saveVertexNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Save/Normals",true).toBool() );
603  saveVertexColor_->setChecked( OpenFlipperSettings().value("FilePLY/Save/VertexColor",true).toBool() );
604  saveVertexTexCoord_->setChecked( OpenFlipperSettings().value("FilePLY/Save/TexCoords",true).toBool() );
605  saveFaceNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Save/FaceNormal",true).toBool() );
606  saveFaceColor_->setChecked( OpenFlipperSettings().value("FilePLY/Save/FaceColor",true).toBool() );
607  }
608 
609  return saveOptions_;
610 }
611 
612 //-----------------------------------------------------------------------------------------------------
613 
614 QWidget* FilePLYPlugin::loadOptionsWidget(QString /*_currentFilter*/) {
615 
616  if (loadOptions_ == 0){
617  //generate widget
618  loadOptions_ = new QWidget();
619  QVBoxLayout* layout = new QVBoxLayout();
620  layout->setAlignment(Qt::AlignTop);
621 
622  QLabel* label = new QLabel(tr("If PolyMesh is a Triangle Mesh:"));
623 
624  layout->addWidget(label);
625 
626  triMeshHandling_ = new QComboBox();
627  triMeshHandling_->addItem( tr("Auto-Detect") );
628  triMeshHandling_->addItem( tr("Ask") );
629  triMeshHandling_->addItem( tr("Always open as PolyMesh") );
630  triMeshHandling_->addItem( tr("Always open as TriangleMesh") );
631 
632  layout->addWidget(triMeshHandling_);
633 
634  loadVertexNormal_ = new QCheckBox("Load Vertex Normals");
635  layout->addWidget(loadVertexNormal_);
636 
637  loadVertexColor_ = new QCheckBox("Load Vertex Colors");
638  layout->addWidget(loadVertexColor_);
639 
640  loadVertexTexCoord_ = new QCheckBox("Load Vertex TexCoords");
641  layout->addWidget(loadVertexTexCoord_);
642 
643  loadFaceNormal_ = new QCheckBox("Load Face Normals");
644  layout->addWidget(loadFaceNormal_);
645 
646  loadFaceColor_ = new QCheckBox("Load Face Colors");
647  layout->addWidget(loadFaceColor_);
648 
649  loadDefaultButton_ = new QPushButton("Make Default");
650  layout->addWidget(loadDefaultButton_);
651 
652  loadOptions_->setLayout(layout);
653 
654  connect(loadDefaultButton_, SIGNAL(clicked()), this, SLOT(slotLoadDefault()));
655 
656 
657  triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("FilePLY/Load/TriMeshHandling",TYPEAUTODETECT).toInt() );
658 
659  loadVertexNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool() );
660  loadVertexColor_->setChecked( OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool() );
661  loadVertexTexCoord_->setChecked( OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool() );
662  loadFaceNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool() );
663  loadFaceColor_->setChecked( OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool() );
664  }
665 
666  return loadOptions_;
667 }
668 
670 
671  OpenFlipperSettings().setValue( "FilePLY/Load/Normals", loadVertexNormal_->isChecked() );
672  OpenFlipperSettings().setValue( "FilePLY/Load/VertexColor", loadVertexColor_->isChecked() );
673  OpenFlipperSettings().setValue( "FilePLY/Load/TexCoords", loadVertexTexCoord_->isChecked() );
674  OpenFlipperSettings().setValue( "FilePLY/Load/FaceNormal", loadFaceNormal_->isChecked() );
675  OpenFlipperSettings().setValue( "FilePLY/Load/FaceColor", loadFaceColor_->isChecked() );
676 
677  OpenFlipperSettings().setValue( "FilePLY/Load/TriMeshHandling", triMeshHandling_->currentIndex() );
678 
679  OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
680 }
681 
682 
684 
685  OpenFlipperSettings().setValue( "FilePLY/Save/Binary", saveBinary_->isChecked() );
686  OpenFlipperSettings().setValue( "FilePLY/Save/TexCoords", saveVertexTexCoord_->isChecked() );
687  OpenFlipperSettings().setValue( "FilePLY/Save/Normals", saveVertexNormal_->isChecked() );
688  OpenFlipperSettings().setValue( "FilePLY/Save/VertexColor", saveVertexColor_->isChecked() );
689  OpenFlipperSettings().setValue( "FilePLY/Save/FaceNormal", saveFaceNormal_->isChecked() );
690  OpenFlipperSettings().setValue( "FilePLY/Save/FaceColor", saveFaceColor_->isChecked() );
691 }
692 #if QT_VERSION < 0x050000
693  Q_EXPORT_PLUGIN2( fileplyplugin , FilePLYPlugin );
694 #endif
695 
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:104
QString getLoadFilters()
Definition: FilePLY.cc:95
MeshT * mesh()
return a pointer to the mesh
Definition: MeshObjectT.cc:351
Type for a Meshobject containing a poly mesh.
Definition: PolyMesh.hh:70
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition: FilePLY.cc:178
Has (r) / store (w) vertex normals.
Definition: Options.hh:109
QString filename() const
return the filename of the object
Definition: BaseObject.cc:717
Type for a MeshObject containing a triangle mesh.
Definition: TriangleMesh.hh:73
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
bool getObject(int _identifier, BSplineCurveObject *&_object)
Has (r) / store (w) face normals.
Definition: Options.hh:113
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
Has (r) / store (w) face colors.
Definition: Options.hh:114
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
Has (r) / store (w) texture coordinates.
Definition: Options.hh:111
Set options for reader/writer modules.
Definition: Options.hh:95
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition: FilePLY.cc:308
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition: FilePLY.cc:669
DrawMode POINTS
draw unlighted points using the default base color
Definition: DrawModes.cc:79
void initializePlugin()
Initialize Plugin.
Definition: FilePLY.cc:90
#define DATA_POLY_MESH
Definition: PolyMesh.hh:65
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FilePLY.cc:107
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition: FilePLY.cc:683
int loadTriMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Loads a triangle mesh.
Definition: FilePLY.cc:331
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void update_normals()
Compute normals for all primitives.
Definition: PolyMeshT.cc:241
Kernel::FaceVertexIter FaceVertexIter
Circulator.
Definition: PolyMeshT.hh:170
QString getSaveFilters()
Definition: FilePLY.cc:101
Set binary mode for r/w.
Definition: Options.hh:105
int objectCount()
Get the number of available objects.
Has (r) / store (w) vertex colors.
Definition: Options.hh:110
int loadPolyMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Always loads mesh as polymesh.
Definition: FilePLY.cc:402
FilePLYPlugin()
Constructor.
Definition: FilePLY.cc:66
Predefined datatypes.
Definition: DataTypes.hh:96
QWidget * loadOptionsWidget(QString)
Definition: FilePLY.cc:614
bool write_mesh(const Mesh &_mesh, const std::string &_filename, Options _opt=Options::Default, std::streamsize _precision=6)
Write a mesh to the file _filename.
Definition: MeshIO.hh:199
Has (r) custom properties (currently only implemented in PLY Reader ASCII version) ...
Definition: Options.hh:118
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
Definition: FilePLYT.cc:62
#define DATA_TRIANGLE_MESH
Definition: TriangleMesh.hh:66
QWidget * saveOptionsWidget(QString)
Definition: FilePLY.cc:557
int id() const
Definition: BaseObject.cc:201