Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed May 7, 2024
1 parent 9460b5d commit f6234bc
Showing 1 changed file with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,81 +30,100 @@ public ResolveSet Resolve(Document context, string target, ParameterInfo[] param
{
return target switch
{
nameof(CurveElement.GetAdjoinedCurveElements) => ResolveSet
.Append(curveElement.GetAdjoinedCurveElements(0), "Point 0")
.AppendVariant(curveElement.GetAdjoinedCurveElements(1), "Point 1"),
nameof(CurveElement.HasTangentLocks) => ResolveSet
.Append(curveElement.HasTangentLocks(0), "Point 0")
.AppendVariant(curveElement.HasTangentLocks(1), "Point 1"),
nameof(CurveElement.GetAdjoinedCurveElements) => ResolveAdjoinedCurveElements(),
nameof(CurveElement.HasTangentLocks) => ResolveHasTangentLocks(),
nameof(CurveElement.GetTangentLock) => ResolveTangentLock(),
nameof(CurveElement.HasTangentJoin) => ResolveTangentJoin(),
nameof(CurveElement.IsAdjoinedCurveElement) => ResolveIsAdjoinedCurveElement(),
_ => null
};

ResolveSet ResolveAdjoinedCurveElements()
{
var resolveSet = new ResolveSet(2);
var startCurveElements = curveElement.GetAdjoinedCurveElements(0);
var endCurveElements = curveElement.GetAdjoinedCurveElements(1);

return resolveSet
.AppendVariant(startCurveElements, "Point 0")
.AppendVariant(endCurveElements, "Point 1");
}

ResolveSet ResolveHasTangentLocks()
{
var resolveSet = new ResolveSet(2);
var startHasTangentLocks = curveElement.HasTangentLocks(0);
var endHasTangentLocks = curveElement.HasTangentLocks(1);

return resolveSet
.AppendVariant(startHasTangentLocks, $"Point 0: {startHasTangentLocks}")
.AppendVariant(endHasTangentLocks, $"Point 1: {endHasTangentLocks}");
}

ResolveSet ResolveTangentLock()
{
var set0 = curveElement.GetAdjoinedCurveElements(0);
var set1 = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(set0.Count + set1.Count);
var startCurveElements = curveElement.GetAdjoinedCurveElements(0);
var endCurveElements = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(startCurveElements.Count + endCurveElements.Count);

foreach (var id in set0)
foreach (var id in startCurveElements)
{
if (!curveElement.HasTangentJoin(0, id)) continue;

var result = curveElement.GetTangentLock(0, id);
var element = id.ToElement(context);
resolveSummary.AppendVariant(result, $"Point 0, {element!.Name}: {result}");
resolveSummary.AppendVariant(result, $"Point 0, {id}: {result}");
}

foreach (var id in set1)
foreach (var id in endCurveElements)
{
if (!curveElement.HasTangentJoin(1, id)) continue;

var result = curveElement.GetTangentLock(1, id);
var element = id.ToElement(context);
resolveSummary.AppendVariant(result, $"Point 1, {element!.Name}: {result}");
resolveSummary.AppendVariant(result, $"Point 1, {id}: {result}");
}

return resolveSummary;
}

ResolveSet ResolveTangentJoin()
{
var set0 = curveElement.GetAdjoinedCurveElements(0);
var set1 = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(set0.Count + set1.Count);
var startCurveElements = curveElement.GetAdjoinedCurveElements(0);
var endCurveElements = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(startCurveElements.Count + endCurveElements.Count);

foreach (var id in set0)
foreach (var id in startCurveElements)
{
var result = curveElement.HasTangentJoin(0, id);
resolveSummary.AppendVariant(result, $"Point 0, {id}: {result}");
}

foreach (var id in set1)
foreach (var id in endCurveElements)
{
var result = curveElement.HasTangentJoin(1, id);
resolveSummary.AppendVariant(result, $"Point 1, {id}: {result}");
}

return resolveSummary;
}

ResolveSet ResolveIsAdjoinedCurveElement()
{
var set0 = curveElement.GetAdjoinedCurveElements(0);
var set1 = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(set0.Count + set1.Count);
var startCurveElements = curveElement.GetAdjoinedCurveElements(0);
var endCurveElements = curveElement.GetAdjoinedCurveElements(1);
var resolveSummary = new ResolveSet(startCurveElements.Count + endCurveElements.Count);

foreach (var id in set0)
foreach (var id in startCurveElements)
{
var result = curveElement.IsAdjoinedCurveElement(0, id);
resolveSummary.AppendVariant(result, $"Point 0, {id}: {result}");
}

foreach (var id in set1)
foreach (var id in endCurveElements)
{
var result = curveElement.IsAdjoinedCurveElement(1, id);
resolveSummary.AppendVariant(result, $"Point 1, {id}: {result}");
}

return resolveSummary;
}
}
Expand Down

0 comments on commit f6234bc

Please sign in to comment.