Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle tolerance gaps for WallsLOD200 #100

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.1.0" />
<PackageReference Include="Hypar.Functions" Version="1.10.0" />
<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.29" />
<PackageReference Include="Hypar.Functions" Version="1.10.0" />
</ItemGroup>

</Project>
35 changes: 25 additions & 10 deletions LayoutFunctions/WallsLOD200/src/WallsLOD200.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ namespace WallsLOD200
{
public static partial class WallsLOD200
{
public static double tolerance = 0.0001;
/// <summary>
/// The WallsLOD200 function.
/// </summary>
@@ -114,17 +115,31 @@ private static List<Line> MergeCollinearLines(List<Line> lines)
{
Line otherLine = mergedLines[j];

if (line.TryGetOverlap(otherLine, out var overlap) || line.DistanceTo(otherLine) < 0.0001)
try
{
// Merge collinear lines
Line mergedLine = line.MergedCollinearLine(otherLine);

// Update the list with the merged line
mergedLines.RemoveAt(j);
mergedLines[i] = mergedLine;

linesMerged = true;
break; // Exit the inner loop as we have merged the lines
if (line.TryGetOverlap(otherLine, out var overlap) || line.DistanceTo(otherLine) < tolerance)
{
// project lines within tolerance but further than epsilon
if (line.DistanceTo(otherLine) > double.Epsilon)
{
otherLine = otherLine.Projected(line);
}
// Merge collinear lines
Line mergedLine = line.MergedCollinearLine(otherLine);

// Update the list with the merged line
mergedLines.RemoveAt(j);
mergedLines[i] = mergedLine;

linesMerged = true;
break; // Exit the inner loop as we have merged the lines
}
}
catch (Exception e)
{
Console.WriteLine($"Failed to merge wall line {otherLine.Start} - {otherLine.End}.");
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
if (linesMerged)

Unchanged files with check annotations Beta

public static List<RoomEdge> DeduplicateWallLines(List<InteriorPartitionCandidate> interiorPartitionCandidates)
{
return interiorPartitionCandidates.SelectMany(i => i.WallCandidateLines).Where(l => l.Type != null && interiorPartitionTypePriority.Keys.Contains(l.Type)).ToList();
var resultCandidates = new List<RoomEdge>();

Check warning on line 118 in LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs

GitHub Actions / build

Unreachable code detected

Check warning on line 118 in LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs

GitHub Actions / build

Unreachable code detected
var typedLines = interiorPartitionCandidates.SelectMany(c => c.WallCandidateLines)
.Where(l => l.Type != null && interiorPartitionTypePriority.Keys.Contains(l.Type));
var collinearLinesGroups = GroupCollinearLines(typedLines);
{
var catalogInstances = new List<ElementInstance>();
var json = "";
using (var client = new WebClient())

Check warning on line 207 in LayoutFunctions/CustomLayout/src/CustomSpaceType.cs

GitHub Actions / build

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.'

Check warning on line 207 in LayoutFunctions/CustomLayout/src/CustomSpaceType.cs

GitHub Actions / build

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.'
{
json = client.DownloadString(url);
}
{
internal static DoorOpeningSide ConvertOpeningSideEnum<T>(T openingSide)
{
if (!Enum.IsDefined(typeof(T), openingSide))

Check warning on line 10 in LayoutFunctions/Doors/src/DoorOpeningEnumsHelper.cs

GitHub Actions / build

Possible null reference argument for parameter 'value' in 'bool Enum.IsDefined(Type enumType, object value)'.
{
return DoorOpeningSide.LeftHand;
}
internal static DoorOpeningType ConvertOpeningTypeEnum<T>(T openingType)
{
if (!Enum.IsDefined(typeof(T), openingType))

Check warning on line 21 in LayoutFunctions/Doors/src/DoorOpeningEnumsHelper.cs

GitHub Actions / build

Possible null reference argument for parameter 'value' in 'bool Enum.IsDefined(Type enumType, object value)'.
{
return DoorOpeningType.SingleSwing;
}