Files
MsAddIns/Mstn.Toolkit/External/PolyfaceProcessor.cs

68 lines
1.9 KiB
C#
Raw Permalink Normal View History

2026-02-28 21:01:57 +08:00
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<PolyfaceHeader> outputPolyface;
private readonly FacetOptions options;
private DTransform3d currentTransform;
public PolyfaceProcessor(ref IList<PolyfaceHeader> 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;
}
}
}