Files
speckle-sharp-sdk/src/Speckle.Objects/Geometry/ControlPoint.cs
T
Jedd Morgan a143553a09
.NET Build and Publish / build (push) Has been cancelled
feat(netcore): Add Net10 target to SDK and drop sln (#442)
* .net10 attempt 2

* bump csharpier

* drop sln

* supress stream analyers for test projects

* readme

* fix package locks post merge

* Microsoft.Extensions.DependencyInjection

* Simplify the dependency structure

* don't bump graphql client for netstandard and net8 targets

* Fix test
2026-04-15 17:48:32 +01:00

73 lines
1.9 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Speckle.Newtonsoft.Json;
using Speckle.Objects.Other;
using Speckle.Sdk.Models;
namespace Speckle.Objects.Geometry;
[SpeckleType("Objects.Geometry.ControlPoint")]
public class ControlPoint : Point, ITransformable<ControlPoint>
{
public ControlPoint() { }
[SetsRequiredMembers]
public ControlPoint(double x, double y, double z, double w, string units, string? applicationId = null)
: base(x, y, z, units, applicationId)
{
weight = w;
}
public required double weight { get; set; }
/// <summary>
/// OBSOLETE - This is just here for backwards compatibility.
/// </summary>
[
JsonProperty(NullValueHandling = NullValueHandling.Ignore),
Obsolete("Access coordinates using XYZ and weight fields", true)
]
internal new List<double> value
{
#pragma warning disable CS8603 // Possible null reference return. Reason: obsolete.
get => null;
#pragma warning restore CS8603 // Possible null reference return. Reason: obsolete.
set
{
x = value[0];
y = value[1];
z = value[2];
weight = value.Count > 3 ? value[3] : 1;
}
}
public bool TransformTo(Transform transform, out ControlPoint transformed)
{
TransformTo(transform, out Point transformedPoint);
transformed = new ControlPoint(
transformedPoint.x,
transformedPoint.y,
transformedPoint.z,
weight,
units,
applicationId
);
return true;
}
public override string ToString()
{
return $"{{{x},{y},{z},{weight}}}";
}
public void Deconstruct(out double x, out double y, out double z, out double weight)
{
Deconstruct(out x, out y, out z, out weight, out _);
}
public void Deconstruct(out double x, out double y, out double z, out double weight, out string? units)
{
Deconstruct(out x, out y, out z, out units);
weight = this.weight;
}
}