From 0c3dc49132049362d2a678b9c0deebd9c22b0951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de> Date: Tue, 6 Jun 2023 13:11:19 +0200 Subject: [PATCH] Some more work --- FileOBJ.cc | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-- OBJImporter.cc | 32 ------------------------ OBJImporter.hh | 9 ------- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/FileOBJ.cc b/FileOBJ.cc index 86dd210..dde6438 100644 --- a/FileOBJ.cc +++ b/FileOBJ.cc @@ -407,6 +407,26 @@ void FileOBJPlugin::createAllGroupObjects(OBJImporter& _importer) { } } +#endif + +#ifdef ENABLE_POLYLINE_SUPPORT + + else if (_importer.isLine(i )) { + + int id = -1; + emit addEmptyObject(DATA_POLY_LINE, id); + + BaseObjectData* object(0); + + if (PluginFunctions::getObject(id, object)) { + + _importer.setObject(object, i); + + object->setPath(_importer.path()); + object->setName(name); + } + } + #endif //force gui settings @@ -1467,7 +1487,7 @@ void FileOBJPlugin::checkTypes(QByteArray& _bufferedFile, QString _filename, OBJ if ( options & OBJImporter::POLYMESH ) PolyMeshCount++; int id = _importer.addGroup(grpName); -#if defined ENABLE_BSPLINECURVE_SUPPORT || defined ENABLE_BSPLINESURFACE_SUPPORT +#if defined ENABLE_BSPLINECURVE_SUPPORT || defined ENABLE_BSPLINESURFACE_SUPPORT || defined ENABLE_POLYLINE_SUPPORT parentId = id; currentGroupName = grpName; currentGroupName.remove(QLatin1String(".obj")); @@ -1744,6 +1764,50 @@ void FileOBJPlugin::checkTypes(QByteArray& _bufferedFile, QString _filename, OBJ } #endif +#ifdef ENABLE_POLYLINE_SUPPORT + if ( mode == NONE && keyWrd == QLatin1String("l")) { + std::cerr << "PolyLine started" << std::endl; + + int value; + + // read full line after detecting a face + QString polyLineLine; + polyLineLine = stream.readLine(); + lineData.setString( &polyLineLine ); + + // work on the line until nothing left to read + while ( !lineData.atEnd() ) + { + // read one block from the line ( vertex/texCoord/normal ) + QString vertex; + lineData >> vertex; + + + tmp.setString( &vertex ); + tmp >> value; + + if ( tmp.status()!=QTextStream::Ok ) + emit log(LOGERR, tr("readOBJFile : Error reading vertex index for line!")); + + + if ( value < 0 ) { + // Calculation of index : + // -1 is the last vertex in the list + // As obj counts from 1 and not zero add +1 + value = _importer.n_vertices() + value + 1; + } + + // Obj counts from 1 and not zero .. array counts from zero therefore -1 + // the importer has to know which vertices are used by the object for correct vertex order + _importer.useVertex( value -1 ); + } + + options = OBJImporter::LINE; + _importer.setObjectOptions(options); + + } +#endif + } if(faceCount > 0) { @@ -1904,7 +1968,7 @@ int FileOBJPlugin::loadObject(QString _filename) { if ( importer.numGroups() > 1){ bool dataControlExists = false; - pluginExists( "datacontrol", dataControlExists ); + emit pluginExists( "datacontrol", dataControlExists ); if ( dataControlExists ){ #if defined ENABLE_BSPLINECURVE_SUPPORT || defined ENABLE_BSPLINESURFACE_SUPPORT diff --git a/OBJImporter.cc b/OBJImporter.cc index 29cc075..f10eff5 100644 --- a/OBJImporter.cc +++ b/OBJImporter.cc @@ -1179,38 +1179,6 @@ int OBJImporter::getSurfaceParentId(const int _surfaceGroup) { //----------------------------------------------------------------------------- -#ifdef ENABLE_POLYLINE_SUPPORT -void OBJImporter::setPolyLineGroupId(const unsigned int _count, const int _id) { - polyLineMap_[_count] = _id; -} -#endif - -//----------------------------------------------------------------------------- - -#ifdef ENABLE_POLYLINE_SUPPORT -int OBJImporter::getPolyLineGroupId(const unsigned int _count) { - return polyLineMap_[_count]; -} -#endif - -//----------------------------------------------------------------------------- - -#ifdef ENABLE_POLYLINE_SUPPORT -void OBJImporter::setPolyLineParentId(const int _lineGroup, const int _parentGroup) { - polyLineParentGroupMap_[_lineGroup] = _parentGroup; -} -#endif - -//----------------------------------------------------------------------------- - -#ifdef ENABLE_POLYLINE_SUPPORT -int OBJImporter::getPolyLineParentId(const int _lineGroup) { - return polyLineParentGroupMap_[_lineGroup]; -} -#endif - -//----------------------------------------------------------------------------- - //used materials const std::vector<std::string> OBJImporter::usedMaterials(unsigned int _objectID){ diff --git a/OBJImporter.hh b/OBJImporter.hh index 1c3c841..2c7c52e 100644 --- a/OBJImporter.hh +++ b/OBJImporter.hh @@ -187,15 +187,6 @@ class OBJImporter PolyLine* currentPolyLine(); unsigned int numPolyLines() { return polyLines_.size(); } - - /// sets the parent group id of the line group - int getPolyLineParentId(const int _lineGroup); - /// maps the counted line to a group id - void setPolyLineGroupId(const unsigned int _count, const int _id); - /// get the group id corresponding to the counted line - int getPolyLineGroupId(const unsigned int _count); - /// sets the parent group id of the line group - void setPolyLineParentId(const int _lineGroup, const int _parentGroup); #endif /// add all vertices that are used to the mesh (in correct order) -- GitLab