SubDEdgeSharpness

References
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 8)] [DebuggerDisplay("{m_sharpness0}, {m_sharpness1}")] public struct SubDEdgeSharpness : IEquatable<SubDEdgeSharpness>
Sharpness values for the two ends of a SubD edge.

A sharp SubD edge is an edge where the limit surface makes a tighter "fillet radius" around the edge than a smooth edge would, while still staying smooth, unlike a crease edge. It is achieved by applying the crease edge subdivision rules for the number of subdivisions given by the sharpness value, and the smooth edge subdivision rules after that. Sharpness can differ at the two ends of an edge.

Remarks: This is a value type wrapping two floats, and the default value is Smooth. It is passed to and from the unmanaged library by value.

Constructors

SubDEdgeSharpness

#Since v8.36
public SubDEdgeSharpness(double sharpness)
Creates a sharpness with the same value at both ends.
Remarks: If sharpness is not valid, the result is Nan.
sharpness (double)Between 0.0 and MaximumValue, or CreaseValue.

SubDEdgeSharpness

#Since v8.36
public SubDEdgeSharpness(double sharpness0, double sharpness1)
Creates a sharpness that varies from one end of the edge to the other.
Remarks: If either value is not valid, the result is Nan. Passing CreaseValue for both values gives Crease.
sharpness0 (double)Sharpness at the start of the edge, between 0.0 and MaximumValue.
sharpness1 (double)Sharpness at the end of the edge, between 0.0 and MaximumValue.

SubDEdgeSharpness

#Since v8.36
public SubDEdgeSharpness(Interval sharpnessInterval)
Creates a sharpness that varies from one end of the edge to the other.
Remarks: If either value is not valid, the result is Nan.
sharpnessInterval (Interval)Sharpness at the start and end of the edge. Both values must be between 0.0 and MaximumValue.

Fields

CreaseValue

#Since v8.36
public const double CreaseValue = 5
The value used to indicate that an edge is a crease, MaximumValue + 1.0. This is deliberately not a valid sharpness value: a crease edge is not a sharp edge. It exists because it is often convenient to use a single value to describe both.

MaximumValue

#Since v8.36
public const double MaximumValue = 4
The largest valid sharpness value, 4.0. Valid SubD edge sharpness values are between 0.0 and MaximumValue.

SmoothValue

#Since v8.36
public const double SmoothValue = 0
The sharpness value of a smooth edge, 0.0.

Tolerance

#Since v8.36
public const double Tolerance = 0.01
If a sharpness is within Tolerance of an integer value, it is snapped to that integer value. See Sanitize(double).

Properties

Average

#Since v8.36
public double Average { get; }
Gets the average of the two end sharpness values.

Crease

#Since v8.36
public static SubDEdgeSharpness Crease { get; }
A sharpness of CreaseValue at both ends, used to indicate that an edge is a crease rather than a sharp edge. IsValid is false for this value; see IsValidOrCrease.

Delta

#Since v8.36
public double Delta { get; }
Gets EndSharpness(1) - EndSharpness(0), or NaN if this is neither valid nor a crease.

IsConstant

#Since v8.36
public bool IsConstant { get; }
Gets true if both ends have the same valid sharpness value. Crease and Nan are both false; see IsConstantOrCrease.

IsConstantOrCrease

#Since v8.36
public bool IsConstantOrCrease { get; }
Gets true if both ends have the same valid sharpness value, or if this is Crease.

IsCrease

#Since v8.36
public bool IsCrease { get; }
Gets true if this is Crease.

IsCreaseOrSharp

#Since v8.36
public bool IsCreaseOrSharp { get; }
Gets (IsCrease || IsSharp).

IsDecreasing

#Since v8.36
public bool IsDecreasing { get; }
Gets true if EndSharpness(0) is greater than EndSharpness(1).

IsIncreasing

#Since v8.36
public bool IsIncreasing { get; }
Gets true if EndSharpness(0) is less than EndSharpness(1).

IsNotValid

#Since v8.36
public bool IsNotValid { get; }
Gets the opposite of IsValid. Crease and Nan are both true.

IsNotValidNorCrease

#Since v8.36
public bool IsNotValidNorCrease { get; }
Gets the opposite of IsValidOrCrease. Nan is true and Crease is false.

IsSharp

#Since v8.36
public bool IsSharp { get; }
Gets true if both ends are valid and at least one is greater than 0.0. Crease and Nan are both false: a crease edge is not a sharp edge.

IsValid

#Since v8.36
public bool IsValid { get; }
Gets true if both ends are between 0.0 and MaximumValue. Crease and Nan are both false; see IsValidOrCrease.

IsValidOrCrease

#Since v8.36
public bool IsValidOrCrease { get; }
Gets true if both ends are between 0.0 and MaximumValue, or if this is Crease.

IsVariable

#Since v8.36
public bool IsVariable { get; }
Gets true if this is valid and the two ends differ. Crease and Nan are both false.

IsZero

#Since v8.36
public bool IsZero { get; }
Gets true if both ends are 0.0, which is the sharpness of a smooth edge.

Maximum

#Since v8.36
public static SubDEdgeSharpness Maximum { get; }
A sharpness of MaximumValue at both ends. This is the sharpest an edge can be without being a crease.

MaximumEndSharpness

#Since v8.36
public double MaximumEndSharpness { get; }
Gets the larger of the two end sharpness values.

MinimumEndSharpness

#Since v8.36
public double MinimumEndSharpness { get; }
Gets the smaller of the two end sharpness values.

Nan

#Since v8.36
public static SubDEdgeSharpness Nan { get; }
A sharpness whose ends are both NaN. This is what the factory methods return when their input is not valid.

Smooth

#Since v8.36
public static SubDEdgeSharpness Smooth { get; }
A sharpness of 0.0 at both ends, which is what a smooth edge has. This is also the default value of a SubDEdgeSharpness.

Trend

#Since v8.36
public int Trend { get; }
Gets +1 if the sharpness increases along the edge, -1 if it decreases, and 0 if it is constant. Returns RhinoMath.UnsetIntIndex if this is not valid.

Indexers

this[]

#Since v8.36
public double this[int endIndex] { get; }
Gets the sharpness at the start or the end of the edge.
endIndex (int)0 for the start of the edge, 1 for the end.
The sharpness, or NaN if endIndex is out of range.

Methods

CreateEdgeChainSharpness

#Since v8.36
public static SubDEdgeSharpness[] CreateEdgeChainSharpness(Interval chainSharpnessRange, int edgeCount)
Builds a sequence of evenly changing sharpnesses for the edges of a chain.
chainSharpnessRange (Interval)The sharpness at the start of the chain and at the end of the chain.
edgeCount (int)The number of edges in the chain.
One sharpness per edge, or an empty array if the input is not valid.

EndSharpness

#Since v8.36
public double EndSharpness(int endIndex)
Gets the sharpness at the start or the end of the edge.
endIndex (int)0 for the start of the edge, 1 for the end.
The sharpness, or NaN if endIndex is out of range.

EqualDelta

#Since v8.36
public static bool EqualDelta(SubDEdgeSharpness s0, SubDEdgeSharpness s1)
Determines whether two sharpnesses have the same Delta and meet with the same value.
s0 (SubDEdgeSharpness)The sharpness of the first edge.
s1 (SubDEdgeSharpness)The sharpness of the second edge.

EqualEndSharpness

#Since v8.36
public static bool EqualEndSharpness(SubDEdgeSharpness s0, SubDEdgeSharpness s1)
Determines whether two sharpnesses meet with the same value, that is, whether s0.EndSharpness(1) equals s1.EndSharpness(0).
s0 (SubDEdgeSharpness)The sharpness of the first edge.
s1 (SubDEdgeSharpness)The sharpness of the second edge.

Equals

#Since v8.36
public override bool Equals(object obj)
Determines whether an object is a sharpness with the same end values as this one.
obj (object)The object to compare with.
ValueType.Equals

Equals

#Since v8.36
public bool Equals(SubDEdgeSharpness other)
Determines whether this sharpness has the same end values as another one.
other (SubDEdgeSharpness)The sharpness to compare with.

EqualTrend

#Since v8.36
public static bool EqualTrend(SubDEdgeSharpness s0, SubDEdgeSharpness s1)
Determines whether two sharpnesses have the same Trend and meet with the same value.
s0 (SubDEdgeSharpness)The sharpness of the first edge.
s1 (SubDEdgeSharpness)The sharpness of the second edge.

FromConstantPercentage

#Since v8.36
public static SubDEdgeSharpness FromConstantPercentage(double percentage)
Creates a sharpness with the same value at both ends, from a percentage. This is useful in user interface code that expresses sharpness as a percentage.
percentage (double)Between 0.0 and 100.0, or double.MaxValue for a crease.
A sharpness with constant value (percentage * MaximumValue / 100.0), Crease if percentage is double.MaxValue, or Nan if percentage is out of range.

FromIntervalPercentage

#Since v8.36
public static SubDEdgeSharpness FromIntervalPercentage(double percentage0, double percentage1)
Creates a sharpness that varies from one end of the edge to the other, from percentages. This is useful in user interface code that expresses sharpness as a percentage.
percentage0 (double)Percentage at the start of the edge, between 0.0 and 100.0, or double.MaxValue for a crease.
percentage1 (double)Percentage at the end of the edge, between 0.0 and 100.0, or double.MaxValue for a crease.
A sharpness running from (percentage0 * MaximumValue / 100.0) to (percentage1 * MaximumValue / 100.0), Crease if both percentages are double.MaxValue, or Nan otherwise. An edge is either a crease or it is not, so mixing double.MaxValue with a percentage gives Nan.

FromIntervalPercentage

#Since v8.36
public static SubDEdgeSharpness FromIntervalPercentage(Interval percentageInterval)
Creates a sharpness that varies from one end of the edge to the other, from percentages. This is useful in user interface code that expresses sharpness as a percentage.
percentageInterval (Interval)Percentages at the start and end of the edge, each between 0.0 and 100.0, or double.MaxValue for a crease.

GetHashCode

#Since v8.36
public override int GetHashCode()
Gets a hash code for this sharpness.

IsValidValue

#Since v8.36
public static bool IsValidValue(double candidateValue, bool creaseResult)
Determines whether a value can be used as an edge end sharpness.
candidateValue (double)The value to check.
creaseResult (bool)The value to return when candidateValue is CreaseValue.

Reversed

#Since v8.36
public SubDEdgeSharpness Reversed()
Gets this sharpness with its two end values swapped.

Sanitize

#Since v8.36
public static double Sanitize(double sharpness, double invalidInputResult)
Verifies that sharpness is between 0.0 and MaximumValue, and snaps it to an integer when it is within Tolerance of one.
sharpness (double)The value to sanitize.
invalidInputResult (double)The value to return when sharpness is not valid.
A usable sharpness value, or invalidInputResult if sharpness is not valid.

Sanitize

#Since v8.36
public static double Sanitize(double sharpness)
Verifies that sharpness is between 0.0 and MaximumValue, and snaps it to an integer when it is within Tolerance of one.
sharpness (double)The value to sanitize.
A usable sharpness value, or 0.0 if sharpness is not valid.

SharpnessFromNormalizedValue

#Since v8.36
public static double SharpnessFromNormalizedValue(double normalizedSliderValue)
Converts a normalized slider value to an edge end sharpness value.
normalizedSliderValue (double)Between 0.0 and 1.0.
normalizedSliderValue scaled to the range 0.0 to MaximumValue, or NaN if it is out of range.

SharpnessFromSliderValue

#Since v8.36
public static double SharpnessFromSliderValue(Interval sliderDomain, double sliderValue, double invalidInputResult)
Converts a user facing slider value to an edge end sharpness value.
sliderDomain (Interval)The non empty domain of the slider, often Interval.ZeroToOne.
sliderValue (double)A value in sliderDomain. sliderDomain.T0 maps to 0.0 and sliderDomain.T1 maps to MaximumValue.
invalidInputResult (double)The value to return when the input is not valid.

Subdivided

#Since v8.36
public SubDEdgeSharpness Subdivided(int endIndex)
Gets the sharpness this edge would have after one subdivision.
endIndex (int)0 for the start of the edge, 1 for the end.
The subdivided sharpness, or Smooth if endIndex is out of range.

ToPercentage

#Since v8.36
public static double ToPercentage(double sharpness, double creasePercentage)
Converts a sharpness value to a percentage between 0.0 and 100.0.
sharpness (double)Between 0.0 and MaximumValue, or CreaseValue.
creasePercentage (double)The value to return when sharpness is CreaseValue.
100.0 * sharpness / MaximumValue, creasePercentage for CreaseValue, or NaN if sharpness is not valid.

ToPercentageText

#Since v8.36
public string ToPercentageText(bool orderMinToMax)
Describes this sharpness as a percentage, for user interface code. A constant sharpness gives a single percentage, a variable one gives a range, and an invalid one gives a warning sign.
orderMinToMax (bool)If true, a variable sharpness is formatted as min%-max%. If false, it is formatted as EndSharpness(0)%-EndSharpness(1)%.

ToPercentageText

#Since v8.36
public static string ToPercentageText(double sharpness)
Describes a single end sharpness value as a percentage, for user interface code.
sharpness (double)Between 0.0 and MaximumValue, or CreaseValue.
A number followed by a percent sign, "crease" for CreaseValue, or a warning sign if sharpness is not valid.

ToString

#Since v8.36
public override string ToString()
Returns a string that represents this sharpness as a percentage.

Union

#Since v8.36
public static SubDEdgeSharpness Union(SubDEdgeSharpness sharpness0, SubDEdgeSharpness sharpness1)
Gets the union of two sharpness ranges, ignoring the ones that are zero, a crease, or not valid.
sharpness0 (SubDEdgeSharpness)The first sharpness.
sharpness1 (SubDEdgeSharpness)The second sharpness.
The union of the nonzero valid inputs, or Smooth if there are none.

VertexSharpness

#Since v8.36
[CLSCompliant(false)] public static double VertexSharpness(SubDVertexTag vertexTag, double interiorCreaseVertexSharpness, uint sharpEdgeEndCount, double maximumEdgeEndSharpness)
Calculates the sharpness of a vertex from the sharp edges attached to it. Vertices tagged as corners always have a sharpness of 0.0.
vertexTag (SubDVertexTag)The vertex tag.
interiorCreaseVertexSharpness (double)Only meaningful for an interior crease vertex, where it is the largest sharpness at this vertex over the smooth edges of both sectors. This matters in low level SubD evaluation code that only has information about one sector. When in doubt, pass 0.0.
sharpEdgeEndCount (uint)The number of sharp edges at the vertex whose sharpness at this vertex is nonzero.
maximumEdgeEndSharpness (double)The largest sharp edge end sharpness at the vertex.
The sharpness to use when subdividing the vertex.

Operators

OperationResultDescription
SubDEdgeSharpness==SubDEdgeSharpnessboolDetermines whether two sharpnesses have the same end values.
SubDEdgeSharpness!=SubDEdgeSharpnessboolDetermines whether two sharpnesses have different end values.

See also