using System.Collections.Generic; using Bentley.DgnPlatformNET; using Bentley.DgnPlatformNET.Elements; using Bentley.GeometryNET; namespace Mstn.Toolkit.External { public class PolyfaceProcessor : ElementGraphicsProcessor { private readonly IList outputPolyface; private readonly FacetOptions options; private DTransform3d currentTransform; public PolyfaceProcessor(ref IList outputPolyface, FacetOptions options) { this.outputPolyface = outputPolyface; currentTransform = DTransform3d.Identity; this.options = options; } public override FacetOptions GetFacetOptions() { return options; } public override bool ProcessAsBody(bool isCurved) { return false; } public override bool ProcessAsFacets(bool isPolyface) { return true; } public override BentleyStatus ProcessFacets(PolyfaceHeader meshData, bool filled = false) { if (meshData.FacetCount == 0) { return BentleyStatus.Error; } PolyfaceHeader header = PolyfaceHeader.New(); header.CopyFrom(meshData); header.TwoSided = true; header.Transform(ref currentTransform, false); outputPolyface.Add(header); return BentleyStatus.Success; } public void Process(Element element) { ElementGraphicsOutput.Process(element, this); } public override void AnnounceTransform(DTransform3d transform) { currentTransform = transform != null ? transform : DTransform3d.Identity; } public override void AnnounceIdentityTransform() { currentTransform = DTransform3d.Identity; } } }