From 1241589d183153e78c1092ba3e73145f4b8df634 Mon Sep 17 00:00:00 2001 From: Dimitrie Stefanescu Date: Thu, 10 Oct 2024 10:26:55 +0100 Subject: [PATCH] Adds new classes for raw encoded objects (Brep, Extrusion and Subd) (#139) * feat: adds wip classes for brep/subd/extrusion-x * Get rid of dub code on ExtrusionX SubDX BrepX * fix: Run format * chore: formatting * chore: more formatting help dis annoying --------- Co-authored-by: oguzhankoral Co-authored-by: Alan Rynne Co-authored-by: Adam Hathcock --- src/Speckle.Objects/Geometry/BrepX.cs | 33 ++++++++++++++++++++++++ src/Speckle.Objects/Other/RawEncoding.cs | 23 +++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/Speckle.Objects/Geometry/BrepX.cs create mode 100644 src/Speckle.Objects/Other/RawEncoding.cs diff --git a/src/Speckle.Objects/Geometry/BrepX.cs b/src/Speckle.Objects/Geometry/BrepX.cs new file mode 100644 index 00000000..fee979a4 --- /dev/null +++ b/src/Speckle.Objects/Geometry/BrepX.cs @@ -0,0 +1,33 @@ +using Speckle.Objects.Other; +using Speckle.Sdk.Models; + +namespace Speckle.Objects.Geometry; + +public interface IRawEncodedObject +{ + public RawEncoding encodedValue { get; set; } +} + +public abstract class RawEncodedObject : Base, IDisplayValue>, IRawEncodedObject, IHasArea, IHasVolume +{ + [DetachProperty] + public required List displayValue { get; set; } + + [DetachProperty] + public required RawEncoding encodedValue { get; set; } + + public required string units { get; set; } + + public double area { get; set; } + + public double volume { get; set; } +} + +[SpeckleType("Objects.Geometry.BrepX")] +public class BrepX : RawEncodedObject; + +[SpeckleType("Objects.Geometry.ExtrusionX")] +public class ExtrusionX : RawEncodedObject; + +[SpeckleType("Objects.Geometry.SubDX")] +public class SubDX : RawEncodedObject; diff --git a/src/Speckle.Objects/Other/RawEncoding.cs b/src/Speckle.Objects/Other/RawEncoding.cs new file mode 100644 index 00000000..97fc1532 --- /dev/null +++ b/src/Speckle.Objects/Other/RawEncoding.cs @@ -0,0 +1,23 @@ +using Speckle.Sdk.Models; + +namespace Speckle.Objects.Other; + +/// +/// Keeps track of a raw-encoded object in a native supported format. see +/// +[SpeckleType("Objects.Other.RawEncoding")] +public class RawEncoding : Base // note: at this stage, since we're using this for extrusions and subds the name doesn't make sense anymore +{ + public required string format { get; set; } + public required string contents { get; set; } + + public RawEncoding() { } +} + +/// +/// Supported encoding types "strongly" typed strings. This needs to match the extension of the file format. +/// +public static class RawEncodingFormats +{ + public const string RHINO_3DM = "3dm"; +}