Developer Documentation
Loading...
Searching...
No Matches
FileOM.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#include <ACG/GL/GLState.hh>
44
47
48#include <OpenMesh/Core/IO/IOManager.hh>
49
50 #include <QtWidgets>
51
52#include "FileOM.hh"
53
54
55// Defines for the type handling drop down box
56#define TYPEAUTODETECT 0
57#define TYPEASK 1
58#define TYPEPOLY 2
59#define TYPETRIANGLE 3
60
63 loadOptions_(nullptr),
64 saveOptions_(nullptr),
65 saveBinary_(nullptr),
66 saveVertexNormal_(nullptr),
67 saveVertexTexCoord_(nullptr),
68 saveVertexColor_(nullptr),
69 saveFaceColor_(nullptr),
70 saveFaceNormal_(nullptr),
71 saveFaceTexCoord_(nullptr),
72 saveCustomProperties_(nullptr),
73 saveStatus_(nullptr),
74 saveDefaultButton_(nullptr),
75 triMeshHandling_(nullptr),
76 loadVertexNormal_(nullptr),
77 loadVertexTexCoord_(nullptr),
78 loadVertexColor_(nullptr),
79 loadFaceColor_(nullptr),
80 loadFaceNormal_(nullptr),
81 loadFaceTexCoord_(nullptr),
82 loadCustomProperties_(nullptr),
83 loadStatus_(nullptr),
84 loadDefaultButton_(nullptr),
85 trimeshOptions_(0)
86
87{
88}
89
90//-----------------------------------------------------------------------------------------------------
91
94
95//-----------------------------------------------------------------------------------------------------
96
98 return QString( tr("OpenMesh Format files ( *.om )") );
99};
100
101//-----------------------------------------------------------------------------------------------------
102
104 return QString( tr("OpenMesh Format files ( *.om )") );
105};
106
107//-----------------------------------------------------------------------------------------------------
108
113
114//-----------------------------------------------------------------------------------------------------
115
116int FileOMPlugin::loadObject(QString _filename) {
117
118 int triMeshControl = TYPEAUTODETECT; // 0 == Auto-Detect
119
120 if ( OpenFlipper::Options::gui() ){
121 if ( triMeshHandling_ != 0 ){
122 triMeshControl = triMeshHandling_->currentIndex();
123 } else {
124 triMeshControl = TYPEAUTODETECT;
125 }
126 }
127
128 int objectId = -1;
129
130 if(triMeshControl == TYPEAUTODETECT) {
131 // If Auto-Detect is selected (triMeshControl == 0)
132 objectId = loadPolyMeshObject(_filename);
133
134 PolyMeshObject *object = 0;
135 if(!PluginFunctions::getObject(objectId, object))
136 return -1;
137
138 for (auto f_it : object->mesh()->faces()) {
139
140 // Count number of vertices for the current face
141 uint count = 0;
142 for (auto fv_it : f_it.vertices())
143 ++count;
144
145 // Check if it is a triangle. If not, this is really a poly mesh
146 if ( count != 3 ) {
147
148 PolyMeshObject* object(0);
149 if(PluginFunctions::getObject( objectId, object )) {
150
151 emit updatedObject(objectId, UPDATE_ALL);
152 emit openedFile( objectId );
153 }
154
155 return objectId;
156 }
157 }
158
159 } else if (triMeshControl == TYPEASK ) {
160
161 // If Ask is selected -> show dialog
162 objectId = loadPolyMeshObject(_filename);
163
164 bool triMesh = true;
165
166 PolyMeshObject *object = 0;
167 if(!PluginFunctions::getObject(objectId, object))
168 return -1;
169
170 for (auto f_it : object->mesh()->faces()) {
171
172 // Count number of vertices for the current face
173 uint count = 0;
174 for (auto fv_it : f_it.vertices())
175 ++count;
176
177 // Check if it is a triangle. If not, this is really a poly mesh
178 if ( count != 3 ) {
179 triMesh = false;
180 break;
181 }
182
183 if(triMesh == false) break;
184 }
185
186 // Note: If in non-gui mode, we will never enter this case branch
187
188 QMetaObject::invokeMethod(this,"handleTrimeshDialog",Qt::BlockingQueuedConnection);
189 if ((trimeshOptions_ == TYPEPOLY) ||
190 (trimeshOptions_ == TYPEASK && !triMesh)) {
191
192 PolyMeshObject* object(0);
193 if(PluginFunctions::getObject( objectId, object )) {
194
195 emit updatedObject(objectId, UPDATE_ALL);
196 emit openedFile( objectId );
197 }
198 return objectId;
199 }
200
201 } else if (triMeshControl == TYPEPOLY) {
202 // If always open as PolyMesh is selected
203
204 objectId = loadPolyMeshObject(_filename);
205
206 PolyMeshObject* object(0);
207 if(PluginFunctions::getObject( objectId, object )) {
208
209 emit updatedObject(objectId, UPDATE_ALL);
210 emit openedFile( objectId );
211 }
212
213 return objectId;
214 } else {
215 // If always open as TriMesh is selected
216
217 objectId = loadTriMeshObject(_filename);
218
219 TriMeshObject* object(0);
220 if(PluginFunctions::getObject( objectId, object )) {
221 emit updatedObject(objectId, UPDATE_ALL);
222 emit openedFile( objectId );
223 }
224
225 return objectId;
226 }
227
228 // Load object as triangle mesh
229 if(objectId != -1) emit deleteObject(objectId);
230
231 objectId = loadTriMeshObject(_filename);
232
233 TriMeshObject* object(0);
234 if(PluginFunctions::getObject( objectId, object )) {
235
236 emit updatedObject(objectId, UPDATE_ALL);
237 emit openedFile( objectId );
238 }
239
240 return objectId;
241};
242
244{
245 QMessageBox msgBox;
246 QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
247 QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
248 QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
249 msgBox.setWindowTitle( tr("Mesh types in file") );
250 msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
251 msgBox.setDefaultButton( detectButton );
252 msgBox.exec();
253
254
255 if (msgBox.clickedButton() == triButton)
256 trimeshOptions_ = TYPETRIANGLE ;
257 else if (msgBox.clickedButton() == polyButton)
258 trimeshOptions_ = TYPEPOLY ;
259 else
260 trimeshOptions_ = TYPEASK;
261}
262
263//-----------------------------------------------------------------------------------------------------
264
266int FileOMPlugin::loadTriMeshObject(QString _filename){
267
268 int id = -1;
269 emit addEmptyObject(DATA_TRIANGLE_MESH, id);
270
271 TriMeshObject* object(nullptr);
272 if(PluginFunctions::getObject( id, object)) {
273
274 if ( PluginFunctions::objectCount() == 1 )
275 object->target(true);
276
277 object->setFromFileName(_filename);
278 object->setName(object->filename());
279
280 std::string filename = std::string( _filename.toUtf8() );
281
282 //set options
284
285 if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() &&
286 !OpenFlipper::Options::loadingRecentFile() && loadOptions_ != nullptr){
287
288 if (loadVertexNormal_->isChecked())
290
291 if (loadVertexTexCoord_->isChecked())
293
294 if (loadVertexColor_->isChecked())
296
297 if (loadFaceColor_->isChecked())
299
300 if (loadFaceNormal_->isChecked())
302
303 if (loadFaceTexCoord_->isChecked())
305
306 if (loadCustomProperties_->isChecked())
308
309 if (loadStatus_->isChecked())
311
312 } else {
313
314 // Load with stored default
315 opt = getDefaultOptions();
316 }
317
319 object->mesh()->request_vertex_texcoords2D();
320 object->mesh()->request_halfedge_texcoords2D();
321 object->mesh()->request_face_texture_index();
322
323 // load file
324 bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
325 if (!ok)
326 {
327 std::cerr << "Plugin FileOM : Read error for Triangle Mesh\n";
328 emit deleteObject( object->id() );
329 return -1;
330 }
331
332 object->mesh()->update_normals();
333
334 backupTextureCoordinates(*(object->mesh()));
335
336 return object->id();
337
338 } else {
339 emit log(LOGERR,"Error : Could not create new triangle mesh object.");
340 return -1;
341 }
342}
343
344//-----------------------------------------------------------------------------------------------------
345
347int FileOMPlugin::loadPolyMeshObject(QString _filename){
348
349 int id = -1;
350 emit addEmptyObject(DATA_POLY_MESH, id);
351
352 PolyMeshObject* object(0);
353 if(PluginFunctions::getObject( id, object)) {
354
356 object->target(true);
357
358 object->setFromFileName(_filename);
359 object->setName(object->filename());
360
361 std::string filename = std::string( _filename.toUtf8() );
362
363 //set options
365
366 if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() &&
367 !OpenFlipper::Options::loadingRecentFile() && loadOptions_ != 0){
368
369 if (loadVertexNormal_->isChecked())
371
372 if (loadVertexTexCoord_->isChecked())
374
375 if (loadVertexColor_->isChecked())
377
378 if (loadFaceColor_->isChecked())
380
381 if (loadFaceNormal_->isChecked())
383
384 if (loadFaceTexCoord_->isChecked())
386
387 if (loadCustomProperties_->isChecked())
389
390 if (loadStatus_->isChecked())
392
393 } else {
394
395 // Load with stored default
396 opt = getDefaultOptions();
397
398 }
399
401 object->mesh()->request_vertex_texcoords2D();
402 object->mesh()->request_halfedge_texcoords2D();
403 object->mesh()->request_face_texture_index();
404
405 // load file
406 bool ok = OpenMesh::IO::read_mesh( (*object->mesh()) , filename, opt );
407 if (!ok)
408 {
409 std::cerr << "Plugin FileOM : Read error for Poly Mesh\n";
410 emit deleteObject( object->id() );
411 return -1;
412
413 }
414
415
417 object->mesh()->release_vertex_texcoords2D();
418 }
419
420
421 if ( ! (opt & OpenMesh::IO::Options::FaceTexCoord) ) {
422 object->mesh()->release_halfedge_texcoords2D();
423 }
424
425
426 object->mesh()->update_normals();
427
428 backupTextureCoordinates(*(object->mesh()));
429
430 return object->id();
431
432 } else {
433 emit log(LOGERR,"Error : Could not create new poly mesh object.");
434 return -1;
435 }
436}
437
438//-----------------------------------------------------------------------------------------------------
439
440template <class MeshT>
442
443 // Create a backup of the original per Vertex texture Coordinates
444 if (_mesh.has_vertex_texcoords2D()) {
445
447 if (!_mesh.get_property_handle(oldVertexCoords, "Original Per Vertex Texture Coords"))
448 _mesh.add_property(oldVertexCoords, "Original Per Vertex Texture Coords");
449
450 for (auto v_it : _mesh.vertices())
451 _mesh.property(oldVertexCoords, v_it) = _mesh.texcoord2D(v_it);
452
453 }
454
455 // Create a backup of the original per Face texture Coordinates
456 if (_mesh.has_halfedge_texcoords2D()) {
457
459 if (!_mesh.get_property_handle(oldHalfedgeCoords,"Original Per Face Texture Coords"))
460 _mesh.add_property(oldHalfedgeCoords,"Original Per Face Texture Coords");
461
462 for (auto he_it : _mesh.halfedges())
463 _mesh.property(oldHalfedgeCoords, he_it) = _mesh.texcoord2D(he_it);
464
465 }
466}
467
468//-----------------------------------------------------------------------------------------------------
469
470bool FileOMPlugin::saveObject(int _id, QString _filename)
471{
472 BaseObjectData* object;
473 if ( !PluginFunctions::getObject(_id,object) ) {
474 emit log(LOGERR, tr("saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
475 return false;
476 }
477
478 std::string filename = std::string( _filename.toUtf8() );
479
480 if ( object->dataType( DATA_POLY_MESH ) ) {
481
482 PolyMeshObject* polObj = dynamic_cast<PolyMeshObject* >( object );
483
485
486 if ( !OpenFlipper::Options::savingSettings() && saveOptions_ != 0){
487
488 PolyMesh* mesh = polObj->mesh();
489
490 if (saveBinary_->isChecked())
492
493 if (saveVertexNormal_->isChecked() && mesh->has_vertex_normals())
495
496 if (saveVertexTexCoord_->isChecked() && (mesh->has_vertex_texcoords1D() || mesh->has_vertex_texcoords2D() || mesh->has_vertex_texcoords3D())) {
497 std::cerr << "File OM texture write" << std::endl;
499 }
500
501 if (saveVertexColor_->isChecked() && mesh->has_vertex_colors())
503
504 if (saveFaceColor_->isChecked() && mesh->has_face_colors())
506
507 if (saveFaceNormal_->isChecked() && mesh->has_face_normals())
509
510 if (saveFaceTexCoord_->isChecked() && (mesh->has_halfedge_texcoords1D() || mesh->has_halfedge_texcoords2D() || mesh->has_halfedge_texcoords3D())) {
511 std::cerr << "File OM texture write" << std::endl;
513 }
514
515 if (saveCustomProperties_->isChecked())
517
518 if (saveStatus_->isChecked() && (mesh->has_face_status() || mesh->has_edge_status() || mesh->has_halfedge_status() || mesh->has_vertex_status()))
520
521 }
522
523 object->setFromFileName(_filename);
524 object->setName(object->filename());
525
526 PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject* >( object );
527
528 if (OpenMesh::IO::write_mesh(*polyObj->mesh(), filename.c_str(),opt) ){
529 emit log(LOGINFO, tr("Saved object to ") + _filename );
530 return true;
531 }else{
532 emit log(LOGERR, tr("Unable to save ") + _filename);
533 return false;
534 }
535 } else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
536
537 object->setFromFileName(_filename);
538 object->setName(object->filename());
539
540 TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
541
543
544 if ( !OpenFlipper::Options::savingSettings() && saveOptions_ != 0){
545
546 TriMesh* mesh = triObj->mesh();
547
548 if (saveBinary_->isChecked())
550
551 if (saveVertexNormal_->isChecked() && mesh->has_vertex_normals())
553
554 if (saveVertexTexCoord_->isChecked() && (mesh->has_vertex_texcoords1D() || mesh->has_vertex_texcoords2D() || mesh->has_vertex_texcoords3D())) {
555 std::cerr << "File OM texture write" << std::endl;
557 }
558
559 if (saveVertexColor_->isChecked() && mesh->has_vertex_colors())
561
562 if (saveFaceColor_->isChecked() && mesh->has_face_colors())
564
565 if (saveFaceNormal_->isChecked() && mesh->has_face_normals())
567
568 if (saveFaceTexCoord_->isChecked() && (mesh->has_halfedge_texcoords1D() || mesh->has_halfedge_texcoords2D() || mesh->has_halfedge_texcoords3D())) {
569 std::cerr << "File OM texture write" << std::endl;
571 }
572
573 if (saveCustomProperties_->isChecked())
575
576 if (saveStatus_->isChecked() && (mesh->has_face_status() || mesh->has_edge_status() || mesh->has_halfedge_status() || mesh->has_vertex_status()))
578
579 }
580
581 if (OpenMesh::IO::write_mesh(*triObj->mesh(), filename.c_str(),opt) ) {
582 emit log(LOGINFO, tr("Saved object to ") + _filename );
583 return true;
584 } else {
585 emit log(LOGERR, tr("Unable to save ") + _filename );
586 return false;
587 }
588 } else {
589 emit log(LOGERR, tr("Unable to save (object is not a compatible mesh type)"));
590 return false;
591 }
592}
593
594//-----------------------------------------------------------------------------------------------------
595
596QWidget* FileOMPlugin::saveOptionsWidget(QString /*_currentFilter*/) {
597
598 if (saveOptions_ == 0){
599 //generate widget
600 saveOptions_ = new QWidget();
601 QVBoxLayout* layout = new QVBoxLayout();
602 layout->setAlignment(Qt::AlignTop);
603
604 saveBinary_ = new QCheckBox("Save Binary");
605 layout->addWidget(saveBinary_);
606
607 saveVertexNormal_ = new QCheckBox("Save Vertex Normals");
608 layout->addWidget(saveVertexNormal_);
609
610 saveVertexTexCoord_ = new QCheckBox("Save Vertex TexCoords");
611 layout->addWidget(saveVertexTexCoord_);
612
613 saveVertexColor_ = new QCheckBox("Save Vertex Colors");
614 layout->addWidget(saveVertexColor_);
615
616 saveFaceColor_ = new QCheckBox("Save Face Colors");
617 layout->addWidget(saveFaceColor_);
618
619 saveFaceNormal_ = new QCheckBox("Save Face Normals");
620 layout->addWidget(saveFaceNormal_);
621
622 saveFaceTexCoord_ = new QCheckBox("Save Face TexCoords");
623 layout->addWidget(saveFaceTexCoord_);
624
625 saveCustomProperties_ = new QCheckBox("Save Custom Properties");
626 layout->addWidget(saveCustomProperties_);
627
628 saveStatus_ = new QCheckBox("Save Status");
629 layout->addWidget(saveStatus_);
630
631 saveDefaultButton_ = new QPushButton("Make Default");
632 layout->addWidget(saveDefaultButton_);
633
634 saveOptions_->setLayout(layout);
635
636 connect(saveDefaultButton_, SIGNAL(clicked()), this, SLOT(slotSaveDefault()));
637
638 saveBinary_->setChecked( OpenFlipperSettings().value("FileOM/Save/Binary",true).toBool() );
639 saveVertexNormal_->setChecked( OpenFlipperSettings().value("FileOM/Save/Normals",true).toBool() );
640 saveVertexTexCoord_->setChecked( OpenFlipperSettings().value("FileOM/Save/TexCoords",true).toBool() );
641 saveVertexColor_->setChecked( OpenFlipperSettings().value("FileOM/Save/VertexColor",true).toBool() );
642 saveFaceColor_->setChecked( OpenFlipperSettings().value("FileOM/Save/FaceColor",true).toBool() );
643 saveFaceNormal_->setChecked( OpenFlipperSettings().value("FileOM/Save/FaceNormal",true).toBool() );
644 saveFaceTexCoord_->setChecked( OpenFlipperSettings().value("FileOM/Save/FaceTexCoords",true).toBool() );
645 saveCustomProperties_->setChecked( OpenFlipperSettings().value("FileOM/Save/CustomProperties",true).toBool() );
646 saveStatus_->setChecked( OpenFlipperSettings().value("FileOM/Save/Status",true).toBool() );
647
648 }
649
650 return saveOptions_;
651}
652
653//-----------------------------------------------------------------------------------------------------
654
655QWidget* FileOMPlugin::loadOptionsWidget(QString /*_currentFilter*/) {
656
657 if (loadOptions_ == 0){
658 //generate widget
659 loadOptions_ = new QWidget();
660 QVBoxLayout* layout = new QVBoxLayout();
661 layout->setAlignment(Qt::AlignTop);
662
663 QLabel* label = new QLabel(tr("If PolyMesh is a Triangle Mesh:"));
664
665 layout->addWidget(label);
666
667 triMeshHandling_ = new QComboBox();
668 triMeshHandling_->addItem( tr("Auto-Detect") );
669 triMeshHandling_->addItem( tr("Ask") );
670 triMeshHandling_->addItem( tr("Always open as PolyMesh") );
671 triMeshHandling_->addItem( tr("Always open as TriangleMesh") );
672
673 layout->addWidget(triMeshHandling_);
674
675 loadVertexNormal_ = new QCheckBox("Load Vertex Normals");
676 layout->addWidget(loadVertexNormal_);
677
678 loadVertexTexCoord_ = new QCheckBox("Load Vertex TexCoords");
679 layout->addWidget(loadVertexTexCoord_);
680
681 loadVertexColor_ = new QCheckBox("Load Vertex Colors");
682 layout->addWidget(loadVertexColor_);
683
684 loadFaceColor_ = new QCheckBox("Load Face Colors");
685 layout->addWidget(loadFaceColor_);
686
687 loadFaceNormal_ = new QCheckBox("Load Face Normals");
688 layout->addWidget(loadFaceNormal_);
689
690 loadFaceTexCoord_ = new QCheckBox("Load Face TexCoords");
691 layout->addWidget(loadFaceTexCoord_);
692
693 loadCustomProperties_ = new QCheckBox("Load Custom Properties");
694 layout->addWidget(loadCustomProperties_);
695
696 loadStatus_ = new QCheckBox("Load Status");
697 layout->addWidget(loadStatus_);
698
699 loadDefaultButton_ = new QPushButton("Make Default");
700 layout->addWidget(loadDefaultButton_);
701
702 loadOptions_->setLayout(layout);
703
704 connect(loadDefaultButton_, SIGNAL(clicked()), this, SLOT(slotLoadDefault()));
705
706
707 triMeshHandling_->setCurrentIndex(OpenFlipperSettings().value("FileOM/Load/TriMeshHandling",TYPEAUTODETECT).toInt() );
708
709 loadVertexNormal_->setChecked( OpenFlipperSettings().value("FileOM/Load/Normals",true).toBool() );
710 loadVertexTexCoord_->setChecked( OpenFlipperSettings().value("FileOM/Load/TexCoords",true).toBool() );
711 loadVertexColor_->setChecked( OpenFlipperSettings().value("FileOM/Load/VertexColor",true).toBool() );
712 loadFaceColor_->setChecked( OpenFlipperSettings().value("FileOM/Load/FaceColor",true).toBool() );
713 loadFaceNormal_->setChecked( OpenFlipperSettings().value("FileOM/Load/FaceNormal",true).toBool() );
714 loadFaceTexCoord_->setChecked( OpenFlipperSettings().value("FileOM/Load/FaceTexCoords",true).toBool() );
715 loadCustomProperties_->setChecked( OpenFlipperSettings().value("FileOM/Load/CustomProperties",true).toBool() );
716 loadStatus_->setChecked( OpenFlipperSettings().value("FileOM/Load/Status",true).toBool() );
717
718 }
719
720 return loadOptions_;
721}
722
723OpenMesh::IO::Options FileOMPlugin::getDefaultOptions()
724{
726 if (OpenFlipperSettings().value( "FileOM/Load/Normals", true).toBool())
728 if (OpenFlipperSettings().value( "FileOM/Load/TexCoords", true).toBool())
730 if (OpenFlipperSettings().value( "FileOM/Load/VertexColor", true).toBool())
732 if (OpenFlipperSettings().value( "FileOM/Load/FaceColor", true).toBool())
734 if (OpenFlipperSettings().value( "FileOM/Load/FaceNormal", true).toBool())
736 if (OpenFlipperSettings().value( "FileOM/Load/FaceTexCoords", true).toBool())
738 if (OpenFlipperSettings().value( "FileOM/Load/CustomProperties", true).toBool())
740 if (OpenFlipperSettings().value( "FileOM/Load/Status", true).toBool())
742
743 return opts;
744}
745
747
748 OpenFlipperSettings().setValue( "FileOM/Load/Normals", loadVertexNormal_->isChecked() );
749 OpenFlipperSettings().setValue( "FileOM/Load/TexCoords", loadVertexTexCoord_->isChecked() );
750 OpenFlipperSettings().setValue( "FileOM/Load/VertexColor", loadVertexColor_->isChecked() );
751 OpenFlipperSettings().setValue( "FileOM/Load/FaceColor", loadFaceColor_->isChecked() );
752 OpenFlipperSettings().setValue( "FileOM/Load/FaceNormal", loadFaceNormal_->isChecked() );
753 OpenFlipperSettings().setValue( "FileOM/Load/FaceTexCoords", loadFaceTexCoord_->isChecked() );
754 OpenFlipperSettings().setValue( "FileOM/Load/CustomProperties", loadCustomProperties_->isChecked() );
755 OpenFlipperSettings().setValue( "FileOM/Load/Status", loadStatus_->isChecked() );
756
757 OpenFlipperSettings().setValue( "FileOM/Load/TriMeshHandling", triMeshHandling_->currentIndex() );
758
759 OpenFlipperSettings().setValue( "Core/File/UseLoadDefaults", true );
760}
761
762
764
765 OpenFlipperSettings().setValue( "FileOM/Save/Binary", saveBinary_->isChecked() );
766 OpenFlipperSettings().setValue( "FileOM/Save/Normals", saveVertexNormal_->isChecked() );
767 OpenFlipperSettings().setValue( "FileOM/Save/TexCoords", saveVertexTexCoord_->isChecked() );
768 OpenFlipperSettings().setValue( "FileOM/Save/VertexColor", saveVertexColor_->isChecked() );
769 OpenFlipperSettings().setValue( "FileOM/Save/FaceColor", saveFaceColor_->isChecked() );
770 OpenFlipperSettings().setValue( "FileOM/Save/FaceNormal", saveFaceNormal_->isChecked() );
771 OpenFlipperSettings().setValue( "FileOM/Save/FaceTexCoords", saveFaceTexCoord_->isChecked() );
772 OpenFlipperSettings().setValue( "FileOM/Save/CustomProperties", saveCustomProperties_->isChecked() );
773 OpenFlipperSettings().setValue( "FileOM/Save/Status", saveStatus_->isChecked() );
774}
775
776
@ LOGERR
@ LOGINFO
#define DATA_POLY_MESH
Definition PolyMesh.hh:59
#define DATA_TRIANGLE_MESH
QString filename() const
return the filename of the object
bool dataType(DataType _type) const
int id() const
Predefined datatypes.
Definition DataTypes.hh:83
QWidget * saveOptionsWidget(QString)
Definition FileOM.cc:596
FileOMPlugin()
Constructor.
Definition FileOM.cc:62
int loadPolyMeshObject(QString _filename)
Always loads mesh as polymesh.
Definition FileOM.cc:347
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
Definition FileOM.cc:763
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Definition FileOM.cc:116
int loadTriMeshObject(QString _filename)
Loads a triangle mesh.
Definition FileOM.cc:266
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
Definition FileOM.cc:243
void backupTextureCoordinates(MeshT &_mesh)
creates a backup of the original per vertex/face texture coordinates
Definition FileOM.cc:441
QString getSaveFilters()
Definition FileOM.cc:103
QString getLoadFilters()
Definition FileOM.cc:97
void initializePlugin()
Initialize Plugin.
Definition FileOM.cc:92
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
Definition FileOM.cc:746
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition FileOM.cc:109
QWidget * loadOptionsWidget(QString)
Definition FileOM.cc:655
MeshT * mesh()
return a pointer to the mesh
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
@ FaceTexCoord
Has (r) / store (w) face texture coordinates.
Definition Options.hh:111
@ Binary
Set binary mode for r/w.
Definition Options.hh:101
@ Default
By default write persistent custom properties.
Definition Options.hh:117
@ Status
Has (r) / store (w) status properties.
Definition Options.hh:115
@ 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
Type for a Meshobject containing a poly mesh.
Definition PolyMesh.hh:65
Type for a MeshObject containing a triangle mesh.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
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.