void QMeshDoc::importObjectBrowser() { MeshBrowserWidget * browser = new MeshBrowserWidget; if(browser->exec()) importObject(browser->selectedFile()); }
void QMeshDoc::importObject() { Workspace * workspace = (Workspace *) parent(); if(workspace->activeScene == NULL) return; // The dialog QString fileName = QFileDialog::getOpenFileName(0, "Import Mesh", DEFAULT_FILE_PATH, "Mesh Files (*.obj *.off *.stl)"); // Read the file QSegMesh * newMesh = importObject(fileName); if (newMesh) { // Save the default path DEFAULT_FILE_PATH = QFileInfo(fileName).absolutePath(); // Emit signals emit(printMessage(newMesh->objectName() + " has been imported.")); emit(objectImported(newMesh)); } }
void QMeshDoc::importObject() { QString fileName = QFileDialog::getOpenFileName(0, "Import Mesh", DEFAULT_FILE_PATH, "Mesh Files (*.obj *.off *.stl)"); importObject(fileName); }
OSPObjectCatalog OSPObjectFile::importObjects() { //! The XML document container. tinyxml2::XMLDocument xml(true, tinyxml2::COLLAPSE_WHITESPACE); //! Read the XML object file. exitOnCondition(xml.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS, "unable to read object file '" + filename + "'"); //! A catalog of the OSPRay objects and attributes contained in the file. ObjectCatalog *catalog = new ObjectCatalog(); std::vector<OSPObjectCatalog> entries; //! Iterate over the object entries, skip the XML declaration and comments. for (const tinyxml2::XMLNode *node = xml.FirstChild() ; node ; node = node->NextSibling()) if (node->ToElement()) entries.push_back(importObject(node)); //! Copy the object entries into the catalog. catalog->entries = new OSPObjectCatalog[entries.size() + 1](); memcpy(catalog->entries, &entries[0], entries.size() * sizeof(OSPObjectCatalog)); //! The populated catalog. return(catalog); }
OSPObject *OSPObjectFile::importObjects() { // The XML document container. tinyxml2::XMLDocument xml(true, tinyxml2::COLLAPSE_WHITESPACE); // Read the XML object file. exitOnCondition(xml.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS, "unable to read object file '" + filename + "'"); // A list of OSPRay objects and their attributes contained in the file. std::vector<OSPObject> objects; // Iterate over the object entries, skip the XML declaration and comments. for (const tinyxml2::XMLNode *node = xml.FirstChild() ; node ; node = node->NextSibling()) if (node->ToElement()) objects.push_back(importObject(node)); // Copy the objects into a list. OSPObject *pointer = new OSPObject[objects.size() + 1]; memcpy(pointer, &objects[0], objects.size() * sizeof(OSPObject)); // Mark the end of the list. pointer[objects.size()] = NULL; return(pointer); }