Developer Documentation
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#include "FilePLY.hh"
45
46 #include <QtWidgets>
47
48
49// Defines for the type handling drop down box
50#define TYPEAUTODETECT 0
51#define TYPEASK 1
52#define TYPEPOLY 2
53#define TYPETRIANGLE 3
54
57: loadOptions_(0),
58 saveOptions_(0),
59 saveBinary_(0),
60 saveVertexNormal_(0),
61 saveVertexColor_(0),
62 saveVertexTexCoord_(0),
63 saveFaceNormal_(0),
64 saveFaceColor_(0),
65 savePrecisionLabel_(0),
66 savePrecision_(0),
67 saveDefaultButton_(0),
68 triMeshHandling_(0),
69 loadVertexNormal_(0),
70 loadVertexColor_(0),
71 loadVertexTexCoord_(0),
72 loadFaceNormal_(0),
73 loadFaceColor_(0),
74 loadDefaultButton_(0),
75 trimeshOptions_(0) {
76}
77
78//-----------------------------------------------------------------------------------------------------
79
81}
82
83//-----------------------------------------------------------------------------------------------------
84
86 return QString( tr("Polygon File Format files ( *.ply )") );
87};
88
89//-----------------------------------------------------------------------------------------------------
90
92 return QString( tr("Polygon File Format files ( *.ply )") );
93};
94
95//-----------------------------------------------------------------------------------------------------
96
99 return type;
100}
101
102//-----------------------------------------------------------------------------------------------------
103int FilePLYPlugin::loadObject(QString _filename, DataType _type) {
104
105 int objectId = -1;
106
107 bool gui = OpenFlipper::Options::gui() && (loadVertexNormal_ != 0) /*buttons initialized*/;
108 // If in no gui mode -> request as much as possible
109 bool vNormals = ((gui && loadVertexNormal_->isChecked()) ||
110 (!gui && OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool()));
111 bool vColors = ((gui && loadVertexColor_->isChecked()) ||
112 (!gui && OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool()));
113 bool vTexCoords = ((gui && loadVertexTexCoord_->isChecked()) ||
114 (!gui && OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool()));
115 bool fNormals = ((gui && loadFaceNormal_->isChecked()) ||
116 (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool()));
117 bool fColors = ((gui && loadFaceColor_->isChecked()) ||
118 (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool()));
119
121 if (vNormals)
123 if (vColors)
125 if (vTexCoords)
127 if (fNormals)
129 if (fColors)
132
133 // Forced polymesh read
134 if ( _type == DATA_POLY_MESH ) {
135 objectId = loadPolyMeshObject(_filename, opt);
136
137 PolyMeshObject* object(0);
138 if(PluginFunctions::getObject( objectId, object )) {
139 emit updatedObject(objectId, UPDATE_ALL);
140 emit openedFile( objectId );
141 }
142
143
144 return objectId;
145 } else if ( _type == DATA_TRIANGLE_MESH) {
146 // If always open as TriMesh is selected
147
148 objectId = loadTriMeshObject(_filename, opt);
149
150 TriMeshObject* object(0);
151 if(PluginFunctions::getObject( objectId, object )) {
152
153 emit updatedObject(objectId, UPDATE_ALL);
154 emit openedFile( objectId );
155 }
156
157
158 return objectId;
159 } else {
160 emit log( LOGERR, tr("FilePLYPlugin::loadObject(): Tried loading with unknown forced data type"));
161 }
162
163 return -1;
164}
165
166//-----------------------------------------------------------------------------------------------------
167
168int FilePLYPlugin::loadObject(QString _filename) {
169
170 int triMeshControl = TYPEAUTODETECT; // 0 == Auto-Detect
171
172 bool gui = OpenFlipper::Options::gui() && (loadVertexNormal_ != 0) /*buttons initialized*/;
173 // If in no gui mode -> request as much as possible
174 bool vNormals = ((gui && loadVertexNormal_->isChecked()) ||
175 (!gui && OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool()));
176 bool vColors = ((gui && loadVertexColor_->isChecked()) ||
177 (!gui && OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool()));
178 bool vTexCoords = ((gui && loadVertexTexCoord_->isChecked()) ||
179 (!gui && OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool()));
180 bool fNormals = ((gui && loadFaceNormal_->isChecked()) ||
181 (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool()));
182 bool fColors = ((gui && loadFaceColor_->isChecked()) ||
183 (!gui && OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool()));
184
186 if (vNormals)
188 if (vColors)
190 if (vTexCoords)
192 if (fNormals)
194 if (fColors)
197
198 if ( OpenFlipper::Options::gui() ){
199 if ( triMeshHandling_ != 0 ){
200 triMeshControl = triMeshHandling_->currentIndex();
201 } else {
202 triMeshControl = TYPEAUTODETECT;
203 }
204 }
205
206 int objectId = -1;
207
208
209 if(triMeshControl == TYPEAUTODETECT || triMeshControl == TYPEASK) {
210
211 objectId = loadPolyMeshObject(_filename, opt);
212
213 PolyMeshObject *object = 0;
214 if(!PluginFunctions::getObject(objectId, object))
215 return -1;
216
217 bool isTriMesh = true;
218 for (auto f_it : object->mesh()->faces()) {
219
220 if (isTriMesh) {
221 // Count number of vertices for the current face
222 unsigned count = 0;
223 for (auto fv_it : f_it.vertices() )
224 ++count;
225
226 // Check if it is a triangle. If not, this is really a poly mesh
227 isTriMesh = isTriMesh && (count == 3);
228 }
229
230 }
231
232 if (triMeshControl == TYPEAUTODETECT)
233 {
234 if(!isTriMesh) {
235 PolyMeshObject* object(0);
236 if(PluginFunctions::getObject( objectId, object )) {
237 emit updatedObject(objectId, UPDATE_ALL);
238 emit openedFile( objectId );
239 }
240 return objectId;
241 }
242 }
243 else if (triMeshControl == TYPEASK) {
244
245 // If Ask is selected -> show dialog
246 QMetaObject::invokeMethod(this,"handleTrimeshDialog",Qt::BlockingQueuedConnection);
247 if ((trimeshOptions_ == TYPEPOLY) ||
248 (trimeshOptions_ == TYPEASK && !isTriMesh)) {
249
250 PolyMeshObject* object(0);
251 if(PluginFunctions::getObject( objectId, object )) {
252 emit updatedObject(object->id(), UPDATE_ALL);
253 emit openedFile( objectId );
254 }
255
256 return objectId;
257 }
258
259 }
260 } else if (triMeshControl == TYPEPOLY) {
261 // If always open as PolyMesh is selected
262
263 objectId = loadPolyMeshObject(_filename, opt);
264
265 PolyMeshObject* object(0);
266 if(PluginFunctions::getObject( objectId, object )) {
267 emit updatedObject(object->id(), UPDATE_ALL);
268 emit openedFile( objectId );
269 }
270
271 return objectId;
272 } else {
273 // If always open as TriMesh is selected
274
275 objectId = loadTriMeshObject(_filename, opt);
276
277 TriMeshObject* object(0);
278 if(PluginFunctions::getObject( objectId, object )) {
279 emit updatedObject(object->id(), UPDATE_ALL);
280 emit openedFile( objectId );
281 }
282
283
284 return objectId;
285 }
286
287 // Load object as triangle mesh
288
289 if(objectId != -1) emit deleteObject(objectId);
290 objectId = loadTriMeshObject(_filename, opt);
291
292 TriMeshObject* object(0);
293 if(PluginFunctions::getObject( objectId, object )) {
294 emit updatedObject(object->id(), UPDATE_ALL);
295 emit openedFile( objectId );
296 }
297
298 return objectId;
299};
300
302{
303 QMessageBox msgBox;
304 QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
305 QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
306 QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
307 msgBox.setWindowTitle( tr("Mesh types in file") );
308 msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
309 msgBox.setDefaultButton( detectButton );
310 msgBox.exec();
311
312
313 if (msgBox.clickedButton() == triButton)
314 trimeshOptions_ = TYPETRIANGLE ;
315 else if (msgBox.clickedButton() == polyButton)
316 trimeshOptions_ = TYPEPOLY ;
317 else
318 trimeshOptions_ = TYPEASK;
319}
320
321//-----------------------------------------------------------------------------------------------------
322
325
326 int id = -1;
327 emit addEmptyObject(DATA_TRIANGLE_MESH, id);
328
329 TriMeshObject* object(0);
330 if(PluginFunctions::getObject( id, object)) {
331
332 if ( PluginFunctions::objectCount() == 1 )
333 object->target(true);
334
335 object->setFromFileName(_filename);
336 object->setName(object->filename());
337
338 // Get mesh
339 TriMesh* mesh = object->mesh();
340
341 bool hadVNormals = mesh->has_vertex_normals();
342 bool hadVColors = mesh->has_vertex_colors();
343 bool hadVTexCoords = mesh->has_vertex_texcoords2D();
344 bool hadFNormals = mesh->has_face_normals();
345 bool hadFColors = mesh->has_face_colors();
346
347 if(_opt.vertex_has_normal())
348 mesh->request_vertex_normals();
349 if(_opt.vertex_has_color())
350 mesh->request_vertex_colors();
351 if(_opt.vertex_has_texcoord())
352 mesh->request_vertex_texcoords2D();
353 if(_opt.face_has_normal())
354 mesh->request_face_normals();
355 if(_opt.face_has_color())
356 mesh->request_face_colors();
357
358 bool ok = OpenMesh::IO::read_mesh( *mesh , _filename.toStdString(), _opt);
359 if (!ok)
360 {
361 emit log(LOGERR, "Error while reading PLY file!");
362 emit deleteObject(id);
363 return -1;
364 }
365
366 //update normals if they aren't read
367 if (!_opt.vertex_has_normal() || !_opt.face_has_normal()) {
368
369
370 if (_opt.vertex_has_normal() ) {
371 // If we have vertex normals, we can use them to compute the face normals
372 emit log(LOGINFO,"Vertex normals loaded from file. Computing Face normals.");
373 mesh->update_face_normals();
374 std::cerr << "Update face normals" << std::endl;
375 } else {
376 // If we don't have any normals, we compute all of them
377 emit log(LOGINFO,"File did not contain normals. Computing automatically.");
378 mesh->update_normals();
379 }
380
381
382 }
383
384 //cleanup mesh if selected option could not be loaded
385 if (!hadVColors && !_opt.vertex_has_color() && mesh->has_vertex_colors())
386 mesh->release_vertex_colors();
387 if (!hadVTexCoords && !_opt.vertex_has_texcoord() && mesh->has_vertex_texcoords2D())
388 mesh->release_vertex_texcoords2D();
389 if (!hadFColors && !_opt.face_has_color() && mesh->has_face_colors())
390 mesh->release_face_colors();
391
392 // Switch to point mode if mesh does not contain one single face
393 if(mesh->n_faces() == 0)
395
397
398 return object->id();
399
400 } else {
401 emit log(LOGERR,"Error : Could not create new triangle mesh object.");
402 return -1;
403 }
404}
405
406//-----------------------------------------------------------------------------------------------------
407
410
411 int id = -1;
412 emit addEmptyObject(DATA_POLY_MESH, id);
413
414 PolyMeshObject* object(0);
415 if(PluginFunctions::getObject(id, object)) {
416
418 object->target(true);
419
420 object->setFromFileName(_filename);
421 object->setName(object->filename());
422
423 // Get mesh
424 PolyMesh* mesh = object->mesh();
425
426 bool hadVNormals = mesh->has_vertex_normals();
427 bool hadVColors = mesh->has_vertex_colors();
428 bool hadVTexCoords = mesh->has_vertex_texcoords2D();
429 bool hadFNormals = mesh->has_face_normals();
430 bool hadFColors = mesh->has_face_colors();
431
432 if(_opt.vertex_has_normal())
433 mesh->request_vertex_normals();
434 if(_opt.vertex_has_color())
435 mesh->request_vertex_colors();
436 if(_opt.vertex_has_texcoord())
437 mesh->request_vertex_texcoords2D();
438 if(_opt.face_has_normal())
439 mesh->request_face_normals();
440 if(_opt.face_has_color())
441 mesh->request_face_colors();
442
443 bool ok = OpenMesh::IO::read_mesh( *mesh , _filename.toStdString(), _opt);
444 if (!ok)
445 {
446 emit log(LOGERR, "Error while reading PLY file!");
447 emit deleteObject(id);
448 return -1;
449 }
450
451
452 //update normals if they aren't read
453 if (!_opt.vertex_has_normal() || !_opt.face_has_normal()) {
454
455
456 if (_opt.vertex_has_normal() ) {
457 // If we have vertex normals, we can use them to compute the face normals
458 emit log(LOGINFO,"Vertex normals loaded from file. Computing Face normals.");
459 mesh->update_face_normals();
460 std::cerr << "Update face normals" << std::endl;
461 } else {
462 // If we don't have any normals, we compute all of them
463 emit log(LOGINFO,"File did not contain normals. Computing automatically.");
464 mesh->update_normals();
465 }
466
467
468 }
469
470 //cleanup mesh if selected option could not be loaded
471 if (!hadVColors && !_opt.vertex_has_color() && mesh->has_vertex_colors())
472 mesh->release_vertex_colors();
473 if (!hadVTexCoords && !_opt.vertex_has_texcoord() && mesh->has_vertex_texcoords2D())
474 mesh->release_vertex_texcoords2D();
475 if (!hadFColors && !_opt.face_has_color() && mesh->has_face_colors())
476 mesh->release_face_colors();
477
478
479 // Switch to point mode if mesh does not contain one single face
480 if(mesh->n_faces() == 0)
482
484
485 return object->id();
486
487 } else {
488 emit log(LOGERR,"Error : Could not create new poly mesh object.");
489 return -1;
490 }
491
492 return id;
493}
494
495//-----------------------------------------------------------------------------------------------------
496
497bool FilePLYPlugin::saveObject(int _id, QString _filename)
498{
499 BaseObjectData* object;
500 if ( !PluginFunctions::getObject(_id,object) ) {
501 emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
502 return false;
503 }
504
505 object->setFromFileName(_filename);
506 object->setName(object->filename());
507
508
510 bool gui = OpenFlipper::Options::gui() && (saveBinary_ != 0) /*buttons initialized?*/;
511 bool binary = ((gui && saveBinary_->isChecked()) ||
512 OpenFlipperSettings().value("FilePLY/Save/Binary",false).toBool());
513
514 if (binary)
516
517 bool vNormals = ((gui && saveVertexNormal_->isChecked())) ||
518 (!gui && OpenFlipperSettings().value("FilePLY/Save/Normals",true).toBool());
519 bool vColors = ((gui && saveVertexColor_->isChecked())) ||
520 (!gui && OpenFlipperSettings().value("FilePLY/Save/VertexColor",true).toBool());
521 bool vTexCoords = ((gui && saveVertexTexCoord_->isChecked())) ||
522 (!gui && OpenFlipperSettings().value("FilePLY/Save/TexCoords",true).toBool());
523 bool fNormals = ((gui && saveFaceNormal_->isChecked())) ||
524 (!gui && OpenFlipperSettings().value("FilePLY/Save/FaceNormal",true).toBool());
525 bool fColors = ((gui && saveFaceColor_->isChecked())) ||
526 (!gui && OpenFlipperSettings().value("FilePLY/Save/FaceColor",true).toBool());
527
528
529 bool ok = false;
530
531 if ( object->dataType(DATA_POLY_MESH) ) {
532
533 PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject*>(object);
534 PolyMesh* mesh = polyObj->mesh();
535
536 if (vNormals && mesh->has_vertex_normals())
538 if (vColors && mesh->has_vertex_colors())
540 if (vTexCoords && mesh->has_vertex_texcoords2D())
542 if (fNormals && mesh->has_face_normals())
544 if (fColors && mesh->has_face_colors())
546
547 ok = OpenMesh::IO::write_mesh(*mesh, _filename.toStdString() ,opt);
548
549 } else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
550
551 TriMeshObject* triObj = dynamic_cast<TriMeshObject*>(object);
552 TriMesh* mesh = triObj->mesh();
553
554 if (vNormals && mesh->has_vertex_normals())
556 if (vColors && mesh->has_vertex_colors())
558 if (vTexCoords && mesh->has_vertex_texcoords2D())
560 if (fNormals && mesh->has_face_normals())
562 if (fColors && mesh->has_face_colors())
564
565 ok = OpenMesh::IO::write_mesh(*mesh, _filename.toStdString() ,opt);
566 }
567
568 if(!ok) {
569 emit log(LOGERR, tr("Unable to save ") + _filename);
570 return false;
571 }
572
573 emit log(LOGINFO, tr("Saved object to ") + _filename );
574 return true;
575}
576
577//-----------------------------------------------------------------------------------------------------
578
579QWidget* FilePLYPlugin::saveOptionsWidget(QString /*_currentFilter*/) {
580
581 if (saveOptions_ == 0){
582 //generate widget
583 saveOptions_ = new QWidget();
584 QVBoxLayout* layout = new QVBoxLayout();
585 layout->setAlignment(Qt::AlignTop);
586
587 saveBinary_ = new QCheckBox("Save Binary");
588 layout->addWidget(saveBinary_);
589
590 saveVertexNormal_ = new QCheckBox("Save Vertex Normals");
591 layout->addWidget(saveVertexNormal_);
592
593 saveVertexColor_ = new QCheckBox("Save Vertex Colors");
594 layout->addWidget(saveVertexColor_);
595
596 saveVertexTexCoord_ = new QCheckBox("Save Vertex TexCoords");
597 layout->addWidget(saveVertexTexCoord_);
598
599 saveFaceNormal_ = new QCheckBox("Save Face Normals");
600 layout->addWidget(saveFaceNormal_);
601
602 saveFaceColor_ = new QCheckBox("Save Face Colors");
603 layout->addWidget(saveFaceColor_);
604
605 savePrecisionLabel_ = new QLabel("Writer Precision");
606 layout->addWidget(savePrecisionLabel_);
607
608 savePrecision_ = new QSpinBox();
609 savePrecision_->setMinimum(1);
610 savePrecision_->setMaximum(12);
611 savePrecision_->setValue(6);
612 layout->addWidget(savePrecision_);
613
614 saveDefaultButton_ = new QPushButton("Make Default");
615 layout->addWidget(saveDefaultButton_);
616
617 saveOptions_->setLayout(layout);
618
619 connect(saveBinary_, SIGNAL(clicked(bool)), savePrecision_, SLOT(setDisabled(bool)));
620 connect(saveDefaultButton_, SIGNAL(clicked()), this, SLOT(slotSaveDefault()));
621
622 saveBinary_->setChecked( OpenFlipperSettings().value("FilePLY/Save/Binary",true).toBool() );
623 savePrecision_->setDisabled(true);
624 saveVertexNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Save/Normals",true).toBool() );
625 saveVertexColor_->setChecked( OpenFlipperSettings().value("FilePLY/Save/VertexColor",true).toBool() );
626 saveVertexTexCoord_->setChecked( OpenFlipperSettings().value("FilePLY/Save/TexCoords",true).toBool() );
627 saveFaceNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Save/FaceNormal",true).toBool() );
628 saveFaceColor_->setChecked( OpenFlipperSettings().value("FilePLY/Save/FaceColor",true).toBool() );
629 }
630
631 return saveOptions_;
632}
633
634//-----------------------------------------------------------------------------------------------------
635
636QWidget* FilePLYPlugin::loadOptionsWidget(QString /*_currentFilter*/) {
637
638 if (loadOptions_ == 0){
639 //generate widget
640 loadOptions_ = new QWidget();
641 QVBoxLayout* layout = new QVBoxLayout();
642 layout->setAlignment(Qt::AlignTop);
643
644 QLabel* label = new QLabel(tr("If PolyMesh is a Triangle Mesh:"));
645
646 layout->addWidget(label);
647
648 triMeshHandling_ = new QComboBox();
649 triMeshHandling_->addItem( tr("Auto-Detect") );
650 triMeshHandling_->addItem( tr("Ask") );
651 triMeshHandling_->addItem( tr("Always open as PolyMesh") );
652 triMeshHandling_->addItem( tr("Always open as TriangleMesh") );
653
654 layout->addWidget(triMeshHandling_);
655
656 loadVertexNormal_ = new QCheckBox("Load Vertex Normals");
657 layout->addWidget(loadVertexNormal_);
658
659 loadVertexColor_ = new QCheckBox("Load Vertex Colors");
660 layout->addWidget(loadVertexColor_);
661
662 loadVertexTexCoord_ = new QCheckBox("Load Vertex TexCoords");
663 layout->addWidget(loadVertexTexCoord_);
664
665 loadFaceNormal_ = new QCheckBox("Load Face Normals");
666 layout->addWidget(loadFaceNormal_);
667
668 loadFaceColor_ = new QCheckBox("Load Face Colors");
669 layout->addWidget(loadFaceColor_);
670
671 loadDefaultButton_ = new QPushButton("Make Default");
672 layout->addWidget(loadDefaultButton_);
673
674 loadOptions_->setLayout(layout);
675
676 connect(loadDefaultButton_, SIGNAL(clicked()), this, SLOT(slotLoadDefault()));
677
678
679 triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("FilePLY/Load/TriMeshHandling",TYPEAUTODETECT).toInt() );
680
681 loadVertexNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Load/Normals",true).toBool() );
682 loadVertexColor_->setChecked( OpenFlipperSettings().value("FilePLY/Load/VertexColor",true).toBool() );
683 loadVertexTexCoord_->setChecked( OpenFlipperSettings().value("FilePLY/Load/TexCoords",true).toBool() );
684 loadFaceNormal_->setChecked( OpenFlipperSettings().value("FilePLY/Load/FaceNormal",true).toBool() );
685 loadFaceColor_->setChecked( OpenFlipperSettings().value("FilePLY/Load/FaceColor",true).toBool() );
686 }
687
688 return loadOptions_;
689}
690
692
693 OpenFlipperSettings().setValue( "FilePLY/Load/Normals", loadVertexNormal_->isChecked() );
694 OpenFlipperSettings().setValue( "FilePLY/Load/VertexColor", loadVertexColor_->isChecked() );
695 OpenFlipperSettings().setValue( "FilePLY/Load/TexCoords", loadVertexTexCoord_->isChecked() );
696 OpenFlipperSettings().setValue( "FilePLY/Load/FaceNormal", loadFaceNormal_->isChecked() );
697 OpenFlipperSettings().setValue( "FilePLY/Load/FaceColor", loadFaceColor_->isChecked() );
698
699 OpenFlipperSettings().setValue( "FilePLY/Load/TriMeshHandling", triMeshHandling_->currentIndex() );
700
701 OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
702}
703
704
706
707 OpenFlipperSettings().setValue( "FilePLY/Save/Binary", saveBinary_->isChecked() );
708 OpenFlipperSettings().setValue( "FilePLY/Save/TexCoords", saveVertexTexCoord_->isChecked() );
709 OpenFlipperSettings().setValue( "FilePLY/Save/Normals", saveVertexNormal_->isChecked() );
710 OpenFlipperSettings().setValue( "FilePLY/Save/VertexColor", saveVertexColor_->isChecked() );
711 OpenFlipperSettings().setValue( "FilePLY/Save/FaceNormal", saveFaceNormal_->isChecked() );
712 OpenFlipperSettings().setValue( "FilePLY/Save/FaceColor", saveFaceColor_->isChecked() );
713}
714
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
@ LOGERR
@ LOGINFO
#define DATA_POLY_MESH
Definition: PolyMesh.hh:59
#define DATA_TRIANGLE_MESH
Definition: TriangleMesh.hh:60
QString filename() const
return the filename of the object
Definition: BaseObject.cc:704
bool dataType(DataType _type) const
Definition: BaseObject.cc:219
int id() const
Definition: BaseObject.cc:188
Predefined datatypes.
Definition: DataTypes.hh:83
QString getLoadFilters()
Definition: FilePLY.cc:85
QWidget * loadOptionsWidget(QString)
Definition: FilePLY.cc:636
QString getSaveFilters()
Definition: FilePLY.cc:91
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition: FilePLY.cc:301
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition: FilePLY.cc:691
int loadPolyMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Always loads mesh as polymesh.
Definition: FilePLY.cc:409
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition: FilePLY.cc:168
FilePLYPlugin()
Constructor.
Definition: FilePLY.cc:56
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FilePLY.cc:97
void initializePlugin()
Initialize Plugin.
Definition: FilePLY.cc:80
QWidget * saveOptionsWidget(QString)
Definition: FilePLY.cc:579
int loadTriMeshObject(QString _filename, OpenMesh::IO::Options &_opt)
Loads a triangle mesh.
Definition: FilePLY.cc:324
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition: FilePLY.cc:705
MeshT * mesh()
return a pointer to the mesh
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
Set options for reader/writer modules.
Definition: Options.hh:92
@ FaceNormal
Has (r) / store (w) face normals.
Definition: Options.hh:109
@ FaceColor
Has (r) / store (w) face colors.
Definition: Options.hh:110
@ Binary
Set binary mode for r/w.
Definition: Options.hh:101
@ VertexNormal
Has (r) / store (w) vertex normals.
Definition: Options.hh:105
@ VertexTexCoord
Has (r) / store (w) texture coordinates.
Definition: Options.hh:107
@ VertexColor
Has (r) / store (w) vertex colors.
Definition: Options.hh:106
@ Custom
Has (r) / store (w) custom properties marked persistent (currently PLY only supports reading and only...
Definition: Options.hh:114
void update_face_normals()
Update normal vectors for all faces.
void update_normals()
Compute normals for all primitives.
Type for a Meshobject containing a poly mesh.
Definition: PolyMesh.hh:65
Type for a MeshObject containing a triangle mesh.
Definition: TriangleMesh.hh:67
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
DrawMode POINTS
draw unlighted points using the default base color
Definition: DrawModes.cc:73
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:190
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Definition: MeshIO.hh:95
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
int objectCount()
Get the number of available objects.
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .