Show line count in the details panel.

This commit is contained in:
kovacsv 2023-10-23 15:54:59 +02:00
parent 9e5ddaead7
commit bd34c2a408
6 changed files with 49 additions and 1 deletions

View File

@ -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]);

View File

@ -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;

View File

@ -70,6 +70,11 @@ export class MeshInstance extends ModelObject3D
return this.mesh.LineCount ();
}
LineSegmentCount ()
{
return this.mesh.LineSegmentCount ();
}
TriangleCount ()
{
return this.mesh.TriangleCount ();

View File

@ -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;

View File

@ -25,6 +25,16 @@ export class Object3D
return 0;
}
LineCount ()
{
return 0;
}
LineSegmentCount ()
{
return 0;
}
TriangleCount ()
{
return 0;

View File

@ -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)));
}