mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
ifcviewer-full: print object volume on click via lazy GPU readback
Adds neutral primitives on ViewportWindow (readbackMeshTriangles, findInstance) so consumers can compute per-object geometry queries without the library retaining a CPU triangle copy. Measurement.cpp in ifcviewer-full uses them to sum signed-tetrahedra in mesh-local space, weighted by |det(placement_3x3)| per instance for mapped-item scaling. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -183,6 +183,31 @@ public:
|
||||
// (CoordinateOperation · placement_transformation), in metres.
|
||||
void printSelectedObjectCoords();
|
||||
|
||||
// Mesh-local CPU triangles read back from the VBO/EBO. Positions are
|
||||
// dequantised against the mesh's local AABB; units match the streamer
|
||||
// (metres). Indices are mesh-local (0..vertex_count-1).
|
||||
struct MeshTriangles {
|
||||
std::vector<float> positions; // 3 * vertex_count
|
||||
std::vector<uint32_t> indices; // 3 * triangle_count
|
||||
};
|
||||
|
||||
// Lazy GPU readback of one mesh's triangles. Fails if model_id /
|
||||
// mesh_id aren't live, the model isn't finalised, or GL isn't ready.
|
||||
// Stalls the GL pipeline for the readback — call from the main thread
|
||||
// and not from inside render().
|
||||
bool readbackMeshTriangles(uint32_t model_id, uint32_t mesh_id,
|
||||
MeshTriangles& out);
|
||||
|
||||
// Pure CPU lookup: object_id → owning model + mesh + raw streamer
|
||||
// placement matrix (column-major, pre-CoordinateOperation /
|
||||
// FederatedFalseOrigin / ModelTransformation).
|
||||
struct InstanceLookup {
|
||||
uint32_t model_id = 0;
|
||||
uint32_t mesh_id = 0;
|
||||
float placement_transformation[16]{};
|
||||
};
|
||||
bool findInstance(uint32_t object_id, InstanceLookup& out) const;
|
||||
|
||||
// Federation pipeline: composed instance transform =
|
||||
// FederatedFalseOrigin · ModelTransformation · CoordinateOperation
|
||||
// · placement_transformation
|
||||
|
||||
Reference in New Issue
Block a user