mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
75c9da5098
Rename the two overloaded model identifiers and make object_id assignment single-authority, fixing a pick -> properties mismatch. Identifiers: - Per-model UUID fed_id -> model_id; the uint32 runtime handle model_id -> session_model_id (SessionState accessors + mirror hashes renamed to match). "fed_id" was a misnomer -- the federation is the whole collection, not one model. object_id assignment (fixes wrong class on click): - Producers (GeometryStreamer, .ifcview sidecar) now stamp model-LOCAL object_ids; ViewportCore::applyCachedModel is the sole authority that assigns the session-global id (base + local). Removed SceneLoader::next_object_id_, GeometryStreamer::lastObjectId(), and the streamer's start_object_id parameter. - The element table is stamped by the same base on both load paths (applySidecarData and onStreamerFinished), so registry ids match the ids pick returns. Previously the sidecar path double-rebased instances vs the registry (click IfcSite -> showed IfcDoor); the live-stream path had the same latent mismatch. Both closed. Naming / cleanup: - SceneLoader::addFiles -> queueModels; startStreamLoadFor -> loadFromGeometryStreamer; readSidecarMetadataOnly -> readSidecarMetadata. - Federation::addModel takes an explicit display_name (no QFileInfo fallback); callers pass QFileInfo(path).fileName(). - Disambiguate cryptic short locals (d->sidecar, m->model, c->chunk, ...) in SceneLoader, Federation, ViewportWindow, AreaMeasurement, SectionGizmoRenderer, and the SidecarData/SidecarReadPlan spots in ViewportCore. Tests: 125/125 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
97 lines
3.6 KiB
C++
97 lines
3.6 KiB
C++
/********************************************************************************
|
|
* *
|
|
* 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>
|
|
|
|
#include "../ifcparse/file.h"
|
|
#include "../ifcgeom/Iterator.h"
|
|
|
|
#include "InstancedGeometry.h"
|
|
|
|
struct ElementInfo {
|
|
uint32_t object_id;
|
|
uint32_t session_model_id;
|
|
int ifc_id;
|
|
std::string guid;
|
|
std::string name;
|
|
std::string type;
|
|
};
|
|
|
|
class GeometryStreamer : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
explicit GeometryStreamer(QObject* parent = nullptr);
|
|
~GeometryStreamer();
|
|
|
|
// Streamer stamps model-LOCAL object_ids (1..N, reset each load).
|
|
// ViewportCore::applyCachedModel assigns the session-global ids at install.
|
|
void loadFile(const std::string& path, uint32_t session_model_id, int num_threads = 0);
|
|
void cancel();
|
|
|
|
// Adopt an externally-opened ifcopenshell::file as the data source
|
|
// (e.g. for the sidecar-hit path, where loadFile never runs). The
|
|
// streamer must not be running geometry iteration when this is called.
|
|
void setIfcFile(std::unique_ptr<ifcopenshell::file> file);
|
|
|
|
bool isRunning() const { return running_.load(); }
|
|
int progress() const { return progress_.load(); }
|
|
uint32_t sessionModelId() const { return session_model_id_; }
|
|
|
|
ifcopenshell::file* ifcFile() const { return ifc_file_.get(); }
|
|
|
|
// Thread-safe access to discovered elements
|
|
std::vector<ElementInfo> drainElements();
|
|
|
|
signals:
|
|
void progressChanged(int percent);
|
|
void meshReady(StreamedMesh mesh);
|
|
void instanceReady(StreamedInstance instance_record);
|
|
void finished();
|
|
void cancelled();
|
|
void errorOccurred(const QString& message);
|
|
|
|
private:
|
|
void run(const std::string& path, int num_threads);
|
|
|
|
std::unique_ptr<ifcopenshell::file> ifc_file_;
|
|
std::unique_ptr<QThread> worker_thread_;
|
|
std::atomic<bool> running_{false};
|
|
std::atomic<bool> cancel_requested_{false};
|
|
std::atomic<bool> succeeded_{false};
|
|
std::atomic<int> progress_{0};
|
|
|
|
std::mutex elements_mutex_;
|
|
std::vector<ElementInfo> pending_elements_;
|
|
|
|
uint32_t next_object_id_ = 1;
|
|
uint32_t session_model_id_ = 0;
|
|
};
|
|
|
|
#endif // GEOMETRYSTREAMER_H
|