From bd34c2a408e92d4f217b492a3c373ee0769aa971 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Mon, 23 Oct 2023 15:54:59 +0200 Subject: [PATCH] Show line count in the details panel. --- source/engine/model/line.js | 8 ++++++++ source/engine/model/mesh.js | 9 +++++++++ source/engine/model/meshinstance.js | 5 +++++ source/engine/model/model.js | 9 +++++++++ source/engine/model/object.js | 10 ++++++++++ source/website/sidebardetailspanel.js | 9 ++++++++- 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/source/engine/model/line.js b/source/engine/model/line.js index e88a962..f8860b3 100644 --- a/source/engine/model/line.js +++ b/source/engine/model/line.js @@ -22,6 +22,14 @@ export class Line return this; } + SegmentCount () + { + if (this.vertices === null) { + return 0; + } + return parseInt (this.vertices.length / 2, 10); + } + Clone () { let cloned = new Line ([...this.vertices]); diff --git a/source/engine/model/mesh.js b/source/engine/model/mesh.js index 753d9d4..9339c3b 100644 --- a/source/engine/model/mesh.js +++ b/source/engine/model/mesh.js @@ -38,6 +38,15 @@ export class Mesh extends ModelObject3D return this.lines.length; } + LineSegmentCount () + { + let lineSegmentCount = 0; + for (let line of this.lines) { + lineSegmentCount += line.SegmentCount (); + } + return lineSegmentCount; + } + TriangleCount () { return this.triangles.length; diff --git a/source/engine/model/meshinstance.js b/source/engine/model/meshinstance.js index 8b5b49a..b3b11a6 100644 --- a/source/engine/model/meshinstance.js +++ b/source/engine/model/meshinstance.js @@ -70,6 +70,11 @@ export class MeshInstance extends ModelObject3D return this.mesh.LineCount (); } + LineSegmentCount () + { + return this.mesh.LineSegmentCount (); + } + TriangleCount () { return this.mesh.TriangleCount (); diff --git a/source/engine/model/model.js b/source/engine/model/model.js index f8e32cb..dbafa3c 100644 --- a/source/engine/model/model.js +++ b/source/engine/model/model.js @@ -102,6 +102,15 @@ export class Model extends ModelObject3D return count; } + LineSegmentCount () + { + let count = 0; + this.EnumerateMeshInstances ((meshInstance) => { + count += meshInstance.LineSegmentCount (); + }); + return count; + } + TriangleCount () { let count = 0; diff --git a/source/engine/model/object.js b/source/engine/model/object.js index 10c4daa..eb9dd1a 100644 --- a/source/engine/model/object.js +++ b/source/engine/model/object.js @@ -25,6 +25,16 @@ export class Object3D return 0; } + LineCount () + { + return 0; + } + + LineSegmentCount () + { + return 0; + } + TriangleCount () { return 0; diff --git a/source/website/sidebardetailspanel.js b/source/website/sidebardetailspanel.js index 4981c01..73211bc 100644 --- a/source/website/sidebardetailspanel.js +++ b/source/website/sidebardetailspanel.js @@ -53,7 +53,14 @@ export class SidebarDetailsPanel extends SidebarPanel let size = SubCoord3D (boundingBox.max, boundingBox.min); let unit = model.GetUnit (); this.AddProperty (table, new Property (PropertyType.Integer, 'Vertices', object3D.VertexCount ())); - this.AddProperty (table, new Property (PropertyType.Integer, 'Triangles', object3D.TriangleCount ())); + let lineSegmentCount = object3D.LineSegmentCount (); + if (lineSegmentCount > 0) { + this.AddProperty (table, new Property (PropertyType.Integer, 'Lines', lineSegmentCount)); + } + let triangleCount = object3D.TriangleCount (); + if (triangleCount > 0) { + this.AddProperty (table, new Property (PropertyType.Integer, 'Triangles', triangleCount)); + } if (unit !== Unit.Unknown) { this.AddProperty (table, new Property (PropertyType.Text, 'Unit', UnitToString (unit))); }