52 #if QT_VERSION >= 0x050000 58 #include <OpenFlipper/Utils/Memory/RAMInfo.hh> 61 #define TYPEAUTODETECT 0 64 #define TYPETRIANGLE 3 66 using namespace Utils;
81 savePrecisionLabel_(0),
83 saveDefaultButton_(0),
90 loadCheckManifold_(0),
91 loadDefaultButton_(0),
94 forceTriangleMesh_(false),
95 forcePolyMesh_(false),
96 readColorComp_(false),
107 userReadOptions_ |= OFFImporter::VERTEXCOLOR;
109 userReadOptions_ |= OFFImporter::FACECOLOR;
111 userReadOptions_ |= OFFImporter::COLORALPHA;
113 userReadOptions_ |= OFFImporter::VERTEXNORMAL;
115 userReadOptions_ |= OFFImporter::VERTEXTEXCOORDS;
118 userWriteOptions_ |= OFFImporter::BINARY;
120 userWriteOptions_ |= OFFImporter::VERTEXCOLOR;
122 userWriteOptions_ |= OFFImporter::FACECOLOR;
124 userWriteOptions_ |= OFFImporter::COLORALPHA;
126 userWriteOptions_ |= OFFImporter::VERTEXNORMAL;
128 userWriteOptions_ |= OFFImporter::VERTEXTEXCOORDS;
135 return QString( tr(
"Object File Format files ( *.off )") );
141 return QString( tr(
"Object File Format files ( *.off )") );
153 void FileOFFPlugin::trimString( std::string& _string) {
156 size_t start = _string.find_first_not_of(
" \t\r\n");
157 size_t end = _string.find_last_not_of(
" \t\r\n");
159 if(( std::string::npos == start ) || ( std::string::npos == end))
162 _string = _string.substr( start, end-start+1 );
173 std::getline(ifs,_string);
179 if ( _string.size() != 0 ) {
182 if ( _string[0] !=
'#') {
187 if ( !_skipEmptyLines )
192 std::cerr <<
"End of file reached while searching for input!" << std::endl;
209 if( OpenFlipper::Options::nogui() )
213 if(loadVertexColor_) {
214 if(loadVertexColor_->isChecked()) userReadOptions_ |= OFFImporter::VERTEXCOLOR;
215 else {
if(userReadOptions_ & OFFImporter::VERTEXCOLOR) userReadOptions_ -= OFFImporter::VERTEXCOLOR; }
218 if(loadFaceColor_->isChecked()) userReadOptions_ |= OFFImporter::FACECOLOR;
219 else {
if(userReadOptions_ & OFFImporter::FACECOLOR) userReadOptions_ -= OFFImporter::FACECOLOR; }
222 if(loadAlpha_->isChecked()) userReadOptions_ |= OFFImporter::COLORALPHA;
223 else {
if(userReadOptions_ & OFFImporter::COLORALPHA) userReadOptions_ -= OFFImporter::COLORALPHA; }
226 if(loadNormals_->isChecked()) userReadOptions_ |= OFFImporter::VERTEXNORMAL;
227 else {
if(userReadOptions_ & OFFImporter::VERTEXNORMAL) userReadOptions_ -= OFFImporter::VERTEXNORMAL; }
230 if(loadTexCoords_->isChecked()) userReadOptions_ |= OFFImporter::VERTEXTEXCOORDS;
231 else {
if(userReadOptions_ & OFFImporter::VERTEXTEXCOORDS) userReadOptions_ -= OFFImporter::VERTEXTEXCOORDS; }
236 if(saveBinary_->isChecked()) userWriteOptions_ |= OFFImporter::BINARY;
237 else {
if(userWriteOptions_ & OFFImporter::BINARY) userWriteOptions_ -= OFFImporter::BINARY; }
239 if(saveVertexColor_) {
240 if(saveVertexColor_->isChecked()) userWriteOptions_ |= OFFImporter::VERTEXCOLOR;
241 else {
if(userWriteOptions_ & OFFImporter::VERTEXCOLOR) userWriteOptions_ -= OFFImporter::VERTEXCOLOR; }
244 if(saveFaceColor_->isChecked()) userWriteOptions_ |= OFFImporter::FACECOLOR;
245 else {
if(userWriteOptions_ & OFFImporter::FACECOLOR) userWriteOptions_ -= OFFImporter::FACECOLOR; }
248 if(saveAlpha_->isChecked()) userWriteOptions_ |= OFFImporter::COLORALPHA;
249 else {
if(userWriteOptions_ & OFFImporter::COLORALPHA) userWriteOptions_ -= OFFImporter::COLORALPHA; }
252 if(saveNormals_->isChecked()) userWriteOptions_ |= OFFImporter::VERTEXNORMAL;
253 else {
if(userWriteOptions_ & OFFImporter::VERTEXNORMAL) userWriteOptions_ -= OFFImporter::VERTEXNORMAL; }
256 if(saveTexCoords_->isChecked()) userWriteOptions_ |= OFFImporter::VERTEXTEXCOORDS;
257 else {
if(userWriteOptions_ & OFFImporter::VERTEXTEXCOORDS) userWriteOptions_ -= OFFImporter::VERTEXTEXCOORDS; }
276 const unsigned int LINE_LEN = 4096;
279 std::ifstream ifs(_filename.toUtf8(), std::ios_base::binary);
281 if ( (!ifs.is_open()) || (!ifs.good())) {
283 emit log(
LOGERR, tr(
"Error: Could not read file options of specified OFF-file! Aborting."));
288 char line[LINE_LEN], *p;
289 ifs.getline(line, LINE_LEN);
292 int remainingChars = ifs.gcount();
295 while(remainingChars > 0) {
297 if ( ( remainingChars > 1 ) && ( p[0] ==
'S' && p[1] ==
'T') ) {
298 _importer.
addOption(OFFImporter::VERTEXTEXCOORDS);
301 }
else if ( ( remainingChars > 0 ) && ( p[0] ==
'C') ) {
302 _importer.
addOption(OFFImporter::VERTEXCOLOR);
305 }
else if ( ( remainingChars > 0 ) && ( p[0] ==
'N') ) {
306 _importer.
addOption(OFFImporter::VERTEXNORMAL);
309 }
else if ( ( remainingChars > 0 ) && (p[0] ==
'3' ) ) {
312 }
else if ( ( remainingChars > 0 ) && (p[0] ==
'4' ) ) {
314 std::cerr <<
"Error: Extended coordinates are currently not supported!" << std::endl;
317 }
else if ( ( remainingChars > 0 ) && (p[0] ==
'n' ) ) {
319 std::cerr <<
"Error: n-dimensional coordinates are currently not supported!" << std::endl;
322 }
else if ( ( remainingChars >= 3 ) && (p[0] ==
'O' && p[1] ==
'F' && p[2] ==
'F') ) {
326 }
else if ( ( remainingChars >= 6 ) && ( strncmp(p,
"BINARY", 6) == 0 ) ) {
327 _importer.
addOption(OFFImporter::BINARY);
330 }
else if ( ( remainingChars > 0 ) && ( p[0] ==
'#' ) ) {
343 unsigned int nV, nF, dummy_uint;
344 unsigned int vertexCount = 0;
345 unsigned int tmp_count = 0;
348 std::istringstream sstr;
350 if(_importer.isBinary()) {
357 readValue(ifs, dummy_uint);
359 for (uint i=0; i<nV && !ifs.eof(); ++i) {
361 for(
int i = 0; i < 3; ++i) readValue(ifs, dummy_f);
364 for(
int i = 0; i < 3; ++i) readValue(ifs, dummy_f);
367 if ( _importer.hasVertexColors() ) {
368 for(
int i = 0; i < 3; ++i) readValue(ifs, dummy_f);
371 if ( _importer.hasTextureCoords() ) {
372 for(
int i = 0; i < 2; ++i) readValue(ifs, dummy_f);
375 for (uint i=0; i<nF; ++i) {
377 readValue(ifs, tmp_count);
382 if(tmp_count > vertexCount) vertexCount = tmp_count;
387 for(uint i = 0; i < tmp_count; ++i) readValue(ifs, dummy_uint);
390 readValue(ifs, tmp_count);
392 if(!_importer.hasFaceColors() && tmp_count > 0) {
393 _importer.
addOption(OFFImporter::FACECOLOR);
397 for (uint i = 0; i < tmp_count; ++i) {
398 readValue(ifs, dummy_f);
411 if ( str.compare(
"OFF") == 0 ) {
422 for(
unsigned int i = 0; i < nV; ++i) {
429 for(
unsigned int i = 0; i < nF; ++i) {
436 if(tmp_count > vertexCount) vertexCount = tmp_count;
439 for(uint i = 0; i < tmp_count; ++i) {
442 emit log(
LOGERR,
"The OFF File is Malformatted! Aborting...");
450 if(!_importer.hasFaceColors()) {
452 _importer.
addOption(OFFImporter::FACECOLOR);
460 _importer.maxFaceValence(vertexCount);
462 if(vertexCount == 3) {
463 _importer.
addOption(OFFImporter::TRIMESH);
465 }
else if (vertexCount == 0 && nF != 0) {
469 _importer.
addOption(OFFImporter::POLYMESH);
479 QFile theFile(_filename);
480 if ( !theFile.exists() ){
481 emit log(
LOGERR, tr(
"Unable to load OFF file. File not found!"));
492 std::ifstream ifile(_filename.toUtf8(), (_importer.isBinary() ? std::ios::binary | std::ios::in
495 unsigned long sz = theFile.size()/1024/1024;
497 if(sz <= 2 * Utils::Memory::queryFreeRAM())
499 ifile.rdbuf()->pubsetbuf(NULL,theFile.size());
502 if (!ifile.is_open() || !ifile.good())
504 emit log(
LOGERR, tr(
"Cannot open OFF file for reading!"));
510 int triMeshControl = TYPEAUTODETECT;
512 if ( OpenFlipper::Options::gui() ){
513 if ( triMeshHandling_ != 0 ){
514 triMeshControl = triMeshHandling_->currentIndex();
516 triMeshControl = TYPEAUTODETECT;
520 if ( forceTriangleMesh_ )
521 triMeshControl = TYPETRIANGLE;
523 if ( forcePolyMesh_ )
524 triMeshControl = TYPEPOLY;
528 switch (triMeshControl) {
535 if( !OpenFlipper::Options::nogui() ) {
537 QMetaObject::invokeMethod(
this,
"handleTrimeshDialog",Qt::BlockingQueuedConnection);
539 if (trimeshOptions_ == OFFImporter::TRIMESH)
541 else if (trimeshOptions_ == OFFImporter::POLYMESH)
568 return _importer.isBinary() ?
parseBinary(ifile, _importer, type, _filename) :
parseASCII(ifile, _importer, type, _filename);
574 QPushButton *detectButton = msgBox.addButton(tr(
"Auto-Detect"), QMessageBox::ActionRole);
575 QPushButton *triButton = msgBox.addButton(tr(
"Open as triangle mesh"), QMessageBox::ActionRole);
576 QPushButton *polyButton = msgBox.addButton(tr(
"Open as poly mesh"), QMessageBox::ActionRole);
577 msgBox.setWindowTitle( tr(
"Mesh types in file") );
578 msgBox.setText( tr(
"You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
579 msgBox.setDefaultButton( detectButton );
583 if (msgBox.clickedButton() == triButton)
584 trimeshOptions_ = OFFImporter::TRIMESH ;
585 else if (msgBox.clickedButton() == polyButton)
586 trimeshOptions_ = OFFImporter::POLYMESH ;
594 unsigned int nV, nF, dummy;
601 std::vector<VertexHandle> vhandles;
605 emit addEmptyObject(_type, objectId);
609 emit log(
LOGERR, tr(
"Could not create new object!"));
614 QFileInfo f(_objectName);
615 object->setName(f.fileName());
621 std::istringstream sstr;
636 _importer.reserve(nV, nF * _importer.maxFaceValence() , nF);
642 if ( (c ==
'\n') || (c ==
'#') )
643 std::getline(_in, tmp);
649 for (uint i=0; i<nV && !_in.eof(); ++i) {
652 v[0] = getFloat(_in);
653 v[1] = getFloat(_in);
654 v[2] = getFloat(_in);
656 const VertexHandle vh = _importer.
addVertex(v);
661 n[0] = getFloat(_in);
662 n[1] = getFloat(_in);
663 n[2] = getFloat(_in);
665 if(userReadOptions_ & OFFImporter::VERTEXNORMAL) {
675 int colorType =
getColorType(line, _importer.hasTextureCoords() );
678 if ( _importer.hasVertexColors() ){
684 case 1 : sstr >> trash;
break;
685 case 2 : sstr >> trash; sstr >> trash;
break;
691 if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
692 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) );
702 if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
703 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) );
705 _importer.
addOption(OFFImporter::COLORALPHA);
710 c3f[0] = getFloat(sstr);
711 c3f[1] = getFloat(sstr);
712 c3f[2] = getFloat(sstr);
713 if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
714 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) );
720 c4f[0] = getFloat(sstr);
721 c4f[1] = getFloat(sstr);
722 c4f[2] = getFloat(sstr);
723 c4f[3] = getFloat(sstr);
724 if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
725 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) );
727 _importer.
addOption(OFFImporter::COLORALPHA);
732 std::cerr <<
"Error in file format (colorType = " << colorType <<
")\n";
738 if ( _importer.hasTextureCoords() ){
739 t[0] = getFloat(sstr);
740 t[1] = getFloat(sstr);
741 if ( userReadOptions_ & OFFImporter::VERTEXTEXCOORDS ) {
751 if ( (c ==
'\n') || (c ==
'#') )
752 std::getline(_in, tmp);
759 for (uint i=0; i<nF; ++i)
774 for (uint i=0; i<nV; ++i) {
776 vhandles.push_back(VertexHandle(idx));
779 bool checkManifold =
true;
780 if(!OpenFlipper::Options::nogui() && loadCheckManifold_ != 0) {
781 checkManifold = loadCheckManifold_->isChecked();
787 fh = _importer.
addFace(vhandles);
792 fh = _importer.
addFace(vhandles);
796 if ( _importer.hasFaceColors() ){
809 case 1 : sstr >> trash;
break;
810 case 2 : sstr >> trash; sstr >> trash;
break;
816 if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
817 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>( c3 ) );
827 if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
828 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>( c4 ) );
830 _importer.
addOption(OFFImporter::COLORALPHA);
835 c3f[0] = getFloat(sstr);
836 c3f[1] = getFloat(sstr);
837 c3f[2] = getFloat(sstr);
838 if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
839 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>(c3f) );
845 c4f[0] = getFloat(sstr);
846 c4f[1] = getFloat(sstr);
847 c4f[2] = getFloat(sstr);
848 c4f[3] = getFloat(sstr);
849 if ( userReadOptions_ & OFFImporter::FACECOLOR ) {
850 int cidx = _importer.
addColor( OpenMesh::color_cast<PolyMesh::Color>(c4f) );
852 _importer.
addOption(OFFImporter::COLORALPHA);
857 std::cerr <<
"Error in file format (colorType = " << colorType <<
")\n";
872 int size = _v.size();
874 for(
int i = 0; i < size; ++i) {
875 for(
int j = i+1; j < size; ++j) {
876 if(_v[i] == _v[j]) check =
false;
896 if ( _line.size() < 1 )
906 found=_line.find_first_of(
" ");
907 while (found!=std::string::npos){
909 found=_line.find_first_of(
" ",found+1);
912 if (!_line.empty()) count++;
914 if (_texCoordsAvailable) count -= 2;
916 if (count == 3 || count == 4){
918 found = _line.find(
" ");
919 std::string c1 = _line.substr (0,found);
921 if (c1.find(
".") != std::string::npos){
936 unsigned int nV, nF, dummy;
942 std::vector<VertexHandle> vhandles;
946 emit addEmptyObject(_type, objectId);
950 emit log(
LOGERR, tr(
"Could not create new object!"));
955 QFileInfo f(_objectName);
956 object->setName(f.fileName());
968 readValue(_in, dummy);
971 _importer.reserve(nV, nF * _importer.maxFaceValence() , nF);
974 for (uint i=0; i<nV && !_in.eof(); ++i)
977 readValue(_in, v[0]);
978 readValue(_in, v[1]);
979 readValue(_in, v[2]);
981 const VertexHandle vh = _importer.
addVertex(v);
984 readValue(_in, n[0]);
985 readValue(_in, n[1]);
986 readValue(_in, n[2]);
988 if ( userReadOptions_ & OFFImporter::VERTEXNORMAL ) {
994 if ( _importer.hasVertexColors() ) {
996 readValue(_in, c[0]);
997 readValue(_in, c[1]);
998 readValue(_in, c[2]);
1001 if ( userReadOptions_ & OFFImporter::VERTEXCOLOR ) {
1002 int cidx = _importer.
addColor( c );
1007 if ( _importer.hasTextureCoords() ) {
1008 readValue(_in, t[0]);
1009 readValue(_in, t[1]);
1011 if ( userReadOptions_ & OFFImporter::VERTEXTEXCOORDS ) {
1023 for (uint i = 0; i<nF && !_in.eof(); ++i)
1028 _in.seekg(0, std::ios::end);
1061 readColorComp_ =
false;
1076 for (uint j = 0; j < nV; ++j) {
1077 readValue(_in, dummy);
1081 if (readColorComp_) {
1084 for (uint j = 0; j < nV; ++j) {
1085 readValue(_in, dummy_f);
1094 for (uint j = 0; j < nV; ++j) {
1095 readValue(_in, idx);
1096 vhandles.push_back(VertexHandle(idx));
1099 fh = _importer.
addFace(vhandles);
1101 if ( !readColorComp_ ) {
1113 if ( nV == 3 || nV == 4 ) {
1116 for(uint k = 0; k < 3; ++k) {
1117 readValue(_in, c[k]);
1123 readValue(_in, alpha);
1126 if(userReadOptions_ & OFFImporter::FACECOLOR) {
1127 if(userReadOptions_ & OFFImporter::COLORALPHA) {
1130 _importer.
addOption(OFFImporter::COLORALPHA);
1132 int cidx = _importer.
addColor(OpenMesh::color_cast<OpenMesh::Vec4f>(c));
1138 for(uint i = 0; i < nV; ++i) {
1139 readValue(_in, dummy_f);
1171 int pos = _in.tellg();
1173 for(uint k = 0; k < _nF; ++k) {
1179 for(uint z = 0; z < nV; ++z) {
1180 readValue(_in, dummy);
1185 int currPos = _in.tellg();
1190 if(_nB - currPos == 0) {
1214 forceTriangleMesh_ =
false;
1215 forcePolyMesh_ =
false;
1220 object->setFromFileName(_filename);
1240 if ( !importer.
hasVertexNormals() || (userReadOptions_ & OFFImporter::FORCE_NONORMALS) )
1250 emit openedFile( object->
id() );
1252 forceTriangleMesh_ =
false;
1253 forcePolyMesh_ =
false;
1254 return object->id();
1261 forceTriangleMesh_ =
false;
1262 forcePolyMesh_ =
false;
1265 forceTriangleMesh_ =
true;
1267 forcePolyMesh_ =
true;
1275 bool FileOFFPlugin::saveObject(
int _id, QString _filename)
1279 emit log(
LOGERR, tr(
"saveObject : cannot get object id %1 for save name %2").arg(_id).arg(_filename) );
1283 std::string filename = std::string( _filename.toUtf8() );
1285 bool binary = userWriteOptions_ & OFFImporter::BINARY;
1286 std::fstream ofs( filename.c_str(), (binary ? std::ios_base::out | std::ios_base::binary : std::ios_base::out));
1290 emit log(
LOGERR, tr(
"saveObject : Cannot not open file %1 for writing!").arg(_filename) );
1299 object->setFromFileName(_filename);
1300 object->setName(object->
filename());
1305 emit log(
LOGINFO, tr(
"Saved object to ") + _filename );
1309 emit log(
LOGERR, tr(
"Unable to save ") + _filename);
1315 object->setFromFileName(_filename);
1316 object->setName(object->
filename());
1321 emit log(
LOGINFO, tr(
"Saved object to ") + _filename );
1325 emit log(
LOGERR, tr(
"Unable to save ") + _filename );
1330 emit log(
LOGERR, tr(
"Unable to save (object is not a compatible mesh type)"));
1338 template <
class MeshT>
1342 if (_mesh.has_vertex_texcoords2D()) {
1345 if (!_mesh.get_property_handle(oldVertexCoords,
"Original Per Vertex Texture Coords"))
1346 _mesh.add_property(oldVertexCoords,
"Original Per Vertex Texture Coords");
1348 for (
typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
1349 _mesh.property(oldVertexCoords, *v_it) = _mesh.texcoord2D(*v_it);
1354 if (_mesh.has_halfedge_texcoords2D()) {
1357 if (!_mesh.get_property_handle(oldHalfedgeCoords,
"Original Per Face Texture Coords"))
1358 _mesh.add_property(oldHalfedgeCoords,
"Original Per Face Texture Coords");
1360 for (
typename MeshT::HalfedgeIter he_it = _mesh.halfedges_begin(); he_it != _mesh.halfedges_end(); ++he_it)
1361 _mesh.property(oldHalfedgeCoords, *he_it) = _mesh.texcoord2D(*he_it);
1370 if (saveOptions_ == 0){
1372 saveOptions_ =
new QWidget();
1373 QVBoxLayout* layout =
new QVBoxLayout();
1374 layout->setAlignment(Qt::AlignTop);
1376 saveBinary_ =
new QCheckBox(
"Save Binary");
1377 layout->addWidget(saveBinary_);
1379 saveVertexColor_ =
new QCheckBox(
"Save Vertex Colors");
1380 layout->addWidget(saveVertexColor_);
1382 saveFaceColor_ =
new QCheckBox(
"Save Face Colors");
1383 layout->addWidget(saveFaceColor_);
1385 saveAlpha_ =
new QCheckBox(
"Save Color Alpha");
1386 layout->addWidget(saveAlpha_);
1388 saveNormals_ =
new QCheckBox(
"Save Normals");
1389 layout->addWidget(saveNormals_);
1391 saveTexCoords_ =
new QCheckBox(
"Save TexCoords");
1392 layout->addWidget(saveTexCoords_);
1394 savePrecisionLabel_ =
new QLabel(
"Writer Precision");
1395 layout->addWidget(savePrecisionLabel_);
1397 savePrecision_ =
new QSpinBox();
1398 savePrecision_->setMinimum(1);
1399 savePrecision_->setMaximum(12);
1400 savePrecision_->setValue(6);
1401 layout->addWidget(savePrecision_);
1403 saveDefaultButton_ =
new QPushButton(
"Make Default");
1404 layout->addWidget(saveDefaultButton_);
1406 saveOptions_->setLayout(layout);
1408 connect(saveBinary_, SIGNAL(clicked(
bool)), savePrecision_, SLOT(setDisabled(
bool)));
1409 connect(saveDefaultButton_, SIGNAL(clicked()),
this, SLOT(
slotSaveDefault()));
1411 saveBinary_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/Binary",
false).toBool() );
1412 saveVertexColor_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/VertexColor",
true).toBool() );
1413 saveFaceColor_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/FaceColor",
true).toBool() );
1414 saveAlpha_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/Alpha",
true).toBool() );
1415 saveNormals_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/Normals",
true).toBool() );
1416 saveTexCoords_->setChecked(
OpenFlipperSettings().value(
"FileOff/Save/TexCoords",
true).toBool() );
1420 return saveOptions_;
1427 if (loadOptions_ == 0){
1429 loadOptions_ =
new QWidget();
1430 QVBoxLayout* layout =
new QVBoxLayout();
1431 layout->setAlignment(Qt::AlignTop);
1433 QLabel* label =
new QLabel(tr(
"If PolyMesh is a Triangle Mesh:"));
1435 layout->addWidget(label);
1437 triMeshHandling_ =
new QComboBox();
1438 triMeshHandling_->addItem( tr(
"Auto-Detect") );
1439 triMeshHandling_->addItem( tr(
"Ask") );
1440 triMeshHandling_->addItem( tr(
"Always open as PolyMesh") );
1441 triMeshHandling_->addItem( tr(
"Always open as TriangleMesh") );
1443 layout->addWidget(triMeshHandling_);
1445 loadVertexColor_ =
new QCheckBox(
"Load Vertex Colors");
1446 layout->addWidget(loadVertexColor_);
1448 loadFaceColor_ =
new QCheckBox(
"Load Face Colors");
1449 layout->addWidget(loadFaceColor_);
1451 loadAlpha_ =
new QCheckBox(
"Load Color Alpha");
1452 layout->addWidget(loadAlpha_);
1454 loadNormals_ =
new QCheckBox(
"Load Normals");
1455 layout->addWidget(loadNormals_);
1457 loadTexCoords_ =
new QCheckBox(
"Load TexCoords");
1458 layout->addWidget(loadTexCoords_);
1460 loadCheckManifold_ =
new QCheckBox(
"Check for manifold configurations");
1461 layout->addWidget(loadCheckManifold_);
1463 loadDefaultButton_ =
new QPushButton(
"Make Default");
1464 layout->addWidget(loadDefaultButton_);
1466 loadOptions_->setLayout(layout);
1468 connect(loadDefaultButton_, SIGNAL(clicked()),
this, SLOT(
slotLoadDefault()));
1470 triMeshHandling_->setCurrentIndex(
OpenFlipperSettings().value(
"FileOff/Load/TriMeshHandling",TYPEAUTODETECT ).toInt() );
1472 loadVertexColor_->setChecked(
OpenFlipperSettings().value(
"FileOff/Load/VertexColor",
true).toBool() );
1473 loadFaceColor_->setChecked(
OpenFlipperSettings().value(
"FileOff/Load/FaceColor",
true).toBool() );
1474 loadAlpha_->setChecked(
OpenFlipperSettings().value(
"FileOff/Load/Alpha",
true).toBool() );
1475 loadNormals_->setChecked(
OpenFlipperSettings().value(
"FileOff/Load/Normals",
true).toBool() );
1476 loadTexCoords_->setChecked(
OpenFlipperSettings().value(
"FileOff/Load/TexCoords",
true).toBool() );
1479 return loadOptions_;
1504 #if QT_VERSION < 0x050000 int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
void backupTextureCoordinates(MeshT &_mesh)
backup per vertex/face texture coordinates
int getColorType(std::string &_line, bool _texCoordsAvailable)
Get color type.
bool writeMesh(std::ostream &_out, MeshT &_mesh, BaseObject &_baseObj)
Writer function.
void setFaceColor(FaceHandle _fh, int _colorIndex)
set face color
Type for a MeshObject containing a triangle mesh.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
void handleTrimeshDialog()
Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
QWidget * saveOptionsWidget(QString)
void update_normals()
Compute normals for all primitives.
QString filename() const
return the filename of the object
bool getObject(int _identifier, BSplineCurveObject *&_object)
int addColor(const Vec4f &_color)
add a color
bool dataType(DataType _type) const
void setVertexColor(VertexHandle _vh, int _colorIndex)
set vertex color
bool readFileOptions(QString _filename, OFFImporter &_importer)
Before Parsing the actual file, read all features supported.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
int addTexCoord(const Vec2f &_coord)
add texture coordinates
BaseObject * getObject()
get BaseObject data of object
void slotLoadDefault()
Slot called when user wants to save the given Load options as default.
bool hasVertexNormals()
Query Object Options.
bool getCleanLine(std::istream &ifs, std::string &_string, bool _skipEmptyLines=true)
Function to retrieve next line.
MeshT * mesh()
return a pointer to the mesh
void initializePlugin()
Initialize Plugin.
void setNormal(VertexHandle _vh, int _normalID)
set vertex normal
void removeOption(ObjectOptionsE _option)
remove an option
int addFace(const VHandles &_indices)
add a face with indices _indices refering to vertices
bool checkDegenerateFace(const std::vector< VertexHandle > &_v)
Check for degenerate faces before adding them.
void setVertexTexCoord(VertexHandle _vh, int _texCoordID)
set vertex texture coordinate
bool parseBinary(std::istream &_in, OFFImporter &_importer, DataType _type, QString &_objectName)
Parse binary OFF file.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
bool parseASCII(std::istream &_in, OFFImporter &_importer, DataType _type, QString &_objectName)
Parse ascii OFF file.
int addNormal(const Vec3f &_normal)
add a normal
bool extendedFaceColorTest(std::istream &_in, uint _nV, uint _nF, int _nB) const
Test if there are face color components (_nV is the initial face valence)
void addObject(BaseObject *_object)
add initial object
bool readOFFFile(QString _filename, OFFImporter &_importer)
Read OFF file and parse it.
void update_face_normals()
Update normal vectors for all faces.
Type for a Meshobject containing a poly mesh.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QWidget * loadOptionsWidget(QString)
FileOFFPlugin()
Constructor.
void slotSaveDefault()
Slot called when user wants to save the given Save options as default.
#define DATA_TRIANGLE_MESH
void addOption(ObjectOptionsE _option)
add an option
VertexHandle addVertex(const Vec3f &_point)
add a vertex with coordinate _point