diff --git a/CadRevealComposer.Tests/BoundingBoxTests.cs b/CadRevealComposer.Tests/BoundingBoxTests.cs
index 3a371ec3..101b274f 100644
--- a/CadRevealComposer.Tests/BoundingBoxTests.cs
+++ b/CadRevealComposer.Tests/BoundingBoxTests.cs
@@ -2,8 +2,6 @@ namespace CadRevealComposer.Tests;
using System.Drawing;
using System.Numerics;
-using Primitives;
-using Tessellation;
public class BoundingBoxTests
{
@@ -68,4 +66,12 @@ public void Extents_ReturnsSizeInAllDimensions()
var extents = new Vector3(3, 3, 3);
Assert.That(boundingBox.Extents, Is.EqualTo(extents));
}
+
+ [Test]
+ public void Volume_CalculatesCorrectVolume()
+ {
+ var boundingBox = new BoundingBox(new Vector3(1, 2, 3), new Vector3(4, 6, 8));
+ const float expectedVolume = 3 * 4 * 5; // Extents.X * Extents.Y * Extents.Z
+ Assert.That(boundingBox.Volume, Is.EqualTo(expectedVolume));
+ }
}
diff --git a/CadRevealComposer/CadRevealNode.cs b/CadRevealComposer/CadRevealNode.cs
index 75c04513..af77bb17 100644
--- a/CadRevealComposer/CadRevealNode.cs
+++ b/CadRevealComposer/CadRevealNode.cs
@@ -5,7 +5,6 @@ namespace CadRevealComposer;
using System.Numerics;
using Primitives;
using ProtoBuf;
-using Tessellation;
using Utils;
[ProtoContract(SkipConstructor = true)]
@@ -29,6 +28,12 @@ public record BoundingBox([property: ProtoMember(1)] Vector3 Min, [property: Pro
///
public Vector3 Extents => (Max - Min);
+ ///
+ /// The Volume of the bounding box
+ /// Expressed as Extents.X * Extents.Y * Extents.Z
+ ///
+ public float Volume => Extents.X * Extents.Y * Extents.Z;
+
///
/// Combine two bounds
///
diff --git a/CadRevealComposer/Operations/SectorSplitting/PrioritySplittingUtils.cs b/CadRevealComposer/Operations/SectorSplitting/PrioritySplittingUtils.cs
index ab5849ed..a82c020b 100644
--- a/CadRevealComposer/Operations/SectorSplitting/PrioritySplittingUtils.cs
+++ b/CadRevealComposer/Operations/SectorSplitting/PrioritySplittingUtils.cs
@@ -11,7 +11,7 @@ public static class PrioritySplittingUtils
///
/// These disciplines have limited amount of data and high highlighting value.
///
- private static readonly string[] PrioritizedDisciplines = ["PIPE", "ELEC", "SAFE", "INST", "TELE"];
+ private static readonly string[] PrioritizedDisciplines = ["PIPE", "ELEC", "SAFE", "INST", "TELE", "MECH"];
public static void SetPriorityForPrioritySplittingWithMutation(IReadOnlyList nodes)
{
@@ -48,10 +48,30 @@ private static void SetPriorityOnNodesAndChildren(IEnumerable nod
{
foreach (var node in nodes)
{
- var allChildren = CadRevealNode.GetAllNodesFlat(node);
- foreach (var child in allChildren)
+ var allChildren = CadRevealNode.GetAllNodesFlat(node).ToList();
+
+ if (node.Attributes["Discipline"] == "MECH" && allChildren.Count > 10)
+ {
+ // This code assumes the nodes that get here are "Tag" nodes.
+ // Prioritize the largest geometries, to avoid the priority sector being too large
+ var geometriesToPrioritize = allChildren
+ .SelectMany(childNode => childNode.Geometries.Select(primitive => (childNode, primitive)))
+ .OrderByDescending(nx => nx.primitive.AxisAlignedBoundingBox.Volume) // Volume here is arbitrary. It will prioritize diagonal "beams". But may be better than just "Diagonal"?
+ .Take((int)Math.Clamp(allChildren.Count * 0.4f, min: 5, max: 100)); // Arbitrary values
+
+ foreach ((CadRevealNode childNode, APrimitive primitive) in geometriesToPrioritize)
+ {
+ childNode.Geometries = childNode
+ .Geometries.Select(g => g == primitive ? g with { Priority = 1 } : g)
+ .ToArray();
+ }
+ }
+ else
{
- child.Geometries = child.Geometries.Select(g => g with { Priority = 1 }).ToArray();
+ foreach (var child in allChildren)
+ {
+ child.Geometries = child.Geometries.Select(g => g with { Priority = 1 }).ToArray();
+ }
}
}
}