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

check points for distance instead #101

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from all commits
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
22 changes: 9 additions & 13 deletions LayoutFunctions/WallsLOD200/src/WallsLOD200.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public static WallsLOD200Outputs Execute(Dictionary<string, Model> inputModels,

public static List<Line> UnifyLines(List<Line> lines)
{
// Remove duplicate lines based on their hash codes
// Remove duplicate lines
List<Line> dedupedlines = RemoveDuplicateLines(lines);
// Merge collinear lines that are touching or overlapping
// Merge collinear lines that are touching, overlapping or nearly so
List<Line> mergedLines = MergeCollinearLines(dedupedlines);

return mergedLines;
Expand Down Expand Up @@ -82,7 +82,6 @@ static List<List<Line>> GroupLinesByCollinearity(List<Line> lines)
{
if (line.IsCollinear(kvp.Value))
{
// Add line to existing group
lineGroups[kvp.Key].Add(line);
addedToGroup = true;
break;
Expand All @@ -91,7 +90,6 @@ static List<List<Line>> GroupLinesByCollinearity(List<Line> lines)

if (!addedToGroup)
{
// Create new group
collinearGroups.Add(groupId, line);
lineGroups.Add(new List<Line>() { line });
groupId++;
Expand Down Expand Up @@ -124,24 +122,22 @@ private static List<Line> MergeCollinearLines(List<Line> 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
// we project the lines because line.IsCollinear resolves to true on
// near 0 differences which MergedCollinearLine does not tolerate
// originally we validated if projection was necessary using line.DistanceTo,
// but it is similarly fuzzy and resolves to 0 on near (but greater than epsilon) distances
otherLine = otherLine.Projected(line);
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
break;
}
}
if (linesMerged)
break; // Exit the outer loop to restart the merging process
break;
}
} while (linesMerged);
merged.AddRange(mergedLines);
Expand Down
Loading