2026-04-11 16:30:10 +10:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef GEOMETRYSTREAMER_H
|
|
|
|
|
#define GEOMETRYSTREAMER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
|
2026-04-11 19:23:10 +10:00
|
|
|
#include "../ifcparse/file.h"
|
2026-04-11 16:30:10 +10:00
|
|
|
#include "../ifcgeom/Iterator.h"
|
|
|
|
|
|
2026-04-12 19:53:06 +10:00
|
|
|
#include "InstancedGeometry.h"
|
2026-04-11 16:30:10 +10:00
|
|
|
|
|
|
|
|
struct ElementInfo {
|
|
|
|
|
uint32_t object_id;
|
2026-04-11 20:49:39 +10:00
|
|
|
uint32_t model_id;
|
2026-04-11 16:30:10 +10:00
|
|
|
int ifc_id;
|
|
|
|
|
std::string guid;
|
|
|
|
|
std::string name;
|
|
|
|
|
std::string type;
|
|
|
|
|
int parent_id;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class GeometryStreamer : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit GeometryStreamer(QObject* parent = nullptr);
|
|
|
|
|
~GeometryStreamer();
|
|
|
|
|
|
2026-04-11 20:49:39 +10:00
|
|
|
void loadFile(const std::string& path, uint32_t start_object_id, uint32_t model_id, int num_threads = 0);
|
2026-04-11 16:30:10 +10:00
|
|
|
void cancel();
|
|
|
|
|
|
|
|
|
|
bool isRunning() const { return running_.load(); }
|
|
|
|
|
int progress() const { return progress_.load(); }
|
2026-04-11 20:49:39 +10:00
|
|
|
uint32_t lastObjectId() const { return next_object_id_; }
|
|
|
|
|
uint32_t modelId() const { return model_id_; }
|
2026-04-11 16:30:10 +10:00
|
|
|
|
2026-04-11 19:23:10 +10:00
|
|
|
ifcopenshell::file* ifcFile() const { return ifc_file_.get(); }
|
2026-04-11 16:30:10 +10:00
|
|
|
|
|
|
|
|
// Thread-safe access to discovered elements
|
|
|
|
|
std::vector<ElementInfo> drainElements();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void progressChanged(int percent);
|
2026-04-12 19:53:06 +10:00
|
|
|
void meshReady(MeshChunk chunk);
|
|
|
|
|
void instanceReady(InstanceChunk chunk);
|
2026-04-11 16:30:10 +10:00
|
|
|
void finished();
|
2026-04-22 11:27:53 +10:00
|
|
|
void cancelled();
|
2026-04-11 16:30:10 +10:00
|
|
|
void errorOccurred(const QString& message);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void run(const std::string& path, int num_threads);
|
|
|
|
|
|
2026-04-11 19:23:10 +10:00
|
|
|
std::unique_ptr<ifcopenshell::file> ifc_file_;
|
2026-04-11 16:30:10 +10:00
|
|
|
std::unique_ptr<QThread> worker_thread_;
|
|
|
|
|
std::atomic<bool> running_{false};
|
|
|
|
|
std::atomic<bool> cancel_requested_{false};
|
2026-04-22 11:27:53 +10:00
|
|
|
std::atomic<bool> succeeded_{false};
|
2026-04-11 16:30:10 +10:00
|
|
|
std::atomic<int> progress_{0};
|
|
|
|
|
|
|
|
|
|
std::mutex elements_mutex_;
|
|
|
|
|
std::vector<ElementInfo> pending_elements_;
|
|
|
|
|
|
2026-04-12 19:53:06 +10:00
|
|
|
uint32_t next_object_id_ = 1;
|
2026-04-11 20:49:39 +10:00
|
|
|
uint32_t model_id_ = 0;
|
2026-04-11 16:30:10 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // GEOMETRYSTREAMER_H
|