diff --git a/Elements.MEP/src/Fittings/FittingRepresentationStorage.cs b/Elements.MEP/src/Fittings/FittingRepresentationStorage.cs index d25c2cd67..fa499f6c5 100644 --- a/Elements.MEP/src/Fittings/FittingRepresentationStorage.cs +++ b/Elements.MEP/src/Fittings/FittingRepresentationStorage.cs @@ -11,17 +11,32 @@ static class FittingRepresentationStorage private static readonly Dictionary> _fittings = new Dictionary>(); public static Dictionary> Fittings => _fittings; - public static void SetFittingRepresentation(Fitting fitting, Func> makeSolids) + public static void SetFittingRepresentation(Fitting fitting, Func> makeSolids, Boolean unioned = true, Boolean updateTransform = true) { var hash = fitting.GetRepresentationHash(); if (!_fittings.ContainsKey(hash)) { var solids = makeSolids(); - _fittings.Add(hash, new List { new RepresentationInstance(new SolidRepresentation(solids), fitting.Material) }); + var representationInstances = new List(); + if (unioned) + { + representationInstances = new List { new RepresentationInstance(new SolidRepresentation(solids), fitting.Material) }; + } + else + { + foreach (var solid in solids) + { + representationInstances.Add(new RepresentationInstance(new SolidRepresentation(solid), fitting.Material)); + } + } + _fittings.Add(hash, representationInstances); } fitting.RepresentationInstances = _fittings[hash]; - fitting.Transform = fitting.GetRotatedTransform().Concatenated(new Transform(fitting.Transform.Origin)); + if (updateTransform) + { + fitting.Transform = fitting.GetRotatedTransform().Concatenated(new Transform(fitting.Transform.Origin)); + } } } } \ No newline at end of file diff --git a/Elements.MEP/src/Fittings/Reducer.cs b/Elements.MEP/src/Fittings/Reducer.cs index 23adcaf28..e4aea1b81 100644 --- a/Elements.MEP/src/Fittings/Reducer.cs +++ b/Elements.MEP/src/Fittings/Reducer.cs @@ -72,12 +72,11 @@ public override void UpdateRepresentations() var arrows = this.Start.GetArrow(branchSideTransformInverted.OfPoint(startNodeTransform.Origin)) .Concat(this.End.GetArrow(endNodeTransform.Origin)).Concat(GetExtensions()); - this.RepresentationInstances.Add(new RepresentationInstance(new SolidRepresentation(sweep1), this.Material)); - this.RepresentationInstances.Add(new RepresentationInstance(new SolidRepresentation(sweep2), this.Material)); - foreach (var arrow in arrows) - { - this.RepresentationInstances.Add(new RepresentationInstance(new SolidRepresentation(arrow), this.Material)); - } + // TODO: Update the Factory pattern for setting representationInstances to work with Reducer transforms. + // It would also be ideal to fully understand the geometry artifacts seen with certain Reducers that result in + // bad boolean graphics which result in invisible or fractured geometry. + var solidOperations = new List { sweep1, sweep2 }.Concat(arrows).ToList(); + FittingRepresentationStorage.SetFittingRepresentation(this, () => solidOperations, false, false); } public override void ApplyAdditionalTransform()